Debian Codegraph @

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

raw
1 #################### mysql-test\t\identity_func.test ##########################
2 # #
3 # Variable Name: identity #
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 identity #
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 drop table if exists t2;
26 --enable_warnings
27
28 #########################
29 # Creating new table #
30 #########################
31
32 --echo ## Creating new table t1 ##
33 CREATE TABLE t1
34 (
35 id INT NOT NULL auto_increment,
36 PRIMARY KEY (id),
37 name VARCHAR(30)
38 ) ENGINE = INNODB;
39
40 --echo ## Creating another new table t2 ##
41 CREATE TABLE t2
42 (
43 id INT NOT NULL auto_increment,
44 PRIMARY KEY (id),
45 name VARCHAR(30)
46 ) ENGINE = INNODB;
47
48 --echo '#--------------------FN_DYNVARS_035_01-------------------------#'
49 ###############################################
50 # Verifying initial value of identity. #
51 ###############################################
52
53 --echo ## It should be zero ##
54 SELECT @@identity = 0;
55
56 --echo ## Creating and connecting with new connection test_con1 ##
57 connect (test_con1, localhost, root,,);
58 connection test_con1;
59 SET @@autocommit = 0;
60
61 --echo ## Inserting rows in table t1 ##
62 INSERT into t1(name) values('Record_1');
63 INSERT into t1(name) values('Record_2');
64 INSERT into t1(name) values('Record_3');
65
66 --echo ## Verifying total values in t1 ##
67 SELECT @@identity from t1;
68
69
70 --echo ## Now inserting some data in table t2 ##
71 INSERT into t2(name) values('Record_1');
72
73 --echo ## Verifying total values in t2 ##
74 SELECT @@identity from t2;
75
76
77 --echo '#--------------------FN_DYNVARS_035_02-------------------------#'
78 ##########################################################
79 # Verifying value of identity with new connection #
80 ##########################################################
81
82 --echo ## Creating and connecting with new connection test_con2 ##
83 connect (test_con2, localhost, root,,);
84 connection test_con2;
85 SELECT * from t1;
86
87 --echo ## Verifying total values in t1 ##
88 SELECT @@identity from t1;
89
90 --echo ## Verifying total values in t2 ##
91 SELECT @@identity from t2;
92
93 --echo ## Inserting some more records in table t1 ##
94 INSERT into t1(name) values('Record_1_1');
95 INSERT into t1(name) values('Record_1_2');
96
97 --echo ## Verifying total values in t1 ##
98 SELECT @@identity from t1;
99
100 --echo ## Inserting row in table t2 ##
101 INSERT into t2(name) values('Record_1_3');
102
103 --echo ## Verifying total values in t2 ##
104 SELECT @@identity from t2;
105
106
107 --echo '#--------------------FN_DYNVARS_035_03-------------------------#'
108 ###################################################################
109 # Verifying identity value by using commit in connectio # 01 #
110 ###################################################################
111
112 --echo ## Switching to connection test_con1 ##
113 connection test_con1;
114
115 --echo ## Commiting rows added in test_con1 ##
116 COMMIT;
117
118 --echo ## Verifying records in both tables ##
119 SELECT * from t1;
120 SELECT * from t2;
121
122 --echo ## Verifying total values in t1 after commiting data ##
123 SELECT @@identity from t1;
124
125 --echo ## Verifying total values in t2 after commiting data ##
126 SELECT @@identity from t2;
127
128 INSERT into t1(name) values('Record_4');
129
130 --echo ## Now verifying value of variable after inserting 1 row in this connection ##
131 SELECT @@identity from t1;
132
133 --echo ## Dropping tables t1 & t2 ##
134 drop table t1, t2;
135
136 --echo ## Disconnecting both the connections ##
137 disconnect test_con1;
138 disconnect test_con2;
139
140
141
142
143