Re: SQL Property Graph Queries (SQL/PGQ) - Mailing list pgsql-hackers

From Henson Choi
Subject Re: SQL Property Graph Queries (SQL/PGQ)
Date
Msg-id CAAAe_zCA_9=JWBf4S5o_C2=EO=6dBZ6-=T0TUH+z5cvJkrtaUA@mail.gmail.com
Whole thread
In response to Re: SQL Property Graph Queries (SQL/PGQ)  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Responses [PATCH] rewriteGraphTable: Fix missing RTEs in FROM clause by setting inFromCl=true
Re: SQL Property Graph Queries (SQL/PGQ)
List 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 

pgsql-hackers by date:

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