[PATCH] Improve error message for graph variable references in subqueries within GRAPH_TABLE

From: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] Improve error message for graph variable references in subqueries within GRAPH_TABLE
Date: 2026-04-25 17:11:40
Message-ID: CAHg+QDfUwNPcxWk_WJWPvVhrGAeeDQrD6CMTuFcSd1ybELie9Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

When a subquery inside GRAPH_TABLE COLUMNS or MATCH WHERE references a
graph pattern variable, the error was a confusing "missing FROM-clause
entry for table". Fix by walking the parentParseState chain in
transformGraphTablePropertyRef() to detect the graph variable and report
a clear "cannot be used in a subquery" error instead.

Based on the below comment and code in transformRangeGraphTable I am
assuming we don't support
subqueries for now.

/*
* If we support subqueries within GRAPH_TABLE, those need to be
* propagated to the queries resulting from rewriting graph table RTE. We
* don't do that right now, hence prohibit it for now.
*/
if (pstate->p_hasSubLinks)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("subqueries within GRAPH_TABLE reference are not supported")));
pstate->p_hasSubLinks = saved_hasSublinks;

Attached a patch to address this which also includes a test.

Thanks,
Satya

Attachment Content-Type Size
0001-Improve-error-for-graph-variable-references-in-subqu.patch application/octet-stream 5.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2026-04-25 17:33:38 Re: [PATCH] Compressed TOAST data corruption with REPACK CONCURRENTLY
Previous Message Álvaro Herrera 2026-04-25 16:56:35 Re: [PATCH] Compressed TOAST data corruption with REPACK CONCURRENTLY