Skip to content

MATCH may fail to see nodes that were created earlier in the same Cypher query after a WITH boundary. #2390

@Silence6666668

Description

@Silence6666668

Describe the bug
MATCH may fail to see nodes that were created earlier in the same Cypher query after a WITH boundary.

In the minimized repro below, the query creates two Person nodes, carries them through WITH, and then immediately runs MATCH (x:Person). Under Cypher semantics, that MATCH should see the two newly created nodes and produce two rows.

Instead, Apache AGE returns no rows at all.

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 create_graph('fuzz_graph');

No graph data is required beyond creating an empty graph.

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', $$
  CREATE (a:Person {id: 1, name: 'Alice'}),
         (m:Person {id: 2, name: 'Bob'})
  WITH a, m
  MATCH (x:Person)
  RETURN a, m, x
$$) AS (a agtype, m agtype, x agtype);

Returned result on AGE:

(0 rows)

Expected behavior
The MATCH (x:Person) clause should see the two newly created nodes, so the query should return two rows.

Observed behavior on both Neo4j and Memgraph:

a = Alice, m = Bob, x = Alice
a = Alice, m = Bob, x = Bob

Environment (please complete the following information):

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

Additional context
A smaller control case without the post-WITH MATCH behaves normally on the same AGE instance:

SELECT * FROM cypher('fuzz_graph', $$
  CREATE (a:Person {id: 1, name: 'Alice'}),
         (m:Person {id: 2, name: 'Bob'})
  WITH a, m
  RETURN a, m
$$) AS (a agtype, m agtype);

AGE returns the two created nodes correctly there.

A filtered variant also fails unexpectedly:

SELECT * FROM cypher('fuzz_graph', $$
  CREATE (a:Person {id: 1, name: 'Alice'}),
         (m:Person {id: 2, name: 'Bob'})
  WITH a, m
  MATCH (x:Person)
  WHERE x.id = 1
  RETURN a, m
$$) AS (a agtype, m agtype);

Neo4j and Memgraph return one row, but AGE still returns no rows.

This same family also appeared during automated differential testing in larger queries such as:

UNWIND range(1, 3) AS i
CREATE (n:Person {id: i})
SET n.name = 'Person' + toString(i)
WITH n
MATCH (m:Person)
OPTIONAL MATCH path = (n)-[:KNOWS]->(m)
RETURN n, m, path

and:

MATCH (p:Person)
WITH p ORDER BY p.age DESC LIMIT 2
CREATE (new:City {name: 'Metropolis'})
WITH collect(p) AS people, new
MATCH (c:City)
WHERE c.name = new.name
RETURN c.name AS city, count(people) AS resident_count, people

In both of those larger variants, Neo4j and Memgraph return rows, while AGE returns none.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions