diff --git a/sql/postgresql/PostgreSQLLexer.g4 b/sql/postgresql/PostgreSQLLexer.g4 index 8b7a21d3b7..9a133ba077 100644 --- a/sql/postgresql/PostgreSQLLexer.g4 +++ b/sql/postgresql/PostgreSQLLexer.g4 @@ -170,6 +170,51 @@ fragment OperatorCharacterAllowPlusMinusAtEnd: [~!@%^&|`?#]; // KEYWORDS (Appendix C) + + +JSON: 'JSON'; +JSON_ARRAY: 'JSON_ARRAY'; +JSON_ARRAYAGG: 'JSON_ARRAYAGG'; +JSON_EXISTS: 'JSON_EXISTS'; +JSON_OBJECT: 'JSON_OBJECT'; +JSON_OBJECTAGG: 'JSON_OBJECTAGG'; +JSON_QUERY: 'JSON_QUERY'; +JSON_SCALAR: 'JSON_SCALAR'; +JSON_SERIALIZE: 'JSON_SERIALIZE'; +JSON_TABLE: 'JSON_TABLE'; +JSON_VALUE: 'JSON_VALUE'; +MERGE_ACTION: 'MERGE_ACTION'; + +SYSTEM_USER: 'SYSTEM_USER'; + +ABSENT: 'ABSENT'; +ASENSITIVE: 'ASENSITIVE'; +ATOMIC: 'ATOMIC'; +BREADTH: 'BREATH'; +COMPRESSION: 'COMPRESSION'; +CONDITIONAL: 'CONDITIONAL'; +DEPTH: 'DEPTH'; +EMPTY_P: 'EMPTY'; +FINALIZE: 'FINALIZE'; +INDENT: 'INDENT'; +KEEP: 'KEEP'; +KEYS: 'KEYS'; +NESTED: 'NESTED'; +OMIT: 'OMIT'; +PARAMETER: 'PARAMETER'; +PATH: 'PATH'; +PLAN: 'PLAN'; +QUOTES: 'QUOTES'; +SCALAR: 'SCALAR'; +SOURCE: 'SOURCE'; +STRING_P: 'STRING'; +TARGET: 'TARGET'; +UNCONDITIONAL: 'UNCONDITIONAL'; + +PERIOD: 'PERIOD'; + +FORMAT_LA: 'FORMAT_LA'; + // // @@ -1121,18 +1166,12 @@ NORMALIZE: 'NORMALIZE'; DUMP: 'DUMP'; -PRINT_STRICT_PARAMS: 'PRINT_STRICT_PARAMS'; - -VARIABLE_CONFLICT: 'VARIABLE_CONFLICT'; - ERROR: 'ERROR'; USE_VARIABLE: 'USE_VARIABLE'; USE_COLUMN: 'USE_COLUMN'; -ALIAS: 'ALIAS'; - CONSTANT: 'CONSTANT'; PERFORM: 'PERFORM'; @@ -1157,8 +1196,6 @@ EXIT: 'EXIT'; RETURN: 'RETURN'; -QUERY: 'QUERY'; - RAISE: 'RAISE'; SQLSTATE: 'SQLSTATE'; diff --git a/sql/postgresql/PostgreSQLParser.g4 b/sql/postgresql/PostgreSQLParser.g4 index be7b26446f..2a429d97f5 100644 --- a/sql/postgresql/PostgreSQLParser.g4 +++ b/sql/postgresql/PostgreSQLParser.g4 @@ -29,20 +29,10 @@ options { superClass = PostgreSQLParserBase; } -@header { -} - -@members { -} - root : stmtblock EOF ; -plsqlroot - : pl_function - ; - stmtblock : stmtmulti ; @@ -285,7 +275,7 @@ set_rest ; generic_set - : var_name (TO | EQUAL) var_list + : var_name (TO | EQUAL) (var_list | DEFAULT) ; set_rest_more @@ -528,7 +518,7 @@ reloption_list ; reloption_elem - : collabel (EQUAL def_arg | DOT collabel (EQUAL def_arg)?)? + : colLabel (EQUAL def_arg | DOT colLabel (EQUAL def_arg)?)? ; alter_identity_column_option_list @@ -639,7 +629,7 @@ copy_generic_opt_list ; copy_generic_opt_elem - : collabel copy_generic_opt_arg? + : colLabel copy_generic_opt_arg? ; copy_generic_opt_arg @@ -1142,7 +1132,7 @@ generic_option_elem ; generic_option_name - : collabel + : colLabel ; generic_option_arg @@ -1354,7 +1344,7 @@ triggerfuncarg : iconst | fconst | sconst - | collabel + | colLabel ; optconstrfromtable @@ -1376,8 +1366,8 @@ constraintattributeElem ; createeventtrigstmt - : CREATE EVENT TRIGGER name ON collabel EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN - | CREATE EVENT TRIGGER name ON collabel WHEN event_trigger_when_list EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN + : CREATE EVENT TRIGGER name ON colLabel EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN + | CREATE EVENT TRIGGER name ON colLabel WHEN event_trigger_when_list EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN ; event_trigger_when_list @@ -1435,7 +1425,7 @@ def_list ; def_elem - : collabel (EQUAL def_arg)? + : colLabel (EQUAL def_arg)? ; def_arg @@ -2325,8 +2315,8 @@ operator_def_list ; operator_def_elem - : collabel EQUAL NONE - | collabel EQUAL operator_def_arg + : colLabel EQUAL NONE + | colLabel EQUAL operator_def_arg ; operator_def_arg @@ -2398,7 +2388,7 @@ publication_name_list ; publication_name_item - : collabel + : colLabel ; altersubscriptionstmt @@ -3004,8 +2994,7 @@ with_clause_ ; into_clause - : INTO (strict_? opttempTableName | into_target) - + : INTO opttempTableName ; strict_ @@ -3189,20 +3178,20 @@ from_list table_ref : ( - relation_expr alias_clause_? tablesample_clause? + relation_expr alias_clause? tablesample_clause? | func_table func_alias_clause? - | xmltable alias_clause_? - | select_with_parens alias_clause_? + | xmltable alias_clause? + | select_with_parens alias_clause? | LATERAL_P ( - xmltable alias_clause_? + xmltable alias_clause? | func_table func_alias_clause? - | select_with_parens alias_clause_? + | select_with_parens alias_clause? ) | OPEN_PAREN table_ref ( CROSS JOIN table_ref | NATURAL join_type? JOIN table_ref | join_type? JOIN table_ref join_qual - )? CLOSE_PAREN alias_clause_? + )? CLOSE_PAREN alias_clause? ) ( CROSS JOIN table_ref | NATURAL join_type? JOIN table_ref @@ -3214,15 +3203,6 @@ alias_clause : AS? colid (OPEN_PAREN name_list CLOSE_PAREN)? ; -alias_clause_ - : table_alias_clause - - ; - -table_alias_clause - : AS? table_alias (OPEN_PAREN name_list CLOSE_PAREN)? - ; - func_alias_clause : alias_clause | (AS colid? | colid) OPEN_PAREN tablefuncelementlist CLOSE_PAREN @@ -3339,7 +3319,7 @@ xml_namespace_list ; xml_namespace_el - : b_expr AS collabel + : b_expr AS colLabel | DEFAULT b_expr ; @@ -3359,6 +3339,7 @@ simpletypename | character | constdatetime | constinterval (interval_? | OPEN_PAREN iconst CLOSE_PAREN) + | jsonType ; consttypename @@ -3366,6 +3347,7 @@ consttypename | constbit | constcharacter | constdatetime + | jsonType ; generictype @@ -3469,6 +3451,10 @@ interval_second : SECOND_P (OPEN_PAREN iconst CLOSE_PAREN)? ; +jsonType + : JSON + ; + escape_ : ESCAPE a_expr @@ -3716,6 +3702,7 @@ c_expr | explicit_row # c_expr_expr | implicit_row # c_expr_expr | row OVERLAPS row /* 14*/ # c_expr_expr + | DEFAULT # c_expr_expr ; plsqlvariablename @@ -3752,15 +3739,16 @@ func_expr_common_subexpr | CURRENT_ROLE | CURRENT_USER | SESSION_USER + | SYSTEM_USER | USER | CURRENT_CATALOG | CURRENT_SCHEMA | CAST OPEN_PAREN a_expr AS typename CLOSE_PAREN | EXTRACT OPEN_PAREN extract_list? CLOSE_PAREN | NORMALIZE OPEN_PAREN a_expr (COMMA unicode_normal_form)? CLOSE_PAREN - | OVERLAY OPEN_PAREN overlay_list CLOSE_PAREN + | OVERLAY OPEN_PAREN (overlay_list | func_arg_list? ) CLOSE_PAREN | POSITION OPEN_PAREN position_list? CLOSE_PAREN - | SUBSTRING OPEN_PAREN substr_list CLOSE_PAREN + | SUBSTRING OPEN_PAREN (substr_list | func_arg_list?) CLOSE_PAREN | TREAT OPEN_PAREN a_expr AS typename CLOSE_PAREN | TRIM OPEN_PAREN (BOTH | LEADING | TRAILING)? trim_list CLOSE_PAREN | NULLIF OPEN_PAREN a_expr COMMA a_expr CLOSE_PAREN @@ -3768,14 +3756,52 @@ func_expr_common_subexpr | GREATEST OPEN_PAREN expr_list CLOSE_PAREN | LEAST OPEN_PAREN expr_list CLOSE_PAREN | XMLCONCAT OPEN_PAREN expr_list CLOSE_PAREN - | XMLELEMENT OPEN_PAREN NAME_P collabel (COMMA (xml_attributes | expr_list))? CLOSE_PAREN + | XMLELEMENT OPEN_PAREN NAME_P colLabel (COMMA (xml_attributes | expr_list))? CLOSE_PAREN | XMLEXISTS OPEN_PAREN c_expr xmlexists_argument CLOSE_PAREN | XMLFOREST OPEN_PAREN xml_attribute_list CLOSE_PAREN | XMLPARSE OPEN_PAREN document_or_content a_expr xml_whitespace_option? CLOSE_PAREN - | XMLPI OPEN_PAREN NAME_P collabel (COMMA a_expr)? CLOSE_PAREN + | XMLPI OPEN_PAREN NAME_P colLabel (COMMA a_expr)? CLOSE_PAREN | XMLROOT OPEN_PAREN XML_P a_expr COMMA xml_root_version xml_root_standalone_? CLOSE_PAREN | XMLSERIALIZE OPEN_PAREN document_or_content a_expr AS simpletypename CLOSE_PAREN - ; + | JSON_OBJECT OPEN_PAREN (func_arg_list + | json_name_and_value_list + json_object_constructor_null_clause? + json_key_uniqueness_constraint? + json_returning_clause? + | json_returning_clause? ) + CLOSE_PAREN + | JSON_ARRAY OPEN_PAREN (json_value_expr_list + json_array_constructor_null_clause? + json_returning_clause? + | select_no_parens + json_format_clause? + json_returning_clause? + | json_returning_clause? + ) + CLOSE_PAREN + | JSON '(' json_value_expr json_key_uniqueness_constraint? ')' + | JSON_SCALAR '(' a_expr ')' + | JSON_SERIALIZE '(' json_value_expr json_returning_clause? ')' + | MERGE_ACTION '(' ')' + | JSON_QUERY '(' + json_value_expr ',' a_expr json_passing_clause? + json_returning_clause? + json_wrapper_behavior + json_quotes_clause? + json_behavior_clause? + ')' + | JSON_EXISTS '(' + json_value_expr ',' a_expr json_passing_clause? + json_on_error_clause? + ')' + | JSON_VALUE '(' + json_value_expr ',' a_expr json_passing_clause? + json_returning_clause? + json_behavior_clause? + ')' + ; + +/* SQL/XML support */ xml_root_version : VERSION_P a_expr @@ -3786,7 +3812,6 @@ xml_root_standalone_ : COMMA STANDALONE_P YES_P | COMMA STANDALONE_P NO | COMMA STANDALONE_P NO VALUE_P - ; xml_attributes @@ -3798,7 +3823,7 @@ xml_attribute_list ; xml_attribute_el - : a_expr (AS collabel)? + : a_expr (AS colLabel)? ; document_or_content @@ -4077,6 +4102,163 @@ opt_indirection : indirection_el* ; +/* SQL/JSON support */ +json_passing_clause: + PASSING json_arguments + ; + +json_arguments: + json_argument + | json_arguments ',' json_argument + ; + +json_argument: + json_value_expr AS colLabel + ; + +/* ARRAY is a noise word */ +json_wrapper_behavior: + WITHOUT WRAPPER + | WITHOUT ARRAY WRAPPER + | WITH WRAPPER + | WITH ARRAY WRAPPER + | WITH CONDITIONAL ARRAY WRAPPER + | WITH UNCONDITIONAL ARRAY WRAPPER + | WITH CONDITIONAL WRAPPER + | WITH UNCONDITIONAL WRAPPER + | + ; + +json_behavior: + DEFAULT a_expr + | json_behavior_type + ; + +json_behavior_type: + ERROR + | NULL_P + | TRUE_P + | FALSE_P + | UNKNOWN + | EMPTY_P ARRAY + | EMPTY_P OBJECT_P + /* non-standard, for Oracle compatibility only */ + | EMPTY_P + ; + +json_behavior_clause: + json_behavior ON EMPTY_P + | json_behavior ON ERROR + | json_behavior ON EMPTY_P json_behavior ON ERROR + ; + +json_on_error_clause: + json_behavior ON ERROR + ; + +json_value_expr: + a_expr json_format_clause? + ; + +json_format_clause: + FORMAT_LA JSON ENCODING name + | FORMAT_LA JSON + ; + + +json_quotes_clause: + KEEP QUOTES ON SCALAR STRING_P + | KEEP QUOTES + | OMIT QUOTES ON SCALAR STRING_P + | OMIT QUOTES + ; + +json_returning_clause: + RETURNING typename json_format_clause? + ; + +/* + * We must assign the only-JSON production a precedence less than IDENT in + * order to favor shifting over reduction when JSON is followed by VALUE_P, + * OBJECT_P, or SCALAR. (ARRAY doesn't need that treatment, because it's a + * fully reserved word.) Because json_predicate_type_constraint is always + * followed by json_key_uniqueness_constraint_opt, we also need the only-JSON + * production to have precedence less than WITH and WITHOUT. UNBOUNDED isn't + * really related to this syntax, but it's a convenient choice because it + * already has a precedence less than IDENT for other reasons. + */ +json_predicate_type_constraint: + JSON + | JSON VALUE_P + | JSON ARRAY + | JSON OBJECT_P + | JSON SCALAR + ; + +/* + * KEYS is a noise word here. To avoid shift/reduce conflicts, assign the + * KEYS-less productions a precedence less than IDENT (i.e., less than KEYS). + * This prevents reducing them when the next token is KEYS. + */ +json_key_uniqueness_constraint: + WITH UNIQUE KEYS + | WITH UNIQUE + | WITHOUT UNIQUE KEYS + | WITHOUT UNIQUE + ; + +json_name_and_value_list: + json_name_and_value + | json_name_and_value_list ',' json_name_and_value + ; + +json_name_and_value: + c_expr VALUE_P json_value_expr + | + a_expr ':' json_value_expr + ; + +/* empty means false for objects, true for arrays */ +json_object_constructor_null_clause: + NULL_P ON NULL_P + | ABSENT ON NULL_P + ; + +json_array_constructor_null_clause: + NULL_P ON NULL_P + | ABSENT ON NULL_P + ; + +json_value_expr_list: + json_value_expr + | json_value_expr_list ',' json_value_expr + ; + +json_aggregate_func: + JSON_OBJECTAGG '(' + json_name_and_value + json_object_constructor_null_clause? + json_key_uniqueness_constraint? + json_returning_clause + ')' + | JSON_ARRAYAGG '(' + json_value_expr + json_array_aggregate_order_by_clause? + json_array_constructor_null_clause? + json_returning_clause + ')' + ; + +json_array_aggregate_order_by_clause: + ORDER BY sortby_list + ; + +/***************************************************************************** + * + * target list for SELECT + * + *****************************************************************************/ + target_list_ : target_list @@ -4087,7 +4269,7 @@ target_list ; target_el - : a_expr (AS collabel | identifier |) # target_label + : a_expr (AS colLabel | bareColLabel |) # target_label | STAR # target_star ; @@ -4108,7 +4290,7 @@ name ; attr_name - : collabel + : colLabel ; file_name @@ -4193,22 +4375,11 @@ colid : identifier | unreserved_keyword | col_name_keyword - | plsql_unreserved_keyword - | LEFT - | RIGHT - ; - -table_alias - : identifier - | unreserved_keyword - | col_name_keyword - | plsql_unreserved_keyword ; type_function_name : identifier | unreserved_keyword - | plsql_unreserved_keyword | type_func_name_keyword ; @@ -4219,13 +4390,18 @@ nonreservedword | type_func_name_keyword ; -collabel +colLabel : identifier - | plsql_unreserved_keyword | unreserved_keyword | col_name_keyword | type_func_name_keyword | reserved_keyword + | EXIT //NB: not in gram.y official source. + ; + +bareColLabel + : identifier + | bare_label_keyword ; identifier @@ -4234,7 +4410,6 @@ identifier | UnicodeQuotedIdentifier | plsqlvariablename | plsqlidentifier - | plsql_unreserved_keyword ; plsqlidentifier @@ -4243,6 +4418,7 @@ plsqlidentifier unreserved_keyword : ABORT_P + | ABSENT | ABSOLUTE_P | ACCESS | ACTION @@ -4253,14 +4429,17 @@ unreserved_keyword | ALSO | ALTER | ALWAYS + | ASENSITIVE | ASSERTION | ASSIGNMENT | AT + | ATOMIC | ATTACH | ATTRIBUTE | BACKWARD | BEFORE | BEGIN_P + | BREADTH | BY | CACHE | CALL @@ -4279,6 +4458,8 @@ unreserved_keyword | COMMENTS | COMMIT | COMMITTED + | COMPRESSION + | CONDITIONAL | CONFIGURATION | CONFLICT | CONNECTION @@ -4305,6 +4486,7 @@ unreserved_keyword | DELIMITER | DELIMITERS | DEPENDS + | DEPTH | DETACH | DICTIONARY | DISABLE_P @@ -4314,10 +4496,12 @@ unreserved_keyword | DOUBLE_P | DROP | EACH + | EMPTY_P | ENABLE_P | ENCODING | ENCRYPTED | ENUM_P + | ERROR | ESCAPE | EVENT | EXCLUDE @@ -4330,9 +4514,11 @@ unreserved_keyword | EXTERNAL | FAMILY | FILTER + | FINALIZE | FIRST_P | FOLLOWING | FORCE + | FORMAT | FORWARD | FUNCTION | FUNCTIONS @@ -4353,6 +4539,7 @@ unreserved_keyword | INCLUDE | INCLUDING | INCREMENT + | INDENT | INDEX | INDEXES | INHERIT @@ -4364,7 +4551,9 @@ unreserved_keyword | INSTEAD | INVOKER | ISOLATION + | KEEP | KEY + | KEYS | LABEL | LANGUAGE | LARGE_P @@ -4380,8 +4569,10 @@ unreserved_keyword | LOGGED | MAPPING | MATCH + | MATCHED | MATERIALIZED | MAXVALUE + | MERGE | METHOD | MINUTE_P | MINVALUE @@ -4390,6 +4581,7 @@ unreserved_keyword | MOVE | NAME_P | NAMES + | NESTED | NEW | NEXT | NFC @@ -4407,6 +4599,7 @@ unreserved_keyword | OFF | OIDS | OLD + | OMIT | OPERATOR | OPTION | OPTIONS @@ -4417,11 +4610,15 @@ unreserved_keyword | OWNED | OWNER | PARALLEL + | PARAMETER | PARSER | PARTIAL | PARTITION | PASSING | PASSWORD + | PATH + | PERIOD + | PLAN | PLANS | POLICY | PRECEDING @@ -4436,10 +4633,11 @@ unreserved_keyword | PROGRAM | PUBLICATION | QUOTE + | QUOTES | RANGE | READ | REASSIGN - | RECHECK +// | RECHECK | RECURSIVE | REF | REFERENCING @@ -4449,10 +4647,12 @@ unreserved_keyword | RELEASE | RENAME | REPEATABLE + | REPLACE | REPLICA | RESET | RESTART | RESTRICT + | RETURN | RETURNS | REVOKE | ROLE @@ -4463,6 +4663,7 @@ unreserved_keyword | ROWS | RULE | SAVEPOINT + | SCALAR | SCHEMA | SCHEMAS | SCROLL @@ -4481,6 +4682,7 @@ unreserved_keyword | SIMPLE | SKIP_P | SNAPSHOT + | SOURCE | SQL_P | STABLE | STANDALONE_P @@ -4492,6 +4694,7 @@ unreserved_keyword | STORAGE | STORED | STRICT_P + | STRING_P | STRIP_P | SUBSCRIPTION | SUPPORT @@ -4499,6 +4702,7 @@ unreserved_keyword | SYSTEM_P | TABLES | TABLESPACE + | TARGET | TEMP | TEMPLATE | TEMPORARY @@ -4514,6 +4718,7 @@ unreserved_keyword | UESCAPE | UNBOUNDED | UNCOMMITTED + | UNCONDITIONAL | UNENCRYPTED | UNKNOWN | UNLISTEN @@ -4561,7 +4766,19 @@ col_name_keyword | INT_P | INTEGER | INTERVAL + | JSON + | JSON_ARRAY + | JSON_ARRAYAGG + | JSON_EXISTS + | JSON_OBJECT + | JSON_OBJECTAGG + | JSON_QUERY + | JSON_SCALAR + | JSON_SERIALIZE + | JSON_TABLE + | JSON_VALUE | LEAST + | MERGE_ACTION | NATIONAL | NCHAR | NONE @@ -4611,11 +4828,13 @@ type_func_name_keyword | IS | ISNULL | JOIN + | LEFT | LIKE | NATURAL | NOTNULL | OUTER_P | OVERLAPS + | RIGHT | SIMILAR | TABLESAMPLE | VERBOSE @@ -4645,7 +4864,7 @@ reserved_keyword | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER - // | DEFAULT + | DEFAULT | DEFERRABLE | DESC | DISTINCT @@ -4664,13 +4883,7 @@ reserved_keyword | IN_P | INITIALLY | INTERSECT - /* -from pl_gram.y, line ~2982 - * Fortunately, INTO is a fully reserved word in the main grammar, so - * at least we need not worry about it appearing as an identifier. -*/ - - // | INTO + | INTO | LATERAL_P | LEADING | LIMIT @@ -4691,6 +4904,7 @@ from pl_gram.y, line ~2982 | SESSION_USER | SOME | SYMMETRIC + | SYSTEM_USER | TABLE | THEN | TO @@ -4707,867 +4921,593 @@ from pl_gram.y, line ~2982 | WITH ; -builtin_function_name - : XMLCOMMENT - | XML_IS_WELL_FORMED - | XML_IS_WELL_FORMED_DOCUMENT - | XML_IS_WELL_FORMED_CONTENT - | XMLAGG - | XPATH - | XPATH_EXISTS - | ABS - | CBRT - | CEIL - | CEILING - | DEGREES - | DIV - | EXP - | FACTORIAL - | FLOOR - | GCD - | LCM - | LN - | LOG - | LOG10 - | MIN_SCALE - | MOD - | PI - | POWER - | RADIANS - | ROUND - | SCALE - | SIGN - | SQRT - | TRIM_SCALE - | TRUNC - | WIDTH_BUCKET - | RANDOM - | SETSEED - | ACOS - | ACOSD - | ACOSH - | ASIN - | ASIND - | ASINH - | ATAN - | ATAND - | ATANH - | ATAN2 - | ATAN2D - | COS - | COSD - | COSH - | COT - | COTD - | SIN - | SIND - | SINH - | TAN - | TAND - | TANH - | BIT_LENGTH - | CHAR_LENGTH - | CHARACTER_LENGTH - | LOWER - | OCTET_LENGTH - | OCTET_LENGTH - | UPPER - | ASCII - | BTRIM - | CHR - | CONCAT - | CONCAT_WS +bare_label_keyword + : ABORT_P + | ABSENT + | ABSOLUTE_P + | ACCESS + | ACTION + | ADD_P + | ADMIN + | AFTER + | AGGREGATE + | ALL + | ALSO + | ALTER + | ALWAYS + | ANALYSE + | ANALYZE + | AND + | ANY + | ASC + | ASENSITIVE + | ASSERTION + | ASSIGNMENT + | ASYMMETRIC + | AT + | ATOMIC + | ATTACH + | ATTRIBUTE + | AUTHORIZATION + | BACKWARD + | BEFORE + | BEGIN_P + | BETWEEN + | BIGINT + | BINARY + | BIT + | BOOLEAN_P + | BOTH + | BREADTH + | BY + | CACHE + | CALL + | CALLED + | CASCADE + | CASCADED + | CASE + | CAST + | CATALOG + | CHAIN + | CHARACTERISTICS + | CHECK + | CHECKPOINT + | CLASS + | CLOSE + | CLUSTER + | COALESCE + | COLLATE + | COLLATION + | COLUMN + | COLUMNS + | COMMENT + | COMMENTS + | COMMIT + | COMMITTED + | COMPRESSION + | CONCURRENTLY + | CONDITIONAL + | CONFIGURATION + | CONFLICT + | CONNECTION + | CONSTRAINT + | CONSTRAINTS + | CONTENT_P + | CONTINUE_P + | CONVERSION_P + | COPY + | COST + | CROSS + | CSV + | CUBE + | CURRENT_CATALOG + | CURRENT_DATE + | CURRENT_P + | CURRENT_ROLE + | CURRENT_SCHEMA + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURRENT_USER + | CURSOR + | CYCLE + | DATA_P + | DATABASE + | DEALLOCATE + | DEC + | DECIMAL_P + | DECLARE + | DEFAULT + | DEFAULTS + | DEFERRABLE + | DEFERRED + | DEFINER + | DELETE_P + | DELIMITER + | DELIMITERS + | DEPENDS + | DEPTH + | DESC + | DETACH + | DICTIONARY + | DISABLE_P + | DISCARD + | DISTINCT + | DO + | DOCUMENT_P + | DOMAIN_P + | DOUBLE_P + | DROP + | EACH + | ELSE + | EMPTY_P + | ENABLE_P + | ENCODING + | ENCRYPTED + | END_P + | ENUM_P + | ERROR + | ESCAPE + | EVENT + | EXCLUDE + | EXCLUDING + | EXCLUSIVE + | EXECUTE + | EXISTS + | EXPLAIN + | EXPRESSION + | EXTENSION + | EXTERNAL + | EXTRACT + | FALSE_P + | FAMILY + | FINALIZE + | FIRST_P + | FLOAT_P + | FOLLOWING + | FORCE + | FOREIGN | FORMAT - | INITCAP - | LENGTH - | LPAD - | LTRIM - | MD5 - | PARSE_IDENT - | PG_CLIENT_ENCODING - | QUOTE_IDENT - | QUOTE_LITERAL - | QUOTE_NULLABLE - | REGEXP_COUNT - | REGEXP_INSTR - | REGEXP_LIKE - | REGEXP_MATCH - | REGEXP_MATCHES - | REGEXP_REPLACE - | REGEXP_SPLIT_TO_ARRAY - | REGEXP_SPLIT_TO_TABLE - | REGEXP_SUBSTR - | REPEAT - | REPLACE - | REVERSE - | RPAD - | RTRIM - | SPLIT_PART - | STARTS_WITH - | STRING_TO_ARRAY - | STRING_TO_TABLE - | STRPOS - | SUBSTR - | TO_ASCII - | TO_HEX - | TRANSLATE - | UNISTR - | AGE - | DATE_BIN - | DATE_PART - | DATE_TRUNC - | ISFINITE - | JUSTIFY_DAYS - | JUSTIFY_HOURS - | JUSTIFY_INTERVAL - | MAKE_DATE - | MAKE_INTERVAL - | MAKE_TIME - | MAKE_TIMESTAMP - | MAKE_TIMESTAMPTZ - | CLOCK_TIMESTAMP - | NOW - | STATEMENT_TIMESTAMP - | TIMEOFDAY - | TRANSACTION_TIMESTAMP - | TO_TIMESTAMP - | JUSTIFY_INTERVAL - | JUSTIFY_INTERVAL - | TO_CHAR - | TO_DATE - | TO_NUMBER - ; - -/************************************************************************************************************************************************************/ -/*PL/SQL GRAMMAR */ - -/*PLSQL grammar */ - -/************************************************************************************************************************************************************/ -pl_function - : comp_options pl_block semi_? - ; - -comp_options - : comp_option* - ; - -comp_option - : sharp OPTION DUMP - | sharp PRINT_STRICT_PARAMS option_value - | sharp VARIABLE_CONFLICT ERROR - | sharp VARIABLE_CONFLICT USE_VARIABLE - | sharp VARIABLE_CONFLICT USE_COLUMN - ; - -sharp - : Operator - ; - -option_value - : sconst - | reserved_keyword - | plsql_unreserved_keyword - | unreserved_keyword - ; - -semi_ - : - SEMI - ; - -// exception_sect means opt_exception_sect in original grammar, don't be confused! - -pl_block - : decl_sect BEGIN_P proc_sect exception_sect? END_P label_? - ; - -decl_sect - : block_label_? (decl_start decl_stmts?)? - ; - -decl_start - : DECLARE - ; - -decl_stmts - : decl_stmt+ - ; - -label_decl - : LESS_LESS any_identifier GREATER_GREATER - ; - -decl_stmt - : decl_statement - | DECLARE - | label_decl - ; - -decl_statement - : decl_varname ( - ALIAS FOR decl_aliasitem - | decl_const? decl_datatype decl_collate? decl_notnull? decl_defval? - | scrollable_? CURSOR decl_cursor_args? decl_is_for decl_cursor_query - ) SEMI - ; - -scrollable_ - : - NO SCROLL - | SCROLL - ; - -decl_cursor_query - : selectstmt - ; - -decl_cursor_args - : - OPEN_PAREN decl_cursor_arglist CLOSE_PAREN - ; - -decl_cursor_arglist - : decl_cursor_arg (COMMA decl_cursor_arg)* - ; - -decl_cursor_arg - : decl_varname decl_datatype - ; - -decl_is_for - : IS - | FOR - ; - -decl_aliasitem - : PARAM - | colid - ; - -decl_varname - : any_identifier - ; - -decl_const - : - CONSTANT - ; - -decl_datatype - : typename - ; //TODO: $$ = read_datatype(yychar); - -decl_collate - : - COLLATE any_name - ; - -decl_notnull - : - NOT NULL_P - ; - -decl_defval - : - decl_defkey sql_expression - ; - -decl_defkey - : assign_operator - | DEFAULT - ; - -assign_operator - : EQUAL - | COLON_EQUALS - ; - -proc_sect - : proc_stmt* - ; - -proc_stmt - : pl_block SEMI - | stmt_return - | stmt_raise - | stmt_assign - | stmt_if - | stmt_case - | stmt_loop - | stmt_while - | stmt_for - | stmt_foreach_a - | stmt_exit - | stmt_assert - | stmt_execsql - | stmt_dynexecute - | stmt_perform - | stmt_call - | stmt_getdiag - | stmt_open - | stmt_fetch - | stmt_move - | stmt_close - | stmt_null - | stmt_commit - | stmt_rollback - | stmt_set - ; - -stmt_perform - : PERFORM expr_until_semi SEMI - ; - -stmt_call - : CALL any_identifier OPEN_PAREN expr_list_? CLOSE_PAREN SEMI - | DO any_identifier OPEN_PAREN expr_list_? CLOSE_PAREN SEMI - ; - -expr_list_ - : - expr_list - ; - -stmt_assign - : assign_var assign_operator sql_expression SEMI - ; - -stmt_getdiag - : GET getdiag_area_opt? DIAGNOSTICS getdiag_list SEMI - ; - -getdiag_area_opt - : - CURRENT_P - | STACKED - ; - -getdiag_list - : getdiag_list_item (COMMA getdiag_list_item)* - ; - -getdiag_list_item - : getdiag_target assign_operator getdiag_item - ; - -getdiag_item - : colid - ; - -getdiag_target - : assign_var - ; - -assign_var - : (any_name | PARAM) (OPEN_BRACKET expr_until_rightbracket CLOSE_BRACKET)* - ; - -stmt_if - : IF_P expr_until_then THEN proc_sect stmt_elsifs stmt_else? END_P IF_P SEMI - ; - -stmt_elsifs - : (ELSIF a_expr THEN proc_sect)* - ; - -stmt_else - : - ELSE proc_sect - ; - -stmt_case - : CASE opt_expr_until_when? case_when_list case_else_? END_P CASE SEMI - ; - -opt_expr_until_when - : - sql_expression - ; - -case_when_list - : case_when+ - ; - -case_when - : WHEN expr_list THEN proc_sect - ; - -case_else_ - : - ELSE proc_sect - ; - -stmt_loop - : loop_label_? loop_body - ; - -stmt_while - : loop_label_? WHILE expr_until_loop loop_body - ; - -stmt_for - : loop_label_? FOR for_control loop_body - ; - -//TODO: rewrite using read_sql_expression logic? - -for_control - : for_variable IN_P ( - cursor_name cursor_parameters_? - | selectstmt - | explainstmt - | EXECUTE a_expr for_using_expression_? - | reverse_? a_expr DOT_DOT a_expr by_expression_? - ) - ; - -for_using_expression_ - : - USING expr_list - ; - -cursor_parameters_ - : - OPEN_PAREN a_expr (COMMA a_expr)* CLOSE_PAREN - ; - -reverse_ - : - REVERSE - ; - -by_expression_ - : - BY a_expr - ; - -for_variable - : any_name_list - ; - -stmt_foreach_a - : loop_label_? FOREACH for_variable foreach_slice? IN_P ARRAY a_expr loop_body - ; - -foreach_slice - : - SLICE iconst - ; - -stmt_exit - : exit_type label_? exitcond_? SEMI - ; - -exit_type - : EXIT - | CONTINUE_P - ; - -//todo implement RETURN statement according to initial grammar line 1754 - -stmt_return - : RETURN ( - NEXT sql_expression - | QUERY (EXECUTE a_expr for_using_expression_? | selectstmt) - | opt_return_result? - ) SEMI - ; - -opt_return_result - : - sql_expression - ; - -//https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html - -//RAISE [ level ] 'format' [, expression [, ... ]] [ USING option = expression [, ... ] ]; - -//RAISE [ level ] condition_name [ USING option = expression [, ... ] ]; - -//RAISE [ level ] SQLSTATE 'sqlstate' [ USING option = expression [, ... ] ]; - -//RAISE [ level ] USING option = expression [, ... ]; - -//RAISE ; - -stmt_raise - : RAISE stmt_raise_level_? sconst raise_list_? raise_using_? SEMI - | RAISE stmt_raise_level_? identifier raise_using_? SEMI - | RAISE stmt_raise_level_? SQLSTATE sconst raise_using_? SEMI - | RAISE stmt_raise_level_? raise_using_? SEMI - | RAISE - ; - -stmt_raise_level_ - : - - DEBUG - | LOG - | INFO - | NOTICE - | WARNING - | EXCEPTION - ; - -raise_list_ - : - (COMMA a_expr)+ - ; - -raise_using_ - : - USING raise_using_elem_list_ - ; - -raise_using_elem_ - : identifier EQUAL a_expr - ; - -raise_using_elem_list_ - : raise_using_elem_ (COMMA raise_using_elem_)* - ; - -//todo imnplement - -stmt_assert - : ASSERT sql_expression stmt_assert_message_? SEMI - ; - -stmt_assert_message_ - : - COMMA sql_expression - ; - -loop_body - : LOOP proc_sect END_P LOOP label_? SEMI - ; - -//TODO: looks like all other statements like INSERT/SELECT/UPDATE/DELETE are handled here; - -//pls take a look at original grammar - -stmt_execsql - : make_execsql_stmt SEMI - /*K_IMPORT - | K_INSERT - | t_word - | t_cword -*/ - ; - -//https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-NORESULT - -//EXECUTE command-string [ INTO [STRICT] target ] [ USING expression [, ... ] ]; - -stmt_dynexecute - : EXECUTE a_expr ( - /*this is silly, but i have to time to find nice way to code */ execute_into_? execute_using_? - | execute_using_? execute_into_? - | - ) SEMI - ; - -execute_using_ - : - USING execute_using_list_ - ; - -execute_using_list_ - : a_expr (COMMA a_expr)* - ; - -execute_into_ - : - INTO STRICT_P? into_target - ; - -//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING - -//OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR query; - -//OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR EXECUTE query_string - -// [ USING expression [, ... ] ]; - -//OPEN bound_cursorvar [ ( [ argument_name := ] argument_value [, ...] ) ]; - -stmt_open - : OPEN ( - cursor_variable scroll_option_? FOR (selectstmt | EXECUTE sql_expression open_using_?) - | colid (OPEN_PAREN open_bound_list_ CLOSE_PAREN)? - ) SEMI - ; - -open_bound_list_item_ - : colid COLON_EQUALS a_expr - | a_expr - ; - -open_bound_list_ - : open_bound_list_item_ (COMMA open_bound_list_item_)* - ; - -open_using_ - : - USING expr_list - ; - -scroll_option_ - : - scroll_option_no_? SCROLL - ; - -scroll_option_no_ - : - NO - ; - -//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING - -//FETCH [ direction { FROM | IN } ] cursor INTO target; - -stmt_fetch - : FETCH direction = fetch_direction_ cursor_from_? cursor_variable INTO into_target SEMI - ; - -into_target - : expr_list - ; - -cursor_from_ - : - FROM - | IN_P - ; - -fetch_direction_ - : - - NEXT - | PRIOR - | FIRST_P - | LAST_P - | ABSOLUTE_P a_expr - | RELATIVE_P a_expr - | a_expr - | ALL - | (FORWARD | BACKWARD) (a_expr | ALL)? - ; - -//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING - -//MOVE [ direction { FROM | IN } ] cursor; - -stmt_move - : MOVE fetch_direction_? cursor_variable SEMI - ; - -stmt_close - : CLOSE cursor_variable SEMI - ; - -stmt_null - : NULL_P SEMI - ; - -stmt_commit - : COMMIT plsql_opt_transaction_chain? SEMI - ; - -stmt_rollback - : ROLLBACK plsql_opt_transaction_chain? SEMI - ; - -plsql_opt_transaction_chain - : AND NO? CHAIN - - ; - -stmt_set - : SET any_name TO DEFAULT SEMI - | RESET (any_name | ALL) SEMI - ; - -cursor_variable - : colid - | PARAM - ; - -exception_sect - : - EXCEPTION proc_exceptions - ; - -proc_exceptions - : proc_exception+ - ; - -proc_exception - : WHEN proc_conditions THEN proc_sect - ; - -proc_conditions - : proc_condition (OR proc_condition)* - ; - -proc_condition - : any_identifier - | SQLSTATE sconst - ; - -//expr_until_semi: - -//; - -//expr_until_rightbracket: - -//; - -//expr_until_loop: - -//; - -block_label_ - : - label_decl - ; - -loop_label_ - : - label_decl - ; - -label_ - : - any_identifier - ; - -exitcond_ - : WHEN expr_until_semi - - ; - -any_identifier - : colid - | plsql_unreserved_keyword - ; - -plsql_unreserved_keyword - : ABSOLUTE_P - | ALIAS - | AND - | ARRAY - | ASSERT - | BACKWARD - | CALL - | CHAIN - | CLOSE - | COLLATE - | COLUMN - //| COLUMN_NAME - | COMMIT - | CONSTANT - | CONSTRAINT - //| CONSTRAINT_NAME - | CONTINUE_P - | CURRENT_P - | CURSOR - //| DATATYPE - | DEBUG - | DEFAULT - //| DETAIL - | DIAGNOSTICS - | DO - | DUMP - | ELSIF - //| ERRCODE - | ERROR - | EXCEPTION - | EXIT - | FETCH - | FIRST_P | FORWARD - | GET - //| HINT - - //| IMPORT - | INFO + | FREEZE + | FULL + | FUNCTION + | FUNCTIONS + | GENERATED + | GLOBAL + | GRANTED + | GREATEST + | GROUPING + | GROUPS + | HANDLER + | HEADER_P + | HOLD + | IDENTITY_P + | IF_P + | ILIKE + | IMMEDIATE + | IMMUTABLE + | IMPLICIT_P + | IMPORT_P + | IN_P + | INCLUDE + | INCLUDING + | INCREMENT + | INDENT + | INDEX + | INDEXES + | INHERIT + | INHERITS + | INITIALLY + | INLINE_P + | INNER_P + | INOUT + | INPUT_P + | INSENSITIVE | INSERT + | INSTEAD + | INT_P + | INTEGER + | INTERVAL + | INVOKER | IS + | ISOLATION + | JOIN + | JSON + | JSON_ARRAY + | JSON_ARRAYAGG + | JSON_EXISTS + | JSON_OBJECT + | JSON_OBJECTAGG + | JSON_QUERY + | JSON_SCALAR + | JSON_SERIALIZE + | JSON_TABLE + | JSON_VALUE + | KEEP + | KEY + | KEYS + | LABEL + | LANGUAGE + | LARGE_P | LAST_P - //| MESSAGE - - //| MESSAGE_TEXT + | LATERAL_P + | LEADING + | LEAKPROOF + | LEAST + | LEFT + | LEVEL + | LIKE + | LISTEN + | LOAD + | LOCAL + | LOCALTIME + | LOCALTIMESTAMP + | LOCATION + | LOCK_P + | LOCKED + | LOGGED + | MAPPING + | MATCH + | MATCHED + | MATERIALIZED + | MAXVALUE + | MERGE + | MERGE_ACTION + | METHOD + | MINVALUE + | MODE | MOVE + | NAME_P + | NAMES + | NATIONAL + | NATURAL + | NCHAR + | NESTED + | NEW | NEXT + | NFC + | NFD + | NFKC + | NFKD | NO - | NOTICE - | OPEN + | NONE + | NORMALIZE + | NORMALIZED + | NOT + | NOTHING + | NOTIFY + | NOWAIT + | NULL_P + | NULLIF + | NULLS_P + | NUMERIC + | OBJECT_P + | OF + | OFF + | OIDS + | OLD + | OMIT + | ONLY + | OPERATOR | OPTION - | PERFORM - //| PG_CONTEXT - - //| PG_DATATYPE_NAME - - //| PG_EXCEPTION_CONTEXT - - //| PG_EXCEPTION_DETAIL - - //| PG_EXCEPTION_HINT - | PRINT_STRICT_PARAMS + | OPTIONS + | OR + | ORDINALITY + | OTHERS + | OUT_P + | OUTER_P + | OVERLAY + | OVERRIDING + | OWNED + | OWNER + | PARALLEL + | PARAMETER + | PARSER + | PARTIAL + | PARTITION + | PASSING + | PASSWORD + | PATH + | PERIOD + | PLACING + | PLAN + | PLANS + | POLICY + | POSITION + | PRECEDING + | PREPARE + | PREPARED + | PRESERVE + | PRIMARY | PRIOR - | QUERY - | RAISE + | PRIVILEGES + | PROCEDURAL + | PROCEDURE + | PROCEDURES + | PROGRAM + | PUBLICATION + | QUOTE + | QUOTES + | RANGE + | READ + | REAL + | REASSIGN + | RECURSIVE + | REF + | REFERENCES + | REFERENCING + | REFRESH + | REINDEX | RELATIVE_P + | RELEASE + | RENAME + | REPEATABLE + | REPLACE + | REPLICA | RESET + | RESTART + | RESTRICT | RETURN - //| RETURNED_SQLSTATE + | RETURNS + | REVOKE + | RIGHT + | ROLE | ROLLBACK - //| ROW_COUNT - | ROWTYPE + | ROLLUP + | ROUTINE + | ROUTINES + | ROW + | ROWS + | RULE + | SAVEPOINT + | SCALAR | SCHEMA - //| SCHEMA_NAME + | SCHEMAS | SCROLL + | SEARCH + | SECURITY + | SELECT + | SEQUENCE + | SEQUENCES + | SERIALIZABLE + | SERVER + | SESSION + | SESSION_USER | SET - | SLICE - | SQLSTATE - | STACKED + | SETOF + | SETS + | SHARE + | SHOW + | SIMILAR + | SIMPLE + | SKIP_P + | SMALLINT + | SNAPSHOT + | SOME + | SOURCE + | SQL_P + | STABLE + | STANDALONE_P + | START + | STATEMENT + | STATISTICS + | STDIN + | STDOUT + | STORAGE + | STORED + | STRICT_P + | STRING_P + | STRIP_P + | SUBSCRIPTION + | SUBSTRING + | SUPPORT + | SYMMETRIC + | SYSID + | SYSTEM_P + | SYSTEM_USER | TABLE - //| TABLE_NAME + | TABLES + | TABLESAMPLE + | TABLESPACE + | TARGET + | TEMP + | TEMPLATE + | TEMPORARY + | TEXT_P + | THEN + | TIES + | TIME + | TIMESTAMP + | TRAILING + | TRANSACTION + | TRANSFORM + | TREAT + | TRIGGER + | TRIM + | TRUE_P + | TRUNCATE + | TRUSTED | TYPE_P - | USE_COLUMN - | USE_VARIABLE - | VARIABLE_CONFLICT - | WARNING - | OUTER_P - ; - -sql_expression - : target_list_? into_clause? from_clause? where_clause? group_clause? having_clause? window_clause? - ; - -expr_until_then - : sql_expression - ; - -expr_until_semi - : sql_expression + | TYPES_P + | UESCAPE + | UNBOUNDED + | UNCOMMITTED + | UNCONDITIONAL + | UNENCRYPTED + | UNIQUE + | UNKNOWN + | UNLISTEN + | UNLOGGED + | UNTIL + | UPDATE + | USER + | USING + | VACUUM + | VALID + | VALIDATE + | VALIDATOR + | VALUE_P + | VALUES + | VARCHAR + | VARIADIC + | VERBOSE + | VERSION_P + | VIEW + | VIEWS + | VOLATILE + | WHEN + | WHITESPACE_P + | WORK + | WRAPPER + | WRITE + | XML_P + | XMLATTRIBUTES + | XMLCONCAT + | XMLELEMENT + | XMLEXISTS + | XMLFOREST + | XMLNAMESPACES + | XMLPARSE + | XMLPI + | XMLROOT + | XMLSERIALIZE + | XMLTABLE + | YES_P + | ZONE ; -expr_until_rightbracket - : a_expr +builtin_function_name + : XMLCOMMENT + | XML_IS_WELL_FORMED + | XML_IS_WELL_FORMED_DOCUMENT + | XML_IS_WELL_FORMED_CONTENT + | XMLAGG + | XPATH + | XPATH_EXISTS + | ABS + | CBRT + | CEIL + | CEILING + | DEGREES + | DIV + | EXP + | FACTORIAL + | FLOOR + | GCD + | LCM + | LN + | LOG + | LOG10 + | MIN_SCALE + | MOD + | PI + | POWER + | RADIANS + | ROUND + | SCALE + | SIGN + | SQRT + | TRIM_SCALE + | TRUNC + | WIDTH_BUCKET + | RANDOM + | SETSEED + | ACOS + | ACOSD + | ACOSH + | ASIN + | ASIND + | ASINH + | ATAN + | ATAND + | ATANH + | ATAN2 + | ATAN2D + | COS + | COSD + | COSH + | COT + | COTD + | SIN + | SIND + | SINH + | TAN + | TAND + | TANH + | BIT_LENGTH + | CHAR_LENGTH + | CHARACTER_LENGTH + | LOWER + | OCTET_LENGTH + | OCTET_LENGTH + | UPPER + | ASCII + | BTRIM + | CHR + | CONCAT + | CONCAT_WS + | FORMAT + | INITCAP + | LENGTH + | LPAD + | LTRIM + | MD5 + | PARSE_IDENT + | PG_CLIENT_ENCODING + | QUOTE_IDENT + | QUOTE_LITERAL + | QUOTE_NULLABLE + | REGEXP_COUNT + | REGEXP_INSTR + | REGEXP_LIKE + | REGEXP_MATCH + | REGEXP_MATCHES + | REGEXP_REPLACE + | REGEXP_SPLIT_TO_ARRAY + | REGEXP_SPLIT_TO_TABLE + | REGEXP_SUBSTR + | REPEAT + | REPLACE + | REVERSE + | RPAD + | RTRIM + | SPLIT_PART + | STARTS_WITH + | STRING_TO_ARRAY + | STRING_TO_TABLE + | STRPOS + | SUBSTR + | TO_ASCII + | TO_HEX + | TRANSLATE + | UNISTR + | AGE + | DATE_BIN + | DATE_PART + | DATE_TRUNC + | ISFINITE + | JUSTIFY_DAYS + | JUSTIFY_HOURS + | JUSTIFY_INTERVAL + | MAKE_DATE + | MAKE_INTERVAL + | MAKE_TIME + | MAKE_TIMESTAMP + | MAKE_TIMESTAMPTZ + | CLOCK_TIMESTAMP + | NOW + | STATEMENT_TIMESTAMP + | TIMEOFDAY + | TRANSACTION_TIMESTAMP + | TO_TIMESTAMP + | JUSTIFY_INTERVAL + | JUSTIFY_INTERVAL + | TO_CHAR + | TO_DATE + | TO_NUMBER ; -expr_until_loop - : a_expr - ; -make_execsql_stmt - : stmt returning_clause_into_? +any_identifier + : colid ; - -returning_clause_into_ - : INTO strict_? into_target - - ; \ No newline at end of file diff --git a/sql/postgresql/README.md b/sql/postgresql/README.md index 5f60d33ed5..fff50bc5e2 100644 --- a/sql/postgresql/README.md +++ b/sql/postgresql/README.md @@ -1,7 +1,7 @@ # PostgreSQL grammar PostgreSQL sql/pgsql grammar based on the -[Bison grammar at the Github mirror](https://github.com/postgres/postgres/blob/9be4e5d293b554d8a0800790c57fc707a3b5cf0f/src/backend/parser/gram.y). +Bison grammar at the Github mirror: [src/backend/parser/gram.y](https://github.com/postgres/postgres/blob/9be4e5d293b554d8a0800790c57fc707a3b5cf0f/src/backend/parser/gram.y). Lexer was derived from https://github.com/tunnelvisionlabs/antlr4-grammar-postgresql/blob/master/src/com/tunnelvisionlabs/postgresql/PostgreSqlLexer.g4. diff --git a/sql/postgresql/desc.xml b/sql/postgresql/desc.xml index 64f0ec5f50..07d4cf392e 100644 --- a/sql/postgresql/desc.xml +++ b/sql/postgresql/desc.xml @@ -2,4 +2,5 @@ ^4.10 CSharp;Java + examples/**/*.sql