diff --git a/expected/multimaster.out b/expected/multimaster.out index 8508626372..269756626e 100644 --- a/expected/multimaster.out +++ b/expected/multimaster.out @@ -488,3 +488,45 @@ table seq_test; 105 (8 rows) +-- +-- Check a sequence generation by function, procedure, direct insertion. +-- +CREATE SEQUENCE seq1; +CREATE TABLE t1 (id int); +CREATE OR REPLACE PROCEDURE p1 () LANGUAGE 'plpgsql' AS $$ +BEGIN + INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); +END; $$; +CREATE OR REPLACE FUNCTION p2 () RETURNS VOID LANGUAGE 'plpgsql' AS $$ +BEGIN + INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); +END; $$; +-- Generate value by different ways. +CALL p1(); +SELECT p2(); + p2 +---- + +(1 row) + +INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); +-- Fix generated values of a sequence +SELECT * FROM t1 ORDER BY id; + id +---- + 1 + 4 + 7 +(3 rows) + +-- Try to UPDATE. In the case of data divergence we will get an error. +UPDATE t1 SET id = id + 1; +-- Check for new values, just to be sure. +SELECT * FROM t1 ORDER BY id; + id +---- + 2 + 5 + 8 +(3 rows) + diff --git a/sql/multimaster.sql b/sql/multimaster.sql index b030b44687..52ec1f717c 100644 --- a/sql/multimaster.sql +++ b/sql/multimaster.sql @@ -327,3 +327,32 @@ insert into seq_test values (default); insert into seq_test values (default); \c :node1 table seq_test; + +-- +-- Check a sequence generation by function, procedure, direct insertion. +-- +CREATE SEQUENCE seq1; +CREATE TABLE t1 (id int); +CREATE OR REPLACE PROCEDURE p1 () LANGUAGE 'plpgsql' AS $$ +BEGIN + INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); +END; $$; + +CREATE OR REPLACE FUNCTION p2 () RETURNS VOID LANGUAGE 'plpgsql' AS $$ +BEGIN + INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); +END; $$; + +-- Generate value by different ways. +CALL p1(); +SELECT p2(); +INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass)); + +-- Fix generated values of a sequence +SELECT * FROM t1 ORDER BY id; + +-- Try to UPDATE. In the case of data divergence we will get an error. +UPDATE t1 SET id = id + 1; + +-- Check for new values, just to be sure. +SELECT * FROM t1 ORDER BY id; diff --git a/src/ddl.c b/src/ddl.c index 0bd82284c0..f15f01f57a 100644 --- a/src/ddl.c +++ b/src/ddl.c @@ -947,6 +947,7 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString, case T_PlannedStmt: case T_FetchStmt: case T_DoStmt: + case T_CallStmt: case T_CommentStmt: case T_PrepareStmt: case T_ExecuteStmt:
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: