Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Bugfix. Multimaster mustn't send the T_CallStmt utility statement to … #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2021
Merged
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
42 changes: 42 additions & 0 deletions expected/multimaster.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

29 changes: 29 additions & 0 deletions sql/multimaster.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/ddl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down