2
{ @nonaggregates = () ; $tables = 0 ; $fields = 0 ; "" } query_type ;
6
select | select | select | select | select |
7
select | select | select | select | select |
8
select | select | select | select | select |
9
update | update | update | delete | delete ;
11
distict: DISTINCT | | | | | | | | | ;
13
select_option: SQL_SMALL_RESULT | | | | | | | | | | | | | | | | | | | | ;
16
| | | | | | | | | explain_extended2 ;
18
explain_extended2: | | | | EXPLAIN | EXPLAIN EXTENDED ;
22
simple_select | mixed_select ;
25
explain_extended SELECT simple_select_list
34
explain_extended SELECT select_list
42
int_update | char_update ;
45
int_update_query ; int_select_count ;
48
UPDATE _table[invariant] SET `int_signed` = _digit[invariant] WHERE special_where_list ;
51
SELECT COUNT(*) FROM _table[invariant] WHERE `int_signed` = _digit[invariant];
54
char_update_query ; char_select_count ;
57
UPDATE _table[invariant] SET `varchar_5` = _char[invariant] WHERE special_where_list;
60
SELECT COUNT(*) FROM _table[invariant] WHERE `varchar_5` = _char[invariant];
67
int_delete_query ; int_select_count ;
70
DELETE FROM _table[invariant] WHERE `int_signed` = _digit[invariant] and_or special_where_list ;
73
( special_where_item ) | ( special_where_item ) |
74
( special_where_list and_or special_where_item ) ;
77
_table[invariant] . partitioned_int_field arithmetic_operator _digit |
78
_table[invariant] . partitioned_int_field not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit ) |
79
_table[invariant] . partitioned_int_field not IN ( number_list ) |
80
_table[invariant] . partitioned_char_field arithmetic_operator _char |
81
_table[invariant] . partitioned_char_field not IN (char_list ) ;
83
#######################################################
85
#######################################################
88
new_select_item | new_select_item | new_select_item |
89
new_select_item, select_list | new_select_item, select_list ;
92
nonaggregate_select_item | nonaggregate_select_item | nonaggregate_select_item |
93
nonaggregate_select_item | nonaggregate_select_item, simple_select_list | nonaggregate_select_item, simple_select_list ;
96
new_table_item join_type new_table_item ON ( join_condition ) |
97
new_table_item | new_table_item | new_table_item | new_table_item ;
100
INNER JOIN | left_right outer JOIN | STRAIGHT_JOIN ;
103
current_table_item . int_indexed = previous_table_item . int_indexed |
104
current_table_item . char_indexed = previous_table_item . char_indexed ;
107
#########################################################
108
# We use partition pruning friendly clauses here
109
#########################################################
112
( where_item ) | ( where_item ) |
113
( where_list and_or where_item ) ;
116
table1 . partitioned_int_field arithmetic_operator existing_table_item . int_field |
117
table1 . partitioned_int_field arithmetic_operator _digit |
118
table1 . partitioned_int_field not BETWEEN _digit[invariant] AND ( _digit[invariant] + _digit ) |
119
table1 . partitioned_int_field not IN ( number_list ) |
120
table1 . partitioned_char_field arithmetic_operator existing_table_item . char_field |
121
table1 . partitioned_char_field arithmetic_operator _char |
122
table1 . partitioned_char_field not IN (char_list ) ;
124
partitioned_int_field:
127
partitioned_char_field:
131
`int_signed` | `int_signed_key` ;
134
`varchar_5` | `varchar_5_key` | `varchar_10` | `varchar_10_key` ;
137
`datetime` | `date_key` | `datetime_key` | `date` ;
140
char_field | date_field ;
143
_digit | number_list, _digit ;
146
_char | char_list, _char ;
148
#########################################################
149
# GROUP BY / HAVING / ORDER BY rules
150
#########################################################
152
{ scalar(@nonaggregates) > 0 ? " GROUP BY ".join (', ' , @nonaggregates ) : "" } ;
155
| | | | | | | | | group_by_clause ;
158
| | | | | | | | | HAVING having_list;
163
(having_list and_or having_item) ;
166
existing_select_item arithmetic_operator value |
167
existing_select_item arithmetic_operator value |
168
existing_select_item arithmetic_operator value |
169
existing_select_item arithmetic_operator value |
170
existing_select_item arithmetic_operator existing_select_item ;
173
| | | | ORDER BY total_order_by desc limit ;
176
{ join(', ', map { "field".$_ } (1..$fields) ) };
182
| | | | | | | | | | LIMIT limit_size | LIMIT limit_size OFFSET _digit;
185
1 | 2 | 10 | 100 | 1000;
187
#########################################################
188
# query component rules
189
#########################################################
192
nonaggregate_select_item | aggregate_select_item ;
194
nonaggregate_select_item:
195
table_one_two . _field AS { my $f = "field".++$fields ; push @nonaggregates , $f ; $f } ;
197
aggregate_select_item:
198
aggregate table_one_two . non_int_field ) AS { "field".++$fields } |
199
int_aggregate table_one_two . int_field ) AS { "field".++$fields } ;
203
_table AS { "table".++$tables };
206
table1 | table1 | table1 | table1 | table2 ;
212
{ "table".($tables - 1) };
215
{ "table".$prng->int(1,$tables) };
223
existing_select_item:
224
{ "field".$prng->int(1,$fields) };
230
`varchar_5_key` | `varchar_10_key` ;
233
= | > | < | != | <> | <= | >= ;
236
COUNT( | MIN( | MAX( ;
249
_digit | _digit | _digit | _digit | _digit |
250
_char | _char | _char | _char | _char ;