RE: SQL statement PREPARE does not work in ECPG - Mailing list pgsql-hackers

From Matsumura, Ryo
Subject RE: SQL statement PREPARE does not work in ECPG
Date
Msg-id 03040DFF97E6E54E88D3BFEE5F5480F737AA7C60@G01JPEXMBYT04
Whole thread Raw
In response to SQL statement PREPARE does not work in ECPG  ("Takahashi, Ryohei" <r.takahashi_2@jp.fujitsu.com>)
Responses Re: SQL statement PREPARE does not work in ECPG
List pgsql-hackers
Hi

I think SQL statement PREPARE *without* parameter is supported,
but one with parameter is not supported (or has some fatal bugs).

Because route for SQL statement PREPARE (line-1837 of preproc.y) always has output an invalid SQL statement and
there is no regression test for SQL statement PREPARE.

[preproc.y]
 1832 |  PrepareStmt
 1833     {
 1834         if ($1.type == NULL || strlen($1.type) == 0)
 1835             output_prepare_statement($1.name, $1.stmt);
 1836         else
 1837             output_statement(cat_str(5, mm_strdup("prepare"), $1.name, $1.type, mm_strdup("as"), $1.stmt), 0,
ECPGst_normal);
 1838     }

The next is log of ECPGdebug() and PQtrace() for the following statement.

  exec sql prepare st(int) as select col1 from foo;

[14968]: ecpg_execute on line 17: query: prepare "st" ( int ) as " select 1 "; with 0 parameter(s) on connection conn
To backend> Msg Q
To backend> "prepare "st" ( int ) as " select 1 ""
To backend> Msg complete, length 42
2019-02-19 06:23:30.429 UTC [14969] ERROR:  syntax error at or near "" select 1 "" at character 25
2019-02-19 06:23:30.429 UTC [14969] STATEMENT:  prepare "st" ( int ) as " select 1 "


Regards
Ryo Matsumura


pgsql-hackers by date:

Previous
From: "Tsunakawa, Takayuki"
Date:
Subject: RE: Protect syscache from bloating with negative cache entries
Next
From: Thomas Munro
Date:
Subject: Some thoughts on NFS