Debian Codegraph @

mysql-test/suite/sys_vars/r/insert_id_func.result

raw
1 drop table if exists t1;
2 ## Creating new table t1 ##
3 CREATE TABLE t1
4 (
5 id INT NOT NULL auto_increment,
6 PRIMARY KEY (id),
7 name VARCHAR(30)
8 );
9 '#--------------------FN_DYNVARS_051_01-------------------------#'
10 ## Setting value of variable to 100 ##
11 SET @@session.insert_id = 100;
12 SELECT @@session.insert_id;
13 @@session.insert_id
14 100
15 ## Inserting some rows in table ##
16 INSERT into t1(name) values('Record_1');
17 INSERT into t1(name) values('Record_2');
18 ## Verifying rows in table ##
19 SELECT * from t1;
20 id name
21 100 Record_1
22 101 Record_2
23 SELECT @@session.insert_id;
24 @@session.insert_id
25 0
26 INSERT into t1(name) values('Record_3');
27 '#--------------------FN_DYNVARS_051_02-------------------------#'
28 connect test_con1, localhost, root,,;
29 connection test_con1;
30 ## Setting value of insert_id to 50 ##
31 SET @@session.insert_id = 50;
32 SELECT @@session.insert_id;
33 @@session.insert_id
34 50
35 ## Inserting rows in table t1 ##
36 INSERT into t1(name) values('Record_4');
37 INSERT into t1(name) values('Record_5');
38 INSERT into t1(name) values('Record_6');
39 SELECT * from t1;
40 id name
41 100 Record_1
42 101 Record_2
43 102 Record_3
44 50 Record_4
45 103 Record_5
46 104 Record_6
47 'Bug#35376 Value of insert_id automatically resets to 0 after inserting
48 ' 1st row'
49 '#--------------------FN_DYNVARS_051_03-------------------------#'
50 connect test_con2, localhost, root,,;
51 connection test_con2;
52 ## Setting session value of variable to 25 ##
53 SET @@session.insert_id = 25;
54 ## Inserting some rows in table ##
55 INSERT into t1(name) values('Record_7');
56 INSERT into t1(name) values('Record_8');
57 ## Verifying data in table t1 ##
58 SELECT * from t1;
59 id name
60 100 Record_1
61 101 Record_2
62 102 Record_3
63 50 Record_4
64 103 Record_5
65 104 Record_6
66 25 Record_7
67 105 Record_8
68 ## Dropping table t1 ##
69 drop table t1;
70 disconnect test_con1;
71 disconnect test_con2;
72 connection default;
73 CREATE TABLE t1(id int primary key auto_increment);
74 SET SESSION insert_id=123;
75 SET SESSION insert_id=0;
76 INSERT INTO t1 VALUES ();
77 SET SESSION insert_id=123;
78 SET SESSION insert_id=default;
79 INSERT INTO t1 VALUES ();
80 SET SESSION insert_id=123;
81 SET SESSION insert_id=-1;
82 Warnings:
83 Warning 1292 Truncated incorrect insert_id value: '-1'
84 INSERT INTO t1 VALUES ();
85 SET SESSION insert_id=123;
86 SET SESSION insert_id=-10;
87 Warnings:
88 Warning 1292 Truncated incorrect insert_id value: '-10'
89 INSERT INTO t1 VALUES ();
90 SELECT * FROM t1;
91 id
92 1
93 2
94 3
95 4
96 DROP TABLE t1;