Debian Codegraph @

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

raw
1 drop table if exists t1;
2 ## Creating new table ##
3 CREATE TABLE t1
4 (
5 id INT NOT NULL auto_increment,
6 PRIMARY KEY (id),
7 name VARCHAR(30)
8 ) ENGINE = INNODB;
9 '#--------------------FN_DYNVARS_059_01-------------------------#'
10 ## Verifying initial value of ##
11 SELECT @@session.last_insert_id;
12 @@session.last_insert_id
13 0
14 ## Inserting records in table t1 ##
15 INSERT into t1(name) values('Record_1');
16 INSERT into t1(name) values('Record_2');
17 SELECT * from t1;
18 id name
19 1 Record_1
20 2 Record_2
21 ## Verifying value of variable after inserting some rows ##
22 SELECT @@session.last_insert_id = 2;
23 @@session.last_insert_id = 2
24 1
25 '#--------------------FN_DYNVARS_059_02-------------------------#'
26 connect test_con1, localhost, root,,;
27 connection test_con1;
28 SET @@autocommit = 0;
29 ## Verifying initial value of variable in new connection ##
30 SELECT @@session.last_insert_id;
31 @@session.last_insert_id
32 0
33 ## Inserting rows in table t1 ##
34 START TRANSACTION;
35 INSERT into t1(name) values('Record_3');
36 INSERT into t1(name) values('Record_4');
37 INSERT into t1(name) values('Record_5');
38 ## Verifying value of variable without committing rows ##
39 SELECT @@session.last_insert_id;
40 @@session.last_insert_id
41 5
42 '#--------------------FN_DYNVARS_059_03-------------------------#'
43 connect test_con2, localhost, root,,;
44 connection test_con2;
45 ## Inserting values through new connection ##
46 INSERT into t1(name) values('Record_6');
47 INSERT into t1(name) values('Record_7');
48 SELECT * from t1;
49 id name
50 1 Record_1
51 2 Record_2
52 6 Record_6
53 7 Record_7
54 ## Verifying value of variable in second connection ##
55 SELECT @@last_insert_id;
56 @@last_insert_id
57 7
58 '#--------------------FN_DYNVARS_059_04-------------------------#'
59 connection test_con1;
60 ## Verifying all records in table & value of variable ##
61 SELECT * from t1;
62 id name
63 1 Record_1
64 2 Record_2
65 3 Record_3
66 4 Record_4
67 5 Record_5
68 6 Record_6
69 7 Record_7
70 SELECT @@session.last_insert_id;
71 @@session.last_insert_id
72 5
73 ## Commiting records in table ##
74 COMMIT;
75 SELECT @@session.last_insert_id;
76 @@session.last_insert_id
77 5
78 ## Switching to test_con2 & verifying value of variable in it ##
79 connection test_con2;
80 SELECT @@session.last_insert_id;
81 @@session.last_insert_id
82 7
83 '#--------------------FN_DYNVARS_059_05-------------------------#'
84 ## Setting value of variable ##
85 SET @@session.last_insert_id = 100;
86 SELECT @@session.last_insert_id;
87 @@session.last_insert_id
88 100
89 ## Inserting new record and verifying variable's effect on it ##
90 INSERT into t1(name) values('Record_8');
91 SELECT @@session.last_insert_id;
92 @@session.last_insert_id
93 8
94 ## Dropping table t1 ##
95 drop table t1;
96 disconnect test_con1;
97 disconnect test_con2;