BUG #13708: strange behaviour instead of syntax error - Mailing list pgsql-bugs

From yozh.ne@gmail.com
Subject BUG #13708: strange behaviour instead of syntax error
Date
Msg-id 20151023100339.931.54397@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #13708: strange behaviour instead of syntax error  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      13708
Logged by:          Albert Nurgaleyev
Email address:      yozh.ne@gmail.com
PostgreSQL version: 9.2.4
Operating system:   Red Hat
Description:

In the code below - if I remove semicolon after "po_result := 'ERROR: No
uncollected prize found!'" then no syntax error occurs, return statement is
just ignored instead

create table test_table(
col1 INTEGER, col2 INTEGER
);

DO $$
DECLARE
v_status INTEGER;
po_result VARCHAR;
BEGIN

UPDATE    test_table
SET       col1 = 2
WHERE     2=3
RETURNING col2
INTO      v_status;

IF NOT FOUND THEN
    po_result := 'ERROR: No uncollected prize found!'
    RETURN;
END IF;

RAISE EXCEPTION 'Error';

END;
$$;

pgsql-bugs by date:

Previous
From: Felipe Gasper
Date:
Subject: Re: pg_restore WAS Re: BUG #13702: pg_dump interprets “=” in a db name incorrectly
Next
From: Tom Lane
Date:
Subject: Re: BUG #13708: strange behaviour instead of syntax error