Re: Missing semicolumn in anonymous plpgsql block does not raise syntax error

From: Mor Lehr <mor(dot)lehr(at)deel(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Missing semicolumn in anonymous plpgsql block does not raise syntax error
Date: 2024-06-02 15:26:41
Message-ID: CALyvM2ZJytKx+HfayNkvdJ3YcfeCkp0nc8H0gL0bYfFNPBF4Yw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks for the prompt reply.
Can you please refer me to the section in the documentation that describes
this behavior?
This (automatically interperting 1 as select 1) is totally an unexpected
behavior for me.

Thanks again.
-Mor.

On Sun, Jun 2, 2024, 18:19 David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> On Sunday, June 2, 2024, Mor Lehr <mor(dot)lehr(at)deel(dot)com> wrote:
>
>> Hi,
>>
>> 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:
>>
>> CREATE 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; $$;
>>
>>
>> *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);
>
> Which is a valid query.
>
> David J.
>
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-06-02 15:31:42 Re: Missing semicolumn in anonymous plpgsql block does not raise syntax error
Previous Message Peter Geoghegan 2024-06-02 15:19:19 Re: BUG #18490: Assert in comparetup_index_btree_tiebreak() fails when pg_class reindexed during a table creation