diff --git a/sql/plsql/PlSqlParser.g4 b/sql/plsql/PlSqlParser.g4 index ec54c30347..66f3cf1e2d 100644 --- a/sql/plsql/PlSqlParser.g4 +++ b/sql/plsql/PlSqlParser.g4 @@ -6925,11 +6925,7 @@ table_alias ; where_clause - : WHERE (CURRENT OF cursor_name | condition | quantitative_where_stmt) - ; - -quantitative_where_stmt - : expression relational_operator (SOME | ALL | ANY) '(' expression (',' expression)* ')' + : WHERE (CURRENT OF cursor_name | condition) ; into_clause @@ -7398,7 +7394,7 @@ constant | MINUTE | SECOND ) ('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable))? ')')? ( - TO (DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?) + TO (MONTH | DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?) )? | numeric | DATE quoted_string diff --git a/sql/plsql/desc.xml b/sql/plsql/desc.xml index 1e35e2a1fc..8540e66292 100644 --- a/sql/plsql/desc.xml +++ b/sql/plsql/desc.xml @@ -1,7 +1,7 @@ ^4.12.0 - Antlr4ng;Cpp;CSharp;Java;JavaScript;Python3;TypeScript + Antlr4ng;Cpp;CSharp;Dart;Go;Java;JavaScript;Python3;TypeScript Antlr4ng;Cpp;CSharp;Dart;Go;Java examples/**/*.sql diff --git a/sql/plsql/examples/4357-not-ambig.sql b/sql/plsql/examples/4357-not-ambig.sql new file mode 100644 index 0000000000..540e733dce --- /dev/null +++ b/sql/plsql/examples/4357-not-ambig.sql @@ -0,0 +1 @@ +select interval '0 02:30:00' day to second; \ No newline at end of file diff --git a/sql/plsql/examples/4357.sql b/sql/plsql/examples/4357.sql new file mode 100644 index 0000000000..5b83cbc3bc --- /dev/null +++ b/sql/plsql/examples/4357.sql @@ -0,0 +1,6 @@ +CREATE TABLE CUSTOMERS_TEST ( + id NUMBER PRIMARY KEY, + CUSTOMER_MEMBERSHIP_DURATION INTERVAL YEAR TO MONTH, + CUSTOMER_CALL_DURATION INTERVAL DAY TO SECOND(2) +); +INSERT INTO CUSTOMERS_TEST (ID,CUSTOMER_MEMBERSHIP_DURATION,CUSTOMER_CALL_DURATION) VALUES (1, INTERVAL '1-6' YEAR TO MONTH, INTERVAL '0 02:30:00' DAY TO SECOND(2)); diff --git a/sql/postgresql/PostgreSQLLexer.g4 b/sql/postgresql/PostgreSQLLexer.g4 index 7538b65d04..f23b70ff14 100644 --- a/sql/postgresql/PostgreSQLLexer.g4 +++ b/sql/postgresql/PostgreSQLLexer.g4 @@ -1317,6 +1317,12 @@ InvalidUnterminatedHexadecimalStringConstant: 'X' UnterminatedStringConstant; Integral: Digits; +BinaryIntegral: '0b' Digits; + +OctalIntegral: '0o' Digits; + +HexadecimalIntegral: '0x' Digits; + NumericFail: Digits '..' {this.HandleNumericFail();}; Numeric: diff --git a/sql/postgresql/PostgreSQLParser.g4 b/sql/postgresql/PostgreSQLParser.g4 index e0e1263baa..f13fc4ddef 100644 --- a/sql/postgresql/PostgreSQLParser.g4 +++ b/sql/postgresql/PostgreSQLParser.g4 @@ -4345,6 +4345,9 @@ fconst iconst : Integral + | BinaryIntegral + | OctalIntegral + | HexadecimalIntegral ; sconst diff --git a/sql/postgresql/examples/numbers.sql b/sql/postgresql/examples/numbers.sql new file mode 100644 index 0000000000..6d24589621 --- /dev/null +++ b/sql/postgresql/examples/numbers.sql @@ -0,0 +1,6 @@ +-- +-- Tests for numeric literal +-- +SELECT 0b10, 0B10, 0x10, 0X10, 0o10, 0O10, 010, 0 x10, 0 b10, 0 o10; +SELECT abs(0b10), abs(0B10), abs(0x10), abs(0X10), abs(0o10), abs(0O10), + ('{1}'::int[])[0b01], 1::char(0o01), (array[1])[0x01]; diff --git a/sql/postgresql/examples/numbers.sql.tree b/sql/postgresql/examples/numbers.sql.tree new file mode 100644 index 0000000000..e210f205e1 --- /dev/null +++ b/sql/postgresql/examples/numbers.sql.tree @@ -0,0 +1 @@ +(root (stmtblock (stmtmulti (stmt (selectstmt (select_no_parens (select_clause (simple_select_intersect (simple_select_pramary SELECT (target_list_ (target_list (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0b10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0B10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0x10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0X10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0o10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0O10))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 010))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0)))))))))))))))))))))))) (bareColLabel (identifier x10))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0)))))))))))))))))))))))) (bareColLabel (identifier b10))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0)))))))))))))))))))))))) (bareColLabel (identifier o10))))))))))) ; (stmt (selectstmt (select_no_parens (select_clause (simple_select_intersect (simple_select_pramary SELECT (target_list_ (target_list (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0b10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0B10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0x10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0X10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0o10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (func_expr (func_application (func_name (type_function_name (identifier abs))) ( (func_arg_list (func_arg_expr (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0O10)))))))))))))))))))))))))) )))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr ( (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (sconst (anysconst '{1}')))) :: (typename (simpletypename (numeric int)) (opt_array_bounds [ ]))))))))))))))))))))))) ) (opt_indirection (indirection_el [ (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0b01)))))))))))))))))))))))) ]))))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 1))) :: (typename (simpletypename (character (character_c char) ( (iconst 0o01) ))) opt_array_bounds))))))))))))))))))))))) , (target_el (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr ( (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr array (array_expr [ (expr_list (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 1))))))))))))))))))))))))) ]))))))))))))))))))))))) ) (opt_indirection (indirection_el [ (a_expr (a_expr_qual (a_expr_lessless (a_expr_or (a_expr_and (a_expr_between (a_expr_in (a_expr_unary_not (a_expr_isnull (a_expr_is_not (a_expr_compare (a_expr_like (a_expr_qual_op (a_expr_unary_qualop (a_expr_add (a_expr_mul (a_expr_caret (a_expr_unary_sign (a_expr_at_time_zone (a_expr_collate (a_expr_typecast (c_expr (aexprconst (iconst 0x01)))))))))))))))))))))))) ]))))))))))))))))))))))))))))))))) ;)) ) \ No newline at end of file