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
|
include/master-slave.inc
[connection master]
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 4 increment by 1 cache 1 nocycle ENGINE=MyISAM
SELECT NEXTVAL(s);
NEXTVAL(s)
1
connection slave;
SELECT NEXTVAL(s);
NEXTVAL(s)
2
SELECT NEXTVAL(s);
NEXTVAL(s)
3
connection master;
SELECT NEXTVAL(s);
NEXTVAL(s)
2
SELECT NEXTVAL(s);
NEXTVAL(s)
3
SELECT NEXTVAL(s);
NEXTVAL(s)
4
select * from s;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
5 1 4 1 1 1 0 0
connection slave;
select * from s;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
5 1 4 1 1 1 0 0
connection master;
DROP SEQUENCE s;
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 3 increment by 1 cache 1 cycle ENGINE=MyISAM
SELECT NEXTVAL(s);
NEXTVAL(s)
1
connection slave;
SELECT NEXTVAL(s);
NEXTVAL(s)
2
SELECT NEXTVAL(s);
NEXTVAL(s)
3
connection master;
SELECT NEXTVAL(s);
NEXTVAL(s)
2
SELECT NEXTVAL(s);
NEXTVAL(s)
3
SELECT NEXTVAL(s);
NEXTVAL(s)
1
select * from s;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
2 1 3 1 1 1 1 1
connection slave;
select * from s;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
2 1 3 1 1 1 1 1
connection master;
DROP SEQUENCE s;
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
SELECT NEXTVAL(s);
NEXTVAL(s)
1
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 $
connect con1,localhost,root,,;
CALL pr(100);
connect con2,localhost,root,,;
CALL pr(100);
connect con3,localhost,root,,;
CALL pr(100);
connect con4,localhost,root,,;
CALL pr(100);
connect con5,localhost,root,,;
CALL pr(100);
connect con6,localhost,root,,;
CALL pr(100);
connect con7,localhost,root,,;
CALL pr(100);
connect con8,localhost,root,,;
CALL pr(100);
connection master;
connection slave;
connection master;
DROP SEQUENCE s;
DROP PROCEDURE pr;
include/rpl_end.inc
|