Richard Yen wrote:
Hi All,

I'm trying to put pg_bouncer between my app and postgres, but occasionally, I'll run into "prepared statement 'dbdpg_x' already exists" errors. I've been looking through the source code for DBD::Pg, but to no avail, looking for where the "PREPARE dbdpg_x AS <statement>" code is at. I'm hoping to add a little bit that would check for the existence of a prepared statement, and to rename the prepared statement to dbdpg_x+<something else> if dbdpg_x already exists.

Any pointers on where to look?

I've run into this issue mostly when prepare_cached() was used for my statement handles. I used prepare() instead of prepare_cached() and made sure that I called $sth->finish for each statement handle I didn't see these errors any more.

I'm pretty sure that's the correct way to deal with that error since Postgres will keep the statements prepared on the server side (unless you specify pg_server_prepare => 0 in DBI->connect).

I think prepare_cached() is mostly used for dbs that don't prepare statements on the server side, like mysql and sqlite, but I could be wrong there.

Reply via email to