From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | WireSpot <wirespot(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Prepared statement already exists |
Date: | 2008-11-20 12:20:26 |
Message-ID: | b42b73150811200420j78593927hd746be43545656b2@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Nov 19, 2008 at 2:42 PM, WireSpot <wirespot(at)gmail(dot)com> wrote:
> I'm trying to use prepared statements in an application and I'm
> running into this error: "Query failed: prepared statement already
> exists".
>
> The reason is obvious. What I want to know is the best way to avoid
> getting this error. The client application sets statement names as MD5
> of the actual query text, which means there's a possibility of a clash
> between different parts of the applications if they attempt to prepare
> the same query in the lifetime of a connection.
>
> Possible solutions, please advise:
>
> 1) Something like PREPARE IF NOT EXISTS. I'm guessing no such luck.
>
> 2) Tweaking the Postgres error reporting to ignore this particular
> error. Is it possible? From a non-priviledged client connection?
>
> 3) Reading a list of all the currently defined prepared statements to
> see if the one I want is already prepared. I'm hoping some "magic"
> SELECT in pg's internal tables may do the trick. But I also worry
> about introducing overhead this way.
pg_prepared_statements (on recent versions of postgresql)
also, watch out for race conditions.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2008-11-20 12:21:41 | Re: Prepared statement already exists |
Previous Message | Merlin Moncure | 2008-11-20 12:18:10 | Re: hidden errors calling a volatile function inside a stable function |