Skip to content

Support expressions in DELETE clauses - #2631

Open
sanketpatel32 wants to merge 6 commits into
apache:masterfrom
sanketpatel32:devin/1796084334-delete-expression-support
Open

sanketpatel32 wants to merge 6 commits into
apache:masterfrom
sanketpatel32:devin/1796084334-delete-expression-support

Conversation

@sanketpatel32

Copy link
Copy Markdown

Summary

Fixes #2617

The DELETE grammar accepted arbitrary expressions, but transformation only supported a bare graph variable. Expressions such as DELETE bs[0] therefore failed during analysis with the internal error unexpected Node for cypher_clause.

This change transforms non-variable DELETE items as hidden target-list expressions and passes their result positions to the delete executor, so expressions that evaluate to vertices or edges can be deleted. Bare variables keep the existing transformation-time permission handling, and variable-length edge variables remain supported. Runtime validation reports a user-facing error when an expression evaluates to a non-entity value, while expressions are checked for DELETE permission against the concrete label table at execution time because their labels are not known during transformation.

Regression coverage includes:

  • DELETE and DETACH DELETE of a collect() list element
  • a terminal DELETE expression without a following RETURN
  • DETACH DELETE of a nodes(path) element
  • deletion of an edge collected in a list
  • clean errors for non-entity expressions
  • permission failure/success for expression deletes
  • rejection of aggregation in a DELETE expression

Tests run with PostgreSQL 18.7:

  • make PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config COPT=-Werror -j$(nproc)
  • make PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config installcheck — all 44 tests passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DELETE / DETACH DELETE of a collect()-list element fails with "unexpected Node for cypher_clause"

1 participant