Re: SQL Property Graph Queries (SQL/PGQ)

From: Henson Choi <assam258(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, zengman <zengman(at)halodbtech(dot)com>
Cc: 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-18 19:22:16
Message-ID: CAAAe_zCA_9=JWBf4S5o_C2=EO=6dBZ6-=T0TUH+z5cvJkrtaUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

Regards,
Henson

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-03-18 19:24:42 Re: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error
Previous Message Bertrand Drouvot 2026-03-18 19:15:33 Re: Enable -Wstrict-prototypes and -Wold-style-definition by default