~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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA

query:
	select | select | select | select | select | select |
	select | select | select | select | select | select |
	select | select | select | select | select | select |

	insert | update | delete | insert | update | delete |
	insert | update | delete | insert | update | delete |
	insert | update | delete | insert | update | delete |

	create | create | drop | alter |
	cache_index | load_index |
	set_key_buffer_size | set_key_cache_block_size ;

cache_index:
	CACHE INDEX table_name /*!50400 PARTITION ( ALL ) */ IN cache_name |
	CACHE INDEX table_name /*!50400 PARTITION ( partition_name_list ) */ IN cache_name ;

load_index:
	LOAD INDEX INTO CACHE table_name /*!50400 PARTITION ( ALL ) */ ignore_leaves |
	LOAD INDEX INTO CACHE table_name /*!50400 PARTITION ( partition_name_list ) */ ignore_leaves ;

ignore_leaves:
	| IGNORE LEAVES ;

set_key_buffer_size:
	/*!50400 SET GLOBAL cache_name . key_buffer_size = _tinyint_unsigned  */ |
	/*!50400 SET GLOBAL cache_name . key_buffer_size = _smallint_unsigned */ |
	/*!50400 SET GLOBAL cache_name . key_buffer_size = _mediumint_unsigned */ ;

set_key_cache_block_size:
	/*!50400 SET GLOBAL key_cache_block_size = key_cache_block_size_enum */ ;

key_cache_block_size_enum:
	512 | 1024 | 2048 | 4096 | 8192 | 16384 ;	
		
cache_name:
	c1 | c2 | c3 | c4;

select:
	SELECT `col_int_nokey` % 10 AS `col_int_nokey` , `col_int_key` % 10 AS `col_int_key` FROM _table where ;

where:
	| | WHERE _field sign value ;

sign:
	> | < | = | <> | != | >= | <= ;

insert:
	insert_replace INTO table_name ( `col_int_nokey`, `col_int_key` ) VALUES ( value , value ) , ( value , value ) |
	insert_replace INTO table_name ( `col_int_nokey`, `col_int_key` ) select LIMIT _digit ;

insert_replace:
	INSERT | REPLACE ;

update:
	UPDATE table_name SET _field = value WHERE _field = value ;

delete:
	DELETE FROM table_name WHERE _field = value LIMIT _digit ;

_field:
	`col_int_nokey` | `col_int_nokey` ;

table_name:
	_letter | _table ;

value:
	_digit ;

create:
	CREATE TABLE _letter (
		`col_int_nokey` INTEGER,
		`col_int_key` INTEGER NOT NULL,
		KEY (`col_int_key`)
	) ENGINE = engine /*!50100 partition */ select ;

drop:
	DROP TABLE IF EXISTS _letter ;

alter:
	/*!50400 ALTER TABLE _letter alter_operation */;

alter_operation:
	ENGINE = engine |
	enable_disable KEYS |
	ORDER BY _field |
	DROP PARTITION partition_name_list |
	partition |
	ADD PARTITION (PARTITION p3 VALUES LESS THAN MAXVALUE) |
	COALESCE PARTITION one_two | 
	REORGANIZE PARTITION |
	ANALYZE PARTITION partition_name_list |
	CHECK PARTITION partition_name_list |
	OPTIMIZE PARTITION partition_name_list |
	REBUILD PARTITION partition_name_list |
	REPAIR PARTITION partition_name_list |
	TRUNCATE PARTITION partition_name_list |
	REMOVE PARTITIONING;

one_two:
	1 | 2;

partition_name_list:
	partition_name |
	partition_name |
	partition_name |
	partition_name_list;

partition_name:
	p0 | p1 | p2 | p3 ;

enable_disable:
	ENABLE | DISABLE ;

# Give preference to MyISAM because key caching is specific to MyISAM

engine:
	MYISAM | MYISAM | MYISAM |
	INNODB | MEMORY ;

partition:
	|
	partition_by_range |
	partition_by_list |
	partition_by_hash |
	partition_by_key
;

subpartition:
	|
	SUBPARTITION BY linear HASH ( _field ) SUBPARTITIONS _digit ;

partition_by_range:
	populate_ranges PARTITION BY RANGE ( _field ) subpartition (
		PARTITION p0 VALUES LESS THAN ( shift_range ),
		PARTITION p1 VALUES LESS THAN ( shift_range ),
		PARTITION p2 VALUES LESS THAN ( shift_range ),
		PARTITION p3 VALUES LESS THAN MAXVALUE
	);

populate_ranges:
	{ @ranges = sort { $a <=> $b } ($prng->digit(), $prng->fieldType('tinyint_unsigned'), $prng->fieldType('smallint_unsigned')) ; return undef } ;

shift_range:
	{ shift @ranges };

partition_by_list:
	populate_digits PARTITION BY LIST ( _field ) subpartition (
		PARTITION p0 VALUES IN ( shift_digit, NULL ),
		PARTITION p1 VALUES IN ( shift_digit, shift_digit, shift_digit ),
		PARTITION p2 VALUES IN ( shift_digit, shift_digit, shift_digit ),
		PARTITION p3 VALUES IN ( shift_digit, shift_digit, shift_digit )
	);

populate_digits:
	{ @digits = @{$prng->shuffleArray([0..9])} ; return undef };

shift_digit:
	{ shift @digits };

partition_by_hash:
	PARTITION BY linear HASH ( _field ) PARTITIONS _digit;

linear:
	| LINEAR;

partition_by_key:
	PARTITION BY KEY(`col_int_key`) PARTITIONS _digit ;

partition_item:
	PARTITION partition_name VALUES 


	PARTITION BY partition_hash_or_key;

partition_hash_or_key:
	HASH ( field_name ) partitions |
	KEY ( field_name ) partitions ;

partitions:
	PARTITIONS digit ;

_digit:
	1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;