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

Reply via email to