]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add a graph pattern variable only once
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 27 Mar 2026 09:49:49 +0000 (10:49 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 27 Mar 2026 09:55:17 +0000 (10:55 +0100)
An element pattern variable may be repeated in the path pattern.
GraphTableParseState maintains a list of all variable names used in
the graph pattern.  Add a new variable name to that list only when it
is not present already.  This isn't a problem right now, but it could
be in the future.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5tR4O0vjeqTCPr2VB5pYjNYbJgbCBEQf63NtU5Pz1MiOQ%40mail.gmail.com

src/backend/parser/parse_graphtable.c

index 136d87e61cf4f6e048e88ca34136db4d4a4bb892..49ec5c469c2330fa493381b4501e3e3e5c4b5fba 100644 (file)
@@ -231,7 +231,7 @@ transformGraphElementPattern(ParseState *pstate, GraphElementPattern *gep)
                                 errmsg("element pattern quantifier is not supported")));
 
        if (gep->variable)
-               gpstate->variables = lappend(gpstate->variables, makeString(pstrdup(gep->variable)));
+               gpstate->variables = list_append_unique(gpstate->variables, makeString(pstrdup(gep->variable)));
 
        gep->labelexpr = transformLabelExpr(gpstate, gep->labelexpr);