BUG #2963: PQprepare and transactions. - Mailing list pgsql-bugs

From DUVAL Jean-Pierre
Subject BUG #2963: PQprepare and transactions.
Date
Msg-id 200702031711.l13HBvGa011565@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #2963: PQprepare and transactions.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2963
Logged by:          DUVAL Jean-Pierre
Email address:      jp.duval@up-comp.com
PostgreSQL version: 8.1.3
Operating system:   Windows XP
Description:        PQprepare and transactions.
Details:

To speed up programs, I call:
1) PQprepare("MyStatement") one time.
2) PQexecPrepared("MyStatement") many times.
3) PQexec("DEALLOCATE MyStatement") to deallocate the statement prepared.

This works with no transaction.

Case A :
--------
If I put all these three steps in a loop finished by a commit or rollback, I
cann't neither do again:
A) PQprepare("MyStatement") one time.
B) PQexecPrepared("MyStatement") many times.

Case B :
--------
Moreover, just after connecting, if I just do a rollback and then a begin
transaction, I cann't neither do at second iteration:
A) PQprepare("MyStatement") one time.
B) PQexecPrepared("MyStatement") many times.

It seems that PQprepare() is using something like DECLARE CURSOR WITHOUT
HOLD, that is impacted by transactions:
X) Either destroyed at the end of the transaction.
Y) Or not possible to do when a transaction is open.

It should be better to use WITH HOLD inside PQprepare() or to add a
parameter to do so. In this case the behavior of PostgreSQL to manage
prepared statements and transactions should be like the one of other
database engines - Db2, Informix, Oracle, Max DB, My Sql, Sql Server for
which I am sure of the behavior.

At this time, due to this bug, it is not possible to write a large batch
program handling millions of datas.

Jean-Pierre DUVAL - jp.duva@up-comp.com - www.up-comp.com

pgsql-bugs by date:

Previous
From: "Gary Chambers"
Date:
Subject: BUG #2962: 8.2.1 lo_creat Documentation incorrect?
Next
From: "Rich Teer"
Date:
Subject: BUG #2969: Inaccuracies in Solaris FAQ