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)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-07 09:35:21
Message-ID: 03040DFF97E6E54E88D3BFEE5F5480F737AC1DFB@G01JPEXMBYT04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Meskes-san

Thank you for your comment.
I write three points in this mail.

1.
> This also seems to be conflicting with
> bd7c95f0c1a38becffceb3ea7234d57167f6d4bf. If we want to keep this
> commit in for the release, I think we need to get these things fixed.

I understand it.
My idea is that add an argument for statement-name to ECPGdo() or
add a new function that is a wrapper of ECPGdo() and has the argument.
The argument is used for lookup related connection. Is it good?

2.
> I wrote:
> But it doesn't allow to use host variable in parameter clause of EXECUTE statement like the following.

I found a way to support host variables in parameter list of EXECUTE statement.
ecpg_build_params() replace each parameter to string-formatted data that can be
created by ecpg_store_input(). I will try it.

3.
I found a bug in my patch. Replacing $ to @ in AS clause is not good
because @ is absolute value operator.
Therefore, the replacing cannot accept valid statement like the following.

exec sql prepare st(int) select $1 + @1; -- It equals to "select $1 + 1"

I choose $$1 unavoidably.
Other character seems to be used as any operator.

P.S.
- PREPARE with FROM is the standard for Embedded SQL.
- PREPARE with AS is not defined in the standard.
- PREPARE with AS clause is PostgreSQL style.
- Oracle and MySQL support only the standard.

Regards
Ryo Matsumura

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Arthur Zakirov 2019-03-07 09:46:06 [PROPOSAL] Drop orphan temp tables in single-mode
Previous Message David Steele 2019-03-07 09:34:55 Re: Remove Deprecated Exclusive Backup Mode