I would like to report a potential bug in postgres 15.4, also reproduced on 15.6.
The exact sequence of steps:
Connect to a postgres 15.4 database and run the following statements:
CREATETABLE foo3(id serial PRIMARYkey, txt text);
INSERTINTO foo3 (txt) VALUES ('aaa'),('bbb');
DO$$
DECLARE
l_cnt int;
BEGIN
l_cnt := 1
DELETEFROM foo3 WHERE id=1;
END;$$;
The output you got:
1. The script passes (no error message) even though there's a missing semicolon (;) after "l_cnt := 1" 2. The script doesn't actually delete the record from foo3
I think you just wrote the equivalent of:
l_cnt := (select 1 as delete from foo3 where id=1);