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

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/conf/drizzle/outer_join_data_dictionary_drizzle.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
################################################################################
 
19
# outer_join.yy
 
20
# Purpose:  Random Query Generator grammar for testing larger (6 - 10 tables) JOINs
 
21
# Tuning:   Please tweak the rule table_or_joins ratio of table:join for larger joins
 
22
#           NOTE:  be aware that larger (15-20 tables) queries can take far too 
 
23
#                  long to run to be of much interest for fast, automated testing
 
24
#
 
25
# Notes:    This grammar is designed to be used with gendata=conf/optimizer/outer_join.zz
 
26
#           It can be altered, but one will likely need field names
 
27
#           Additionally, it is not recommended to use the standard RQG-produced
 
28
#           tables as they way we pick tables can result in the use of
 
29
#           several large tables that will bog down a generated query
 
30
#           
 
31
#           Please rely largely on the _portable variant of this grammar if
 
32
#           doing 3-way comparisons as it has altered code that will produce
 
33
#           more standards-compliant queries for use with other DBMS's
 
34
#  
 
35
#           We keep the grammar here as it is in order to also test certain
 
36
#           MySQL-specific syntax variants.
 
37
################################################################################
 
38
 
 
39
 
 
40
query:
 
41
  normal_query | normal_query | normal_query | normal_query | data_dictionary ;
 
42
 
 
43
data_dictionary:
 
44
  show_command | data_dictionary_query ;
 
45
 
 
46
show_command:
 
47
  SHOW PROCESSLIST | SHOW PROCESSLIST | SHOW PROCESSLIST | SHOW PROCESSLIST |
 
48
  SHOW TABLE STATUS | SHOW TABLE STATUS | SHOW TABLE STATUS |
 
49
  SHOW TABLES | SHOW TABLES | SHOW TABLES |
 
50
  SHOW SCHEMAS |
 
51
  SHOW TEMPORARY TABLES ;
 
52
 
 
53
data_dictionary_query:
 
54
  SELECT * FROM `data_dictionary` . data_dictionary_table ;
 
55
 
 
56
data_dictionary_table:
 
57
TABLES                 | 
 
58
COLLATIONS              | 
 
59
MYSQL_PROTOCOL_STATUS   | 
 
60
CURRENT_SQL_COMMANDS    | 
 
61
CHARACTER_SETS          | 
 
62
SHOW_TEMPORARY_TABLES   | 
 
63
INDEXES                 | 
 
64
INDEX_PARTS             | 
 
65
INNODB_TRX              | 
 
66
DRIZZLE_PROTOCOL_STATUS | 
 
67
COUNTER                 | 
 
68
RANDOM_NUMBER           | 
 
69
PROCESSLIST             | 
 
70
PLUGINS                 | 
 
71
SHOW_COLUMNS            | 
 
72
TABLE_CACHE             | 
 
73
INNODB_STATUS           | 
 
74
CUMULATIVE_SQL_COMMANDS | 
 
75
INNODB_CMPMEM_RESET     | 
 
76
SCOREBOARD_STATISTICS   | 
 
77
SESSION_VARIABLES       | 
 
78
INNODB_LOCKS            | 
 
79
TABLE_DEFINITION_CACHE  | 
 
80
SHOW_TABLES             | 
 
81
SCHEMAS                 | 
 
82
INNODB_CMPMEM           | 
 
83
REFERENTIAL_CONSTRAINTS | 
 
84
INNODB_INTERNAL_TABLES  | 
 
85
TABLE_CONSTRAINTS       | 
 
86
REPLICATION_STREAMS     | 
 
87
RANDOM_STRING           | 
 
88
SHOW_SCHEMAS            | 
 
89
SESSION_STATUS          | 
 
90
SHOW_TABLE_STATUS       | 
 
91
GLOBAL_VARIABLES        | 
 
92
INNODB_CMP              | 
 
93
COLUMNS                 | 
 
94
SESSION_STATEMENTS      | 
 
95
INNODB_LOCK_WAITS       | 
 
96
SHOW_INDEXES            | 
 
97
GLOBAL_STATEMENTS       | 
 
98
MODULES                 | 
 
99
INNODB_CMP_RESET        | 
 
100
GLOBAL_STATUS           | 
 
101
CUMULATIVE_USER_STATS   ; 
 
102
 
 
103
 
 
104
normal_query:
 
105
  { @nonaggregates = () ; $tables = 0 ; $fields = 0 ;  "" } query_type ;
 
106
 
 
107
query_type:
 
108
  simple_select | simple_select | mixed_select | mixed_select | mixed_select | aggregate_select ;
 
109
 
 
110
mixed_select:
 
111
        { $stack->push() } SELECT distinct straight_join select_option select_list FROM join WHERE where_list group_by_clause having_clause order_by_clause { $stack->pop(undef) } ;
 
112
 
 
113
simple_select:
 
114
        { $stack->push() } SELECT distinct straight_join select_option simple_select_list FROM join WHERE where_list  optional_group_by having_clause order_by_clause { $stack->pop(undef) } ;
 
115
 
 
116
aggregate_select:
 
117
        { $stack->push() } SELECT distinct straight_join select_option aggregate_select_list FROM join WHERE where_list optional_group_by having_clause order_by_clause { $stack->pop(undef) } ;
 
118
 
 
119
distinct: DISTINCT | | | |  ;
 
120
 
 
121
select_option:  | | | | | | | | | SQL_SMALL_RESULT ;
 
122
 
 
123
straight_join:  | | | | | | | | | | | STRAIGHT_JOIN ;
 
124
 
 
125
select_list:
 
126
        new_select_item |
 
127
        new_select_item , select_list |
 
128
        new_select_item , select_list ;
 
129
 
 
130
simple_select_list:
 
131
        nonaggregate_select_item |
 
132
        nonaggregate_select_item , simple_select_list |
 
133
        nonaggregate_select_item , simple_select_list ;
 
134
 
 
135
aggregate_select_list:
 
136
        aggregate_select_item | aggregate_select_item |
 
137
        aggregate_select_item, aggregate_select_list ;
 
138
 
 
139
new_select_item:
 
140
        nonaggregate_select_item |
 
141
        nonaggregate_select_item |        
 
142
        nonaggregate_select_item |
 
143
        nonaggregate_select_item |        
 
144
        nonaggregate_select_item |
 
145
        aggregate_select_item ;
 
146
 
 
147
nonaggregate_select_item:
 
148
        table_alias . int_field_name AS { my $f = "field".++$fields ; push @nonaggregates , $f ; $f } ;
 
149
 
 
150
aggregate_select_item:
 
151
        aggregate table_alias . int_field_name ) AS {"field".++$fields } ; 
 
152
        
 
153
join:
 
154
       { $stack->push() }      
 
155
       table_or_join 
 
156
       { $stack->set("left",$stack->get("result")); }
 
157
       left_right outer JOIN table_or_join 
 
158
       ON 
 
159
       join_condition ;
 
160
 
 
161
join_condition:
 
162
   int_condition | char_condition ;
 
163
 
 
164
int_condition: 
 
165
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_indexed = 
 
166
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_indexed
 
167
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
168
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_indexed =
 
169
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_field_name
 
170
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
171
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_field_name =
 
172
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/,
 
173
 $table_string); $table_array[1] } . int_indexed
 
174
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
175
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . int_field_name =
 
176
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/,
 
177
 $table_string); $table_array[1] } . int_field_name
 
178
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } ;
 
179
 
 
180
char_condition:
 
181
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_field_name =
 
182
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_field_name 
 
183
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
184
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_indexed  =
 
185
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_field_name 
 
186
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
187
   { my $left = $stack->get("left"); my %s=map{$_=>1} @$left; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_field_name =
 
188
   { my $right = $stack->get("result"); my %s=map{$_=>1} @$right; my @r=(keys %s); my $table_string = $prng->arrayElement(\@r); my @table_array = split(/AS/, $table_string); $table_array[1] } . char_indexed 
 
189
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } ;
 
190
 
 
191
where_list:
 
192
        where_item | where_item |
 
193
        ( where_list and_or where_item ) ;
 
194
 
 
195
where_item:
 
196
        existing_table_item . `pk` comparison_operator _digit  |
 
197
        existing_table_item . `pk` comparison_operator existing_table_item . int_field_name  |
 
198
        existing_table_item . int_field_name comparison_operator _digit  |
 
199
        existing_table_item . int_field_name comparison_operator existing_table_item . int_field_name |
 
200
        existing_table_item . int_field_name IS not NULL |
 
201
        existing_table_item . int_field_name not IN (number_list) |
 
202
        existing_table_item . int_field_name  not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit );
 
203
 
 
204
number_list:
 
205
        _digit | number_list, _digit ;
 
206
 
 
207
################################################################################
 
208
# We ensure that a GROUP BY statement includes all nonaggregates.              #
 
209
# This helps to ensure the query is more useful in detecting real errors /     #
 
210
# that the query doesn't lend itself to variable result sets                   #
 
211
################################################################################
 
212
group_by_clause:
 
213
        { scalar(@nonaggregates) > 0 ? " GROUP BY ".join (', ' , @nonaggregates ) : "" }  ;
 
214
 
 
215
optional_group_by:
 
216
        | | | | | | | | group_by_clause ;
 
217
 
 
218
having_clause:
 
219
        | HAVING having_list;
 
220
 
 
221
having_list:
 
222
        having_item |
 
223
        having_item |
 
224
        (having_list and_or having_item)  ;
 
225
 
 
226
having_item:
 
227
        existing_select_item comparison_operator _digit ;
 
228
 
 
229
################################################################################
 
230
# We use the total_order_by rule when using the LIMIT operator to ensure that  #
 
231
# we have a consistent result set - server1 and server2 should not differ      #
 
232
################################################################################
 
233
 
 
234
order_by_clause:
 
235
        |
 
236
        ORDER BY total_order_by desc limit |
 
237
        ORDER BY order_by_list ;
 
238
 
 
239
total_order_by:
 
240
        { join(', ', map { "field".$_ } (1..$fields) ) };
 
241
 
 
242
order_by_list:
 
243
        order_by_item  |
 
244
        order_by_item  , order_by_list ;
 
245
 
 
246
order_by_item:
 
247
        existing_select_item desc ;
 
248
 
 
249
desc:
 
250
        ASC | | | | | DESC ; 
 
251
 
 
252
################################################################################
 
253
# We mix digit and _digit here.  We want to alter the possible values of LIMIT #
 
254
# To ensure we hit varying EXPLAIN plans, but the OFFSET can be smaller        #
 
255
################################################################################
 
256
 
 
257
limit:
 
258
        | | LIMIT limit_size | LIMIT limit_size OFFSET _digit;
 
259
 
 
260
################################################################################
 
261
# recommend 8 tables : 2 joins for smaller queries, 6:2 for larger ones
 
262
################################################################################
 
263
 
 
264
table_or_join:
 
265
           table | table | table | table | table | 
 
266
           table | table | table | join | join ;
 
267
 
 
268
table_disabled:
 
269
# We use the "AS table" bit here so we can have unique aliases if we use the same table many times
 
270
       { $stack->push(); my $x = $prng->arrayElement(\@table_set)." AS table".++$tables;  my @s=($x); $stack->pop(\@s); $x } ;
 
271
 
 
272
 
 
273
table:
 
274
# We use the "AS table" bit here so we can have unique aliases if we use the same table many times
 
275
       { $stack->push(); my $x = $prng->arrayElement($executors->[0]->tables())." AS table".++$tables;  my @s=($x); $stack->pop(\@s); $x } ;
 
276
 
 
277
int_field_name:
 
278
  `pk` | `col_int_key` | `col_int` ;
 
279
 
 
280
int_indexed:
 
281
   `pk` | `col_int_key` ;
 
282
 
 
283
char_field_name:
 
284
  `col_varchar_10` | 
 
285
  `col_varchar_1024_key` | 
 
286
  `col_varchar_1024` | 
 
287
  `col_varchar_10_key` ; 
 
288
 
 
289
char_indexed:
 
290
  `col_varchar_10_key` | `col_varchar_10_key` |
 
291
  `col_varchar_1024_key` |`col_varchar_1024_key` ;
 
292
 
 
293
 
 
294
table_alias:
 
295
  table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 |
 
296
  table2 | table2 | table2 | table2 | table2 | table2 | table2 | table2 | table2 | other_table ;
 
297
 
 
298
other_table:
 
299
  table3 | table3 | table3 | table3 | table3 | table4 | table4 | table5 ;
 
300
 
 
301
existing_table_item:
 
302
        { "table".$prng->int(1,$tables) };
 
303
 
 
304
existing_select_item:
 
305
        { "field".$prng->int(1,$fields) };
 
306
 
 
307
_digit:
 
308
    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
 
309
    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | _tinyint_unsigned ;
 
310
 
 
311
 
 
312
and_or:
 
313
   AND | AND | OR ;
 
314
 
 
315
comparison_operator:
 
316
        = | > | < | != | <> | <= | >= ;
 
317
 
 
318
aggregate:
 
319
        COUNT( distinct | SUM( distinct | MIN( distinct | MAX( distinct ;
 
320
 
 
321
not:
 
322
        | | | NOT;
 
323
 
 
324
left_right:
 
325
        LEFT | LEFT | LEFT | RIGHT ;
 
326
 
 
327
outer:
 
328
        | | | | OUTER ;
 
329
 
 
330
################################################################################
 
331
# We define LIMIT_rows in this fashion as LIMIT values can differ depending on      #
 
332
# how large the LIMIT is - LIMIT 2 = LIMIT 9 != LIMIT 19                       #
 
333
################################################################################
 
334
 
 
335
limit_size:
 
336
    1 | 2 | 10 | 100 | 1000;
 
337