RE: SQL statement PREPARE does not work in ECPG

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)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-07 12:56:57
Message-ID: 03040DFF97E6E54E88D3BFEE5F5480F74ABCB772@G01JPEXMBYT04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Meskes-san

There are two points.

(1)
I attach a new patch. Please review it.

- Preproc replaces any prepared_name to "$0" and changes it to an input-variable
for PREARE with typelist and EXECUTE with paramlist.
$0 is replaced in ecpg_build_params().
It's enable not to change ECPGdo interface.
- Host variables can be used in paramlist of EXECUTE.

(2)
I found some bugs (two types). I didn't fix them and only avoid bison error.

Type1. Bugs or intentional unsupported features.
- EXPLAIN EXECUTE
- CREATE TABLE AS with using clause

e.g.
EXPLAIN EXECUTE st; /* It has not been supported before.*/

ExplainableStmt:
ExecuteStmt
{
- $$ = $1;
+ $$ = $1.name; /* only work arround for bison error */
}

Type2. In multi-bytes encoding environment, a part of character of message is cut off.

It may be very difficult to fix. I pretend I didn't see it for a while.

[ecpglib/error.c]
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "%s on line %d", message, line);
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
ecpg_log("raising sqlstate %.*s (sqlcode %ld): %s\n",
(int) sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, sqlca->sqlerrm.sqlerrmc);

Regards
Ryo Matsumura

Attachment Content-Type Size
ecpg_prepare_as_v1_2.patch application/octet-stream 48.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-05-07 13:17:42 Re: accounting for memory used for BufFile during hash joins
Previous Message Daniel Gustafsson 2019-05-07 12:38:57 Typos and wording in jsonpath-exec.c