| 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 order by name; |
| 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 |
## Creating & Connecting new connection test_con1 ## |
| 29 |
## Setting value of insert_id to 50 ## |
| 30 |
SET @@session.insert_id = 50; |
| 31 |
SELECT @@session.insert_id; |
| 32 |
@@session.insert_id |
| 33 |
50 |
| 34 |
## Inserting rows in table t1 ## |
| 35 |
INSERT into t1(name) values('Record_4'); |
| 36 |
INSERT into t1(name) values('Record_5'); |
| 37 |
INSERT into t1(name) values('Record_6'); |
| 38 |
SELECT * from t1 order by name; |
| 39 |
id name |
| 40 |
100 Record_1 |
| 41 |
101 Record_2 |
| 42 |
102 Record_3 |
| 43 |
50 Record_4 |
| 44 |
103 Record_5 |
| 45 |
104 Record_6 |
| 46 |
'Bug#35376 Value of insert_id automatically resets to 0 after inserting |
| 47 |
' 1st row' |
| 48 |
'#--------------------FN_DYNVARS_051_03-------------------------#' |
| 49 |
## Creating and switching to new connection test_con2 ## |
| 50 |
## Setting session value of variable to 25 ## |
| 51 |
SET @@session.insert_id = 25; |
| 52 |
## Inserting some rows in table ## |
| 53 |
INSERT into t1(name) values('Record_7'); |
| 54 |
INSERT into t1(name) values('Record_8'); |
| 55 |
## Verifying data in table t1 ## |
| 56 |
SELECT * from t1 order by name; |
| 57 |
id name |
| 58 |
100 Record_1 |
| 59 |
101 Record_2 |
| 60 |
102 Record_3 |
| 61 |
50 Record_4 |
| 62 |
103 Record_5 |
| 63 |
104 Record_6 |
| 64 |
25 Record_7 |
| 65 |
105 Record_8 |
| 66 |
## Dropping table t1 ## |
| 67 |
drop table t1; |
| 68 |
## Disconnecting connections ## |