Re: Check for prepared statement

Lists: pgsql-generalpgsql-hackers
From: "veramente(at)libero(dot)it" <veramente(at)libero(dot)it>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Check for prepared statement
Date: 2004-02-09 10:40:36
Message-ID: HSTCBO$2AE60BD5E63A8BB7ED1DC0E072B1B30E@libero.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Hello all,

How can i find out if a prepared statement already exists..? Is there a function or a query i can execute ..??

Best Regards,

Fabrizio Mazzoni
Macron Srl


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Check for prepared statement
Date: 2004-02-18 01:40:00
Message-ID: a53ef62e9126b29fec511dc3e31cb66e@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----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 ..??

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

(Cross-posting to hackers due to the lack of response on general)

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200402172039

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

iD8DBQFAMsKDvJuQZxSWSsgRAtbeAJ9mmm3TKSU/hLc+oN3RREzCnM7kkQCfS4TS
6UoHDhGLc8kNyG7F/pT/6IM=
=Lg+O
-----END PGP SIGNATURE-----


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Check for prepared statement
Date: 2004-06-03 20:49:03
Message-ID: 20040603204903.GE31283@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Wed, Feb 18, 2004 at 01:40:00AM -0000, Greg Sabino Mullane wrote:

> Fabrizio Mazzoni asked:
>
> > How can i find out if a prepared statement already exists..? Is there a
> > function or a query i can execute ..??
>
> I have not seen an answer to this, and I am curious as well. Anyone?

Trying to prepare a dummy query maybe.

alvherre=# prepare foo as select 1;
PREPARE
alvherre=# prepare foo as select 2;
ERROR: la sentencia preparada "foo" ya existe
alvherre=# execute foo;
?column?
----------
1
(1 fila)

> (Cross-posting to hackers due to the lack of response on general)

Wow, you are really desperate. Cc'ed two times!

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Es filósofo el que disfruta con los enigmas" (G. Coli)


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Check for prepared statement
Date: 2004-06-06 22:57:42
Message-ID: a1e2f991f8dd68cce16436f82cce0d7e@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----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(at)turnstep(dot)com
PGP Key: 0x14964AC8 200406061855

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

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