public inbox for [email protected]  
help / color / mirror / Atom feed
From: vaibhave postgres <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: BUG #19542: Boolean syntax in GRAPH_TABLE
Date: Sun, 5 Jul 2026 13:50:18 +0530
Message-ID: <CAM_eQjx8oO1CwcnYukKsTzzy-rcTn2vHdXk3jtgA91ZdoQ=4nw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[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


view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: BUG #19542: Boolean syntax in GRAPH_TABLE
  In-Reply-To: <CAM_eQjx8oO1CwcnYukKsTzzy-rcTn2vHdXk3jtgA91ZdoQ=4nw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox