ECPG doesn't compile CREATE AS EXECUTE properly.

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: ECPG doesn't compile CREATE AS EXECUTE properly.
Date: 2021-07-01 09:45:25
Message-ID: 20210701.184525.1412291456001020920.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

While I looked a patch, I found that the following ECPG statement
generates uncompilable .c source.

EXEC SQL CREATE TABLE t AS stmt;

ecpgtest.c:
#line 42 "ecpgtest.pgc"

printf("1:dbname=%s\n", dbname);
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, create table t as execute "stmt", ECPGt_EOIT, ECPGt_EORT);

This is apparently broken. The cause is that the rule ExecutStmt is
assumed to return a statement name when type is empty (or null), while
it actually returns a full statement for the CREATE TABLE AS EXECUTE
syntax.

Separating "CREATE TABLE AS EXECUTE" from ExecuteStmt would be cleaner
but I avoided to change the syntax tree. Instead the attched make
distinction of $$.type of ExecuteStmt between NULL and "" to use to
notify the returned name is name of a prepared statement or a full
statement.

I'll post the test part later.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
v1-0001-Fix-ECPG-s-CREATE-TABLE-AS-EXECUTE.patch text/x-patch 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2021-07-01 10:02:51 Re: Numeric multiplication overflow errors
Previous Message Dean Rasheed 2021-07-01 09:27:00 Re: Numeric multiplication overflow errors