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

« back to all changes in this revision

Viewing changes to tests/test_tools/randgen/conf/percona/outer_join_percona.yy

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

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
  { @nonaggregates = () ; $tables = 0 ; $fields = 0 ;  "" } query_type ;
 
42
 
 
43
query_type:
 
44
  simple_select | simple_select | mixed_select | mixed_select | mixed_select | aggregate_select ;
 
45
 
 
46
mixed_select:
 
47
        { $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) } ;
 
48
 
 
49
simple_select:
 
50
        { $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) } ;
 
51
 
 
52
aggregate_select:
 
53
        { $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) } ;
 
54
 
 
55
distinct: DISTINCT | | | |  ;
 
56
 
 
57
select_option:  | | | | | | | | | SQL_SMALL_RESULT ;
 
58
 
 
59
straight_join:  | | | | | | | | | | | STRAIGHT_JOIN ;
 
60
 
 
61
select_list:
 
62
        new_select_item |
 
63
        new_select_item , select_list |
 
64
        new_select_item , select_list ;
 
65
 
 
66
simple_select_list:
 
67
        nonaggregate_select_item |
 
68
        nonaggregate_select_item , simple_select_list |
 
69
        nonaggregate_select_item , simple_select_list ;
 
70
 
 
71
aggregate_select_list:
 
72
        aggregate_select_item | aggregate_select_item |
 
73
        aggregate_select_item, aggregate_select_list ;
 
74
 
 
75
new_select_item:
 
76
        nonaggregate_select_item |
 
77
        nonaggregate_select_item |        
 
78
        nonaggregate_select_item |
 
79
        nonaggregate_select_item |        
 
80
        nonaggregate_select_item |
 
81
        aggregate_select_item ;
 
82
 
 
83
nonaggregate_select_item:
 
84
        table_alias . int_field_name AS { my $f = "field".++$fields ; push @nonaggregates , $f ; $f } ;
 
85
 
 
86
aggregate_select_item:
 
87
        aggregate table_alias . int_field_name ) AS {"field".++$fields } ; 
 
88
        
 
89
join:
 
90
       { $stack->push() }      
 
91
       table_or_join 
 
92
       { $stack->set("left",$stack->get("result")); }
 
93
       left_right outer JOIN table_or_join 
 
94
       ON 
 
95
       join_condition ;
 
96
 
 
97
join_condition:
 
98
   int_condition | char_condition ;
 
99
 
 
100
int_condition: 
 
101
   { 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 = 
 
102
   { 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
 
103
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
104
   { 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 =
 
105
   { 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
 
106
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
107
   { 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 =
 
108
   { 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/,
 
109
 $table_string); $table_array[1] } . int_indexed
 
110
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
111
   { 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 =
 
112
   { 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/,
 
113
 $table_string); $table_array[1] } . int_field_name
 
114
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } ;
 
115
 
 
116
char_condition:
 
117
   { 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 =
 
118
   { 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 
 
119
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
120
   { 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  =
 
121
   { 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 
 
122
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } |
 
123
   { 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 =
 
124
   { 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 
 
125
   { my $left = $stack->get("left");  my $right = $stack->get("result"); my @n = (); push(@n,@$right); push(@n,@$left); $stack->pop(\@n); return undef } ;
 
126
 
 
127
where_list:
 
128
        where_item | where_item |
 
129
        ( where_list and_or where_item ) ;
 
130
 
 
131
where_item:
 
132
        existing_table_item . `pk` comparison_operator _digit  |
 
133
        existing_table_item . `pk` comparison_operator existing_table_item . int_field_name  |
 
134
        existing_table_item . int_field_name comparison_operator _digit  |
 
135
        existing_table_item . int_field_name comparison_operator existing_table_item . int_field_name |
 
136
        existing_table_item . int_field_name IS not NULL |
 
137
        existing_table_item . int_field_name not IN (number_list) |
 
138
        existing_table_item . int_field_name  not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit );
 
139
 
 
140
number_list:
 
141
        _digit | number_list, _digit ;
 
142
 
 
143
################################################################################
 
144
# We ensure that a GROUP BY statement includes all nonaggregates.              #
 
145
# This helps to ensure the query is more useful in detecting real errors /     #
 
146
# that the query doesn't lend itself to variable result sets                   #
 
147
################################################################################
 
148
group_by_clause:
 
149
        { scalar(@nonaggregates) > 0 ? " GROUP BY ".join (', ' , @nonaggregates ) : "" }  ;
 
150
 
 
151
optional_group_by:
 
152
        | | | | | | | | group_by_clause ;
 
153
 
 
154
having_clause:
 
155
        | HAVING having_list;
 
156
 
 
157
having_list:
 
158
        having_item |
 
159
        having_item |
 
160
        (having_list and_or having_item)  ;
 
161
 
 
162
having_item:
 
163
        existing_select_item comparison_operator _digit ;
 
164
 
 
165
################################################################################
 
166
# We use the total_order_by rule when using the LIMIT operator to ensure that  #
 
167
# we have a consistent result set - server1 and server2 should not differ      #
 
168
################################################################################
 
169
 
 
170
order_by_clause:
 
171
        |
 
172
        ORDER BY total_order_by desc limit |
 
173
        ORDER BY order_by_list ;
 
174
 
 
175
total_order_by:
 
176
        { join(', ', map { "field".$_ } (1..$fields) ) };
 
177
 
 
178
order_by_list:
 
179
        order_by_item  |
 
180
        order_by_item  , order_by_list ;
 
181
 
 
182
order_by_item:
 
183
        existing_select_item desc ;
 
184
 
 
185
desc:
 
186
        ASC | | | | | DESC ; 
 
187
 
 
188
################################################################################
 
189
# We mix digit and _digit here.  We want to alter the possible values of LIMIT #
 
190
# To ensure we hit varying EXPLAIN plans, but the OFFSET can be smaller        #
 
191
################################################################################
 
192
 
 
193
limit:
 
194
        | | LIMIT limit_size | LIMIT limit_size OFFSET _digit;
 
195
 
 
196
################################################################################
 
197
# recommend 8 tables : 2 joins for smaller queries, 6:2 for larger ones
 
198
################################################################################
 
199
 
 
200
table_or_join:
 
201
           table | table | table | table | table | 
 
202
           table | table | table | join | join ;
 
203
 
 
204
table_disabled:
 
205
# We use the "AS table" bit here so we can have unique aliases if we use the same table many times
 
206
       { $stack->push(); my $x = $prng->arrayElement(\@table_set)." AS table".++$tables;  my @s=($x); $stack->pop(\@s); $x } ;
 
207
 
 
208
 
 
209
table:
 
210
# We use the "AS table" bit here so we can have unique aliases if we use the same table many times
 
211
       { $stack->push(); my $x = $prng->arrayElement($executors->[0]->tables())." AS table".++$tables;  my @s=($x); $stack->pop(\@s); $x } ;
 
212
 
 
213
int_field_name:
 
214
  `pk` | `col_int_key` | `col_int` ;
 
215
 
 
216
int_indexed:
 
217
   `pk` | `col_int_key` ;
 
218
 
 
219
char_field_name:
 
220
  `col_varchar_10` | 
 
221
  `col_varchar_255_key` | 
 
222
  `col_varchar_255` | 
 
223
  `col_varchar_10_key` ; 
 
224
 
 
225
char_indexed:
 
226
  `col_varchar_10_key` | `col_varchar_10_key` |
 
227
  `col_varchar_255_key` |`col_varchar_255_key` ;
 
228
 
 
229
 
 
230
table_alias:
 
231
  table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 | table1 |
 
232
  table2 | table2 | table2 | table2 | table2 | table2 | table2 | table2 | table2 | other_table ;
 
233
 
 
234
other_table:
 
235
  table3 | table3 | table3 | table3 | table3 | table4 | table4 | table5 ;
 
236
 
 
237
existing_table_item:
 
238
        { "table".$prng->int(1,$tables) };
 
239
 
 
240
existing_select_item:
 
241
        { "field".$prng->int(1,$fields) };
 
242
 
 
243
_digit:
 
244
    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
 
245
    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | _tinyint_unsigned ;
 
246
 
 
247
 
 
248
and_or:
 
249
   AND | AND | OR ;
 
250
 
 
251
comparison_operator:
 
252
        = | > | < | != | <> | <= | >= ;
 
253
 
 
254
aggregate:
 
255
        COUNT( distinct | SUM( distinct | MIN( distinct | MAX( distinct ;
 
256
 
 
257
not:
 
258
        | | | NOT;
 
259
 
 
260
left_right:
 
261
        LEFT | LEFT | LEFT | RIGHT ;
 
262
 
 
263
outer:
 
264
        | | | | OUTER ;
 
265
 
 
266
################################################################################
 
267
# We define LIMIT_rows in this fashion as LIMIT values can differ depending on      #
 
268
# how large the LIMIT is - LIMIT 2 = LIMIT 9 != LIMIT 19                       #
 
269
################################################################################
 
270
 
 
271
limit_size:
 
272
    1 | 2 | 10 | 100 | 1000;
 
273