You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
-----------
'select currval for Seq' will return the last queried nextval,
It was stored into the current session context, and roll up when query
nextval.
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4
+
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
5
+
[connection master]
6
+
create database s_db;
7
+
grant all on s_db.* to normal_1@'%' identified by 'pass';
8
+
grant all on test.* to normal_2@'%' identified by 'pass';
9
+
grant all on s_db.* to normal_3@'%' identified by 'pass';
10
+
grant all on test.* to normal_4@'%' identified by 'pass';
11
+
set global read_only=on;
12
+
###########################################
13
+
master and slave sync sequence.
14
+
###########################################
15
+
use s_db;
16
+
create sequence s1;
17
+
show create table s1;
18
+
Table Create Table
19
+
s1 CREATE SEQUENCE `s1` (
20
+
`currval` bigint(21) NOT NULL COMMENT 'current value',
21
+
`nextval` bigint(21) NOT NULL COMMENT 'next value',
22
+
`minvalue` bigint(21) NOT NULL COMMENT 'min value',
23
+
`maxvalue` bigint(21) NOT NULL COMMENT 'max value',
24
+
`start` bigint(21) NOT NULL COMMENT 'start value',
25
+
`increment` bigint(21) NOT NULL COMMENT 'increment value',
26
+
`cache` bigint(21) NOT NULL COMMENT 'cache size',
27
+
`cycle` bigint(21) NOT NULL COMMENT 'cycle state',
28
+
`round` bigint(21) NOT NULL COMMENT 'already how many round'
29
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
30
+
use s_db;
31
+
show create table s1;
32
+
Table Create Table
33
+
s1 CREATE SEQUENCE `s1` (
34
+
`currval` bigint(21) NOT NULL COMMENT 'current value',
35
+
`nextval` bigint(21) NOT NULL COMMENT 'next value',
36
+
`minvalue` bigint(21) NOT NULL COMMENT 'min value',
37
+
`maxvalue` bigint(21) NOT NULL COMMENT 'max value',
38
+
`start` bigint(21) NOT NULL COMMENT 'start value',
39
+
`increment` bigint(21) NOT NULL COMMENT 'increment value',
40
+
`cache` bigint(21) NOT NULL COMMENT 'cache size',
41
+
`cycle` bigint(21) NOT NULL COMMENT 'cycle state',
42
+
`round` bigint(21) NOT NULL COMMENT 'already how many round'
43
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
44
+
use s_db;
45
+
drop sequence s1;
46
+
###########################################
47
+
Session context currval
48
+
###########################################
49
+
use s_db;
50
+
create sequence s1 start with 1 minvalue 1 maxvalue 7 cache 2 cycle increment by 2;
51
+
select currval for s1;
52
+
ERROR HY000: Sequence 's_db.s1' is not yet defined in this session
53
+
select currval from s1;
54
+
currval
55
+
0
56
+
select currval, start, minvalue, cache, cycle, increment, round for s1;
57
+
ERROR HY000: Sequence 's_db.s1' is not yet defined in this session
58
+
select currval, start, minvalue, cache, cycle, increment, round from s1;
0 commit comments