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