Re: PL/pgSQL cursors should get generated portal names by default
От | Pavel Stehule |
---|---|
Тема | Re: PL/pgSQL cursors should get generated portal names by default |
Дата | |
Msg-id | CAFj8pRAG=uwyfNRF=3pPC_YuU79MM--kg5Q58b=89jpjzeTyUA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: PL/pgSQL cursors should get generated portal names by default (Kirk Wolak <wolakk@gmail.com>) |
Список | 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)
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 по дате отправления: