Skip to content

When a query has multiple input rows, creating a node into a variable and then immediately creating a relationship to that variable may fail with: #2389

@Silence6666668

Description

@Silence6666668

Describe the bug
When a query has multiple input rows, creating a node into a variable and then immediately creating a relationship to that variable may fail with:

vertex assigned to variable new was deleted

In the repro below, the query should create one new Person node per matched a row, connect a to that new node, and then return the matched names.

Instead, Apache AGE errors out during execution.

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'}),
         (:Person {name:'Bob'})
$$) 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 (a:Person)
  CREATE (new:Person {name:'Zoe'})
  CREATE (a)-[:FRIEND]->(new)
  RETURN a.name AS a_name
$$) AS (a_name agtype);

Returned result on AGE:

ERROR: vertex assigned to variable new was deleted

Expected behavior
The query should succeed and return the two matched rows:

Alice
Bob

Neo4j returns exactly those two rows for the equivalent Cypher query.

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
Two nearby control cases behave correctly on the same AGE instance:

  1. The same pattern works when restricted to a single input row:
SELECT * FROM cypher('fuzz_graph', $$
  MATCH (a:Person)
  WITH a LIMIT 1
  CREATE (new:Person {name:'Nia'})
  CREATE (a)-[:FRIEND]->(new)
  RETURN a.name AS a_name
$$) AS (a_name agtype);

Observed result:

Alice
  1. The multi-row query also works if the target node is created anonymously instead of being bound to a variable:
SELECT * FROM cypher('fuzz_graph', $$
  MATCH (a:Person)
  CREATE (a)-[:FRIEND]->(:Person {name:'Mia'})
  RETURN a.name AS a_name
$$) AS (a_name agtype);

Observed result:

Alice
Bob
  1. Creating the node into new without immediately using it in the relationship also works:
SELECT * FROM cypher('fuzz_graph', $$
  MATCH (a:Person {name:'Alice'})
  CREATE (new:Person {name:'Eve'})
  RETURN a.name AS a_name, new.name AS new_name
$$) AS (a_name agtype, new_name agtype);

Observed result:

Alice, Eve

So the failure appears to be specifically tied to multi-row execution of:

  1. CREATE a new node bound to a variable
  2. immediately CREATE a relationship to that bound node

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