Re: PL/pgSQL cursors should get generated portal names by default

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: Jan Wieck <jan(at)wi3ck(dot)info>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: PL/pgSQL cursors should get generated portal names by default
Date: 2023-01-09 15:50:29
Message-ID: CAFj8pRAG=uwyfNRF=3pPC_YuU79MM--kg5Q58b=89jpjzeTyUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I wrote a new check in plpgsql_check, that tries to identify explicit work
with the name of the referenced portal.

create or replace function foo01()
returns refcursor as $$#option dump
declare
c cursor for select 1;
r refcursor;
begin
open c;
r := 'c';
return r;
end;
$$ language plpgsql;
CREATE FUNCTION
(2023-01-09 16:49:10) postgres=# select * from
plpgsql_check_function('foo01', compatibility_warnings => true);
┌───────────────────────────────────────────────────────────────────────────────────┐
│ plpgsql_check_function

╞═══════════════════════════════════════════════════════════════════════════════════╡
│ compatibility:00000:7:assignment:obsolete setting of refcursor or cursor
variable │
│ Detail: Internal name of cursor should not be specified by users.

│ Context: at assignment to variable "r" declared on line 4

│ warning extra:00000:3:DECLARE:never read variable "c"

└───────────────────────────────────────────────────────────────────────────────────┘
(4 rows)

Regards

Pavel

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Karl O. Pinc 2023-01-09 15:53:38 Re: doc: add missing "id" attributes to extension packaging page
Previous Message Andrew Dunstan 2023-01-09 15:40:34 Re: [PATCH] Add `verify-system` sslmode to use system CA pool for server cert