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-26 09:09:36
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Takahashi-san

> In the case of standard types, ECPG can get oids from pg_type.h.
> However, in the case of user defined types, ECPG needs to access
> pg_type table and it is overhead.

The overhead wouldn't be too bad. In fact it's already done, at least
sometimes. Please check ecpg_is_type_an_array().

> By the way, should we support prepare statement like following?
> (I think yes.)

If the standard allows it, we want to be able to process it.

> ============================
> EXEC SQL PREPARE test_prep (int) AS SELECT id from test_table where
> id = :ID or id =$1;
> ============================
> Current ECPG produces following code.
> ============================
> ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "prepare \"test_prep\"
> ( int ) as \" select id from test_table where id = $1 or id = $1
> \"",
> ECPGt_int,&(ID),(long)1,(long)1,sizeof(int),
> ============================
> In this case, both ":ID" and "$1" in the original statement are
> converted to "$1" and ECPGdo() cannot distinguish them.
> Therefore, ECPG should produce different code.

I agree. It seems that stuff really broke over the years and nobody
noticed, sigh.

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

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-02-26 09:28:22 Re: pgsql: Avoid creation of the free space map for small heap relations, t
Previous Message Nagaura, Ryohei 2019-02-26 08:15:50 RE: Timeout parameters