The Quack docs state that transactions are forwarded on attached peers, but it seems something like BEGIN; ...; INSERT INTO quackpeer.t VALUES ('hello'); COMMIT; only works transactionally if there was some DDL statement such as CREATE TABLE quackpeer.othert (v INT) within ... before the insertion.
Steps to reproduce
Setup server:
CREATE TABLE t1 (v INT);
CALL quack_serve('quack:localhost',token:='1234');
On client:
ATTACH 'quack:localhost' AS peer (TOKEN '1234');
-- TRANSACTION 1: Quack doesn't actually start a multi-statement transaction
BEGIN;
INSERT INTO peer.t1 VALUES (1);
FROM peer.t1;
-- ┌───────┐
-- │ v │
-- │ int32 │
-- ├───────┤
-- │ 1 │ <- OK: inserted this commit
-- └───────┘
ROLLBACK;
FROM peer.t1;
-- ┌───────┐
-- │ v │
-- │ int32 │
-- ├───────┤
-- │ 1 │ <- should've been rolled back
-- └───────┘
-- TRANSACTION 2: Quack starts multi-statement transaction after DDL statement
BEGIN;
CREATE TABLE peer.t2 (v INT);
INSERT INTO peer.t1 VALUES (2);
FROM peer.t1;
-- ┌───────┐
-- │ v │
-- │ int32 │
-- ├───────┤
-- │ 1 │
-- │ 2 │ <- OK: inserted this commit
-- └───────┘
ROLLBACK;
FROM peer.t1;
-- ┌───────┐
-- │ v │
-- │ int32 │
-- ├───────┤
-- │ 1 │
-- └───────┘ <- OK: insertion of '2' was rolled back
Note that the table created in TRANSACTION 2 wasn't even the one we inserted into!
You can also verify that even before TRANSACTION 1 should finish, row 1 is readable for other peers/the server, and even before TRANSACTION 2 rolls back, row 2 isn't visible for anyone else other than the client that inserted it.
The Quack docs state that transactions are forwarded on attached peers, but it seems something like
BEGIN; ...; INSERT INTO quackpeer.t VALUES ('hello'); COMMIT;only works transactionally if there was some DDL statement such asCREATE TABLE quackpeer.othert (v INT)within...before the insertion.Steps to reproduce
Setup server:
On client:
Note that the table created in TRANSACTION 2 wasn't even the one we inserted into!
You can also verify that even before TRANSACTION 1 should finish, row
1is readable for other peers/the server, and even before TRANSACTION 2 rolls back, row2isn't visible for anyone else other than the client that inserted it.