[Bug Fix] ECPG: could not use some CREATE TABLE AS syntax - Mailing list pgsql-hackers

From Higuchi, Daisuke
Subject [Bug Fix] ECPG: could not use some CREATE TABLE AS syntax
Date
Msg-id 1803D792815FC24D871C00D17AE95905DB29DB@g01jpexmbkw24
Whole thread Raw
Responses Re: [Bug Fix] ECPG: could not use some CREATE TABLE AS syntax  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Hi, 

I found some "CREATE TABLE ... AS ... " syntaxes could not be used in ECPG. 

[PROBLEM]
First, ECPG command is failed when the source code (*.pgc) has "IF NOT EXISTS". 
-------------------------------------------------------------------
EXEC SQL CREATE TABLE IF NOT EXISTS test_cta AS SELECT * FROM test;
-------------------------------------------------------------------

Second, ECPG command is succeeded when the source code (*.pgc) has following embedded SQL. However, created c program
hasno "WITH NO DATA". 
 
------------------------------------------------------------------
EXEC SQL CREATE TABLE test_cta AS SELECT * FROM test WITH NO DATA;
------------------------------------------------------------------

[Investigation]
In my investigation, parse.pl ignore type CreateAsStmt of gram.y and CreateAsStmt is defined in ecpg.trailer. ECPG use
ecpg.trailer'sCreateAsStmt. However, ecpg.trailer lacks some syntaxes. 
 
I feel ignoring type CreateAsStmt of gram.y is strange. Seeing ecpg.trailer, it seems that ECPG wanted to output the
message"CREATE TABLE AS cannot specify INTO" but is this needed now? In view of the maintenance, ECPG should use not
ecpg.trailer'sdefinition but gram.y's one. 
 

I attached the patch for this and I will register this for next CF. 

Regards, 
Daisuke Higuchi


Attachment

pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: pg_basebackup ignores the existing data directory permissions
Next
From: Michael Paquier
Date:
Subject: Re: Prevent extension creation in temporary schemas