After statement failure, no other statement can success.
See the following example.
agens=# create graph graph;
CREATE GRAPH
agens=# create vlabel v;
CREATE VLABEL
agens=# create unique property index on v ( id );
CREATE PROPERTY INDEX
agens=# begin transaction;
BEGIN
agens=# create (:v{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# create (:v{id:1});
ERROR: duplicate key value violates unique constraint "v_id_idx"
DETAIL: Key ((properties.'id'::text))=(1) already exists.
agens=# create (:v{id:2});
ERROR: current transaction is aborted, commands ignored until end of transaction block
agens=# commit;
ROLLBACK
agens=# match (n:v) return n;
n
---
(0 rows)
How to abort failed statement on AgensGraph?
Use SAVEPOINT for abort partial rollback.
agens=# begin transaction;
BEGIN
agens=# create (:v{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# savepoint sp;
SAVEPOINT
agens=# create (:v{id:1});
ERROR: duplicate key value violates unique constraint "v_id_idx"
DETAIL: Key ((properties.'id'::text))=(1) already exists.
agens=# rollback to sp;
ROLLBACK
agens=# create (:v{id:2});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# commit;
COMMIT
agens=# match (n:v) return n;
n
-----------------
v[3.1]{"id": 1}
v[3.3]{"id": 2}
(2 rows)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.