11/*
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
108 * 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.
2520 */
2621
2722/* *
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
3025 */
3126
3227/* *
@@ -2142,12 +2137,8 @@ from_list
21422137
21432138table_ref
21442139 : (
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
21512142 | OPEN_PAREN table_ref (
21522143 KW_CROSS KW_JOIN table_ref
21532144 | KW_NATURAL join_type? KW_JOIN table_ref
@@ -2160,6 +2151,12 @@ table_ref
21602151 )*
21612152 ;
21622153
2154+ expressionTable
2155+ : xmltable alias_clause?
2156+ | func_table func_alias_clause?
2157+ | select_with_parens alias_clause?
2158+ ;
2159+
21632160alias_clause
21642161 : KW_AS ? alias=colid (OPEN_PAREN name_list CLOSE_PAREN )?
21652162 ;
@@ -2585,8 +2582,8 @@ column_expr
25852582 ;
25862583
25872584column_expr_noparen
2588- : expression
2589- | column_name
2585+ : expression # selectExpressionColumnName
2586+ | column_name # selectLiteralColumnName
25902587 ;
25912588
25922589func_arg_list
@@ -2650,8 +2647,12 @@ target_list
26502647 ;
26512648
26522649target_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
26552656 ;
26562657
26572658qualified_name_list
0 commit comments