Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc14ed1b

Browse files
committed
Bugfix. Multimaster mustn't send the T_CallStmt utility statement to all multimaster nodes.
Also, replay the problem of sequence generation in a stored procedurein multimaster.sql.
1 parent55754e0 commitc14ed1b

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

‎expected/multimaster.out

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,45 @@ table seq_test;
488488
105
489489
(8 rows)
490490

491+
--
492+
-- Check a sequence generation by function, procedure, direct insertion.
493+
--
494+
CREATE SEQUENCE seq1;
495+
CREATE TABLE t1 (id int);
496+
CREATE OR REPLACE PROCEDURE p1 () LANGUAGE 'plpgsql' AS $$
497+
BEGIN
498+
INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass));
499+
END; $$;
500+
CREATE OR REPLACE FUNCTION p2 () RETURNS VOID LANGUAGE 'plpgsql' AS $$
501+
BEGIN
502+
INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass));
503+
END; $$;
504+
-- Generate value by different ways.
505+
CALL p1();
506+
SELECT p2();
507+
p2
508+
----
509+
510+
(1 row)
511+
512+
INSERT INTO t1 (id) VALUES (nextval('seq1'::regclass));
513+
-- Fix generated values of a sequence
514+
SELECT * FROM t1 ORDER BY id;
515+
id
516+
----
517+
1
518+
4
519+
7
520+
(3 rows)
521+
522+
-- Try to UPDATE. In the case of data divergence we will get an error.
523+
UPDATE t1 SET id = id + 1;
524+
-- Check for new values, just to be sure.
525+
SELECT * FROM t1 ORDER BY id;
526+
id
527+
----
528+
2
529+
5
530+
8
531+
(3 rows)
532+

‎sql/multimaster.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,32 @@ insert into seq_test values (default);
327327
insert into seq_testvalues (default);
328328
\c :node1
329329
table seq_test;
330+
331+
--
332+
-- Check a sequence generation by function, procedure, direct insertion.
333+
--
334+
CREATESEQUENCEseq1;
335+
CREATETABLEt1 (idint);
336+
CREATEOR REPLACE PROCEDURE p1 () LANGUAGE'plpgsql'AS $$
337+
BEGIN
338+
INSERT INTO t1 (id)VALUES (nextval('seq1'::regclass));
339+
END; $$;
340+
341+
CREATE OR REPLACEFUNCTIONp2 () RETURNS VOID LANGUAGE'plpgsql'AS $$
342+
BEGIN
343+
INSERT INTO t1 (id)VALUES (nextval('seq1'::regclass));
344+
END; $$;
345+
346+
-- Generate value by different ways.
347+
CALL p1();
348+
SELECT p2();
349+
INSERT INTO t1 (id)VALUES (nextval('seq1'::regclass));
350+
351+
-- Fix generated values of a sequence
352+
SELECT*FROM t1ORDER BY id;
353+
354+
-- Try to UPDATE. In the case of data divergence we will get an error.
355+
UPDATE t1SET id= id+1;
356+
357+
-- Check for new values, just to be sure.
358+
SELECT*FROM t1ORDER BY id;

‎src/ddl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
947947
caseT_PlannedStmt:
948948
caseT_FetchStmt:
949949
caseT_DoStmt:
950+
caseT_CallStmt:
950951
caseT_CommentStmt:
951952
caseT_PrepareStmt:
952953
caseT_ExecuteStmt:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp