Skip to content

List predicates over relationship or node value lists in WHERE fail planning with XX000 "no relation entry for relid" #2624

Open

Description

@zihaozeng0021

List predicates over relationship or node value lists in WHERE fail planning with XX000 "no relation entry for relid"

Configuration

Docker Image: apache/age:release_PG18_1.8.0
Image Digest: sha256:47a0b054c3663a3e64a25fc0c5a982f1b58348019274b326a691cdf77f78eb58
PostgreSQL Version: 18.6
Apache AGE Extension Version: 1.8.0
Operating System: WSL2, Ubuntu 24.04.1 LTS
Installation Method: Docker
Query Interface: psql (SELECT * FROM cypher('xgdb', $$ ... $$) AS (...))


Description

A list predicate function (all / any / none / single) applied in
WHERE to a relationship or node value list - for example all(x IN e WHERE x.id > 0) over the
relationship-list variable e of a variable-length pattern - aborts query planning with the
PostgreSQL internal error XX000: no relation entry for relid 2
(find_base_rel, relnode.c:426). The query never reaches execution. The failure is independent
of data (an empty graph triggers it as well) and of the surrounding pattern shape.


Steps to reproduce

  1. Start the AGE container and connect with psql.
  2. Create one edge, then run the predicate query:
SELECT ag_catalog.create_graph('xgdb');
SELECT * FROM cypher('xgdb', $$ CREATE (:A {x: 1})-[:E {id: 1}]->(:B) $$) AS (r agtype);
SELECT * FROM cypher('xgdb', $$ MATCH (:A {x: 1})-[e:E*0..1]->(m) WHERE all(x IN e WHERE x.id > 0) RETURN 1 $$) AS (one agtype);
  1. Minimize with the probe set: variants without the
    inline node filter (P1), with a plain label variable (P2), with the vacuous predicate
    all(x IN e WHERE true) (P3), and with count(*) (P4) all fail the same way; the controls
    all([f]) (P5), all([n]) (P6), and e[0].id (P7) all succeed.

Expected behaviour

Per openCypher, a variable-length relationship variable binds a list of relationships and
all() is a documented predicate function that is vacuously true on the empty list. The query
must execute and return one row per match (2 rows on this data). At worst an unsupported shape
should fail with a clean user-level error, never with an internal planner error.


Actual behaviour

Planning aborts before execution on every fresh-container run
(both runs end with EXIT=3):

ERROR:  no relation entry for relid 2

With \set VERBOSITY verbose:

ERROR:  XX000: no relation entry for relid 2
LOCATION:  find_base_rel, relnode.c:426

Workarounds succeed on the same data: projecting the list through
WITH first (W1) returns 2 rows, and placing the predicate in RETURN (W2) returns true, true.
Upstream #2516 (open) reports the same signature for all/any/none/single over
nodes(p).


Minimal reproduction

SELECT * FROM cypher('xgdb', $$ MATCH (:A {x: 1})-[e:E*0..1]->(m) WHERE all(x IN e WHERE x.id > 0) RETURN 1 $$) AS (one agtype);

An empty graph triggers the same error; no data required.


Why this appears to be a bug

A documented Cypher construct (list predicate over a variable-length relationship list) crashes
the planner with an internal error that leaks implementation details (relnode.c location). The
same predicates work when the list is computed through WITH or in RETURN, isolating the
defect to the planner's handling of the predicate's list expression in WHERE.

Activity

  1. added
    bug
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions