Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt - Mailing list pgsql-hackers

From Matsumura, Ryo
Subject Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt
Date
Msg-id 03040DFF97E6E54E88D3BFEE5F5480F74ABEF804@G01JPEXMBYT04
Whole thread Raw
Responses Re: Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt
List pgsql-hackers
Meskes-san

This thread is branched from the following.
https://www.postgresql.org/message-id/03040DFF97E6E54E88D3BFEE5F5480F74ABEADE7@G01JPEXMBYT04

> > Type1. Bugs or intentional unsupported features.
> >   - EXPLAIN EXECUTE
> >   - **CREATE TABLE AS with using clause**

I noticed that CREATE AS EXECUTE with using clause needs a new
implementation that all parameters in using clause must be embedded into
expr-list of EXECUTE in text-format as the following because there is
no interface of protocol for our purpose. 
It spends more time for implementing. Do you have any advice?

  int id = 100;
  EXEC SQL CREATE TABLE test AS EXECUTE stmt using :id;
  -->
  PQexec("CREATE TABLE test AS EXECUTE stmt(100)");


e.g. PQexecParamas("CREATE TABLE test AS EXECUTE stmt", {23,0},{"100",0},{3,0},NULL)
     It sends the following.

    To backend> Msg P
    To backend> ""
    To backend> "create table test as execute stmt"
    :
    To backend> Msg B
    To backend> ""
    To backend> ""      ---> It means execute request "create table test as execute stmt" with the value.
    To backend (2#)> 1       But the create statement has no $x. Since the value may be discard.
    To backend (2#)> 0       In result, the following error is occurred.
    To backend (2#)> 1
    To backend (4#)> 3
    To backend> 100
    To backend (2#)> 1
    To backend (2#)> 0
    :
    2019-06-06 07:26:35.252 UTC [1630] ERROR:  wrong number of parameters for prepared statement "stmt"
    2019-06-06 07:26:35.252 UTC [1630] DETAIL:  Expected 1 parameters but got 0.
    2019-06-06 07:26:35.252 UTC [1630] STATEMENT:  create table test2 as execute stmt

Regards
Ryo Matsumura




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: crash testing suggestions for 12 beta 1
Next
From: "Kato, Sho"
Date:
Subject: RE: Why does not subquery pruning conditions inherit to parentquery?