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

From Matsumura, Ryo
Subject RE: Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt
Date
Msg-id 03040DFF97E6E54E88D3BFEE5F5480F74AC13FBC@G01JPEXMBYT04
Whole thread Raw
In response to Re: Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Meskes-san

Thank you for your comment.

I attach a patch.
It doesn't include tests, but it passed some test(*1).

Explanation about the patch:

- Add a new ECPGst_exec_embedded_in_other_stmt whether EXECUTE
  statement has exprlist or not.

  This type name may not be good.
  It is a type for [CREATE TABLE ... AS EXECUTE ...].
  But I doesn't consider about [EXPLAIN EXECUTE ...].

- If statement type is a new one, ecpglib embeds variables into 
  query in text format at ecpg_build_params().
  Even if the statement does not have exprlist, ecpglib makes
  exprlist and embeds into it.
  The list is expanded incrementally in loop of ecpg_build_params().

- ecpg_build_params() is difficult to read and insert the above
  logic. Therefore, I refactor it. The deitail is described in comments.

(*1) The followings run expectively.
  exec sql create table if not exists foo (c1 int);
  exec sql insert into foo select generate_series(1, 20);
  exec sql prepare st as select * from foo where c1 % $1 = 0 and c1 % $2 = 0;

  exec sql execute st using :v1,:v2;
  exec sql execute st(:v1,:v2);
  exec sql create table if not exists bar (c1) as execute st(2, 3);
  exec sql create table if not exists bar (c1) as execute st using 2,3;
  exec sql create table if not exists bar (c1) as execute st using :v1,:v2;
  exec sql create table bar (c1) as execute st using :v1,:v2;

Regards
Ryo Matsumura

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: buildfarm's typedefs list has gone completely nutso
Next
From: Alvaro Herrera
Date:
Subject: Re: A little report on informal commit tag usage