pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #11944: plpgsql if-case-then syntax error. 2+ messages / 2 participants [nested] [flat]
* BUG #11944: plpgsql if-case-then syntax error. @ 2014-11-12 04:46 jasen@treshna.com 0 siblings, 1 reply; 2+ messages in thread From: jasen@treshna.com @ 2014-11-12 04:46 UTC (permalink / raw) To: pgsql-bugs The following bug has been logged on the website: Bug reference: 11944 Logged by: Jasen Betts Email address: jasen@treshna.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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #11944: plpgsql if-case-then syntax error. @ 2014-11-12 20:47 Pavel Stehule <pavel.stehule@gmail.com> parent: jasen@treshna.com 0 siblings, 0 replies; 2+ messages in thread From: Pavel Stehule @ 2014-11-12 20:47 UTC (permalink / raw) To: jasen@treshna.com; +Cc: pgsql-bugs 2014-11-12 5:46 GMT+01:00 <jasen@treshna.com>: > The following bug has been logged on the website: > > Bug reference: 11944 > Logged by: Jasen Betts > Email address: jasen@treshna.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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-bugs > ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-11-12 20:47 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2014-11-12 04:46 BUG #11944: plpgsql if-case-then syntax error. jasen@treshna.com 2014-11-12 20:47 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox