Re: proposal: plpgsql, new check for extra_errors - strict_expr_check
От | Marcos Pegoraro |
---|---|
Тема | Re: proposal: plpgsql, new check for extra_errors - strict_expr_check |
Дата | |
Msg-id | CAB-JLwbKmKpqRhVWb1uU13-vi36zANCaTh6ikwcZ+q2s0mAQPQ@mail.gmail.com обсуждение исходный текст |
Ответ на | proposal: plpgsql, new check for extra_errors - strict_expr_check (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: proposal: plpgsql, new check for extra_errors - strict_expr_check
|
Список | pgsql-hackers |
Can you remove or just ignore double ; too ?
postgres=# do $$
declare var_x integer;
begin
var_x = 99;;
delete from x where x = var_x;
end; $$;
ERROR: syntax error at or near ";"
LINE 1: do $$ declare var_x integer; begin var_x = 99;; delete from ...
ERROR: syntax error at or near ";"
LINE 1: do $$ declare var_x integer; begin var_x = 99;; delete from ...
Atenciosamente,

Em dom., 16 de jun. de 2024 às 11:12, Pavel Stehule <pavel.stehule@gmail.com> escreveu:
Hi,assigned patch try to solve issue reported by Mor Lehr (Missing semicolon in anonymous plpgsql block does not raise syntax error).by introducing a new extra error check. With this check only a_expr exprs are allowed as plpgsql expressions. This is a small step to behaviour described in SQL/PSM standard (although the language is different, the expression syntax and features are almost similar. With this check the undocumented (but supported syntax)var := column FROM tabis disallowed. Only ANSI syntax for embedded queries (inside assignment statement) is allowedvar := (SELECT column FROM tab);With this check, the reported issue (by Mor Lehr) is detecteddefault settingCREATE TABLE foo3(id serial PRIMARY key, txt text);
INSERT INTO foo3 (txt) VALUES ('aaa'),('bbb');DO $$
DECLARE
l_cnt int;
BEGIN
l_cnt := 1
DELETE FROM foo3 WHERE id=1;
END; $$-- without reaction - just don't work(2024-06-16 16:05:55) postgres=# set plpgsql.extra_errors to 'strict_expr_check';
SET
(2024-06-16 16:06:43) postgres=# DO $$
DECLARE
l_cnt int;
BEGIN
l_cnt := 1
DELETE FROM foo3 WHERE id=1;
END; $$;
ERROR: syntax error at or near "DELETE"
LINE 11: DELETE FROM foo3 WHERE id=1;
^This patch has three parts1. Introduction strict_expr_check2. set strict_expr_check as default, and impact on regress tests3. revert @2I don't propose to be strict_expr_check active by default.Comments, notes?RegardsPavel
В списке pgsql-hackers по дате отправления: