On Thu, Mar 19, 2026 at 12:52 AM Henson Choi <[email protected]> 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


Reply via email to