Re: SQL statement PREPARE does not work in ECPG

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: "Takahashi, Ryohei" <r(dot)takahashi_2(at)jp(dot)fujitsu(dot)com>, "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL statement PREPARE does not work in ECPG
Date: 2019-02-20 11:47:00
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> I tried as follows.
> ...
> Unfortunately, this does not work.
> ECPGst_execute seems good, but prepare statement is the same as my
> first post.

Ah right, my bad. The workaround should have been:

EXEC SQL PREPARE test_prep from "SELECT id from test_table where id =
EXEC SQL EXECUTE test_prep using 2;

> It fails with "PostgreSQL error : -202[too few arguments on line
> 16]".
> This error is caused by following source code.
> ...
> I think next_insert() should ignore "$n" in the case of SQL statement

Actually I am not so sure.

> In addition, we should fix following, right?
> (1)
> As Matsumura-san wrote, ECPG should not produce '"' for SQL statement

Why's that?

> (2)
> ECPG should produce argument for execute statement such as "EXEC SQL
> EXECUTE test_prep (2);"


As for the PREPARE statement itself, could you try the attached small
patch please.

This seems to create the correct ECPGPrepare call, but I have not yet
tested it for many use cases.


Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

Attachment Content-Type Size
prepare.diff text/x-patch 791 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2019-02-20 11:47:01 Re: [HACKERS] Time to change pg_regress diffs to unified by default?
Previous Message Michael Meskes 2019-02-20 11:41:17 Re: SQL statement PREPARE does not work in ECPG