Re: Check for prepared statement - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Check for prepared statement
Date
Msg-id a1e2f991f8dd68cce16436f82cce0d7e@biglumber.com
Whole thread Raw
In response to Re: Check for prepared statement  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Fabrizio Mazzoni asked:
>>> How can i find out if a prepared statement already exists..? Is
>>> there a function  or a query i can execute ..??

Greg replied:
>> I have not seen an answer to this, and I am curious as well. Anyone?

Alvaro Herrera suggested:
> Trying to prepare a dummy query maybe.

Sure, but this creates additional traffic, and causes a transaction
to fail, so it's not really feasible if you are within one. I checked
the pgsql source, and there is no public interface to determine if a
named statement already exists.

I do not know why the original poster needed to know, but I've solved
it within DBD::Pg by simply using the fact that statement names are
not shared across connections and having each connection (that is,
ecah database handle) store an integer starting at 1. Generated
statements are simply named "dbdpg_1", "dbdpg_2", etc. and the
increment is increased only after a statement is created successfully.
There is also support for user-created (and user-named) statements,
with the caveat that it is up to the user, not DBD::Pg, to watch for
name collisions.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200406061855

-----BEGIN PGP SIGNATURE-----

iD8DBQFAw6G9vJuQZxSWSsgRAkOPAJ9ioEBN2dhUFNdsKzACdLCzEmmrYwCfZY4P
5qkzlSPmdFwmU3vG14pDSmA=
=hEeT
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Bambero
Date:
Subject: row access
Next
From: Brendan Jurd
Date:
Subject: Re: Turn off "money" formatting?