Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions regress/expected/cypher_merge.out
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,55 @@ SELECT * FROM cypher('merge_actions', $$ MATCH (n) DETACH DELETE n $$) AS (a agt
---
(0 rows)

--
-- Regression test for #2537: DELETE edge + full-path MERGE segfault
-- (apply_update_list scanTupleSlot NULL deref)
--
SELECT * FROM create_graph('issue_2537');
NOTICE: graph "issue_2537" has been created
create_graph
--------------

(1 row)

SELECT * FROM cypher('issue_2537', $$
CREATE (a:base {id: 1})-[r1:r {k0: false}]->
(n:base {id: 2})-[r0:s {k5: 'x'}]->(b:base {id: 3})
$$) AS (created agtype);
created
---------
(0 rows)

SELECT * FROM cypher('issue_2537', $$
MATCH (a:base)-[r1:r]->(n:base)-[r0:s]->(b:base)
SET r0.k5 = 'J', r1.k0 = true
WITH range(0, 0) + [0] AS keep, r1 AS old
WHERE 0 IN keep
DELETE old
CREATE (:x)
MERGE p0 = ({id: 129})-[r2:r]->(n2 {id: 130})-[:s]->(:c {id: 131})
RETURN 1
$$) AS (value agtype);
value
-------
1
(1 row)

SELECT * FROM drop_graph('issue_2537', true);
NOTICE: drop cascades to 7 other objects
DETAIL: drop cascades to table issue_2537._ag_label_vertex
drop cascades to table issue_2537._ag_label_edge
drop cascades to table issue_2537.base
drop cascades to table issue_2537.r
drop cascades to table issue_2537.s
drop cascades to table issue_2537.x
drop cascades to table issue_2537.c
NOTICE: graph "issue_2537" has been dropped
drop_graph
------------

(1 row)

--
-- delete graphs
--
Expand Down
24 changes: 24 additions & 0 deletions regress/sql/cypher_merge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,30 @@ $$) AS (src agtype, last agtype);
-- cleanup
SELECT * FROM cypher('merge_actions', $$ MATCH (n) DETACH DELETE n $$) AS (a agtype);

--
-- Regression test for #2537: DELETE edge + full-path MERGE segfault
-- (apply_update_list scanTupleSlot NULL deref)
--
SELECT * FROM create_graph('issue_2537');

SELECT * FROM cypher('issue_2537', $$
CREATE (a:base {id: 1})-[r1:r {k0: false}]->
(n:base {id: 2})-[r0:s {k5: 'x'}]->(b:base {id: 3})
$$) AS (created agtype);

SELECT * FROM cypher('issue_2537', $$
MATCH (a:base)-[r1:r]->(n:base)-[r0:s]->(b:base)
SET r0.k5 = 'J', r1.k0 = true
WITH range(0, 0) + [0] AS keep, r1 AS old
WHERE 0 IN keep
DELETE old
CREATE (:x)
MERGE p0 = ({id: 129})-[r2:r]->(n2 {id: 130})-[:s]->(:c {id: 131})
RETURN 1
$$) AS (value agtype);

SELECT * FROM drop_graph('issue_2537', true);

--
-- delete graphs
--
Expand Down
4 changes: 4 additions & 0 deletions src/backend/executor/cypher_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ void apply_update_list(CustomScanState *node,
HTAB *index_cache = NULL;
HASHCTL idx_hashctl;

/* if scanTupleSlot is NULL, there is no data to update */
if (scanTupleSlot == NULL)
return;

/* allocate an array to hold the last update index of each 'entity' */
luindex = palloc0(sizeof(int) * scanTupleSlot->tts_nvalid);

Expand Down
Loading