From: Michael Meskes Date: Mon, 22 Jan 2001 17:05:50 +0000 (+0000) Subject: Synced preproc.y with gram.y and added missing include file to pgc.l. X-Git-Tag: REL7_1~730 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88ce6a2ba041fbaf9216f4a33dfa56ca5fb02840;p=postgresql Synced preproc.y with gram.y and added missing include file to pgc.l. --- diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index db7b89e113..f0724bf0c7 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -1035,8 +1035,9 @@ Fri Dec 22 13:33:31 CET 2000 - Fixed bug in a connect statement using varchars. - Synced gram.y and preproc.y. -Tue Jan 9 20:24:56 CET 2001 +Mon Jan 22 17:56:02 CET 2001 - - Synced gram.y. + - Synced gram.y and preproc.y. + - Added #include "postgres.h" to pgc.l. - Set ecpg version to 2.8.0. - Set library version to 3.2.0. diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 1bfb406ac5..8b21af1fb9 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,17 +12,16 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.71 2001/01/14 05:08:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.72 2001/01/22 17:05:50 meskes Exp $ * *------------------------------------------------------------------------- */ -#include "postgres.h" - #include #include #include #include +#include "postgres.h" #include "miscadmin.h" #include "nodes/parsenodes.h" #include "nodes/pg_list.h" diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index cc37c128cd..a888f93392 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -294,7 +294,7 @@ make_name(void) %type opt_indirection expr_list extract_list extract_arg %type position_list substr_list substr_from alter_column_action %type trim_list in_expr substr_for attr attrs drop_behavior -%type Typename SimpleTypename GenericType Numeric opt_float opt_numeric +%type Typename SimpleTypename Generic Numeric generic opt_float opt_numeric %type opt_decimal Character character opt_varying opt_charset %type opt_collate datetime opt_timezone opt_interval table_ref %type row_expr row_descriptor row_list ConstDatetime opt_chain @@ -313,7 +313,7 @@ make_name(void) %type index_list func_index index_elem opt_class access_method_clause %type index_opt_unique IndexStmt func_return ConstInterval %type func_args_list func_args opt_with ProcedureStmt def_arg -%type def_elem def_list definition DefineStmt +%type def_elem def_list definition DefineStmt select_with_parens %type opt_instead event event_object RuleActionList opt_using %type RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type %type RuleStmt opt_column opt_name oper_argtypes sysid_clause @@ -2066,16 +2066,7 @@ RuleActionMulti: RuleActionMulti ';' RuleActionStmtOrEmpty { $$ = cat2_str($1, make_str(";")); } ; -/* - * Allowing RuleActionStmt to be a SelectStmt creates an ambiguity: - * is the RuleActionList "((SELECT foo))" a standalone RuleActionStmt, - * or a one-entry RuleActionMulti list? We don't really care, but yacc - * wants to know. We use operator precedence to resolve the ambiguity: - * giving this rule a higher precedence than ')' will force a reduce - * rather than shift decision, causing the one-entry-list interpretation - * to be chosen. - */ -RuleActionStmt: SelectStmt %prec TYPECAST +RuleActionStmt: SelectStmt | InsertStmt | UpdateStmt | DeleteStmt @@ -2491,11 +2482,17 @@ opt_cursor: BINARY { $$ = make_str("binary"); } * *****************************************************************************/ -SelectStmt: select_no_parens %prec TYPECAST +SelectStmt: select_no_parens %prec UMINUS + { $$ = $1; } + | select_with_parens %prec UMINUS + { $$ = $1; } + ; + +select_with_parens: '(' select_no_parens ')' { - $$ = $1; + $$ = cat_str(3, make_str("("), $2, make_str(")")); } - | '(' SelectStmt ')' + | '(' select_with_parens ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); } @@ -2524,9 +2521,9 @@ select_clause: simple_select $$ = $1; } - | '(' SelectStmt ')' + | select_with_parens { - $$ = cat_str(3, make_str("("), $2, make_str(")")); + $$ = $1; } ; @@ -2745,10 +2742,6 @@ from_list: from_list ',' table_ref { $$ = cat_str(3, $1, make_str(","), $3); } * between table_ref := '(' joined_table ')' alias_clause * and joined_table := '(' joined_table ')'. So, we must have the * redundant-looking productions here instead. - * - * Note that the SQL spec does not permit a subselect () - * without an alias clause, so we don't either. This avoids the problem - * of needing to invent a refname for an unlabeled subselect. */ table_ref: relation_expr { @@ -2758,9 +2751,13 @@ table_ref: relation_expr { $$= cat2_str($1, $2); } - | '(' SelectStmt ')' alias_clause + | select_with_parens + { + mmerror(ET_ERROR, "sub-SELECT in FROM must have an alias"); + } + | select_with_parens alias_clause { - $$=cat_str(4, make_str("("), $2, make_str(")"), $4); + $$=cat2_str($1, $2); } | joined_table { @@ -2856,12 +2853,12 @@ relation_expr: relation_name /* normal relations */ $$ = $1; } - | relation_name '*' %prec '=' + | relation_name '*' { /* inheritance query */ $$ = cat2_str($1, make_str("*")); } - | ONLY relation_name %prec '=' + | ONLY relation_name { /* inheritance query */ $$ = cat2_str(make_str("ONLY "), $2); @@ -2928,7 +2925,7 @@ SimpleTypename: ConstTypename { $$ = $1; } | ConstInterval { $$ = $1; } ; -ConstTypename: GenericType { $$ = $1; } +ConstTypename: Generic { $$ = $1; } | ConstDatetime { $$ = $1; } | Numeric { $$ = $1; } | Geometric { $$ = $1; } @@ -2936,7 +2933,14 @@ ConstTypename: GenericType { $$ = $1; } | Character { $$ = $1; } ; -GenericType: ident { $$ = $1; } +Generic: generic + { + $$ = $1; + } + ; + +generic: ident { $$ = $1; } + | TYPE_P { $$ = make_str("type"); } | ECPGKeywords { $$ = $1; } | ECPGTypeName { $$ = $1; } ; @@ -3170,21 +3174,21 @@ opt_interval: datetime { $$ = $1; } * Define row_descriptor to allow yacc to break the reduce/reduce conflict * with singleton expressions. */ -row_expr: '(' row_descriptor ')' IN '(' SelectStmt ')' +row_expr: '(' row_descriptor ')' IN select_with_parens { - $$ = cat_str(5, make_str("("), $2, make_str(") in ("), $6, make_str(")")); + $$ = cat_str(4, make_str("("), $2, make_str(") in "), $5); } - | '(' row_descriptor ')' NOT IN '(' SelectStmt ')' + | '(' row_descriptor ')' NOT IN select_with_parens { - $$ = cat_str(5, make_str("("), $2, make_str(") not in ("), $7, make_str(")")); + $$ = cat_str(4, make_str("("), $2, make_str(") not in "), $6); } - | '(' row_descriptor ')' all_Op sub_type '(' SelectStmt ')' + | '(' row_descriptor ')' all_Op sub_type select_with_parens { - $$ = cat_str(8, make_str("("), $2, make_str(")"), $4, $5, make_str("("), $7, make_str(")")); + $$ = cat_str(6, make_str("("), $2, make_str(")"), $4, $5, $6); } - | '(' row_descriptor ')' all_Op '(' SelectStmt ')' + | '(' row_descriptor ')' all_Op select_with_parens { - $$ = cat_str(7, make_str("("), $2, make_str(")"), $4, make_str("("), $6, make_str(")")); + $$ = cat_str(5, make_str("("), $2, make_str(")"), $4, $5); } | '(' row_descriptor ')' all_Op '(' row_descriptor ')' { @@ -3349,17 +3353,17 @@ a_expr: c_expr { $$ = cat_str(5, $1, make_str("not between"), $4, make_str("and"), $6); } - | a_expr IN '(' in_expr ')' + | a_expr IN in_expr { - $$ = cat_str(4, $1, make_str(" in ("), $4, make_str(")")); + $$ = cat_str(3, $1, make_str(" in"), $3); } - | a_expr NOT IN '(' in_expr ')' + | a_expr NOT IN in_expr { - $$ = cat_str(4, $1, make_str(" not in ("), $5, make_str(")")); + $$ = cat_str(3, $1, make_str(" not in "), $4); } - | a_expr all_Op sub_type '(' SelectStmt ')' + | a_expr all_Op sub_type select_with_parens { - $$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); + $$ = cat_str(4, $1, $2, $3, $4); } | row_expr { $$ = $1; } @@ -3494,10 +3498,10 @@ c_expr: attr { $$ = cat_str(3, make_str("trim(trailing"), $4, make_str(")")); } | TRIM '(' trim_list ')' { $$ = cat_str(3, make_str("trim("), $3, make_str(")")); } - | '(' select_no_parens ')' - { $$ = cat_str(3, make_str("("), $2, make_str(")")); } - | EXISTS '(' SelectStmt ')' - { $$ = cat_str(3, make_str("exists("), $3, make_str(")")); } + | select_with_parens %prec UMINUS + { $$ = $1; } + | EXISTS select_with_parens + { $$ = cat2_str(make_str("exists"), $2); } ; /* * This used to use ecpg_expr, but since there is no shift/reduce conflict @@ -3583,12 +3587,12 @@ trim_list: a_expr FROM expr_list { $$ = $1; } ; -in_expr: SelectStmt +in_expr: select_with_parens { $$ = $1; } - | in_expr_nodes - { $$ = $1; } + | '(' in_expr_nodes ')' + { $$ = cat_str(3, make_str("("), $2, make_str(")")); } ; in_expr_nodes: a_expr @@ -5069,7 +5073,6 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); } | TRIGGER { $$ = make_str("trigger"); } | TRUNCATE { $$ = make_str("truncate"); } | TRUSTED { $$ = make_str("trusted"); } - | TYPE_P { $$ = make_str("type"); } | UNLISTEN { $$ = make_str("unlisten"); } | UNTIL { $$ = make_str("until"); } | UPDATE { $$ = make_str("update"); } @@ -5103,7 +5106,6 @@ ECPGColLabel: ECPGColId { $$ = $1; } | ALL { $$ = make_str("all"); } | ANALYSE { $$ = make_str("analyse"); } | ANALYZE { $$ = make_str("analyze"); } - | AND { $$ = make_str("and"); } | ANY { $$ = make_str("any"); } | ASC { $$ = make_str("asc"); } | BETWEEN { $$ = make_str("between"); } @@ -5198,7 +5200,6 @@ ECPGColLabel: ECPGColId { $$ = $1; } | TABLE { $$ = make_str("table"); } | THEN { $$ = make_str("then"); } | TO { $$ = make_str("to"); } - | TRAILING { $$ = make_str("trailing"); } | TRANSACTION { $$ = make_str("transaction"); } | TRIM { $$ = make_str("trim"); } | TRUE_P { $$ = make_str("true"); }