fix: Execute deferred constraint triggers when using Prefer: tx=rollback

Resolves #2020
This commit is contained in:
Wolfgang Walther
2021-11-30 15:54:12 +01:00
committed by Wolfgang Walther
parent bbc07d3f40
commit 1cb00d3c62
5 changed files with 63 additions and 2 deletions
+14
View File
@@ -2448,3 +2448,17 @@ CREATE TABLE chores (
, name text
, done bool
);
CREATE TABLE deferrable_unique_constraint (
col INT UNIQUE DEFERRABLE INITIALLY IMMEDIATE
);
CREATE FUNCTION raise_constraint(deferred BOOL DEFAULT FALSE) RETURNS void
LANGUAGE plpgsql AS $$
BEGIN
IF deferred THEN
SET CONSTRAINTS ALL DEFERRED;
END IF;
INSERT INTO deferrable_unique_constraint VALUES (1), (1);
END$$;