1
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
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.
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.
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
19
SELECT select_option grandparent_select_items
22
grandparent_group_having_order_limit;
24
grandparent_select_items:
25
grandparent_select_item;
27
grandparent_select_item:
28
GRANDPARENT1 . field_name AS G1;
31
table_name AS GRANDPARENT1 |
32
table_name AS GRANDPARENT1 LEFT JOIN table_name AS GRANDPARENT2 USING ( field_name ) |
33
table_name AS GRANDPARENT1 LEFT JOIN table_name AS GRANDPARENT2 ON ( grandparent_join_condition );
35
grandparent_join_condition:
36
GRANDPARENT2 . int_field_name arithmetic_operator GRANDPARENT1 . int_field_name |
37
GRANDPARENT2 . char_field_name arithmetic_operator GRANDPARENT1 . char_field_name ;
40
WHERE grandparent_subquery_expr AND grandparent_condition ;
42
grandparent_subquery_expr:
43
GRANDPARENT1 . int_field_name IN ( SELECT select_option PARENT1 . int_field_name AS P1 parent_select_body ) |
44
GRANDPARENT1 . char_field_name IN ( SELECT select_option PARENT1 . char_field_name AS P1 parent_select_body ) |
45
( GRANDPARENT1 . int_field_name , GRANDPARENT1 . int_field_name ) IN ( SELECT select_option PARENT1 . int_field_name AS P1 , PARENT1 . int_field_name AS P2 parent_select_body ) |
46
( GRANDPARENT1 . char_field_name , GRANDPARENT1 . char_field_name ) IN ( SELECT select_option PARENT1 . char_field_name AS P1 , PARENT1 . char_field_name AS P2 parent_select_body ) ;
48
grandparent_group_having_order_limit:
49
grandparent_group_by grandparent_having grandparent_order_by grandparent_limit |
50
grandparent_group_by grandparent_having grandparent_limit |
51
grandparent_having grandparent_order_by grandparent_limit |
55
GROUP BY GRANDPARENT1 . field_name ;
58
ORDER BY GRANDPARENT1 . field_name ;
61
| HAVING G1 arithmetic_operator value;
72
table_name AS PARENT1 |
73
table_name AS PARENT1 LEFT JOIN table_name AS PARENT2 USING ( field_name ) |
74
table_name AS PARENT1 LEFT JOIN table_name AS PARENT2 ON ( parent_join_condition ) ;
76
parent_join_condition:
77
PARENT1 . int_field_name arithmetic_operator PARENT2 . int_field_name |
78
PARENT1 . char_field_name arithmetic_operator PARENT2 . char_field_name ;
81
| WHERE parent_subquery_expr AND parent_condition
82
| WHERE parent_condition ;
85
| ORDER BY PARENT1 . field_name ;
88
PARENT1 . int_field_name IN ( SELECT select_option CHILD1 . int_field_name AS C1 child_select_body ) |
89
GRANDPARENT1 . int_field_name IN ( SELECT select_option CHILD1 . int_field_name AS C1 child_select_body ) |
91
PARENT1 . char_field_name IN ( SELECT select_option CHILD1 . char_field_name AS C1 child_select_body ) |
92
GRANDPARENT1 . char_field_name IN ( SELECT select_option CHILD1 . char_field_name AS C1 child_select_body ) |
94
( PARENT1 . int_field_name , PARENT1 . int_field_name ) IN ( SELECT select_option CHILD1 . int_field_name AS C1 , CHILD1 . int_field_name AS C2 child_select_body ) |
95
( PARENT1 . int_field_name , GRANDPARENT1 . int_field_name ) IN ( SELECT select_option CHILD1 . int_field_name AS C1 , CHILD1 . int_field_name AS C2 child_select_body ) |
97
( PARENT1 . char_field_name , PARENT1 . char_field_name ) IN ( SELECT select_option CHILD1 . char_field_name AS C1 , CHILD1 . char_field_name AS C2 child_select_body ) ;
98
( PARENT1 . char_field_name , GRANDPARENT1 . char_field_name ) IN ( SELECT select_option CHILD1 . char_field_name AS C1 , CHILD1 . char_field_name AS C2 child_select_body ) ;
100
( PARENT1 . char_field_name , PARENT1 . char_field_name ) IN ( SELECT select_option CHILD1 . char_field_name AS C1 , CHILD1 . char_field_name AS C2 child_select_body ) ;
101
( PARENT1 . int_field_name , PARENT1 . int_field_name ) IN ( SELECT select_option CHILD1 . int_field_name AS C1 , CHILD1 . int_field_name AS C2 child_select_body ) ;
109
table_name AS CHILD1 |
110
table_name AS CHILD1 LEFT JOIN table_name AS CHILD2 USING ( field_name ) |
111
table_name AS CHILD1 LEFT JOIN table_name AS CHILD2 ON ( child_join_condition ) ;
113
child_join_condition:
114
CHILD1 . int_field_name arithmetic_operator CHILD2 . int_field_name |
115
CHILD1 . char_field_name arithmetic_operator CHILD2 . char_field_name ;
118
| WHERE child_condition ;
121
| ORDER BY CHILD1 . field_name ;
124
( GRANDPARENT1 . expression ) |
125
( PARENT1 . expression ) |
126
( CHILD1 . expression ) |
127
( child_condition_bottom logical_operator child_condition ) |
128
( child_condition_bottom logical_operator parent_condition ) |
129
( child_condition_bottom logical_operator grandparent_condition ) ;
131
child_condition_bottom:
133
( CHILD1 . expression ) |
135
( CHILD1 . int_field_name arithmetic_operator CHILD1 . int_field_name ) |
136
( CHILD1 . char_field_name arithmetic_operator CHILD1 . char_field_name ) |
138
( CHILD1 . int_field_name arithmetic_operator PARENT1 . int_field_name ) |
139
( CHILD1 . char_field_name arithmetic_operator PARENT1 . char_field_name ) |
141
( CHILD1 . int_field_name arithmetic_operator GRANDPARENT1 . int_field_name ) |
142
( CHILD1 . char_field_name arithmetic_operator GRANDPARENT1 . char_field_name ) ;
144
grandparent_condition:
145
grandparent_condition_bottom |
146
( grandparent_condition logical_operator grandparent_condition_bottom ) ;
148
grandparent_condition_bottom:
149
GRANDPARENT1 . expression ;
152
field_name null_operator |
153
int_field_name int_expression |
154
char_field_name char_expression ;
157
arithmetic_operator digit ;
161
arithmetic_operator _varchar(1);
164
( GRANDPARENT1 . expression ) |
165
( PARENT1 . expression ) |
166
( parent_condition_bottom logical_operator parent_condition ) |
167
( parent_condition_bottom logical_operator grandparent_condition ) ;
169
parent_condition_bottom:
170
( PARENT1 . expression ) |
172
( PARENT1 . int_field_name arithmetic_operator PARENT1 . int_field_name ) |
173
( PARENT1 . char_field_name arithmetic_operator PARENT1 . char_field_name ) |
175
( PARENT1 . int_field_name arithmetic_operator GRANDPARENT1 . int_field_name ) |
176
( PARENT1 . char_field_name arithmetic_operator GRANDPARENT1 . char_field_name ) ;
178
null_operator: IS NULL | IS NOT NULL | IS UNKNOWN ;
183
arithmetic_operator: = | > | < | <> | >= | <= ;
186
int_field_name | char_field_name ;
189
`pk` | `col_int_key` | `col_int` |
190
`col_bigint` | `col_bigint_key` |
191
`col_int_not_null` | `col_int_not_null_key` ;
194
`col_char_10` | `col_char_10_key` | `col_text_not_null` | `col_text_not_null_key` |
195
`col_text_key` | `col_text` | `col_char_10_not_null_key` | `col_char_10_not_null` |
196
`col_char_1024` | `col_char_1024_key` | `col_char_1024_not_null` | `col_char_1024_not_null_key` ;
198
char_field_name_disabled:
199
# need to explore enum more before enabling this
200
`col_enum` | `col_enum_key` | `col_enum_not_null` | `col_enum_not_null_key` ;
203
AA | BB | CC | DD | AA | BB | CC | DD | C | D | C | D | A | B ;
205
value: _digit | _date | _time | _datetime | _varchar(1) | NULL ;