[PATCH] Improve error message for graph variable references in subqueries within GRAPH_TABLE
SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
From: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-25T17:11:40Z
Lists: pgsql-hackers
Attachments
- 0001-Improve-error-for-graph-variable-references-in-subqu.patch (application/octet-stream) patch 0001
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