[odb-users] ERROR: prepared statement already exists

Boris Kolpackov boris at codesynthesis.com
Tue Oct 12 09:42:59 EDT 2021

Andrea Ranfone <a.ranfone at gyala.it> writes:

> thanks for your fast reply. I switched to version 2.5.0-b.19 but it seems
> the problem is permanent only with tables for which I specified a FOR UPDATE
> clause on SELECT, In other cases the fix is working fine.

I am not sure I follow. Are you saying that the fix does not work if the
query that causes the transaction to abort is SELECT FOR UPDATE?

> Do you think that the only possible solution would be setting up a new
> connection when a duplicate prepared statement exception occurs?

It's definitely not the only possible solution but it's probably the
simplest and, assuming that such aborts are not too frequent, adequate.
See the comment in the fix for background:


One thing you could try is to prepare (and thus deallocate) the query
yourself, outside of any transaction. See "Prepared Queries" in the
manual for details.

More information about the odb-users mailing list