From 5106aff99a056ea6bcc530d4ece1549d111c8dad Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Fri, 2 Dec 2005 15:03:57 +0000 Subject: [PATCH] Added special handling of CONNECTION variable that is used by ECPG instead of given to the backend. --- src/interfaces/ecpg/ChangeLog | 5 +++ src/interfaces/ecpg/preproc/ecpg_keywords.c | 3 +- src/interfaces/ecpg/preproc/preproc.y | 38 +++++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 6357bf98cb..b7765568db 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -1957,6 +1957,11 @@ Wed Nov 30 12:49:13 CET 2005 - Made several variables "const char *" instead of "char *" as proposed by Qingqing Zhou . - Replaced all strdup() calls by ECPGstrdup(). + +Fri Dec 2 16:00:10 CET 2005 + + - Added special handling of CONNECTION variable that is used by ECPG + instead of given to the backend. - Set ecpg library version to 5.2. - Set ecpg version to 4.2.1. diff --git a/src/interfaces/ecpg/preproc/ecpg_keywords.c b/src/interfaces/ecpg/preproc/ecpg_keywords.c index cd4f8668a7..45bd54f1a1 100644 --- a/src/interfaces/ecpg/preproc/ecpg_keywords.c +++ b/src/interfaces/ecpg/preproc/ecpg_keywords.c @@ -4,7 +4,7 @@ * lexical token lookup for reserved words in postgres embedded SQL * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.31 2005/10/15 02:49:47 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.32 2005/12/02 15:03:57 meskes Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,6 @@ static ScanKeyword ScanKeywords[] = { {"call", SQL_CALL}, {"cardinality", SQL_CARDINALITY}, {"connect", SQL_CONNECT}, - {"connection", SQL_CONNECTION}, {"continue", SQL_CONTINUE}, {"count", SQL_COUNT}, {"current", SQL_CURRENT}, diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index 643d62d5f5..3317e9e8f7 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.312 2005/11/27 01:22:23 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.313 2005/12/02 15:03:57 meskes Exp $ */ /* Copyright comment */ %{ @@ -324,7 +324,7 @@ add_additional_variables(char *name, bool insert) /* special embedded SQL token */ %token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK - SQL_CALL SQL_CARDINALITY SQL_CONNECT SQL_CONNECTION + SQL_CALL SQL_CARDINALITY SQL_CONNECT SQL_CONTINUE SQL_COUNT SQL_CURRENT SQL_DATA SQL_DATETIME_INTERVAL_CODE SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE @@ -506,7 +506,7 @@ add_additional_variables(char *name, bool insert) %type opt_instead event RuleActionList opt_using CreateAssertStmt %type RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type %type RuleStmt opt_column oper_argtypes NumConst var_name -%type MathOp RemoveFuncStmt aggr_argtype +%type MathOp RemoveFuncStmt aggr_argtype ECPGunreserved_con %type RemoveAggrStmt opt_procedural select_no_parens CreateCastStmt %type RemoveOperStmt RenameStmt all_Op opt_trusted opt_lancompiler %type VariableSetStmt var_value zone_value VariableShowStmt @@ -537,7 +537,7 @@ add_additional_variables(char *name, bool insert) %type CreateGroupStmt AlterGroupStmt DropGroupStmt key_delete %type opt_force key_update CreateSchemaStmt PosIntStringConst %type IntConst PosIntConst grantee_list func_type opt_or_replace -%type select_limit CheckPointStmt +%type select_limit CheckPointStmt ECPGColId %type OptSchemaName OptSchemaEltList schema_stmt opt_drop_behavior %type handler_name any_name_list any_name opt_as insert_column_list %type columnref function_name insert_target_el AllConstVar @@ -1117,7 +1117,7 @@ set_rest: var_name TO var_list_or_default { $$ = make_str("session authorization default"); } ; -var_name: ColId { $$ = $1; } +var_name: ECPGColId { $$ = $1; } | var_name '.' ColId { $$ = cat_str(3, $1, make_str("."), $3); } ; @@ -5649,9 +5649,9 @@ on_off: ON { $$ = make_str("on"); } * set the actual connection, this needs a differnet handling as the other * set commands */ -ECPGSetConnection: SET SQL_CONNECTION TO connection_object { $$ = $4; } - | SET SQL_CONNECTION '=' connection_object { $$ = $4; } - | SET SQL_CONNECTION connection_object { $$ = $3; } +ECPGSetConnection: SET CONNECTION TO connection_object { $$ = $4; } + | SET CONNECTION '=' connection_object { $$ = $4; } + | SET CONNECTION connection_object { $$ = $3; } ; /* @@ -5936,6 +5936,14 @@ symbol: ColLabel { $$ = $1; } * is chosen in part to make keywords acceptable as names wherever possible. */ +ECPGColId:ident { $$ = $1; } + | ECPGunreserved_interval { $$ = $1; } + | ECPGunreserved_con { $$ = $1; } + | col_name_keyword { $$ = $1; } + | ECPGKeywords { $$ = $1; } + | ECPGCKeywords { $$ = $1; } + | CHAR_P { $$ = make_str("char"); } + ; /* Column identifier --- names that can be column, table, etc names. */ ColId: ident { $$ = $1; } @@ -6016,7 +6024,7 @@ ECPGCKeywords: S_AUTO { $$ = make_str("auto"); } */ unreserved_keyword: ECPGunreserved_interval | ECPGunreserved; -ECPGunreserved_interval: DAY_P { $$ = make_str("day"); } +ECPGunreserved_interval: DAY_P { $$ = make_str("day"); } | HOUR_P { $$ = make_str("hour"); } | MINUTE_P { $$ = make_str("minute"); } | MONTH_P { $$ = make_str("month"); } @@ -6024,7 +6032,15 @@ ECPGunreserved_interval: DAY_P { $$ = make_str("day"); } | YEAR_P { $$ = make_str("year"); } ; -ECPGunreserved: ABORT_P { $$ = make_str("abort"); } +/* The following symbol must be excluded from var_name but still included in ColId + to enable ecpg special postgresql variables with this name: + CONNECTION + */ +ECPGunreserved: ECPGunreserved_con { $$ = $1; } + | CONNECTION { $$ = make_str("connection"); } + ; + +ECPGunreserved_con: ABORT_P { $$ = make_str("abort"); } | ABSOLUTE_P { $$ = make_str("absolute"); } | ACCESS { $$ = make_str("access"); } | ACTION { $$ = make_str("action"); } @@ -6052,7 +6068,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); } | COMMENT { $$ = make_str("comment"); } | COMMIT { $$ = make_str("commit"); } | COMMITTED { $$ = make_str("committed"); } - | CONNECTION { $$ = make_str("connection"); } +/* | CONNECTION { $$ = make_str("connection"); }*/ | CONSTRAINTS { $$ = make_str("constraints"); } | CONVERSION_P { $$ = make_str("conversion"); } | COPY { $$ = make_str("copy"); } -- 2.40.0