Thread: create temporary sequence and ecpg

create temporary sequence and ecpg

From
Edmund Bacon
Date:
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Edmund Bacon
Your email address    :    ebacon@onesystem.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)     :  Linux 2.4.20

  PostgreSQL version (example: PostgreSQL-7.3.4):   PostgreSQL-7.3.4

  Compiler used (example:  gcc 2.95.2)        :  gcc 3.2.2


Please enter a FULL description of your problem:
------------------------------------------------

Trying to create a TEMPORARY SEQUENCE with ecpg produces
a runtime erorr.  the sqlprint error is:

sql error 'ERROR:  parser: parse error at or near "foo" at character 27'
in lin

A workaround is to use EXECUTE IMMEDIATE



Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

exec sql include sqlca;

$ cat tmpseq.pgc

int main()
{
    exec sql whenever sqlerror sqlprint;

    exec sql connect to test;

    exec sql create temporary sequence foo;

    exec sql disconnect;

    return 0;
}

Looking at the emitted C code we see:

 { ECPGdo(__LINE__, NULL, "create sequence temporary foo ", ECPGt_EOIT,
ECPGt_EORT);

Note that the tokens "sequence" and "temporary" have been reversed.

If you know how this problem might be fixed, list the solution below:

---------------------------------------------------------------------





--
Edmund Bacon <ebacon@onesystem.com>

Re: create temporary sequence and ecpg

From
Bruce Momjian
Date:
Nice bug report.  I have attached a fix that will appear in our 7.4
release.  Thanks.

---------------------------------------------------------------------------

Edmund Bacon wrote:
>
> ============================================================================
>                         POSTGRESQL BUG REPORT TEMPLATE
> ============================================================================
>
>
> Your name        :    Edmund Bacon
> Your email address    :    ebacon@onesystem.com
>
>
> System Configuration
> ---------------------
>   Architecture (example: Intel Pentium)      : Intel Pentium
>
>   Operating System (example: Linux 2.0.26 ELF)     :  Linux 2.4.20
>
>   PostgreSQL version (example: PostgreSQL-7.3.4):   PostgreSQL-7.3.4
>
>   Compiler used (example:  gcc 2.95.2)        :  gcc 3.2.2
>
>
> Please enter a FULL description of your problem:
> ------------------------------------------------
>
> Trying to create a TEMPORARY SEQUENCE with ecpg produces
> a runtime erorr.  the sqlprint error is:
>
> sql error 'ERROR:  parser: parse error at or near "foo" at character 27'
> in lin
>
> A workaround is to use EXECUTE IMMEDIATE
>
>
>
> Please describe a way to repeat the problem.   Please try to provide a
> concise reproducible example, if at all possible:
> ----------------------------------------------------------------------
>
> exec sql include sqlca;
>
> $ cat tmpseq.pgc
>
> int main()
> {
>     exec sql whenever sqlerror sqlprint;
>
>     exec sql connect to test;
>
>     exec sql create temporary sequence foo;
>
>     exec sql disconnect;
>
>     return 0;
> }
>
> Looking at the emitted C code we see:
>
>  { ECPGdo(__LINE__, NULL, "create sequence temporary foo ", ECPGt_EOIT,
> ECPGt_EORT);
>
> Note that the tokens "sequence" and "temporary" have been reversed.
>
> If you know how this problem might be fixed, list the solution below:
>
> ---------------------------------------------------------------------
>
>
>
>
>
> --
> Edmund Bacon <ebacon@onesystem.com>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/interfaces/ecpg/preproc/preproc.y
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/preproc/preproc.y,v
retrieving revision 1.259
diff -c -c -r1.259 preproc.y
*** src/interfaces/ecpg/preproc/preproc.y    23 Sep 2003 12:56:35 -0000    1.259
--- src/interfaces/ecpg/preproc/preproc.y    24 Sep 2003 19:03:50 -0000
***************
*** 1499,1505 ****
   *****************************************************************************/

  CreateSeqStmt:    CREATE OptTemp SEQUENCE qualified_name OptSeqList
!             { $$ = cat_str(4, make_str("create sequence"), $2, $4, $5); }
          ;

  AlterSeqStmt: ALTER SEQUENCE qualified_name OptSeqList
--- 1499,1505 ----
   *****************************************************************************/

  CreateSeqStmt:    CREATE OptTemp SEQUENCE qualified_name OptSeqList
!             { $$ = cat_str(4, make_str("create"), $2, make_str("sequence"), $4, $5); }
          ;

  AlterSeqStmt: ALTER SEQUENCE qualified_name OptSeqList