~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/randgen/conf/partitioning/partition_pruning.yy

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
 
2
# Use is subject to license terms.
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
11
# General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
16
# USA
 
17
 
 
18
# **NOTE** Joins for this grammar are currently not working as intended.
 
19
# For example, if we have tables 1, 2, and 3, we end up with ON conditions that 
 
20
# only involve tables 2 and 3.
 
21
# This will be fixed, but initial attempts at altering this had a negative 
 
22
# impact on the coverage the test was providing.  To be fixed when scheduling 
 
23
# permits.  We are still seeing significant coverage with the grammar as-is.
 
24
 
 
25
################################################################################
 
26
# partition_pruning.yy
 
27
#
 
28
# Purpose:  RQG grammar for testing partitioning by COLUMN_LIST
 
29
#           , introduced in WL#3352
 
30
#
 
31
# NOTES:    * Must be used with conf/partitioning/partition_pruning.zz as the gendata
 
32
#             configuration file
 
33
#           * Designed for:
 
34
#             ** server-server comparisons, particularly
 
35
#                comparing a version of MySQL without partitioning
 
36
#                (like 5.0) to one that has partition_pruning
 
37
#             ** valgrind runs
 
38
#             ** Single-server stress / endurance testing
 
39
#            
 
40
#           * Will NOT work if the server has partitioning, but
 
41
#             not partitioning by COLUMN_LIST and
 
42
#           * Basically, the grammar was designed to ensure
 
43
#             that no result-set differences occur via the 
 
44
#             server-server compare and to look for crashes
 
45
#             and memory leaks
 
46
#           * the gendata file, conf/partitioning/partition_pruning.zz
 
47
#             contains the table setups / partitioning schemes
 
48
################################################################################
 
49
 
 
50
 
 
51
query:
 
52
  { @nonaggregates = () ; $tables = 0 ; $fields = 0 ; "" } query_type ;
 
53
 
 
54
################################################################################
 
55
# We use a mix of SELECT, UPDATE, INSERT, and DELETE to ensure data consistency
 
56
################################################################################
 
57
 
 
58
query_type:
 
59
  select | select | select | select | select |
 
60
  select | select | select | select | select |
 
61
  select | select | select | select | select |
 
62
  update | update | update | delete | delete |
 
63
  insert | insert ;
 
64
 
 
65
distict:  DISTINCT | | | | | | | | | ;
 
66
 
 
67
select_option: SQL_SMALL_RESULT | | | | | | | | | | | | | | | | | | | | ;
 
68
 
 
69
explain_extended:
 
70
    | | | | | | | | | explain_extended2 ;
 
71
 
 
72
explain_extended2: | | | | EXPLAIN | EXPLAIN EXTENDED ;
 
73
 
 
74
 
 
75
select:
 
76
  simple_select | mixed_select ;
 
77
 
 
78
simple_select:
 
79
  explain_extended SELECT simple_select_list
 
80
  FROM join_list
 
81
  WHERE where_list 
 
82
  optional_group_by
 
83
  having_clause
 
84
  order_by_clause ;
 
85
 
 
86
 
 
87
mixed_select:
 
88
  explain_extended SELECT select_list
 
89
  FROM join_list
 
90
  WHERE where_list
 
91
  group_by_clause
 
92
  having_clause
 
93
  order_by_clause ;
 
94
 
 
95
################################################################################
 
96
# For every UPDATE, INSERT and DELETE, we first do the action (UPDATE, etc)
 
97
# *then* we do a SELECT COUNT(*), looking for those rows that should have been
 
98
# touched by the previous query - most useful in server-server comparisons
 
99
################################################################################
 
100
 
 
101
update:
 
102
  int_update | char_update ;
 
103
 
 
104
int_update:
 
105
 int_update_query ; int_select_count ;
 
106
 
 
107
int_update_query:
 
108
  UPDATE _table[invariant] SET `col_int_signed` = _digit[invariant] WHERE special_where_list ; 
 
109
 
 
110
int_select_count:
 
111
  SELECT COUNT(*) FROM _table[invariant] WHERE `col_int_signed` = _digit[invariant];
 
112
 
 
113
char_update:
 
114
  utf8_char_update | utf8_char_update2 | utf8_char_update3 ;
 
115
 
 
116
utf8_char_update:
 
117
  utf8_char_update_query ; utf8_char_select_count ;
 
118
 
 
119
utf8_char_update_query:
 
120
  UPDATE _table[invariant] SET `col_varchar_256_utf8` = _char[invariant] WHERE special_where_list;
 
121
 
 
122
utf8_char_select_count:
 
123
  SELECT COUNT(*) FROM _table[invariant] WHERE `col_varchar_256_utf8` = _char[invariant];
 
124
 
 
125
utf8_char_update2:
 
126
  utf8_char_update_query2 ; utf8_char_select_count2 ;
 
127
 
 
128
utf8_char_update_query2:
 
129
  UPDATE _table[invariant] SET `col_varchar_512_utf8` = _char[invariant] WHERE special_where_list;
 
130
 
 
131
utf8_char_select_count2:
 
132
  SELECT COUNT(*) FROM _table[invariant] WHERE `col_varchar_512_utf8` = _char[invariant];
 
133
 
 
134
utf8_char_update3:
 
135
  utf8_char_update_query3 ; utf8_char_select_count3 ;
 
136
 
 
137
utf8_char_update_query3:
 
138
  UPDATE _table[invariant] SET `col_varchar_5_utf8` = _char[invariant] WHERE special_where_list;
 
139
 
 
140
utf8_char_select_count3:
 
141
  SELECT COUNT(*) FROM _table[invariant] WHERE `col_varchar_5_utf8` = _char[invariant];
 
142
 
 
143
 
 
144
delete:
 
145
  int_delete ;
 
146
 
 
147
int_delete:
 
148
  int_delete_query ; int_select_count ;
 
149
 
 
150
int_delete_query:
 
151
  DELETE FROM _table[invariant] WHERE `col_int_signed` = _digit[invariant] AND special_where_list ;
 
152
 
 
153
special_where_list:
 
154
  not ( special_where_item ) | not ( special_where_item ) |
 
155
  ( special_where_list and_or special_where_item ) ;
 
156
 
 
157
special_where_item:
 
158
  _table[invariant] . partitioned_int_field comparison_operator _digit  |
 
159
  _table[invariant] . int_field comparison_operator _digit  |
 
160
  _table[invariant] . partitioned_int_field not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit ) |
 
161
  _table[invariant] . int_field not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit ) |
 
162
  _table[invariant] . partitioned_int_field not IN ( number_list ) |
 
163
  _table[invariant] . int_field not in (number_list) |
 
164
  _table[invariant] . partitioned_char_field comparison_operator _char |
 
165
  _table[invariant] . partitioned_char_field not IN (char_list ) |
 
166
  _table[invariant] . char_field not IN (char_list) ; 
 
167
 
 
168
insert:
 
169
  INSERT INTO _table SELECT _field_list FROM _table[invariant] WHERE special_where_list ORDER BY _field_list LIMIT _digit ;
 
170
 
 
171
#######################################################
 
172
# query clause rules
 
173
#######################################################
 
174
 
 
175
select_list:
 
176
   new_select_item | new_select_item | new_select_item |
 
177
   new_select_item, select_list | new_select_item, select_list ;
 
178
 
 
179
simple_select_list:
 
180
   nonaggregate_select_item | nonaggregate_select_item | nonaggregate_select_item |
 
181
   nonaggregate_select_item | nonaggregate_select_item, simple_select_list | nonaggregate_select_item, simple_select_list ;
 
182
 
 
183
join_list_disabled:
 
184
   ( new_table_item join_type ( ( new_table_item join_type new_table_item ON ( join_condition ) ) ) ON ( join_condition ) ) ;
 
185
 
 
186
join_list:
 
187
   new_table_item join_type new_table_item ON ( join_condition ) |
 
188
   new_table_item | new_table_item | new_table_item | new_table_item | new_table_item  ;
 
189
 
 
190
join_type:
 
191
   INNER JOIN | left_right outer JOIN | STRAIGHT_JOIN ;
 
192
 
 
193
join_condition:
 
194
   current_table_item . int_indexed = previous_table_item . int_indexed |
 
195
   current_table_item . char_indexed = previous_table_item . char_indexed ; 
 
196
 
 
197
 
 
198
#########################################################
 
199
# We use partition pruning friendly clauses here
 
200
#########################################################
 
201
 
 
202
where_list:
 
203
  not ( where_item ) | not ( where_item ) |
 
204
  not ( where_list and_or where_item ) ;
 
205
 
 
206
where_item:
 
207
  table1 . partitioned_int_field comparison_operator existing_table_item . int_field  |
 
208
  table1 . partitioned_int_field comparison_operator _digit  |
 
209
  table1 . partitioned_int_field not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit ) |
 
210
  table1 . partitioned_int_field not IN ( number_list ) |
 
211
  table1 . partitioned_char_field comparison_operator _char  |
 
212
  table1 . partitioned_char_field not IN (char_list ) | 
 
213
  table1 . utf8_char_field comparison_operator existing_table_item . utf8_char_field  |
 
214
  table1 . latin1_char_field comparison_operator existing_table_item . latin1_char_field  |
 
215
  table1 . cp932_char_field comparison_operator existing_table_item . cp932_char_field  | 
 
216
  table1 . `col_date` comparison_operator _date  |
 
217
  table1 . `col_datetime` comparison_operator _datetime  |
 
218
  table1 . date_field comparison_operator _date  |
 
219
  table1 . char_field comparison_operator _char  |
 
220
  table1 . int_field  comparison_operator _digit  ;
 
221
 
 
222
partitioned_int_field:
 
223
    `col_int_signed` ;
 
224
 
 
225
partitioned_char_field:
 
226
    `col_varchar_5_utf8`    | `col_varchar_5_cp932`    | `col_varchar_5_latin1`    |
 
227
    `col_varchar_256_utf8` | `col_varchar_256_cp932` | `col_varchar_256_latin1` |
 
228
    `col_varchar_512_utf8` | `col_varchar_512_cp932` | `col_varchar_512_latin1` ;
 
229
 
 
230
int_field:
 
231
    `col_int_signed` | `col_int_signed_key` ;
 
232
 
 
233
utf8_char_field:
 
234
  `col_varchar_5_utf8` | `col_varchar_5_utf8_key` | `col_varchar_256_utf8` | `col_varchar_256_utf8_key` | `col_varchar_512_utf8` | `col_varchar_512_utf8_key` ;
 
235
 
 
236
latin1_char_field:
 
237
  `col_varchar_5_latin1`  | `col_varchar_5_latin1_key` | `col_varchar_256_latin1` | `col_varchar_256_latin1_key` | `col_varchar_512_latin1` | `col_varchar_512_latin1_key`;
 
238
 
 
239
cp932_char_field:
 
240
  `col_varchar_5_cp932` | `col_varchar_5_cp932_key` | `col_varchar_256_cp932` | `col_varchar_256_cp932_key` | `col_varchar_512_cp932` | `col_varchar_512_cp932_key` ; 
 
241
 
 
242
char_field:
 
243
  utf8_char_field | latin1_char_field | cp932_char_field ;
 
244
 
 
245
date_field:
 
246
  `col_datetime` | `col_date_key` | `col_datetime_key` | `col_date` ; 
 
247
 
 
248
non_int_field:
 
249
  char_field | date_field ;
 
250
 
 
251
number_list:
 
252
        _digit | number_list, _digit ;
 
253
 
 
254
char_list: 
 
255
        char | char_list, char ;
 
256
 
 
257
char:
 
258
  _char | _char | _char | _char | _char |
 
259
  _char | _char | _char | _char | big_char ;
 
260
 
 
261
big_char:
 
262
   _varchar(512) | _varchar(1024) ;
 
263
 
 
264
#########################################################
 
265
# GROUP BY / HAVING / ORDER BY rules
 
266
#########################################################
 
267
group_by_clause:
 
268
        { scalar(@nonaggregates) > 0 ? " GROUP BY ".join (', ' , @nonaggregates ) : "" }  ;
 
269
 
 
270
optional_group_by:
 
271
        | | | | | | | | | group_by_clause ;
 
272
 
 
273
having_clause:
 
274
        | | | | | | | | | HAVING having_list;
 
275
 
 
276
having_list:
 
277
        not ( having_item ) |
 
278
        not ( having_item ) |
 
279
        (having_list and_or having_item)  ;
 
280
 
 
281
having_item:
 
282
         existing_table_item . char_field comparison_operator _char |
 
283
         existing_table_item . int_field comparison_operator _digit |
 
284
         existing_table_item . date_field comparison_operator _date |
 
285
         existing_table_item . char_field comparison_operator existing_table_item . char_field |
 
286
         existing_table_item . int_field comparison_operator existing_table_item . int_field |
 
287
         existing_table_item . date_field comparison_operator existing_table_tiem . date_field ;
 
288
 
 
289
order_by_clause:
 
290
 | | | | ORDER BY total_order_by desc limit ;
 
291
 
 
292
total_order_by:
 
293
        { join(', ', map { "field".$_ } (1..$fields) ) };
 
294
 
 
295
desc:
 
296
  ASC | | | | DESC ;
 
297
 
 
298
limit:
 
299
  | | | | | | | | | | LIMIT limit_size | LIMIT limit_size OFFSET _digit;
 
300
 
 
301
limit_size:
 
302
    1 | 2 | 10 | 100 | 1000;
 
303
 
 
304
#########################################################
 
305
# query component rules
 
306
#########################################################
 
307
 
 
308
new_select_item:
 
309
  nonaggregate_select_item  | aggregate_select_item ;
 
310
 
 
311
nonaggregate_select_item:
 
312
  table_one_two . _field AS { my $f = "field".++$fields ; push @nonaggregates , $f ; $f } ;
 
313
 
 
314
aggregate_select_item:
 
315
  aggregate table_one_two . non_int_field ) AS { "field".++$fields } |
 
316
  int_aggregate table_one_two . int_field ) AS { "field".++$fields } ;
 
317
 
 
318
 
 
319
new_table_item:
 
320
        _table AS { "table".++$tables };
 
321
 
 
322
table_one_two:
 
323
      table1 ;
 
324
 
 
325
# disabled this to reduce number of bad queries
 
326
# can merge with rule table_one_two to add more
 
327
# variety to queries, but it is recommended that   
 
328
# table1 is still favored disproportionately
 
329
# (there aren't a lot of joins)
 
330
table_one_two_disabled:
 
331
 table2 ;
 
332
 
 
333
current_table_item:
 
334
        { "table".$tables };
 
335
 
 
336
previous_table_item:
 
337
        { "table".($tables - 1) };
 
338
 
 
339
existing_table_item:
 
340
        { "table".$prng->int(1,$tables) };
 
341
 
 
342
left_right:
 
343
        LEFT | RIGHT ;
 
344
 
 
345
outer: 
 
346
        | | | OUTER ;
 
347
 
 
348
existing_select_item:
 
349
        { "field".$prng->int(1,$fields) };
 
350
 
 
351
int_indexed:
 
352
    `col_int_signed_key` ;
 
353
 
 
354
char_indexed:
 
355
    `col_varchar_256_utf8_key` | `col_varchar_512_utf8_key` |
 
356
    `col_varchar_256_latin1_key` | `col_varchar_512_latin1_key` |
 
357
    `col_varchar_256_cp932_key` | `col_varchar_512_cp932_key` ;
 
358
 
 
359
comparison_operator:
 
360
        = | > | < | != | <> | <= | >= ;
 
361
 
 
362
aggregate:
 
363
        COUNT( distinct | MIN( distinct | MAX( distinct ;
 
364
 
 
365
int_aggregate:
 
366
        SUM( | aggregate ;
 
367
 
 
368
and_or:
 
369
        AND | AND | AND | AND | OR | OR | XOR ;
 
370
 
 
371
not:
 
372
   | | | | NOT ;
 
373
 
 
374
 
 
375
value:
 
376
        _digit | _digit | _digit | _digit | _digit |
 
377
        _char | _char | _char | _char | _char ;
 
378