From: Michael Meskes Date: Sun, 1 Sep 2002 09:31:58 +0000 (+0000) Subject: Synced parser. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3223374e671183e25021c35502638ad791e5a348;p=thirdparty%2Fpostgresql.git Synced parser. --- diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 09291b0c4b0..80a76c6a4c9 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -1286,7 +1286,12 @@ Sun Aug 18 16:09:06 CEST 2002 Tue Aug 20 14:13:34 CEST 2002 - - Removed ',' from preproc.y to bit bison 1.49b. + - Removed ',' from preproc.y for bison 1.49b. + +Sun Sep 1 11:13:04 CEST 2002 + + - Synced preproc.y with gram.y. + - Synced keywords.c. - Set ecpg version to 2.10.0. - Set library version to 3.4.0. diff --git a/src/interfaces/ecpg/preproc/keywords.c b/src/interfaces/ecpg/preproc/keywords.c index bbb27b16f5a..7313eae775c 100644 --- a/src/interfaces/ecpg/preproc/keywords.c +++ b/src/interfaces/ecpg/preproc/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.50.2.3 2002/08/18 14:32:21 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.50.2.4 2002/09/01 09:31:58 meskes Exp $ * *------------------------------------------------------------------------- */ @@ -94,6 +94,7 @@ static ScanKeyword ScanKeywords[] = { {"cycle", CYCLE}, {"database", DATABASE}, {"day", DAY_P}, + {"deallocate", DEALLOCATE}, {"dec", DEC}, {"decimal", DECIMAL}, {"declare", DECLARE}, @@ -223,6 +224,7 @@ static ScanKeyword ScanKeywords[] = { {"pendant", PENDANT}, {"position", POSITION}, {"precision", PRECISION}, + {"prepare", PREPARE}, {"primary", PRIMARY}, {"prior", PRIOR}, {"privileges", PRIVILEGES}, diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index d1404ae719f..576ddf1399a 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.190.2.4 2002/08/20 12:23:36 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.190.2.5 2002/09/01 09:31:58 meskes Exp $ */ /* Copyright comment */ %{ @@ -191,8 +191,9 @@ make_name(void) CREATE CREATEDB CREATEUSER CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE - DATABASE DAY_P DEC DECIMAL DECLARE DEFAULT DEFERRABLE DEFERRED - DEFINER DELETE_P DELIMITER DELIMITERS DESC DISTINCT DO DOMAIN_P DOUBLE DROP + DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT + DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS + DESC DISTINCT DO DOMAIN_P DOUBLE DROP EACH ELSE ENCODING ENCRYPTED END_TRANS ESCAPE EXCEPT EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT @@ -221,8 +222,8 @@ make_name(void) OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OR ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNER - PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION PRECISION PRIMARY - PRIOR PRIVILEGES PROCEDURE PROCEDURAL + PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION PRECISION PREPARE + PRIMARY PRIOR PRIVILEGES PROCEDURE PROCEDURAL READ REAL RECHECK REFERENCES REINDEX RELATIVE RENAME REPLACE RESET RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW RULE @@ -287,9 +288,9 @@ make_name(void) %type CreateAsElement OptCreateAs CreateAsList CreateAsStmt %type comment_text ConstraintDeferrabilitySpec TableElementList %type key_match ColLabel SpecialRuleRelation ColId columnDef -%type ColConstraint ColConstraintElem drop_type Bconst -%type TableConstraint OptTableElementList Xconst -%type ConstraintElem key_actions ColQualList type_name +%type ColConstraint ColConstraintElem drop_type Bconst +%type TableConstraint OptTableElementList Xconst prep_type_clause +%type ConstraintElem key_actions ColQualList type_name PrepareStmt %type target_list target_el update_target_list alias_clause %type update_target_el opt_id qualified_name database_name %type access_method attr_name index_name name func_name @@ -300,7 +301,7 @@ make_name(void) %type trim_list in_expr substr_for attrs TableFuncElement %type Typename SimpleTypename Numeric opt_float opt_numeric %type opt_decimal Character character opt_varying opt_charset -%type opt_collate opt_timezone opt_interval table_ref +%type opt_collate opt_timezone opt_interval table_ref DeallocateStmt %type row_descriptor row_list ConstDatetime trans_options %type SelectStmt into_clause OptTemp ConstraintAttributeSpec %type opt_table opt_all sort_clause sortby_list ConstraintAttr @@ -321,7 +322,7 @@ make_name(void) %type def_elem def_list definition DefineStmt select_with_parens %type opt_instead event RuleActionList opt_using CreateAssertStmt %type RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type -%type RuleStmt opt_column opt_name oper_argtypes NumConst +%type RuleStmt opt_column opt_name oper_argtypes NumConst ExecuteStmt %type MathOp RemoveFuncStmt aggr_argtype for_update_clause %type RemoveAggrStmt opt_procedural select_no_parens CreateCastStmt %type RemoveOperStmt RenameStmt all_Op opt_Trusted opt_lancompiler @@ -363,10 +364,11 @@ make_name(void) %type opt_oids TableLikeClause key_action opt_definition %type opt_assignment row r_expr qual_Op qual_all_Op opt_default %type CreateConversionStmt any_operator opclass_item_list -%type iso_level OptTableFuncElementList convert_list +%type iso_level convert_list prep_type_list %type convert_args type_list CharacterWithLength ConstCharacter %type CharacterWithoutLength BitWithLength BitWithoutLength -%type ConstBit GenericType TableFuncElementList +%type ConstBit GenericType TableFuncElementList execute_param_clause +%type execute_param_list opt_sort_clause %type ECPGWhenever ECPGConnect connection_target ECPGOpen %type indicator ECPGExecute ECPGPrepare ecpg_using ecpg_into @@ -454,6 +456,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } | CreateTrigStmt { output_statement($1, 0, connection); } | CreateUserStmt { output_statement($1, 0, connection); } | ClusterStmt { output_statement($1, 0, connection); } + | DeallocateStmt { output_statement($1, 0, connection); } | DefineStmt { output_statement($1, 0, connection); } | DropStmt { output_statement($1, 0, connection); } | TruncateStmt { output_statement($1, 0, connection); } @@ -466,6 +469,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } | DropRuleStmt { output_statement($1, 0, connection); } | DropUserStmt { output_statement($1, 0, connection); } | ExplainStmt { output_statement($1, 0, connection); } + | ExecuteStmt { output_statement($1, 0, connection); } | FetchStmt { output_statement($1, 1, connection); } | GrantStmt { output_statement($1, 0, connection); } | IndexStmt { output_statement($1, 0, connection); } @@ -473,6 +477,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } | UnlistenStmt { output_statement($1, 0, connection); } | LockStmt { output_statement($1, 0, connection); } | NotifyStmt { output_statement($1, 0, connection); } + | PrepareStmt { output_statement($1, 0, connection); } | ReindexStmt { output_statement($1, 0, connection); } | RemoveAggrStmt { output_statement($1, 0, connection); } | RemoveOperStmt { output_statement($1, 0, connection); } @@ -1122,10 +1127,10 @@ OptTableElementList: TableElementList | /*EMPTY*/ { $$ = EMPTY; } ; -TableElementList: TableElementList ',' TableElement - { $$ = cat_str(3, $1, make_str(","), $3); } - | TableElement +TableElementList: TableElement { $$ = $1; } + | TableElementList ',' TableElement + { $$ = cat_str(3, $1, make_str(","), $3); } ; TableElement: columnDef { $$ = $1; } @@ -2358,6 +2363,54 @@ ExplainStmt: EXPLAIN opt_verbose OptimizableStmt { $$ = cat_str(4, make_str("explain"), $2, $3, $4); } ; +/***************************************************************************** + * + * QUERY: + * PREPARE [(args, ...)] AS + * + *****************************************************************************/ + +PrepareStmt: PREPARE name prep_type_clause AS OptimizableStmt + { $$ = cat_str(5, make_str("prepare"), $2, $3, make_str("as"), $5); } + ; + +prep_type_clause: '(' prep_type_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); } + | /* EMPTY */ { $$ = EMPTY; } + ; + +prep_type_list: Typename { $$ = $1; } + | prep_type_list ',' Typename { $$ = cat_str(3, $1, make_str(","), $3); } + ; + +/***************************************************************************** + * + * QUERY: + * EXECUTE [(params, ...)] [INTO ...] + * + *****************************************************************************/ + +ExecuteStmt: EXECUTE name execute_param_clause into_clause + { $$ = cat_str(4, make_str("execute"), $2, $3, $4); } + ; + +execute_param_clause: '(' execute_param_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); } + | /* EMPTY */ { $$ = EMPTY; } + ; + +execute_param_list: a_expr { $$ = $1; } + | execute_param_list ',' a_expr { $$ = cat_str(3, $1, make_str(","), $3); } + ; + +/***************************************************************************** + * + * QUERY: + * DEALLOCATE [PREPARE] + * + *****************************************************************************/ + +DeallocateStmt: DEALLOCATE name { $$ = cat2_str(make_str("deallocate"), $2); } + | DEALLOCATE PREPARE name { $$ = cat2_str(make_str("deallocate prepare"), $3); } + ; /***************************************************************************** * * @@ -2523,12 +2576,12 @@ select_with_parens: '(' select_no_parens ')' select_no_parens: simple_select { $$ = $1; } - | select_clause sort_clause opt_for_update_clause opt_select_limit - { $$ = cat_str(4, $1, $2, $3, $4); } - | select_clause for_update_clause opt_select_limit - { $$ = cat_str(3, $1, $2, $3); } - | select_clause select_limit + | select_clause sort_clause { $$ = cat2_str($1, $2); } + | select_clause opt_sort_clause for_update_clause opt_select_limit + { $$ = cat_str(4, $1, $2, $3, $4); } + | select_clause opt_sort_clause select_limit opt_for_update_clause + { $$ = cat_str(4, $1, $2, $3, $4); } ; select_clause: simple_select { $$ = $1; } @@ -2605,6 +2658,10 @@ opt_distinct: DISTINCT { $$ = EMPTY; } ; +opt_sort_clause: sort_clause { $$ = $1; } + | /* EMPTY */ { $$ = EMPTY; } + ; + sort_clause: ORDER BY sortby_list { $$ = cat2_str(make_str("order by"), $3); } ; @@ -2720,14 +2777,14 @@ table_ref: relation_expr { $$= cat2_str($1, $2); } | func_table { $$ = $1; } - | func_table AS '(' OptTableFuncElementList ')' + | func_table alias_clause + { $$= cat2_str($1, $2); } + | func_table AS '(' TableFuncElementList ')' { $$=cat_str(4, $1, make_str("as ("), $4, make_str(")")); } - | func_table AS ColId '(' OptTableFuncElementList ')' + | func_table AS ColId '(' TableFuncElementList ')' { $$=cat_str(6, $1, make_str("as"), $3, make_str("("), $5, make_str(")")); } - | func_table ColId '(' OptTableFuncElementList ')' + | func_table ColId '(' TableFuncElementList ')' { $$=cat_str(5, $1, $2, make_str("("), $4, make_str(")")); } - | func_table alias_clause - { $$= cat2_str($1, $2); } | select_with_parens {mmerror(PARSE_ERROR, ET_ERROR, "sub-SELECT in FROM must have an alias");} | select_with_parens alias_clause @@ -2825,14 +2882,10 @@ where_clause: WHERE a_expr { $$ = cat2_str(make_str("where"), $2); } | /*EMPTY*/ { $$ = EMPTY; /* no qualifiers */ } ; -OptTableFuncElementList: TableFuncElementList { $$ = $1; } - | /* EMPTY */ { $$ = EMPTY; } - ; - -TableFuncElementList: TableFuncElementList ',' TableFuncElement +TableFuncElementList: TableFuncElement + { $$ = $1; } + | TableFuncElementList ',' TableFuncElement { $$ = cat_str(3, $1, ',', $3); } - | TableFuncElement - { $$ = $1; } ; TableFuncElement: ColId Typename { $$ = cat2_str($1, $2); } @@ -5102,6 +5155,7 @@ unreserved_keyword: | CYCLE { $$ = make_str("cycle"); } | DATABASE { $$ = make_str("database"); } | DAY_P { $$ = make_str("day"); } + | DEALLOCATE { $$ = make_str("deallocate"); } | DECLARE { $$ = make_str("declare"); } | DEFERRED { $$ = make_str("deferred"); } | DELETE_P { $$ = make_str("delete"); } @@ -5169,6 +5223,7 @@ unreserved_keyword: | PATH_P { $$ = make_str("path"); } | PENDANT { $$ = make_str("pendant"); } | PRECISION { $$ = make_str("precision"); } + | PREPARE { $$ = make_str("prepare"); } | PRIOR { $$ = make_str("prior"); } | PRIVILEGES { $$ = make_str("privileges"); } | PROCEDURAL { $$ = make_str("procedural"); }