Re: PL/pgSQL cursors should get generated portal names by default - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: PL/pgSQL cursors should get generated portal names by default
Date
Msg-id CAFj8pRAG=uwyfNRF=3pPC_YuU79MM--kg5Q58b=89jpjzeTyUA@mail.gmail.com
Whole thread Raw
In response to Re: PL/pgSQL cursors should get generated portal names by default  (Kirk Wolak <wolakk@gmail.com>)
List 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



pgsql-hackers by date:

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