Debian Codegraph @

mysql-test/suite/sys_vars/t/insert_id_func.test

raw
1 ################### mysql-test\t\insert_id_func.test ##########################
2 # #
3 # Variable Name: insert_id #
4 # Scope: SESSION #
5 # Access Type: Dynamic #
6 # Data Type: numeric #
7 # Default Value:- #
8 # Range: - #
9 # #
10 # #
11 # Creation Date: 2008-03-07 #
12 # Author: Salman Rawala #
13 # #
14 # Description: Test Cases of Dynamic System Variable insert_id #
15 # that checks the functionality of this variable #
16 # #
17 # Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
18 # server-system-variables.html #
19 # #
20 ###############################################################################
21
22
23 --disable_warnings
24 drop table if exists t1;
25 --enable_warnings
26
27 #########################
28 # Creating new table #
29 #########################
30
31 --echo ## Creating new table t1 ##
32 CREATE TABLE t1
33 (
34 id INT NOT NULL auto_increment,
35 PRIMARY KEY (id),
36 name VARCHAR(30)
37 );
38
39 --echo '#--------------------FN_DYNVARS_051_01-------------------------#'
40 #######################################################################
41 # Setting initial value of insert_id and verifying its behavior #
42 #######################################################################
43
44 --echo ## Setting value of variable to 100 ##
45 SET @@session.insert_id = 100;
46 SELECT @@session.insert_id;
47
48 --echo ## Inserting some rows in table ##
49 INSERT into t1(name) values('Record_1');
50 INSERT into t1(name) values('Record_2');
51
52 --echo ## Verifying rows in table ##
53 SELECT * from t1;
54 SELECT @@session.insert_id;
55
56 INSERT into t1(name) values('Record_3');
57
58
59
60 --echo '#--------------------FN_DYNVARS_051_02-------------------------#'
61 ##########################################################
62 # Verifying value of insert_id with new connection #
63 ##########################################################
64
65 connect (test_con1, localhost, root,,);
66 connection test_con1;
67
68 --echo ## Setting value of insert_id to 50 ##
69 SET @@session.insert_id = 50;
70 SELECT @@session.insert_id;
71
72 --echo ## Inserting rows in table t1 ##
73 INSERT into t1(name) values('Record_4');
74 INSERT into t1(name) values('Record_5');
75 INSERT into t1(name) values('Record_6');
76
77 SELECT * from t1;
78
79 --echo 'Bug#35376 Value of insert_id automatically resets to 0 after inserting
80 --echo ' 1st row'
81
82 --echo '#--------------------FN_DYNVARS_051_03-------------------------#'
83 #############################################################################
84 # Now verifying some new value of insert_id with second new connection #
85 #############################################################################
86
87 connect (test_con2, localhost, root,,);
88 connection test_con2;
89
90 --echo ## Setting session value of variable to 25 ##
91 SET @@session.insert_id = 25;
92
93 --echo ## Inserting some rows in table ##
94 INSERT into t1(name) values('Record_7');
95 INSERT into t1(name) values('Record_8');
96
97 --echo ## Verifying data in table t1 ##
98 SELECT * from t1;
99
100
101 --echo ## Dropping table t1 ##
102 drop table t1;
103
104 disconnect test_con1;
105 disconnect test_con2;
106
107 # MDEV-22711 Assertion `nr != 0' failed in handler::update_auto_increment.
108 #
109 connection default;
110 CREATE TABLE t1(id int primary key auto_increment);
111 SET SESSION insert_id=123;
112 SET SESSION insert_id=0;
113 INSERT INTO t1 VALUES ();
114 SET SESSION insert_id=123;
115 SET SESSION insert_id=default;
116 INSERT INTO t1 VALUES ();
117 SET SESSION insert_id=123;
118 SET SESSION insert_id=-1;
119 INSERT INTO t1 VALUES ();
120 SET SESSION insert_id=123;
121 SET SESSION insert_id=-10;
122 INSERT INTO t1 VALUES ();
123 SELECT * FROM t1;
124 DROP TABLE t1;
125