Re: SQL Property Graph Queries (SQL/PGQ)

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: assam258(at)gmail(dot)com
Cc: Junwang Zhao <zhjwpku(at)gmail(dot)com>, zengman <zengman(at)halodbtech(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Ajay Pal <ajay(dot)pal(dot)k(at)gmail(dot)com>, Imran Zaheer <imran(dot)zhir(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL Property Graph Queries (SQL/PGQ)
Date: 2026-03-20 13:42:04
Message-ID: CAExHW5uLV5iqyU-7AL1o8_01tz-y2oHGw2esF=53pi2VpxA9iA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 19, 2026 at 12:52 AM Henson Choi <assam258(at)gmail(dot)com> wrote:
>
> Hi Ashutosh,
>
> Thanks for the patch and the analysis.
>
>> In my patch I have added a test for forward reference, but didn't
>> implement the support for the same. I am not sure whether we want to
>> support forward references right now, for the reasons mentioned below
>>
>> a. Other products allow cross referencing, but it seems it's optional
>> in SQL standard. Conformance rule 11 of subclause 10.6 seems to make
>> the feature optional. If that's the case, we need to throw an error in
>> case of cross reference. Peter, what do you think?
>
>
> I looked into this. Conformance Rule 11 says:
>
> "Without Feature G041, 'Non-local element pattern predicates',
> in conforming SQL language, the <element pattern where clause>
> of an <element pattern> EP shall only reference the
> <element variable> declared in EP."
>
> This makes *all* cross-variable references in element WHERE clauses
> optional under G041 -- it does not distinguish between backward and
> forward references. So if we support G041 (which we effectively do,
> since backward cross-references already work after the
> list_make1(pe) -> graph_path fix), then SR 18 applies in full:
>
> "The scope of an <element variable> that is declared by an
> <element pattern> EP is the innermost <graph table> containing EP."
>
> The current state -- backward yes, forward no -- is a
> half-implementation that does not correspond to either option.
>
> We should either:
>
> (1) Support G041 fully -- both directions. Junwang's patch handles
> this cleanly with minimal code change, or
> (2) Not support G041 -- reject all non-local element pattern
> references, throwing an error for both directions.
>
> What do you think?

We will support the cross variable references in future once we
support more path patterns leading to a more mature code in that area.
But it doesn't harm to support backward references which can be easily
supported now. I don't see the code to do so getting disturbed as it
matures. For the segmentation fault a simple fix to add graph_pattern
suffices for now. Let's see if Peter has a different opinion.

--
Best Wishes,
Ashutosh Bapat

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexandre Felipe 2026-03-20 13:43:43 Re: Index scan with bitmap filter - has this been explored
Previous Message Andrey Borodin 2026-03-20 13:39:32 Re: Bug in MultiXact replay compat logic for older minor version after crash-recovery