Re: cursor already in use, UPDATE RETURNING bug?

From: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: cursor already in use, UPDATE RETURNING bug?
Date: 2021-03-31 14:47:08
Message-ID: CAJKUy5iLV2ddvadjZEjVa2a5f8ThP9dayE18w90+2nGTVomgfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 31, 2021 at 7:50 AM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> On Wed, Mar 31, 2021 at 6:09 AM Jaime Casanova
>
> >
> > -- this fails
> > update t2 set i = 5 returning cursor_bug() as c1;
> > ERROR: cursor "c1" already in use
> > CONTEXT: PL/pgSQL function cursor_bug() line 6 at OPEN
>
> but that's called as many time as the number of rows in t2 in the same
> transaction. The first row will go fine. For the second row it will
> find c1 is already open. Shouldn't cursor_bug() close c1 at the end?
> Is it intended to be kept open when the function finishes? May be you
> are expecting it to be closed automatically when the function
> finishes. But that's not what is documented at
> https://www.postgresql.org/docs/13/plpgsql-cursors.html.
>

Now that I see it again, after sleeping, I can see you're right! sorry
for the noise

--
Jaime Casanova
Director de Servicios Profesionales
SYSTEMGUARDS - Consultores de PostgreSQL

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2021-03-31 15:01:02 Re: unconstrained memory growth in long running procedure stored procedure after upgrading 11-12
Previous Message Laurenz Albe 2021-03-31 14:44:19 Re: Prevent query cancel packets from being replayed by an attacker (From TODO)