1
1
/*
2
- * [The "MIT license"]
3
- * Copyright (C) 2014 Sam Harwell, Tunnel Vision Laboratories, LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
2
+ * [The "MIT license"] Copyright (C) 2014 Sam Harwell, Tunnel Vision Laboratories, LLC
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5
+ * associated documentation files (the "Software"), to deal in the Software without restriction,
6
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
10
8
* furnished to do so, subject to the following conditions:
11
- *
12
- * 1. The above copyright notice and this permission notice shall be included in
13
- * all copies or substantial portions of the Software.
14
- * 2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
- * DEALINGS IN THE SOFTWARE.
21
- * 3. Except as contained in this notice, the name of Tunnel Vision
22
- * Laboratories, LLC. shall not be used in advertising or otherwise to
23
- * promote the sale, use or other dealings in this Software without prior
24
- * written authorization from Tunnel Vision Laboratories, LLC.
9
+ *
10
+ * 1. The above copyright notice and this permission notice shall be included in all copies or
11
+ * substantial portions of the Software. 2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
12
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16
+ * DEALINGS IN THE SOFTWARE. 3. Except as contained in this notice, the name of Tunnel Vision
17
+ * Laboratories, LLC. shall not be used in advertising or otherwise to promote the sale, use or
18
+ * other dealings in this Software without prior written authorization from Tunnel Vision
19
+ * Laboratories, LLC.
25
20
*/
26
21
27
22
/* *
28
- * This file is an adaptation of antlr's sql/postgresql/PostgreSQLParser.g4 grammar.
29
- * Reference: https://github.com/antlr/grammars-v4/blob/master/sql/postgresql/PostgreSQLParser.g4
23
+ * This file is an adaptation of antlr's sql/postgresql/PostgreSQLParser.g4 grammar. Reference:
24
+ * https://github.com/antlr/grammars-v4/blob/master/sql/postgresql/PostgreSQLParser.g4
30
25
*/
31
26
32
27
/* *
@@ -2142,12 +2137,8 @@ from_list
2142
2137
2143
2138
table_ref
2144
2139
: (
2145
- (relation_expr | (KW_ONLY ? view_name STAR ? column_list? where_clause?)) alias_clause? tablesample_clause?
2146
- | KW_LATERAL ? (
2147
- xmltable alias_clause?
2148
- | func_table func_alias_clause?
2149
- | select_with_parens alias_clause?
2150
- )
2140
+ (relation_expr | ( KW_ONLY ? view_name STAR ? column_list? where_clause?)) alias_clause? tablesample_clause?
2141
+ | KW_LATERAL ? expressionTable
2151
2142
| OPEN_PAREN table_ref (
2152
2143
KW_CROSS KW_JOIN table_ref
2153
2144
| KW_NATURAL join_type? KW_JOIN table_ref
@@ -2160,6 +2151,12 @@ table_ref
2160
2151
)*
2161
2152
;
2162
2153
2154
+ expressionTable
2155
+ : xmltable alias_clause?
2156
+ | func_table func_alias_clause?
2157
+ | select_with_parens alias_clause?
2158
+ ;
2159
+
2163
2160
alias_clause
2164
2161
: KW_AS ? alias=colid (OPEN_PAREN name_list CLOSE_PAREN )?
2165
2162
;
@@ -2585,8 +2582,8 @@ column_expr
2585
2582
;
2586
2583
2587
2584
column_expr_noparen
2588
- : expression
2589
- | column_name
2585
+ : expression # selectExpressionColumnName
2586
+ | column_name # selectLiteralColumnName
2590
2587
;
2591
2588
2592
2589
func_arg_list
@@ -2650,8 +2647,12 @@ target_list
2650
2647
;
2651
2648
2652
2649
target_el
2653
- : column_expr_noparen (KW_AS collabel | identifier |) # target_label
2654
- | STAR # target_star
2650
+ : tableAllColumns # target_star
2651
+ | column_expr_noparen (KW_AS ? alias=identifier |) # target_label
2652
+ ;
2653
+
2654
+ tableAllColumns
2655
+ : (colid DOT )* STAR
2655
2656
;
2656
2657
2657
2658
qualified_name_list
0 commit comments