pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: George Neuner <gneuner2@comcast.net>
To: pgsql-general@postgresql.org
Subject: Re: status of CURSORs after DISCONNECT
Date: Thu, 28 Nov 2019 10:04:53 -0500
Message-ID: <lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com> (raw)
References: <20191128062715.GA2642@c720-r342378>

On Thu, 28 Nov 2019 07:27:15 +0100, Matthias Apitz <guru@unixarea.de>
wrote:

>When an ESQL/C written process issues a
>
>EXEC SQL DISCONNECT [connection];
>
>do the opened CURSOR(s) still survive? We run into the problem that the
>father process issues DISCONNECT before forking children, the forked child
>CONNECTs to the same server and database again and "thinks" it has to CLOSE the
>CURSOR (perhaps a long standing bug in our application we port now from
>Sybase(...) to PostgreSQL).
>
>Thanks
>
>	matthias

Cursors are session specific so if the PG backend exits due to the
disconnect, any cursors it is managing will be closed.  

However, if you are using a connection pooler to keep PG backend
processes alive for reuse, then disconnecting does not necessarily end
the session.  In this case, you need to make sure any cursors are
closed because the next connection to the same backend process may
know nothing about them.

In any event, it's good practice always to close cursors when you are
done with them - if for no reason other than to release resources they
are holding.

George






view thread (4+ messages)  latest in thread

Message-ID: <lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com>
Permalink:  ../lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com/
Also on:    postgresql.org/message-id/lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: gneuner2@comcast.net
  Subject: Re: status of CURSORs after DISCONNECT
  In-Reply-To: <lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com>
  References: <20191128062715.GA2642@c720-r342378> <lnnvtedcbvlreleta8t188odnb1r91nge9@4ax.com>

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

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