From: | "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com> |
---|---|
To: | 'Michael Meskes' <meskes(at)postgresql(dot)org>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Bug: ECPG: Cannot use CREATE AS EXECUTE statemnt |
Date: | 2019-07-17 02:40:20 |
Message-ID: | 03040DFF97E6E54E88D3BFEE5F5480F74AC13FBC@G01JPEXMBYT04 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
ecpg_createas_execute.v1.0.patch | application/octet-stream | 16.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2019-07-17 02:45:13 | Re: A little report on informal commit tag usage |
Previous Message | Andres Freund | 2019-07-17 02:35:39 | Re: buildfarm's typedefs list has gone completely nutso |