Prepared statement already exists

Поиск
Список
Период
Сортировка
От WireSpot
Тема Prepared statement already exists
Дата
Msg-id b2d4b0380811191142rff7dbb0ya8bf93422dff8508@mail.gmail.com
обсуждение исходный текст
Ответы Re: Prepared statement already exists  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Re: Prepared statement already exists  ("Merlin Moncure" <mmoncure@gmail.com>)
Re: Prepared statement already exists  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
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.

I also imagined some workarounds in the code (PHP), such as defining a
global/static hash table and registering statement names with it. But
I'd like to know if there's a better way.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Any risks in using FUNCTIONs (stored procedures) instead of raw sql queries?
Следующее
От: "Brandon Metcalf"
Дата:
Сообщение: caching issue in function