From: | "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com> |
---|---|
To: | "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com>, 'Michael Meskes' <meskes(at)postgresql(dot)org>, "Takahashi, Ryohei" <r(dot)takahashi_2(at)jp(dot)fujitsu(dot)com>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org> |
Cc: | "Ideriha, Takeshi" <ideriha(dot)takeshi(at)jp(dot)fujitsu(dot)com>, "Kuroda, Hayato" <kuroda(dot)hayato(at)jp(dot)fujitsu(dot)com> |
Subject: | RE: SQL statement PREPARE does not work in ECPG |
Date: | 2019-03-13 11:55:12 |
Message-ID: | 03040DFF97E6E54E88D3BFEE5F5480F737AC339B@G01JPEXMBYT04 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Meskes-san
cc: Takahashi-san, Kuroda-san, Ideriha-san
I attach a new patch. Please review it.
Excuse:
It doesn't include regression tests and pass them.
Because I must reset all expected C program of regression.
# I add an argument to ECPGdo().
I explain the patch as follows:
1. Specification
It accepts the following .pgc.
I confirmed it works well for AT clause.
All results for st1 and st2 are same.
exec sql prepare st0 as select 1;
exec sql prepare st1(int,int) as select $1 + 5 + $2;
exec sql prepare st2 from "select ? + 5 + ?";
exec sql prepare st3(bytea) as select octet_length($1);
exec sql execute st0 into :ovar;
exec sql execute st1(:var1,:var2) into :ovar;
exec sql execute st1(11, :var2) into :ovar;
exec sql execute st2(:var1,:var2) into :ovar;
exec sql execute st2(11, :var2) into :ovar;
exec sql execute st1 into :ovar using :var1,:var2;
exec sql execute st2 into :ovar using :var1,:var2;
exec sql execute st3(:b) into :ovar;
2. Behavior of ecpglib
(1) PREPARE with AS clause
Ecpglib sends the PREPARE statement to backend as is. (using PQexec).
(2) EXECUTE with parameter list
Ecpglib sends the EXECUTE statement as is (using PQexec), but all host variables in
the list are converted to string-formatted and embedded into the EXECUTE statement.
(3) PREPARE with FROM clause (not changed)
Ecpglib sends 'P' libpq-message with statement (using PQprepare).
(4) EXECUTE without parameter list (not changed)
Ecpglib sends 'B' libpq-message with parameters. (using PQexecPrepared).
3. Change of preprocessor
- I add ECPGst_prepare and ECPGst_execnormal.
ECPGst_prepare is only for (1) and ECPGst_execnormal is only for (2).
# I think the names are not good.
- I add one argument to ECPGdo(). It's for prepared statement name.
4.
I wonder whether I should merge (3) to (1) and (4) to (4) or not.
Regards
Ryo Matsumura
Attachment | Content-Type | Size |
---|---|---|
ecpg_prepare_as_v1_1.patch | application/octet-stream | 22.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2019-03-13 11:56:33 | Re: Offline enabling/disabling of data checksums |
Previous Message | Magnus Hagander | 2019-03-13 11:43:49 | Re: Offline enabling/disabling of data checksums |