public inbox for [email protected]  
help / color / mirror / Atom feed
BUG #19542: Boolean syntax in GRAPH_TABLE
3+ messages / 3 participants
[nested] [flat]

* BUG #19542: Boolean syntax in GRAPH_TABLE
@ 2026-07-03 13:25 PG Bug reporting form <[email protected]>
  2026-07-05 08:20 ` Re: BUG #19542: Boolean syntax in GRAPH_TABLE vaibhave postgres <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2026-07-03 13:25 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following bug has been logged on the website:

Bug reference:      19542
Logged by:          Hervé Lefebvre
Email address:      [email protected]
PostgreSQL version: 19beta1
Operating system:   Linux
Description:        

In MATCH clause you cannot use "WHERE boolean" Syntax. aka :

select * from GRAPH_TABLE (trajet MATCH ( a IS quai where
a.nom_station='Place des Fêtes' )-[t IS dessert where t.correspondance ]->(b
IS quai) columns (a.nom_station as station1, a.num_ligne as ligne1,
b.nom_station as station2, b.num_ligne as ligne2, T.correspondance as
correspondance));
ERROR:  unrecognized node type: 63

You have to add " = true"  (ugly) :
select * from GRAPH_TABLE (trajet MATCH ( a IS quai where
a.nom_station='Place des Fêtes' )-[t IS dessert where t.correspondance=true
]->(b IS quai) columns (a.nom_station as station1, a.num_ligne as ligne1,
b.nom_station as station2, b.num_ligne as ligne2, T.correspondance as
correspondance));
    station1     | ligne1 |    station2     | ligne2 | correspondance
-----------------+--------+-----------------+--------+----------------
 Place des Fêtes | 7bis   | Place des Fêtes | 11     | t
 Place des Fêtes | 11     | Place des Fêtes | 7bis   | t
(2 rows)








^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #19542: Boolean syntax in GRAPH_TABLE
  2026-07-03 13:25 BUG #19542: Boolean syntax in GRAPH_TABLE PG Bug reporting form <[email protected]>
@ 2026-07-05 08:20 ` vaibhave postgres <[email protected]>
  2026-07-08 07:51   ` Re: BUG #19542: Boolean syntax in GRAPH_TABLE Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: vaibhave postgres @ 2026-07-05 08:20 UTC (permalink / raw)
  To: [email protected]; [email protected]

Thanks for reporting.

The crash comes from replace_property_refs()
(src/backend/rewrite/rewriteGraphTable.c) which rewrites the
GraphPropertyRef nodes.

It calls expression_tree_mutator() directly on the top level node instead
of calling it's mutator (replace_property_refs_mutator()) which treats
GraphPropertyRef as a leaf & just copies it unchanged.

```
case T_GraphLabelRef:
case T_GraphPropertyRef:
case T_MergeSupportFunc:

return copyObject(node);

```


The fix is to call the mutator directly at the entry point.

Thanks,
Vaibhave.

On Fri, Jul 3, 2026 at 7:53 PM PG Bug reporting form <[email protected]>
wrote:

> The following bug has been logged on the website:
>
> Bug reference:      19542
> Logged by:          Hervé Lefebvre
> Email address:      [email protected]
> PostgreSQL version: 19beta1
> Operating system:   Linux
> Description:
>
> In MATCH clause you cannot use "WHERE boolean" Syntax. aka :
>
> select * from GRAPH_TABLE (trajet MATCH ( a IS quai where
> a.nom_station='Place des Fêtes' )-[t IS dessert where t.correspondance
> ]->(b
> IS quai) columns (a.nom_station as station1, a.num_ligne as ligne1,
> b.nom_station as station2, b.num_ligne as ligne2, T.correspondance as
> correspondance));
> ERROR:  unrecognized node type: 63
>
> You have to add " = true"  (ugly) :
> select * from GRAPH_TABLE (trajet MATCH ( a IS quai where
> a.nom_station='Place des Fêtes' )-[t IS dessert where t.correspondance=true
> ]->(b IS quai) columns (a.nom_station as station1, a.num_ligne as ligne1,
> b.nom_station as station2, b.num_ligne as ligne2, T.correspondance as
> correspondance));
>     station1     | ligne1 |    station2     | ligne2 | correspondance
> -----------------+--------+-----------------+--------+----------------
>  Place des Fêtes | 7bis   | Place des Fêtes | 11     | t
>  Place des Fêtes | 11     | Place des Fêtes | 7bis   | t
> (2 rows)
>
>
>
>
>


Attachments:

  [application/octet-stream] fix-19542.patch (2.7K, ../../CAM_eQjx8oO1CwcnYukKsTzzy-rcTn2vHdXk3jtgA91ZdoQ=4nw@mail.gmail.com/3-fix-19542.patch)
  download | inline diff:
diff --git a/src/backend/rewrite/rewriteGraphTable.c b/src/backend/rewrite/rewriteGraphTable.c
index 33d4e866d74..d8c364d6588 100644
--- a/src/backend/rewrite/rewriteGraphTable.c
+++ b/src/backend/rewrite/rewriteGraphTable.c
@@ -1152,7 +1152,11 @@ replace_property_refs(Oid propgraphid, Node *node, const List *mappings)
 	context.mappings = mappings;
 	context.propgraphid = propgraphid;
 
-	return expression_tree_mutator(node, replace_property_refs_mutator, &context);
+	/*
+	 * Invoke the mutator directly rather than through expression_tree_mutator()
+	 * so that a top-level GraphPropertyRef is replaced too.
+	 */
+	return replace_property_refs_mutator(node, &context);
 }
 
 /*
diff --git a/src/test/regress/expected/graph_table.out b/src/test/regress/expected/graph_table.out
index cc6d80afd82..9e62d213e38 100644
--- a/src/test/regress/expected/graph_table.out
+++ b/src/test/regress/expected/graph_table.out
@@ -1044,4 +1044,23 @@ SELECT src.vname, count(*) FROM v1 AS src
  v13   |     1
 (3 rows)
 
+-- a WHERE clause that is a bare boolean property reference (a top-level
+-- GraphPropertyRef) must be rewritten just like a nested property reference
+ALTER PROPERTY GRAPH g1 ALTER VERTEX TABLE v1 ALTER LABEL vl1 ADD PROPERTIES (vprop1 > 15 AS is_big);
+-- bare boolean property in an element pattern WHERE clause
+SELECT * FROM GRAPH_TABLE (g1 MATCH (a IS vl1 WHERE a.is_big) COLUMNS (a.vname AS self)) ORDER BY self;
+ self 
+------
+ v12
+ v13
+(2 rows)
+
+-- bare boolean property in the graph pattern WHERE clause
+SELECT * FROM GRAPH_TABLE (g1 MATCH (a IS vl1) WHERE a.is_big COLUMNS (a.vname AS self)) ORDER BY self;
+ self 
+------
+ v12
+ v13
+(2 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 0e381ec72bc..46668233e64 100644
--- a/src/test/regress/sql/graph_table.sql
+++ b/src/test/regress/sql/graph_table.sql
@@ -596,4 +596,12 @@ SELECT src.vname, count(*) FROM v1 AS src
   HAVING count(*) >= (SELECT count(*) FROM GRAPH_TABLE (g1 MATCH (a IS vl1 | vl2) COLUMNS (a.vname AS n)) WHERE n = src.vname)
   ORDER BY vname;
 
+-- a WHERE clause that is a bare boolean property reference (a top-level
+-- GraphPropertyRef) must be rewritten just like a nested property reference
+ALTER PROPERTY GRAPH g1 ALTER VERTEX TABLE v1 ALTER LABEL vl1 ADD PROPERTIES (vprop1 > 15 AS is_big);
+-- bare boolean property in an element pattern WHERE clause
+SELECT * FROM GRAPH_TABLE (g1 MATCH (a IS vl1 WHERE a.is_big) COLUMNS (a.vname AS self)) ORDER BY self;
+-- bare boolean property in the graph pattern WHERE clause
+SELECT * FROM GRAPH_TABLE (g1 MATCH (a IS vl1) WHERE a.is_big COLUMNS (a.vname AS self)) ORDER BY self;
+
 -- leave the objects behind for pg_upgrade/pg_dump tests


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #19542: Boolean syntax in GRAPH_TABLE
  2026-07-03 13:25 BUG #19542: Boolean syntax in GRAPH_TABLE PG Bug reporting form <[email protected]>
  2026-07-05 08:20 ` Re: BUG #19542: Boolean syntax in GRAPH_TABLE vaibhave postgres <[email protected]>
@ 2026-07-08 07:51   ` Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Peter Eisentraut @ 2026-07-08 07:51 UTC (permalink / raw)
  To: vaibhave postgres <[email protected]>; [email protected]; [email protected]

On 05.07.26 10:20, vaibhave postgres wrote:
> Thanks for reporting.
> 
> The crash comes from replace_property_refs() (src/backend/rewrite/ 
> rewriteGraphTable.c) which rewrites the GraphPropertyRef nodes.
> 
> It calls expression_tree_mutator() directly on the top level node 
> instead of calling it's mutator (replace_property_refs_mutator()) which 
> treats GraphPropertyRef as a leaf & just copies it unchanged.
> 
>     ```
>     case T_GraphLabelRef:
>     case T_GraphPropertyRef:
>     case T_MergeSupportFunc:
> 
>         return copyObject(node);
> 
>     ```
> 
> 
> The fix is to call the mutator directly at the entry point.

Thanks, this has also been discovered in [0], and the fix there is the same.

[0]: 
https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com







^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-07-08 07:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 13:25 BUG #19542: Boolean syntax in GRAPH_TABLE PG Bug reporting form <[email protected]>
2026-07-05 08:20 ` vaibhave postgres <[email protected]>
2026-07-08 07:51   ` Peter Eisentraut <[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