[Bug Fix] ECPG: could not use some CREATE TABLE AS syntax

From: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: [Bug Fix] ECPG: could not use some CREATE TABLE AS syntax
Date: 2019-02-14 07:39:50
Message-ID: 1803D792815FC24D871C00D17AE95905DB29DB@g01jpexmbkw24
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 has no "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's CreateAsStmt. 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's definition but gram.y's one.

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

Regards,
Daisuke Higuchi

Attachment Content-Type Size
FIX_ECPG_CREATE_TABLE_AS_v1.patch application/octet-stream 13.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-02-14 07:56:48 Re: Prevent extension creation in temporary schemas
Previous Message Haribabu Kommi 2019-02-14 07:34:07 Re: pg_basebackup ignores the existing data directory permissions