public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dominique Devienne <[email protected]>
To: Sebastien Flaesch <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: prepared statement "cu1" already exists (but it does not)
Date: Mon, 8 Apr 2024 18:40:07 +0200
Message-ID: <CAFCRh--GRPHBhdgrnQOMRves3hKr==S90Mkq7RmnRgjChX8gVw@mail.gmail.com> (raw)
In-Reply-To: <AM9P191MB1286DAAE95E27A8FB79376D5B0002@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>
References: <AM9P191MB1286DAAE95E27A8FB79376D5B0002@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>

On Mon, Apr 8, 2024 at 5:31 PM Sebastien Flaesch <[email protected]>
wrote:

> I understand when this can happen, but in fact I do de-allocate prepared
> statements when I should.
>

We've run into similar issues. We're in C++, and with RAII deallocate
resources (Prepared Statements, Cursors) in Dtors.
But as you saw, when a TX is KO, any Dtor trying to release resources via
libpq will fail. So what I do it record those
resources (stmt and cursor names basically) on the Connection (in our
wrapper), and will release them at the first opportunity,
once the TX has rolled back for example. FWIW.

OTOH, we tend not to reuse names, generating random ones, since when using
our wrappers, the name is an impl details basically.
We also tend to prepare outside transactions, so can't answer your question
on whether prepared statements within TX are "scoped" or not. --DD


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: prepared statement "cu1" already exists (but it does not)
  In-Reply-To: <CAFCRh--GRPHBhdgrnQOMRves3hKr==S90Mkq7RmnRgjChX8gVw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox