Re: BUG #11944: plpgsql if-case-then syntax error.

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: jasen(at)treshna(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #11944: plpgsql if-case-then syntax error.
Date: 2014-11-12 20:47:47
Message-ID: CAFj8pRD+Mabyt1A7QzV7pwNx44Wn66rM3mWWBN3S8RAbK2c_nQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2014-11-12 5:46 GMT+01:00 <jasen(at)treshna(dot)com>:

> The following bug has been logged on the website:
>
> Bug reference: 11944
> Logged by: Jasen Betts
> Email address: jasen(at)treshna(dot)com
> PostgreSQL version: 9.1.13
> Operating system: linux
> Description:
>
> this does work
>
> create function fails( a int) returns int language plpgsql as $$ begin
> if CASE when a = 1 then true else false END
> then return 1; else return 0; end if ;
> end $$;
>
> parentheses can make it work.
>
> create function fails_not( a int) returns int language plpgsql as $$ begin
> if ( CASE when a = 1 then true else false END )
> then return 1; else return 0; end if ;
> end $$;
>
> It seems to be the plpgsql parser not treating the CASE-END as atomic when
> looking for the end of the IF xpression.
>
>
yes, it is true. plpgsql parser doesn't understand to SQL and mechanically
searching ending keywords in expected level of parentheses. There is a
problem in fact, so SQL CASE, and PLpgSQL CASE uses same keyword.

Regards

Pavel

>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-11-12 21:04:13 Re: BUG #11335: an invalid prepare statement causes crash at log_statement = 'mod' or 'ddl'.
Previous Message hendrik.grewe 2014-11-12 14:36:32 BUG #11949: pg_basebackup creates defective tar file