| 1 |
SET @@default_storage_engine = 'InnoDB'; |
| 2 |
SHOW VARIABLES LIKE 'default_storage_engine'; |
| 3 |
Variable_name Value |
| 4 |
default_storage_engine InnoDB |
| 5 |
SHOW VARIABLES LIKE 'tx_isolation'; |
| 6 |
Variable_name Value |
| 7 |
tx_isolation REPEATABLE-READ |
| 8 |
CREATE TABLE statistics ( |
| 9 |
tx_errors INTEGER NOT NULL |
| 10 |
); |
| 11 |
INSERT INTO statistics (tx_errors) VALUES (0); |
| 12 |
CREATE TABLE t1 ( |
| 13 |
`pk` INTEGER AUTO_INCREMENT NOT NULL, |
| 14 |
`id` INTEGER NOT NULL, |
| 15 |
`int1` INTEGER, |
| 16 |
`int1_key` INTEGER, |
| 17 |
`int1_unique` INTEGER, |
| 18 |
`int2` INTEGER, |
| 19 |
`int2_key` INTEGER, |
| 20 |
`int2_unique` INTEGER, |
| 21 |
`for_update` BOOLEAN DEFAULT 0, |
| 22 |
`timestamp` TIMESTAMP, |
| 23 |
`connection_id` INTEGER, |
| 24 |
`thread_id` INTEGER DEFAULT 0, |
| 25 |
`is_uncommitted` BOOLEAN DEFAULT 0, |
| 26 |
`is_consistent` BOOLEAN DEFAULT 0, |
| 27 |
KEY (`id`), |
| 28 |
KEY (`int1_key`), |
| 29 |
KEY (`int2_key`), |
| 30 |
UNIQUE (`int1_unique`), |
| 31 |
UNIQUE (`int2_unique`), |
| 32 |
PRIMARY KEY (`pk`) |
| 33 |
); |
| 34 |
SHOW CREATE TABLE t1; |
| 35 |
Table Create Table |
| 36 |
t1 CREATE TABLE `t1` ( |
| 37 |
`pk` int(11) NOT NULL AUTO_INCREMENT, |
| 38 |
`id` int(11) NOT NULL, |
| 39 |
`int1` int(11) DEFAULT NULL, |
| 40 |
`int1_key` int(11) DEFAULT NULL, |
| 41 |
`int1_unique` int(11) DEFAULT NULL, |
| 42 |
`int2` int(11) DEFAULT NULL, |
| 43 |
`int2_key` int(11) DEFAULT NULL, |
| 44 |
`int2_unique` int(11) DEFAULT NULL, |
| 45 |
`for_update` tinyint(1) DEFAULT '0', |
| 46 |
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 47 |
`connection_id` int(11) DEFAULT NULL, |
| 48 |
`thread_id` int(11) DEFAULT '0', |
| 49 |
`is_uncommitted` tinyint(1) DEFAULT '0', |
| 50 |
`is_consistent` tinyint(1) DEFAULT '0', |
| 51 |
PRIMARY KEY (`pk`), |
| 52 |
UNIQUE KEY `int1_unique` (`int1_unique`), |
| 53 |
UNIQUE KEY `int2_unique` (`int2_unique`), |
| 54 |
KEY `id` (`id`), |
| 55 |
KEY `int1_key` (`int1_key`), |
| 56 |
KEY `int2_key` (`int2_key`) |
| 57 |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
| 58 |
CREATE PROCEDURE insertRows(rows INT) |
| 59 |
BEGIN |
| 60 |
SET @n = 1; |
| 61 |
REPEAT |
| 62 |
INSERT INTO t1 (`id`, `int1`, `int1_key`, `int1_unique`, |
| 63 |
`int2`, `int2_key`, `int2_unique`, |
| 64 |
`for_update`, `connection_id`, `thread_id`, |
| 65 |
`is_uncommitted`, `is_consistent`) |
| 66 |
VALUES (0, 1000, 1000, @n, |
| 67 |
-1000, -1000, -@n, |
| 68 |
0, CONNECTION_ID(), 0, |
| 69 |
0, 1); |
| 70 |
SET @n = @n + 1; |
| 71 |
UNTIL @n > rows |
| 72 |
END REPEAT; |
| 73 |
END; |
| 74 |
// |
| 75 |
CALL insertRows(1000); |
| 76 |
SELECT SUM(`int1` + `int1_key` + `int1_unique` |
| 77 |
+ `int2` + `int2_key` + `int2_unique`) |
| 78 |
AS TotalSum |
| 79 |
FROM t1; |
| 80 |
TotalSum |
| 81 |
0 |