pgsql-hackers
❮
[PATCH] Resolve unknown-type literals in GRAPH_TABLE COLUMNS
- Jump to comment-1SATYANARAYANA NARLAPURAM<satyanarlapuram@gmail.com>Apr 25, 2026, 7:53 PM UTCHi hackers,
transformRangeGraphTable() calls transformExpr() and
assignlistcollations() for COLUMNS expressions but missed calling
resolveTargetListUnknowns(). As a result, literals such as 'val1'
in a COLUMNS clause retained type "unknown", causing failures with
Fix by calling resolveTargetListUnknowns() on the columns targetORDER BY, UNION, and output conversions.
list right after assignlistcollations(), similar to SELECT target lists
in
transformSelectStmt().
Attached a patch to fix this, which also includes test cases to reproduce.
Thanks,
Satya- Jump to comment-1Junwang Zhao<zhjwpku@gmail.com>Apr 26, 2026, 3:10 PM UTCHi SATYANARAYANA,
On Sun, Apr 26, 2026 at 3:53 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:
I can reproduce this and the patch fixes it.
Hi hackers,
transformRangeGraphTable() calls transformExpr() and
assignlistcollations() for COLUMNS expressions but missed calling
resolveTargetListUnknowns(). As a result, literals such as 'val1'
in a COLUMNS clause retained type "unknown", causing failures with
ORDER BY, UNION, and output conversions.
Fix by calling resolveTargetListUnknowns() on the columns target
list right after assignlistcollations(), similar to SELECT target lists in
transformSelectStmt().
Attached a patch to fix this, which also includes test cases to reproduce.
One question: why is resolveTargetListUnknowns called after
assignlistcollations?
I'm asking because in transformSelectStmt, resolveTargetListUnknowns
is invoked before assignquerycollations. It might not matter, but keeping
the order consistent would be good for readers.
--
Thanks,
Satya
Regards
Junwang Zhao- Jump to comment-1SATYANARAYANA NARLAPURAM<satyanarlapuram@gmail.com>Apr 27, 2026, 6:09 AM UTCHi,
On Sun, Apr 26, 2026 at 8:10 AM Junwang Zhao <zhjwpku@gmail.com> wrote:Hi SATYANARAYANA,
On Sun, Apr 26, 2026 at 3:53 AM SATYANARAYANA NARLAPURAM<satyanarlapuram@gmail.com> wrote:
Hi hackers,
transformRangeGraphTable() calls transformExpr() and
assignlistcollations() for COLUMNS expressions but missed calling
resolveTargetListUnknowns(). As a result, literals such as 'val1'
in a COLUMNS clause retained type "unknown", causing failures with
ORDER BY, UNION, and output conversions.
Fix by calling resolveTargetListUnknowns() on the columns target
list right after assignlistcollations(), similar to SELECT targetlists in
transformSelectStmt().
Attached a patch to fix this, which also includes test cases toreproduce.
Updated the patch. It should be before.
I can reproduce this and the patch fixes it.
One question: why is resolveTargetListUnknowns called after
assignlistcollations?
I'm asking because in transformSelectStmt, resolveTargetListUnknowns
is invoked before assignquerycollations. It might not matter, but keeping
the order consistent would be good for readers.
Thanks,
Satya- Jump to comment-1Ashutosh Bapat<ashutosh.bapat.oss@gmail.com>Apr 29, 2026, 2:10 PM UTCOn Mon, Apr 27, 2026 at 11:34 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:
Hi,On Sun, Apr 26, 2026 at 8:10 AM Junwang Zhao <zhjwpku@gmail.com> wrote:
Hi SATYANARAYANA,
On Sun, Apr 26, 2026 at 3:53 AM SATYANARAYANA NARLAPURAM<satyanarlapuram@gmail.com> wrote:
Hi hackers,
transformRangeGraphTable() calls transformExpr() and
assignlistcollations() for COLUMNS expressions but missed calling
resolveTargetListUnknowns(). As a result, literals such as 'val1'
in a COLUMNS clause retained type "unknown", causing failures with
ORDER BY, UNION, and output conversions.
Fix by calling resolveTargetListUnknowns() on the columns target
list right after assignlistcollations(), similar to SELECT target lists in
transformSelectStmt().
Attached a patch to fix this, which also includes test cases to reproduce.
I can reproduce this and the patch fixes it.
One question: why is resolveTargetListUnknowns called after
assignlistcollations?
I'm asking because in transformSelectStmt, resolveTargetListUnknowns
is invoked before assignquerycollations. It might not matter, but keeping
the order consistent would be good for readers.
Do we really need a test for ORDER BY on a literal column? I replaced
Updated the patch. It should be before.
all the test queries with a single one which covers all the scenarios
covered by those queries.
The patch needed to consider pstate->presolveunknowns. Unknown
literals are not resolved as text always. See the test query.
--
Best Wishes,
Ashutosh Bapat