Re: [PATCH] Resolve unknown-type literals in GRAPH_TABLE COLUMNS

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Cc: Junwang Zhao <zhjwpku(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Resolve unknown-type literals in GRAPH_TABLE COLUMNS
Date: 2026-04-29 14:09:41
Message-ID: CAExHW5vmmAS6Vroh8W9+vmuM2ReocODRCWPqYozGSyhxCxxL+Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 27, 2026 at 11:34 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram(at)gmail(dot)com> wrote:
>
> Hi,
>
> On Sun, Apr 26, 2026 at 8:10 AM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>>
>> Hi SATYANARAYANA,
>>
>> On Sun, Apr 26, 2026 at 3:53 AM SATYANARAYANA NARLAPURAM
>> <satyanarlapuram(at)gmail(dot)com> wrote:
>> >
>> > Hi hackers,
>> >
>> > transformRangeGraphTable() calls transformExpr() and
>> > assign_list_collations() 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 assign_list_collations(), 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
>> assign_list_collations?
>>
>> I'm asking because in transformSelectStmt, resolveTargetListUnknowns
>> is invoked before assign_query_collations. It might not matter, but keeping
>> the order consistent would be good for readers.
>
>
> Updated the patch. It should be before.

Do we really need a test for ORDER BY on a literal column? I replaced
all the test queries with a single one which covers all the scenarios
covered by those queries.

The patch needed to consider pstate->p_resolve_unknowns. Unknown
literals are not resolved as text always. See the test query.

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
v20260429-0001-Resolve-unknown-type-literals-in-GRAPH_TAB.patch text/x-patch 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message DaeMyung Kang 2026-04-29 15:18:11 [PATCH] Fix EINTR retry condition in pg_flush_data sync_file_range path.
Previous Message Ashutosh Bapat 2026-04-29 14:00:01 Re: [PATCH] Improve error message for graph variable references in subqueries within GRAPH_TABLE