Change "name" nonterminal in cursor-related productions to cursor_name.
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 11 Nov 2009 20:31:26 +0000 (20:31 +0000)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 11 Nov 2009 20:31:26 +0000 (20:31 +0000)
This is a preparatory patch for allowing a dynamic cursor name be used in the
ECPG grammar.

Author: Zoltan Boszormenyi

src/backend/parser/gram.y
src/interfaces/ecpg/preproc/ecpg.addons
src/interfaces/ecpg/preproc/ecpg.trailer

index 38d9764b551ab60144e08529dc824951bb628dd6..a61729135bd70dd40309ed1361b7b6242cb80c61 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.691 2009/11/11 19:25:40 alvherre Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.692 2009/11/11 20:31:26 alvherre Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -251,7 +251,7 @@ static TypeName *TableFuncTypeName(List *columns);
 
 %type <str>        copy_file_name
                database_name access_method_clause access_method attr_name
-               index_name name file_name cluster_index_specification
+               index_name name cursor_name file_name cluster_index_specification
 
 %type <list>   func_name handler_name qual_Op qual_all_Op subquery_Op
                opt_class opt_inline_handler opt_validator validator_clause
@@ -1941,7 +1941,7 @@ reloption_elem:
  *****************************************************************************/
 
 ClosePortalStmt:
-           CLOSE name
+           CLOSE cursor_name
                {
                    ClosePortalStmt *n = makeNode(ClosePortalStmt);
                    n->portalname = $2;
@@ -4194,7 +4194,7 @@ FetchStmt:    FETCH fetch_args
                }
        ;
 
-fetch_args:    name
+fetch_args:    cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $1;
@@ -4202,7 +4202,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | from_in name
+           | from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $2;
@@ -4210,7 +4210,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | NEXT opt_from_in name
+           | NEXT opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4218,7 +4218,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | PRIOR opt_from_in name
+           | PRIOR opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4226,7 +4226,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | FIRST_P opt_from_in name
+           | FIRST_P opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4234,7 +4234,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | LAST_P opt_from_in name
+           | LAST_P opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4242,7 +4242,7 @@ fetch_args:   name
                    n->howMany = -1;
                    $$ = (Node *)n;
                }
-           | ABSOLUTE_P SignedIconst opt_from_in name
+           | ABSOLUTE_P SignedIconst opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -4250,7 +4250,7 @@ fetch_args:   name
                    n->howMany = $2;
                    $$ = (Node *)n;
                }
-           | RELATIVE_P SignedIconst opt_from_in name
+           | RELATIVE_P SignedIconst opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -4258,7 +4258,7 @@ fetch_args:   name
                    n->howMany = $2;
                    $$ = (Node *)n;
                }
-           | SignedIconst opt_from_in name
+           | SignedIconst opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4266,7 +4266,7 @@ fetch_args:   name
                    n->howMany = $1;
                    $$ = (Node *)n;
                }
-           | ALL opt_from_in name
+           | ALL opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4274,7 +4274,7 @@ fetch_args:   name
                    n->howMany = FETCH_ALL;
                    $$ = (Node *)n;
                }
-           | FORWARD opt_from_in name
+           | FORWARD opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4282,7 +4282,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | FORWARD SignedIconst opt_from_in name
+           | FORWARD SignedIconst opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -4290,7 +4290,7 @@ fetch_args:   name
                    n->howMany = $2;
                    $$ = (Node *)n;
                }
-           | FORWARD ALL opt_from_in name
+           | FORWARD ALL opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -4298,7 +4298,7 @@ fetch_args:   name
                    n->howMany = FETCH_ALL;
                    $$ = (Node *)n;
                }
-           | BACKWARD opt_from_in name
+           | BACKWARD opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $3;
@@ -4306,7 +4306,7 @@ fetch_args:   name
                    n->howMany = 1;
                    $$ = (Node *)n;
                }
-           | BACKWARD SignedIconst opt_from_in name
+           | BACKWARD SignedIconst opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -4314,7 +4314,7 @@ fetch_args:   name
                    n->howMany = $2;
                    $$ = (Node *)n;
                }
-           | BACKWARD ALL opt_from_in name
+           | BACKWARD ALL opt_from_in cursor_name
                {
                    FetchStmt *n = makeNode(FetchStmt);
                    n->portalname = $4;
@@ -7108,7 +7108,7 @@ set_target_list:
  *             CURSOR STATEMENTS
  *
  *****************************************************************************/
-DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
+DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
                {
                    DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
                    n->portalname = $2;
@@ -7119,6 +7119,9 @@ DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
                }
        ;
 
+cursor_name:   name                        { $$ = $1; }
+       ;
+
 cursor_options: /*EMPTY*/                  { $$ = 0; }
            | cursor_options NO SCROLL      { $$ = $1 | CURSOR_OPT_NO_SCROLL; }
            | cursor_options SCROLL         { $$ = $1 | CURSOR_OPT_SCROLL; }
index 9ef3d19100961024d3bb2d41c8fff3de679f10a6..1c610f3dd56f423c86249517ee6750947167b2c5 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.7 2009/11/11 19:25:40 alvherre Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.8 2009/11/11 20:31:26 alvherre Exp $ */
 
 ECPG: stmtClosePortalStmt block
    {
@@ -211,32 +211,32 @@ ECPG: var_valueNumericOnly addon
            free($1);
            $1 = make_str("$0");
        }
-ECPG: fetch_argsname addon
+ECPG: fetch_argscursor_name addon
        add_additional_variables($1, false);
-ECPG: fetch_argsfrom_inname addon
+ECPG: fetch_argsfrom_incursor_name addon
        add_additional_variables($2, false);
-ECPG: fetch_argsNEXTopt_from_inname addon
-ECPG: fetch_argsPRIORopt_from_inname addon
-ECPG: fetch_argsFIRST_Popt_from_inname addon
-ECPG: fetch_argsLAST_Popt_from_inname addon
-ECPG: fetch_argsALLopt_from_inname addon
-ECPG: fetch_argsFORWARDopt_from_inname addon
-ECPG: fetch_argsBACKWARDopt_from_inname addon
+ECPG: fetch_argsNEXTopt_from_incursor_name addon
+ECPG: fetch_argsPRIORopt_from_incursor_name addon
+ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
+ECPG: fetch_argsLAST_Popt_from_incursor_name addon
+ECPG: fetch_argsALLopt_from_incursor_name addon
+ECPG: fetch_argsFORWARDopt_from_incursor_name addon
+ECPG: fetch_argsBACKWARDopt_from_incursor_name addon
        add_additional_variables($3, false);
-ECPG: fetch_argsSignedIconstopt_from_inname addon
+ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
        add_additional_variables($3, false);
        if ($1[0] == '$')
        {
            free($1);
            $1 = make_str("$0");
        }
-ECPG: fetch_argsFORWARDALLopt_from_inname addon
-ECPG: fetch_argsBACKWARDALLopt_from_inname addon
+ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
+ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
        add_additional_variables($4, false);
-ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_inname addon
-ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_inname addon
-ECPG: fetch_argsFORWARDSignedIconstopt_from_inname addon
-ECPG: fetch_argsBACKWARDSignedIconstopt_from_inname addon
+ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
+ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
+ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
+ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
        add_additional_variables($4, false);
        if ($2[0] == '$')
        {
@@ -257,7 +257,7 @@ ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
    }
 ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
    { $$ = $2; }
-ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
+ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
    {
        struct cursor *ptr, *this;
        char *comment;
index eca263b249152439d8fa6452993cf580d7061dae..dc63c21bab1c3c340f9ea2811024f6ed634a5c3e 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.13 2009/11/05 23:24:27 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.14 2009/11/11 20:31:26 alvherre Exp $ */
 
 statements: /*EMPTY*/
                 | statements statement
@@ -275,7 +275,7 @@ prepared_name: name             {
  * Declare a prepared cursor. The syntax is different from the standard
  * declare statement, so we create a new rule.
  */
-ECPGCursorStmt:  DECLARE name cursor_options CURSOR opt_hold FOR prepared_name
+ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
        {
            struct cursor *ptr, *this;
            struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
@@ -947,7 +947,7 @@ ECPGFree:   SQL_FREE name   { $$ = $2; }
 /*
  * open is an open cursor, at the moment this has to be removed
  */
-ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; };
+ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using { $$ = $2; };
 
 opt_ecpg_using: /*EMPTY*/  { $$ = EMPTY; }
        | ecpg_using        { $$ = $1; }