public inbox for [email protected]help / color / mirror / Atom feed
[Patch]Add Graph* node support to expression_tree_mutator 7+ messages / 4 participants [nested] [flat]
* [Patch]Add Graph* node support to expression_tree_mutator @ 2026-04-21 15:56 SATYANARAYANA NARLAPURAM <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: SATYANARAYANA NARLAPURAM @ 2026-04-21 15:56 UTC (permalink / raw) To: PostgreSQL Hackers <[email protected]>; Ashutosh Bapat <[email protected]> Hi hackers, expression_tree_mutator_impl() was missing case handlers for T_GraphPattern, T_GraphElementPattern, and T_GraphPropertyRef. The corresponding expression_tree_walker_impl() already handled all three node types, but the mutator did not, causing an "unrecognized node type: 106" error whenever a GRAPH_TABLE subquery appeared in a HAVING clause. SELECT 1 FROM hv GROUP BY id HAVING (SELECT COUNT(*) FROM GRAPH_TABLE(gh MATCH (a) COLUMNS (a.id AS x))) > 0; SET ERROR: unrecognized node type: 106 Attached a patch to address this. Thanks, Satya Attachments: [application/octet-stream] 0001-Add-Graph-node-support-to-expression_tree_mutator.patch (4.5K, 3-0001-Add-Graph-node-support-to-expression_tree_mutator.patch) download | inline diff: From 00340faa3be64541f6fac2bca55880f621f940d0 Mon Sep 17 00:00:00 2001 From: satyanarayana narlapuram <[email protected]> Date: Tue, 21 Apr 2026 14:33:33 +0000 Subject: [PATCH] Add Graph* node support to expression_tree_mutator expression_tree_mutator_impl() was missing case handlers for T_GraphPattern, T_GraphElementPattern, and T_GraphPropertyRef. The corresponding expression_tree_walker_impl() already handled all three node types, but the mutator did not, causing an "unrecognized node type: 106" error whenever a GRAPH_TABLE subquery appeared in a HAVING clause. The fix adds three case handlers mirroring the walker: - T_GraphPropertyRef: leaf node, FLATCOPY only - T_GraphElementPattern: FLATCOPY + MUTATE subexpr, whereClause - T_GraphPattern: FLATCOPY + MUTATE path_pattern_list, whereClause --- src/backend/nodes/nodeFuncs.c | 31 +++++++++++++++++++++++ src/test/regress/expected/graph_table.out | 15 +++++++++++ src/test/regress/sql/graph_table.sql | 9 +++++++ 3 files changed, 55 insertions(+) diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index c0b880ec..c18f2b0e 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -3810,6 +3810,37 @@ expression_tree_mutator_impl(Node *node, return (Node *) newnode; } break; + case T_GraphPropertyRef: + { + GraphPropertyRef *newnode; + + FLATCOPY(newnode, node, GraphPropertyRef); + /* leaf node, no expression subnodes */ + return (Node *) newnode; + } + break; + case T_GraphElementPattern: + { + GraphElementPattern *gep = (GraphElementPattern *) node; + GraphElementPattern *newnode; + + FLATCOPY(newnode, gep, GraphElementPattern); + MUTATE(newnode->subexpr, gep->subexpr, List *); + MUTATE(newnode->whereClause, gep->whereClause, Node *); + return (Node *) newnode; + } + break; + case T_GraphPattern: + { + GraphPattern *gp = (GraphPattern *) node; + GraphPattern *newnode; + + FLATCOPY(newnode, gp, GraphPattern); + MUTATE(newnode->path_pattern_list, gp->path_pattern_list, List *); + MUTATE(newnode->whereClause, gp->whereClause, Node *); + return (Node *) newnode; + } + break; default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); diff --git a/src/test/regress/expected/graph_table.out b/src/test/regress/expected/graph_table.out index b579e3df..5e57d248 100644 --- a/src/test/regress/expected/graph_table.out +++ b/src/test/regress/expected/graph_table.out @@ -1022,4 +1022,19 @@ SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > ERROR: subqueries within GRAPH_TABLE reference are not supported SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); ERROR: subqueries within GRAPH_TABLE reference are not supported +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + vname | count +-------+------- + v13 | 1 + v12 | 1 + v11 | 1 +(3 rows) + -- leave the objects behind for pg_upgrade/pg_dump tests diff --git a/src/test/regress/sql/graph_table.sql b/src/test/regress/sql/graph_table.sql index 4ff98817..3d5224d3 100644 --- a/src/test/regress/sql/graph_table.sql +++ b/src/test/regress/sql/graph_table.sql @@ -582,4 +582,13 @@ SELECT * FROM customers co WHERE co.customer_id = (SELECT customer_id FROM GRAPH SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > (SELECT max(v1.vprop1) FROM v1) COLUMNS(src.vname AS sname, dest.vname AS dname)); SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + -- leave the objects behind for pg_upgrade/pg_dump tests -- 2.43.0 ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-04-23 06:48 Ashutosh Bapat <[email protected]> parent: SATYANARAYANA NARLAPURAM <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Ashutosh Bapat @ 2026-04-23 06:48 UTC (permalink / raw) To: SATYANARAYANA NARLAPURAM <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]> On Tue, Apr 21, 2026 at 9:26 PM SATYANARAYANA NARLAPURAM <[email protected]> wrote: > > Hi hackers, > > expression_tree_mutator_impl() was missing case handlers for > T_GraphPattern, T_GraphElementPattern, and T_GraphPropertyRef. > The corresponding expression_tree_walker_impl() already handled > all three node types, but the mutator did not, causing an > "unrecognized node type: 106" error whenever a GRAPH_TABLE > subquery appeared in a HAVING clause. > > SELECT 1 FROM hv GROUP BY id > HAVING (SELECT COUNT(*) FROM GRAPH_TABLE(gh MATCH (a) COLUMNS (a.id AS x))) > 0; > SET > ERROR: unrecognized node type: 106 > > Attached a patch to address this. Thanks for the report and the patch. I first thought that the nodes needn't be part of the mutator since they will be rewritten into some other nodes. But in this case the mutator is being called from the transformation phase which does not rewrite these nodes. I also found that range_table_mutator_impl() invokes MUTATE on RangeTblEntry::graph_table and RangeTblEntry::graph_table_columns which contain these three nodes in their trees. So it seems like we forgot to handle these three nodes in expression_tree_mutator(). From the name of the function, I thought it only handles expressions (nodes which have Expr as their first member). In that case adding GraphElementPattern and GraphPattern should be handled somewhere else. But it seems the function also handles Node types as well (e.g. List, TableFunc). GraphPropertyRef has char *elvarname. Only the char * is copied by FLATCOPY but not the character string it's pointing to. That made me a bit uncomfortable because the mutated GraphPropertyRef would point to the old name. But it looks like that's how other node types are handled in that function. E.g. XmlExpr has member name which is also FLATCOPY'ed. So we are good. Why is MUTATE not called on GraphElementPattern::labelexpr and GraphElementPattern::quantifier? The test query is placed at the appropriate section in the file. I would try to fit the query in lesser lines by placing SELECT, FROM, GROUP BY on the same line. But that's more of a personal style. -- Best Wishes, Ashutosh Bapat ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-04-28 15:05 Ashutosh Bapat <[email protected]> parent: Ashutosh Bapat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Ashutosh Bapat @ 2026-04-28 15:05 UTC (permalink / raw) To: SATYANARAYANA NARLAPURAM <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]> On Thu, Apr 23, 2026 at 12:18 PM Ashutosh Bapat <[email protected]> wrote: > > > Why is MUTATE not called on GraphElementPattern::labelexpr and > GraphElementPattern::quantifier? The walker didn't WALK labelexpr and quantifier either. Given that labelexpr is a boolean expression it needs to be WALKed. quantifier is IntList which is ignored by other nodes as well when WALKing. But we need to copy quantifier in mutator otherwise the mutated expression will point to the same IntList as the original node. Other nodes also copy the OidLists and IntLists when mutating them. I have modified the test query to cover the label expression mutator. raw_expression_walker didn't cover labelexpr either. Added it there. The label expression at that stage contains ColumnRef and BoolExpr which are already covered by raw expression tree walker. -- Best Wishes, Ashutosh Bapat Attachments: [text/x-patch] v20260428-0001-Handle-nodes-that-may-appear-in-GraphPatte.patch (6.0K, 2-v20260428-0001-Handle-nodes-that-may-appear-in-GraphPatte.patch) download | inline diff: From f0c7384ee37cf0b64d54efb53b2d97600ebdb928 Mon Sep 17 00:00:00 2001 From: satyanarayana narlapuram <[email protected]> Date: Tue, 21 Apr 2026 14:33:33 +0000 Subject: [PATCH v20260428 3/3] Handle nodes that may appear in GraphPattern expression trees expression_tree_mutator_impl() was missing case handlers for T_GraphPattern, T_GraphElementPattern, and T_GraphPropertyRef. The corresponding expression_tree_walker_impl() already handled all three node types, but the mutator did not, causing an "unrecognized node type " error whenever a GRAPH_TABLE appeared in an expression tree. While at it also update raw_expression_tree_walker() and expression_tree_walker() to handle missing nodes that may appear in GraphPattern expression trees. When raw_expression_tree_walker() is called, GraphElementPattern::labelexpr does contains ColumnRefs instead of GraphLabelRefs. Hence those are not handled in raw_expression_tree_walker(). Reported by: Satyanarayana Narlapuram <[email protected]> Author: Satyanarayana Narlapuram <[email protected]> Author: Ashutosh Bapat <[email protected]> Reviewed by: Ashutosh Bapat <[email protected]> Discussion: https://www.postgresql.org/message-id/CAHg+QDc97WFTSkXg=g_ZAH8GnY2gJrvq72cs+YjqEAuZgXnkAQ@mail.gmail.com --- src/backend/nodes/nodeFuncs.c | 45 +++++++++++++++++++++++ src/test/regress/expected/graph_table.out | 15 ++++++++ src/test/regress/sql/graph_table.sql | 9 +++++ 3 files changed, 69 insertions(+) diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 7edbd5b7225..db2eff343d7 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2135,6 +2135,7 @@ expression_tree_walker_impl(Node *node, case T_RangeTblRef: case T_SortGroupClause: case T_CTESearchClause: + case T_GraphLabelRef: case T_GraphPropertyRef: case T_MergeSupportFunc: /* primitive node types with no expression subnodes */ @@ -2698,6 +2699,8 @@ expression_tree_walker_impl(Node *node, { GraphElementPattern *gep = (GraphElementPattern *) node; + if (WALK(gep->labelexpr)) + return true; if (WALK(gep->subexpr)) return true; if (WALK(gep->whereClause)) @@ -3814,6 +3817,46 @@ expression_tree_mutator_impl(Node *node, return (Node *) newnode; } break; + case T_GraphLabelRef: + { + GraphLabelRef *newnode; + + FLATCOPY(newnode, node, GraphLabelRef); + return (Node *) newnode; + } + break; + case T_GraphPropertyRef: + { + GraphPropertyRef *newnode; + + FLATCOPY(newnode, node, GraphPropertyRef); + return (Node *) newnode; + } + break; + case T_GraphElementPattern: + { + GraphElementPattern *gep = (GraphElementPattern *) node; + GraphElementPattern *newnode; + + FLATCOPY(newnode, gep, GraphElementPattern); + MUTATE(newnode->labelexpr, gep->labelexpr, Node *); + MUTATE(newnode->subexpr, gep->subexpr, List *); + MUTATE(newnode->whereClause, gep->whereClause, Node *); + newnode->quantifier = list_copy(gep->quantifier); + return (Node *) newnode; + } + break; + case T_GraphPattern: + { + GraphPattern *gp = (GraphPattern *) node; + GraphPattern *newnode; + + FLATCOPY(newnode, gp, GraphPattern); + MUTATE(newnode->path_pattern_list, gp->path_pattern_list, List *); + MUTATE(newnode->whereClause, gp->whereClause, Node *); + return (Node *) newnode; + } + break; default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); @@ -4796,6 +4839,8 @@ raw_expression_tree_walker_impl(Node *node, { GraphElementPattern *gep = (GraphElementPattern *) node; + if (WALK(gep->labelexpr)) + return true; if (WALK(gep->subexpr)) return true; if (WALK(gep->whereClause)) diff --git a/src/test/regress/expected/graph_table.out b/src/test/regress/expected/graph_table.out index 12b8706b5f3..8038fcd39b7 100644 --- a/src/test/regress/expected/graph_table.out +++ b/src/test/regress/expected/graph_table.out @@ -1032,4 +1032,19 @@ SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > ERROR: subqueries within GRAPH_TABLE reference are not supported SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); ERROR: subqueries within GRAPH_TABLE reference are not supported +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1 | vl2) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + vname | count +-------+------- + v13 | 1 + v12 | 1 + v11 | 1 +(3 rows) + -- leave the objects behind for pg_upgrade/pg_dump tests diff --git a/src/test/regress/sql/graph_table.sql b/src/test/regress/sql/graph_table.sql index a5df4647b6a..a3681c6c0ef 100644 --- a/src/test/regress/sql/graph_table.sql +++ b/src/test/regress/sql/graph_table.sql @@ -590,4 +590,13 @@ SELECT * FROM customers co WHERE co.customer_id = (SELECT customer_id FROM GRAPH SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > (SELECT max(v1.vprop1) FROM v1) COLUMNS(src.vname AS sname, dest.vname AS dname)); SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1 | vl2) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + -- leave the objects behind for pg_upgrade/pg_dump tests -- 2.34.1 ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-04-29 20:46 Robert Haas <[email protected]> parent: Ashutosh Bapat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Robert Haas @ 2026-04-29 20:46 UTC (permalink / raw) To: Ashutosh Bapat <[email protected]>; +Cc: SATYANARAYANA NARLAPURAM <[email protected]>; PostgreSQL Hackers <[email protected]> On Tue, Apr 28, 2026 at 11:05 AM Ashutosh Bapat <[email protected]> wrote: > The walker didn't WALK labelexpr and quantifier either. Given that > labelexpr is a boolean expression it needs to be WALKed. quantifier is > IntList which is ignored by other nodes as well when WALKing. But we > need to copy quantifier in mutator otherwise the mutated expression > will point to the same IntList as the original node. Other nodes also > copy the OidLists and IntLists when mutating them. I have modified the > test query to cover the label expression mutator. > > raw_expression_walker didn't cover labelexpr either. Added it there. > The label expression at that stage contains ColumnRef and BoolExpr > which are already covered by raw expression tree walker. Hi, Thanks for working on this. I ran into it independently today, and then discovered this thread. In expression_tree_mutator_impl, T_GraphLabelRef can be added to the "Primitive node types with no expression subnodes" section just as was done in expression_tree_walker_impl. Other than that, this looks good to me. -- Robert Haas EDB: http://www.enterprisedb.com ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-04-30 06:44 Ashutosh Bapat <[email protected]> parent: Robert Haas <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Ashutosh Bapat @ 2026-04-30 06:44 UTC (permalink / raw) To: Robert Haas <[email protected]>; +Cc: SATYANARAYANA NARLAPURAM <[email protected]>; PostgreSQL Hackers <[email protected]> On Thu, Apr 30, 2026 at 2:17 AM Robert Haas <[email protected]> wrote: > Thanks for reviewing the patch. > Thanks for working on this. I ran into it independently today, and > then discovered this thread. In expression_tree_mutator_impl, > T_GraphLabelRef can be added to the "Primitive node types with no > expression subnodes" section just as was done in > expression_tree_walker_impl. Right. Fixed in the attached patch. Both GraphPropertyLabel and GraphLabelRef need to be placed in that section since both are primitive nodes. -- Best Wishes, Ashutosh Bapat Attachments: [text/x-patch] v20260430-0001-Handle-nodes-that-may-appear-in-GraphPatte.patch (6.0K, 2-v20260430-0001-Handle-nodes-that-may-appear-in-GraphPatte.patch) download | inline diff: From f2e847421c52ea3073a82cc30ad0072d5cd68c58 Mon Sep 17 00:00:00 2001 From: satyanarayana narlapuram <[email protected]> Date: Tue, 21 Apr 2026 14:33:33 +0000 Subject: [PATCH v20260430 3/5] Handle nodes that may appear in GraphPattern expression trees expression_tree_mutator_impl() was does not handle T_GraphPattern, T_GraphElementPattern, and T_GraphPropertyRef. The corresponding expression_tree_walker_impl() already handles all three node types. This causes an "unrecognized node type " error whenever a GRAPH_TABLE appeared in an expression tree. While at it also update raw_expression_tree_walker() and expression_tree_walker() to handle missing nodes that may appear in GraphPattern expression trees. When raw_expression_tree_walker() is called, GraphElementPattern::labelexpr does contains ColumnRefs instead of GraphLabelRefs. Hence those are not handled in raw_expression_tree_walker(). Reported by: Satyanarayana Narlapuram <[email protected]> Author: Satyanarayana Narlapuram <[email protected]> Author: Ashutosh Bapat <[email protected]> Reviewed by: Ashutosh Bapat <[email protected]> Reviewed by: Robert Haas <[email protected]> Discussion: https://www.postgresql.org/message-id/CAHg+QDc97WFTSkXg=g_ZAH8GnY2gJrvq72cs+YjqEAuZgXnkAQ@mail.gmail.com --- src/backend/nodes/nodeFuncs.c | 31 +++++++++++++++++++++++ src/test/regress/expected/graph_table.out | 15 +++++++++++ src/test/regress/sql/graph_table.sql | 9 +++++++ 3 files changed, 55 insertions(+) diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 7edbd5b7225..a712b76eeb1 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2135,6 +2135,7 @@ expression_tree_walker_impl(Node *node, case T_RangeTblRef: case T_SortGroupClause: case T_CTESearchClause: + case T_GraphLabelRef: case T_GraphPropertyRef: case T_MergeSupportFunc: /* primitive node types with no expression subnodes */ @@ -2698,6 +2699,8 @@ expression_tree_walker_impl(Node *node, { GraphElementPattern *gep = (GraphElementPattern *) node; + if (WALK(gep->labelexpr)) + return true; if (WALK(gep->subexpr)) return true; if (WALK(gep->whereClause)) @@ -3062,6 +3065,8 @@ expression_tree_mutator_impl(Node *node, case T_SortGroupClause: case T_CTESearchClause: case T_MergeSupportFunc: + case T_GraphLabelRef: + case T_GraphPropertyRef: return copyObject(node); case T_WithCheckOption: { @@ -3814,6 +3819,30 @@ expression_tree_mutator_impl(Node *node, return (Node *) newnode; } break; + case T_GraphElementPattern: + { + GraphElementPattern *gep = (GraphElementPattern *) node; + GraphElementPattern *newnode; + + FLATCOPY(newnode, gep, GraphElementPattern); + MUTATE(newnode->labelexpr, gep->labelexpr, Node *); + MUTATE(newnode->subexpr, gep->subexpr, List *); + MUTATE(newnode->whereClause, gep->whereClause, Node *); + newnode->quantifier = list_copy(gep->quantifier); + return (Node *) newnode; + } + break; + case T_GraphPattern: + { + GraphPattern *gp = (GraphPattern *) node; + GraphPattern *newnode; + + FLATCOPY(newnode, gp, GraphPattern); + MUTATE(newnode->path_pattern_list, gp->path_pattern_list, List *); + MUTATE(newnode->whereClause, gp->whereClause, Node *); + return (Node *) newnode; + } + break; default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); @@ -4796,6 +4825,8 @@ raw_expression_tree_walker_impl(Node *node, { GraphElementPattern *gep = (GraphElementPattern *) node; + if (WALK(gep->labelexpr)) + return true; if (WALK(gep->subexpr)) return true; if (WALK(gep->whereClause)) diff --git a/src/test/regress/expected/graph_table.out b/src/test/regress/expected/graph_table.out index 12b8706b5f3..8038fcd39b7 100644 --- a/src/test/regress/expected/graph_table.out +++ b/src/test/regress/expected/graph_table.out @@ -1032,4 +1032,19 @@ SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > ERROR: subqueries within GRAPH_TABLE reference are not supported SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); ERROR: subqueries within GRAPH_TABLE reference are not supported +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1 | vl2) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + vname | count +-------+------- + v13 | 1 + v12 | 1 + v11 | 1 +(3 rows) + -- leave the objects behind for pg_upgrade/pg_dump tests diff --git a/src/test/regress/sql/graph_table.sql b/src/test/regress/sql/graph_table.sql index a5df4647b6a..a3681c6c0ef 100644 --- a/src/test/regress/sql/graph_table.sql +++ b/src/test/regress/sql/graph_table.sql @@ -590,4 +590,13 @@ SELECT * FROM customers co WHERE co.customer_id = (SELECT customer_id FROM GRAPH SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE src.vprop1 > (SELECT max(v1.vprop1) FROM v1) COLUMNS(src.vname AS sname, dest.vname AS dname)); SELECT sname, dname FROM GRAPH_TABLE (g1 MATCH (src)->(dest) WHERE out_degree(src.vname) > (SELECT max(out_degree(nname)) FROM GRAPH_TABLE (g1 MATCH (node) COLUMNS (node.vname AS nname))) COLUMNS(src.vname AS sname, dest.vname AS dname)); +-- GRAPH_TABLE subquery in HAVING clause +SELECT src.vname, count(*) + FROM v1 AS src + GROUP BY src.vname + HAVING count(*) >= (SELECT count(*) + FROM GRAPH_TABLE (g1 MATCH (a IS vl1 | vl2) + COLUMNS (a.vname AS n)) + WHERE n = src.vname); + -- leave the objects behind for pg_upgrade/pg_dump tests -- 2.34.1 ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-05-04 15:39 Peter Eisentraut <[email protected]> parent: Ashutosh Bapat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Peter Eisentraut @ 2026-05-04 15:39 UTC (permalink / raw) To: Ashutosh Bapat <[email protected]>; Robert Haas <[email protected]>; +Cc: SATYANARAYANA NARLAPURAM <[email protected]>; PostgreSQL Hackers <[email protected]> On 30.04.26 08:44, Ashutosh Bapat wrote: > On Thu, Apr 30, 2026 at 2:17 AM Robert Haas <[email protected]> wrote: >> > > Thanks for reviewing the patch. > >> Thanks for working on this. I ran into it independently today, and >> then discovered this thread. In expression_tree_mutator_impl, >> T_GraphLabelRef can be added to the "Primitive node types with no >> expression subnodes" section just as was done in >> expression_tree_walker_impl. > > Right. Fixed in the attached patch. Both GraphPropertyLabel and > GraphLabelRef need to be placed in that section since both are > primitive nodes. Committed. (I reformatted the test query a little bit as you had suggested upstream. Also, the ordering of the switch cases was slightly different between the walker and the mutator, which I fixed.) ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [Patch]Add Graph* node support to expression_tree_mutator @ 2026-05-11 06:15 Ashutosh Bapat <[email protected]> parent: Peter Eisentraut <[email protected]> 0 siblings, 0 replies; 7+ messages in thread From: Ashutosh Bapat @ 2026-05-11 06:15 UTC (permalink / raw) To: Peter Eisentraut <[email protected]>; +Cc: Robert Haas <[email protected]>; SATYANARAYANA NARLAPURAM <[email protected]>; PostgreSQL Hackers <[email protected]> On Mon, May 4, 2026 at 9:09 PM Peter Eisentraut <[email protected]> wrote: > > On 30.04.26 08:44, Ashutosh Bapat wrote: > > On Thu, Apr 30, 2026 at 2:17 AM Robert Haas <[email protected]> wrote: > >> > > > > Thanks for reviewing the patch. > > > >> Thanks for working on this. I ran into it independently today, and > >> then discovered this thread. In expression_tree_mutator_impl, > >> T_GraphLabelRef can be added to the "Primitive node types with no > >> expression subnodes" section just as was done in > >> expression_tree_walker_impl. > > > > Right. Fixed in the attached patch. Both GraphPropertyLabel and > > GraphLabelRef need to be placed in that section since both are > > primitive nodes. > > Committed. (I reformatted the test query a little bit as you had > suggested upstream. Also, the ordering of the switch cases was slightly > different between the walker and the mutator, which I fixed.) > Thanks. The changes look good to me. -- Best Wishes, Ashutosh Bapat ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-05-11 06:15 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-04-21 15:56 [Patch]Add Graph* node support to expression_tree_mutator SATYANARAYANA NARLAPURAM <[email protected]> 2026-04-23 06:48 ` Ashutosh Bapat <[email protected]> 2026-04-28 15:05 ` Ashutosh Bapat <[email protected]> 2026-04-29 20:46 ` Robert Haas <[email protected]> 2026-04-30 06:44 ` Ashutosh Bapat <[email protected]> 2026-05-04 15:39 ` Peter Eisentraut <[email protected]> 2026-05-11 06:15 ` Ashutosh Bapat <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox