~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# This grammar is suitable for general stress testing of storage engines
# including the InnoDB plugin and Falcon, their locking and transactional mechanisms. It can
# also be used along with the Combinations facility in order to provide stress testing under
# various configurations
#
# The goal is to spend as much time as possible inside the storage engine and as little time
# as possible in the optimizer. Therefore, most of the queries have trivial optimizer plans
# and run very quickly. 
#
# At the same time, please note that this grammar does not aim to cover all possible
# table access methods. The grammars from conf/optimizer* are more suitable for that.
#

query:
	transaction |
	select | select | select |
	select | select | select |
	insert_replace | update | delete ;

transaction:
	START TRANSACTION |
	COMMIT | ROLLBACK |
	SELECT SLEEP( zero_one ) |
	SAVEPOINT A | ROLLBACK TO SAVEPOINT A |
	SET AUTOCOMMIT=OFF | SET AUTOCOMMIT=ON |
	SET TRANSACTION ISOLATION LEVEL isolation_level;

isolation_level:
	READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE ;

select:
	SELECT select_list FROM join_list where LIMIT large_digit for_update_lock_in_share_mode;

select_list:
	X . _field_key | X . _field_key |
	X . `pk` |
	X . _field |
	* |
	( subselect );

subselect:
	SELECT _field_key FROM _table WHERE `pk` = value ;

# Use index for all joins
join_list:
	_table AS X | 
	_table AS X LEFT JOIN _table AS Y USING ( _field_key );

for_update_lock_in_share_mode:
	| | | | | 
#	FOR UPDATE |		# bug 46539
	LOCK IN SHARE MODE ;

# Insert more than we delete
insert_replace:
	i_r ignore INTO _table (`pk`) VALUES (NULL) |
	i_r ignore INTO _table ( _field_no_pk , _field_no_pk ) VALUES ( value , value ) , ( value , value ) ;
#|
#	i_r ignore INTO _table ( _field_no_pk ) SELECT X . _field_key FROM join_list where order_by LIMIT large_digit;	# bug46650

i_r:
	INSERT | REPLACE ;

ignore:
	;
#	IGNORE # bug 46539

update:
	UPDATE ignore _table AS X SET _field_no_pk = value where LIMIT large_digit ;

# We use a smaller limit on DELETE so that we delete less than we insert

delete:
	DELETE FROM _table where_delete order_by_delete LIMIT small_digit ;

order_by:
	| ORDER BY X . _field_key ;

order_by_delete:
	| ORDER BY _field_key ;

# Use an index at all times
where:
	WHERE X . _field_key < value | 	# Use only < to reduce deadlocks
	WHERE X . _field_key IN ( value , value , value ) |
	WHERE X . _field_key BETWEEN small_digit AND large_digit ;
# |
#	WHERE X . _field_key = ( subselect ) ;

where_delete:
	|
	WHERE _field_key = value |
	WHERE _field_key IN ( value , value , value ) |
	WHERE _field_key IN ( subselect ) |
	WHERE _field_key BETWEEN small_digit AND large_digit ;

large_digit:
	5 | 6 | 7 | 8 ;

small_digit:
	1 | 2 | 3 | 4 ;

value:
	_digit | _tinyint_unsigned | _varchar(1);

zero_one:
	0 | 0 | 1;