You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Could not find rte error when using path variable in WHERE #1045
It appears that the error is related to the pnsi in the transform_ColumnRef() function. The pnsi tries to receive a value from refnameNamespaceItem() but it returns nil. In this postgres function, it goes inside a loop and checks if the pstate variable is different than NULL, updating it with pstate = pstate->parentParseState;. It also verifies if the relid is valid with OidIsValid(relId)). Depending on this, it will call different functions to give a value for the result variable. If this variable has a non-nil value, it returns it. But this variable always receives a NULL value throughout the while loop.
while (pstate!=NULL)
{
ParseNamespaceItem*result;
if (OidIsValid(relId))
result=scanNameSpaceForRelid(pstate, relId, location);
elseresult=scanNameSpaceForRefname(pstate, refname, location);
if (result)
returnresult;
if (sublevels_up)
(*sublevels_up)++;
elsebreak;
pstate=pstate->parentParseState;
}
returnNULL;
After that, it goes back to AGE's function and the else error section is executed:
pnsi=refnameNamespaceItem(pstate, NULL, colname,
cref->location, &levels_up);
if (pnsi)
{
node=transform_WholeRowRef(pstate, pnsi, cref->location,
levels_up);
}
else
{
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("could not find rte for %s", colname),
parser_errposition(pstate, cref->location)));
}
The code calls only scanNamespaceItemForRefname(), and calls it three times. The rte->eref->aliasname has value only the first time this function is called, the other two times it contains no value. And these values are: 'm', '_', and 'b'. These characters match the same ones provided in the path (m)-[]->(b), but the 'p' character cannot be found. When it does the comparison of the strings with if (strcmp(rte->eref->aliasname, refname) == 0), it just skips that, not being able to find the correct nsitem and letting result to be nil.
if (strcmp(rte->eref->aliasname, refname) ==0)
{
if (result)
ereport(ERROR,
(errcode(ERRCODE_AMBIGUOUS_ALIAS),
errmsg("table reference \"%s\" is ambiguous",
refname),
parser_errposition(pstate, location)));
check_lateral_ref_ok(pstate, nsitem, location);
result=nsitem;
}
psql-15.4-5432-pgsql=# select * from create_graph('graph');
NOTICE: graph "graph" has been created
create_graph
--------------
(1 row)
psql-15.4-5432-pgsql=# SELECT * FROM cypher('graph',$$
psql-15.4-5432-pgsql$# CREATE (n)-[:KNOWS {n:'hello'}]->({n:'hello'})
psql-15.4-5432-pgsql$# $$) as (a agtype);
a
---
(0 rows)
psql-15.4-5432-pgsql=# SELECT * FROM cypher('graph', $$
psql-15.4-5432-pgsql$# MATCH p = (m)-[]->(b)
psql-15.4-5432-pgsql$# WHERE length(p) >1
psql-15.4-5432-pgsql$# RETURN p
psql-15.4-5432-pgsql$# $$) AS (pattern agtype);
ERROR: could not find rte for p
LINE 3: WHERE length(p) >1
^
psql-15.4-5432-pgsql=#
Activity
MatheusFarias03 commentedon Jul 21, 2023
It appears that the error is related to the
pnsiin thetransform_ColumnRef()function. Thepnsitries to receive a value fromrefnameNamespaceItem()but it returns nil. In this postgres function, it goes inside a loop and checks if thepstatevariable is different thanNULL, updating it withpstate = pstate->parentParseState;. It also verifies if therelidis valid withOidIsValid(relId)). Depending on this, it will call different functions to give a value for theresultvariable. If this variable has a non-nil value, it returns it. But this variable always receives a NULL value throughout the while loop.After that, it goes back to AGE's function and the else error section is executed:
The code calls only
scanNamespaceItemForRefname(), and calls it three times. Therte->eref->aliasnamehas value only the first time this function is called, the other two times it contains no value. And these values are: 'm', '_', and 'b'. These characters match the same ones provided in the path(m)-[]->(b), but the 'p' character cannot be found. When it does the comparison of the strings withif (strcmp(rte->eref->aliasname, refname) == 0), it just skips that, not being able to find the correct nsitem and letting result to be nil.jrgemignani commentedon Oct 21, 2023
@MatheusFarias03 @MuhammadTahaNaveed This looks to still be an issue -
Is there a plan to fix it?
MuhammadTahaNaveed commentedon Oct 23, 2023
@jrgemignani Thanks for bringing this up.... I'll be working on it.
Fix issue apache#1045 - error using path var in WHERE
Fix issue #1045 - error using path var in WHERE (#1295)
Fix issue #1045 - error using path var in WHERE (#1295)
Fix issue apache#1045 - error using path var in WHERE (apache#1295)
Added integer conversion in toBoolean functions