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 order by name;
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 --echo ## Creating & Connecting new connection test_con1 ##
66 connect (test_con1, localhost, root,,);
67 connection test_con1;
68
69 --echo ## Setting value of insert_id to 50 ##
70 SET @@session.insert_id = 50;
71 SELECT @@session.insert_id;
72
73 --echo ## Inserting rows in table t1 ##
74 INSERT into t1(name) values('Record_4');
75 INSERT into t1(name) values('Record_5');
76 INSERT into t1(name) values('Record_6');
77
78 SELECT * from t1 order by name;
79
80 --echo 'Bug#35376 Value of insert_id automatically resets to 0 after inserting
81 --echo ' 1st row'
82
83 --echo '#--------------------FN_DYNVARS_051_03-------------------------#'
84 #############################################################################
85 # Now verifying some new value of insert_id with second new connection #
86 #############################################################################
87
88 --echo ## Creating and switching to new connection test_con2 ##
89 connect (test_con2, localhost, root,,);
90 connection test_con2;
91
92 --echo ## Setting session value of variable to 25 ##
93 SET @@session.insert_id = 25;
94
95 --echo ## Inserting some rows in table ##
96 INSERT into t1(name) values('Record_7');
97 INSERT into t1(name) values('Record_8');
98
99 --echo ## Verifying data in table t1 ##
100 SELECT * from t1 order by name;
101
102
103 --echo ## Dropping table t1 ##
104 drop table t1;
105
106 --echo ## Disconnecting connections ##
107 disconnect test_con1;
108 disconnect test_con2;
109
110
111
112
113