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
|
query:
{@nonaggregates = () ; $tables = 0 ; $fields = 0; "" } main_query ;
main_query:
SELECT straight_join select_type
FROM table_list
where_clause
group_by_clause
having_clause
order_clause;
straight_join:
| STRAIGHT_JOIN ;
select_type:
rand_select_list | rand_select_list ;
rand_select_list:
rand_select_item |
rand_select_item , rand_select_list |
rand_select_item , rand_select_list ;
rand_select_item:
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
aggregate_function x_y . field_name ) |
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
x_y . field_name AS {my $f = "field".++$fields ; push @nonaggregates , $f ; $f } |
aggregate_function x_y . field_name ) |
x_y . * ;
inner_cross:
INNER | CROSS ;
left_right:
LEFT | RIGHT ;
outer:
| OUTER ;
opt_join_condition:
| join_condition ;
join_condition:
ON join_expr ;
join_expr:
( X . field_name arithmetic_operator Y . field_name ) ;
table_list:
table_item X , table_item Y |
table_item X inner_cross JOIN table_item Y |
table_item X STRAIGHT_JOIN table_item Y opt_join_condition |
table_item X left_right outer JOIN table_item Y join_condition |
table_item X NATURAL left_right outer JOIN table_item Y ;
table_item:
B | C | BB | CC | BBB | CCC ;
where_clause:
| WHERE where_list | WHERE where_list;
where_list:
where_condition |
( where_condition ) logical_operator where_list ;
where_condition:
x_y . field_name arithmetic_operator x_y . field_name |
x_y . field_name arithmetic_operator x_y . field_name |
x_y . field_name arithmetic_operator value ;
x_y: X | Y ;
group_by_clause:
{ scalar(@nonaggregates) > 0 ? " GROUP BY ".join(', ' , @nonaggregates ) : "" } ;
having_clause:
| HAVING having_list ;
having_list:
not having_item |
not having_item |
not (having_list logical_operator having_item) |
existing_select_item null_operator ;
having_item:
( existing_select_item arithmetic_operator digit ) |
( existing_select_item arithmetic_operator existing_select_item );
not:
NOT | | |;
existing_select_item:
{ "field".$prng->int(1,$fields) } ;
order_clause:
|
ORDER BY order_list desc |
ORDER BY order_list desc limit |
ORDER BY total_order_by desc limit ;
order_list:
order_by_item |
order_by_item , order_list ;
order_by_item:
x_y . _field | existing_select_item ;
total_order_by:
{ join(', ', map { "field".$_ } (1..$fields) ) } ;
desc:
ASC | | DESC ;
digit:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 20 ;
limit:
LIMIT digit | LIMIT digit | | | | LIMIT digit OFFSET digit ;
aggregate_function:
AVG( |
COUNT(DISTINCT | COUNT( |
MIN( | MIN(DISTINCT |
MAX( | MAX(DISTINCT |
SUM( | SUM(DISTINCT ;
arithmetic_operator:
= | > | < | <> | >= | <= ;
logical_operator:
AND | OR | OR NOT | AND NOT ;
null_operator: IS NULL | IS NOT NULL | IS NOT NULL ;
field_name:
int_field_name ;
int_field_name:
`pk` | `int_key` | `int_nokey` ;
value:
_digit ;
|