Skip to content

After a multi-row path CREATE, WITH * CREATE (...) DELETE ... changes cardinality instead of preserving the incoming rows. #2565

Description

@YGY-001

Environment

Apache AGE 1.8.0 on PostgreSQL 18.6, Docker image
apache/age:release_PG18_1.8.0.

Setup

Run this setup separately on two fresh graphs, one named
age_issue_case20_left and one named age_issue_case20_right:

LOAD 'age';
SET search_path = ag_catalog, public;
SELECT ag_catalog.create_graph('age_issue_case20_left');

SELECT *
FROM ag_catalog.cypher('age_issue_case20_left', $$
CREATE (a {id: 46}),
       (b1 {k7: -1, k6: 2}),
       (b2 {k7: -1, k6: 2}),
       (c:l1 {k6: 3, klist: [4]}),
       (n1:l0 {id: 10}),
       (n0 {k4: [1]}),
       (a)<-[:rt10 {k8: 2147483647}]-(b1),
       (a)<-[:rt10 {k8: 2147483647}]-(b2),
       (b1)<-[:R {k6: 3, klist: [4]}]-(c),
       (b2)<-[:R {k6: 3, klist: [4]}]-(c),
       (c)-[:X]->(n1)-[:Y]->(n0)
$$) AS (v agtype);

For the right graph, replace both graph-name occurrences above with
age_issue_case20_right.

Baseline query (run on the left graph)

SELECT *
FROM ag_catalog.cypher('age_issue_case20_left', $$
MATCH p = ({id: 46})<-[:rt10 {k8: 2147483647}]-({k7: -1, k6: 2})
  <-[r1 {k6: 3, klist: [4]}]-(:l1)-[]->(n1:l0)
  -[r0]->(n0 {k4: [1]})
WHERE size(n0.k4) >= 0
CREATE (n1)-[:rt5 {id: 421}]->(n0)-[:rt4 {id: 422}]->(:l1 {id: 128})
RETURN count(*) AS rows
$$) AS (rows agtype);

Barrier query (run on the right graph)

Use the same query, but insert the following clauses before the final return:

WITH *
CREATE (__dinkel_n0)
DELETE __dinkel_n0
WITH n1, n0, r1, r0, p

Expected

Both queries preserve the two input rows and return 2.

Actual

On Apache AGE 1.8.0 / PostgreSQL 18.6, the baseline returns 2, while
the barrier query returns 4. The result rows include duplicated bindings;
the barrier also creates twice as many path-write entities. A read-only
WITH * control preserves the two rows. This is a real AGE cardinality
defect, not an outer-column-definition, JDBC, probe, or fingerprint issue.

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions