summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/sql_sequence/slave_nextval.test
blob: 41aca1506250c2b2e9cf46130497700dbc4c1e65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--source include/master-slave.inc
--source include/have_binlog_format_row.inc

#
# MDEV-14092  NEXTVAL() fails on slave
#

--disable_ps2_protocol
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
show create sequence s;
SELECT NEXTVAL(s);

--sync_slave_with_master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);

--connection master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);

select * from s;

--sync_slave_with_master

select * from s;
--connection master
DROP SEQUENCE s;

#
# Same as above, but with cycles
#

CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
show create sequence s;
SELECT NEXTVAL(s);

--sync_slave_with_master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);

--connection master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);

select * from s;

--sync_slave_with_master

select * from s;

--connection master
DROP SEQUENCE s;

# Here is a bit more complicated concurrent scenario that
# causes the same effect without any updates on the slave. You might
# need to replace 100 with a bigger value if it doesn't happen on your
# machine right away.

CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
SELECT NEXTVAL(s);

--delimiter $
CREATE PROCEDURE pr(n INT)
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i < n
DO
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SET i= i+1;
END WHILE;
END $
--delimiter ;

--connect (con1,localhost,root,,)
--send CALL pr(100)
--connect (con2,localhost,root,,)
--send CALL pr(100)
--connect (con3,localhost,root,,)
--send CALL pr(100)
--connect (con4,localhost,root,,)
--send CALL pr(100)
--connect (con5,localhost,root,,)
--send CALL pr(100)
--connect (con6,localhost,root,,)
--send CALL pr(100)
--connect (con7,localhost,root,,)
--send CALL pr(100)
--connect (con8,localhost,root,,)
--send CALL pr(100)


--disable_query_log
--disable_result_log

--connection con1
--reap
--connection con2
--reap
--connection con3
--reap
--connection con4
--reap
--connection con5
--reap
--connection con6
--reap
--connection con7
--reap
--connection con8
--reap

--enable_query_log
--enable_result_log

--connection master

--sync_slave_with_master

--connection master
DROP SEQUENCE s;
DROP PROCEDURE pr;
--enable_ps2_protocol

#
# Cleanup
#
--source include/rpl_end.inc