ECPG: "EXEC SQL CREATE SCHEMA foo" Broken - Mailing list pgsql-hackers

From Lee Kindness
Subject ECPG: "EXEC SQL CREATE SCHEMA foo" Broken
Date
Msg-id 16315.19939.40112.428230@kelvin.csl.co.uk
Whole thread Raw
Responses Re: ECPG: "EXEC SQL CREATE SCHEMA foo" Broken  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Hi, please apply patch below to correct the EXEC SQL CREATE SCHEMA
construct in ECPG. Currently (versions 7.3.x, 7.4) the preprocessor
emmits "create scheme" in error, rather than "create schema".

A workaround also exists for those who require it (but I guess no-one
apart from me does since it's went unreported through 7.3), rather
than (checking omitted):

 EXEC SQL CREATE SCHEMA foo;

you can use:

 EXEC SQL BEGIN DECLARE SECTION;
 char l_cmd[50];
 EXEC SQL END DECLARE SECTION;

 snprintf(l_cmd, sizeof(l_cmd), "CREATE SCHEMA foo");
 EXEC SQL EXECUTE IMMEDIATE :l_cmd;

Thanks, L.

*** src/interfaces/ecpg/preproc/preproc.y.orig    2003-11-19 10:52:25.000000000 +0000
--- src/interfaces/ecpg/preproc/preproc.y    2003-11-19 10:52:30.000000000 +0000
***************
*** 966,974 ****
   *****************************************************************************/

  CreateSchemaStmt:  CREATE SCHEMA UserId OptSchemaName AUTHORIZATION UserId OptSchemaEltList
!             { $$ = cat_str(6, make_str("create scheme"), $3, $4, make_str("authorization"), $6, $7); }
          | CREATE SCHEMA ColId OptSchemaEltList
!             { $$ = cat_str(3, make_str("create scheme"), $3, $4); }
          ;

  OptSchemaName: ColId        { $$ = $1; }
--- 966,974 ----
   *****************************************************************************/

  CreateSchemaStmt:  CREATE SCHEMA UserId OptSchemaName AUTHORIZATION UserId OptSchemaEltList
!             { $$ = cat_str(6, make_str("create schema"), $3, $4, make_str("authorization"), $6, $7); }
          | CREATE SCHEMA ColId OptSchemaEltList
!             { $$ = cat_str(3, make_str("create schema"), $3, $4); }
          ;

  OptSchemaName: ColId        { $$ = $1; }

pgsql-hackers by date:

Previous
From: Sailesh Krishnamurthy
Date:
Subject: Re: Is there going to be a port to Solaris 9 x86 in the
Next
From: strk
Date:
Subject: initdb segfaults - latest cvs