RE: SQL statement PREPARE does not work in ECPG

From: "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com>
To: 'Michael Meskes' <meskes(at)postgresql(dot)org>, "Takahashi, Ryohei" <r(dot)takahashi_2(at)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)fujitsu(dot)com>
Subject: RE: SQL statement PREPARE does not work in ECPG
Date: 2019-05-05 19:37:40
Message-ID: 03040DFF97E6E54E88D3BFEE5F5480F74ABC1B80@G01JPEXMBYT04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Meskes-san

I'm sorry for my long blank. I restarted.

Review of previous discussion:
I made a patch that makes ecpglib to send "PREPARE st(typelist) AS PreparableStmt"
with PQexec(), because the type resolution is difficult.
I tried to merge PREPARE FROM that uses PQprepare() to the PREPARE AS.
Meskes-san pointed that there may be a problem that PREPARE FROM cannot use PQexec().

Now, I noticed a problem of the merging.
Therefore, I will not change the existing implementation of PREPARE FROM.

The problem is:
Statement name of PREPARE FROM can include double quote, because the statement name
is sent by PQprepare() directly and backend doesn't parse it.
In other hand, the statement name of PREPARE AS cannot include double quote,
because it is embedded into query and backend parser disallows it.
This is a specification of PostgreSQL's PREPARE AS.

I defined the following specifications. Please review it.
* ECPG can accept any valid PREPARE AS statement.
* A char-type host variable can be used as the statement name of PREPARE AS,
but its value is constrained by the specification of PREPARE AS.
(e.g. the name cannot include double quotation.)
* The above also allows the following. It's a bit strange but there is no reason
for forbidding.
prepare :st(type_list) as select $1
* ECPG can accept EXECUTE statement with expression list that is allocated
by both PREPARE FROM and PREPARE AS under the following constraints:
- It must not include a using-clause.
- The statement name must follow to the specification of PREPARE AS.

Regards
Ryo Matsumura

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2019-05-05 20:14:40 Re: What is an item pointer, anyway?
Previous Message Andres Freund 2019-05-05 18:48:16 Re: REINDEX INDEX results in a crash for an index of pg_class since 9.6