pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix cross variable references in graph pattern causing segfault
Date: Tue, 31 Mar 2026 09:53:08 +0000
Message-ID: <E1w7VmV-002I3X-0h@gemulon.postgresql.org> (raw)

Fix cross variable references in graph pattern causing segfault

When converting the WHERE clause in an element pattern,
generate_query_for_graph_path() calls replace_property_refs() to
replace the property references in it.  Only the current graph element
pattern is passed as the context for replacement.  If there are
references to variables from other element patterns, it causes a
segmentation fault (an assertion failure in an Assert enabled build)
since it does not find path_element object corresponding to those
variables.

We do not support forward and backward variable references within a
graph table clause.  Hence prohibit all the cross references.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reported-by: Man Zeng <zengman@halodbtech.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5u6AoDfNg4%3DR5eVJn_bJn%3DC%3DwVPrto02P_06fxy39fniA%40ma...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a0dd0702e464f206b08c99a74cb58809c51aafa5

Modified Files
--------------
src/backend/parser/parse_graphtable.c     | 43 ++++++++++++++++++++++++++++---
src/include/parser/parse_node.h           |  3 +++
src/test/regress/expected/graph_table.out | 20 ++++++++++++++
src/test/regress/sql/graph_table.sql      |  8 ++++++
4 files changed, 71 insertions(+), 3 deletions(-)



Message-ID: <E1w7VmV-002I3X-0h@gemulon.postgresql.org>
Permalink:  ../E1w7VmV-002I3X-0h@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w7VmV-002I3X-0h@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix cross variable references in graph pattern causing segfault
  In-Reply-To: <E1w7VmV-002I3X-0h@gemulon.postgresql.org>

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

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