Debian Codegraph @

mysql-test/suite/engines/rr_trx/include/rr_init.test

raw
1 #
2 # Specify storage engine to use. Variable $engine is set in wrapper test.
3 #
4 eval SET @@default_storage_engine = $engine;
5 if (`SELECT @@default_storage_engine LIKE 'InnoDB' AND @@version LIKE '%6.%'`)
6 {
7 # Need this due to Bug#43447 - Crash when executing SELECT ... LIMIT n FOR UPDATE query
8 # Hopefully temporary...
9 # Not applicable to 5.1 server or earlier.
10 --disable_query_log
11 SET GLOBAL optimizer_use_mrr='disable';
12 --enable_query_log
13 }
14
15 # Verify default storage engine.
16 SHOW VARIABLES LIKE 'default_storage_engine';
17
18 # Verify default isolation level
19 SHOW VARIABLES LIKE 'transaction_isolation';
20
21 #
22 # Create table for keeping track of test metadata/statistics (counters etc.).
23 # (Need a data structure that will hold across tests, clients, sessions).
24 # Expand/modify if needeed, but take care of test files using it.
25 #
26 # Columns:
27 # deadlocks - keeps track of the total number of deadlocks so far.
28 #
29 # Using default storage engine (see above).
30 CREATE TABLE statistics (
31 tx_errors INTEGER NOT NULL
32 );
33
34 # Initialize statistics table.
35 INSERT INTO statistics (tx_errors) VALUES (0);
36
37 #
38 # Create main test / data table. Some notes:
39 # * timestamp is automatically DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
40 # * BOOLEAN is TINYINT(1)
41 # * `is_consistent` means that the sum of int1* and int2* columns in that row
42 # is = 0. NOTE: Do not change meaning unless you take care to
43 # change test cases that rely on it (e.g. rr_id_900).
44 # Set `is_consistent` = 0 if changing a row's sum to non-zero.
45 #
46 # TODO: Get TID (thread_id) from mysql-stress-test.pl somehow.
47 #
48
49 CREATE TABLE t1 (
50 `pk` INTEGER AUTO_INCREMENT NOT NULL,
51 `id` INTEGER NOT NULL,
52 `int1` INTEGER,
53 `int1_key` INTEGER,
54 `int1_unique` INTEGER,
55 `int2` INTEGER,
56 `int2_key` INTEGER,
57 `int2_unique` INTEGER,
58 `for_update` BOOLEAN DEFAULT 0,
59 `timestamp` TIMESTAMP,
60 `connection_id` INTEGER,
61 `thread_id` INTEGER DEFAULT 0,
62 `is_uncommitted` BOOLEAN DEFAULT 0,
63 `is_consistent` BOOLEAN DEFAULT 0,
64 KEY (`id`),
65 KEY (`int1_key`),
66 KEY (`int2_key`),
67 UNIQUE (`int1_unique`),
68 UNIQUE (`int2_unique`),
69 PRIMARY KEY (`pk`)
70 );
71
72 # Check that the table was really created with the intended storage engine.
73 SHOW CREATE TABLE t1;
74
75 ## Procedure for inserting the value 1000 into integer fieds, "rows" times.
76
77 --delimiter //
78
79 eval CREATE PROCEDURE insertRows(rows INT)
80 BEGIN
81 SET @n = 1;
82 REPEAT
83 INSERT INTO t1 (`id`, `int1`, `int1_key`, `int1_unique`,
84 `int2`, `int2_key`, `int2_unique`,
85 `for_update`, `connection_id`, `thread_id`,
86 `is_uncommitted`, `is_consistent`)
87 VALUES (0, 1000, 1000, @n,
88 -1000, -1000, -@n,
89 0, CONNECTION_ID(), 0,
90 0, 1);
91 SET @n = @n + 1;
92 UNTIL @n > rows
93 END REPEAT;
94 END;
95 //
96
97 --delimiter ;
98
99 ## Insert 1000 rows.
100 CALL insertRows(1000);
101
102 ## Check the sum of all int columns
103 SELECT SUM(`int1` + `int1_key` + `int1_unique`
104 + `int2` + `int2_key` + `int2_unique`)
105 AS TotalSum
106 FROM t1;