Skip to content

Variable-length relationship patterns with a zero lower bound may fail to produce the expected zero-hop self-binding. #2382

Description

@Silence6666668

Describe the bug
Variable-length relationship patterns with a zero lower bound may fail to produce the expected zero-hop self-binding.

In the repro below, the graph contains a single Person node and no FRIEND relationships. Under Cypher semantics, the pattern [:FRIEND*0..1] should still match with length 0, so f should bind to the same node as p.

Instead, Apache AGE returns f = null, and collect(f.name) becomes [] instead of ['Alice'].

How are you accessing AGE (Command line, driver, etc.)?

  • PostgreSQL cypher(...) wrapper through the local Python differential-testing harness
  • Reproducible directly in psql inside the Docker container

What data setup do we need to do?

SELECT * FROM cypher('fuzz_graph', $$
  CREATE (:Person {name: 'Alice'})
$$) AS (v agtype);

What is the necessary configuration info needed?

  • Plain Apache AGE Docker image was enough
  • Docker image in local repro: apache/age
  • AGE extension version: 1.7.0
  • PostgreSQL version: 18.1
  • Graph name used in repro: fuzz_graph
  • No extra extensions or special configuration were required

What is the command that caused the error?

SELECT * FROM cypher('fuzz_graph', $$
  MATCH (p:Person {name: 'Alice'})
  OPTIONAL MATCH (p)-[:FRIEND*0..1]-(f:Person)
  RETURN p.name AS person, f.name AS friend
$$) AS (person agtype, friend agtype);

Returned result on AGE:

person | friend
-------+-------
Alice  | null

Expected behavior
The zero-hop match should bind f to the same node as p, so the expected result is:

person | friend
-------+-------
Alice  | Alice

Neo4j returns exactly that result for the equivalent Cypher query.

Environment (please complete the following information):

  • Version: Apache AGE 1.7.0
  • PostgreSQL: 18.1
  • Host OS: Windows 10
  • Architecture: x86_64
  • Deployment: Docker

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions