From: joshuadburns@hotmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
Date: Wed, 30 Oct 2013 00:07:37 +0000
Message-ID: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 8568
Logged by: Joshua D. Burns
Email address: joshuadburns@hotmail.com
PostgreSQL version: 9.3.1
Operating system: Linux
Description:
Documentation Sections Affected:
* 8.4: 38.6
* 9.0, 9.1 & 9.2: 39.6
* 9.3 & devel: 40.6
Example Documentation URL:
http://www.postgresql.org/docs/9.3/static/plpgsql-control-structures.html
Every example within the PLPGSQL "control structures" documentation states
that the proper syntax for closing a "CASE" statement is to use "END CASE;"
however in reality, on every version of PostgreSQL I can my hands on, "END
CASE;" throws the following exception:
ERROR: syntax error at or near "CASE"
LINE 9: END CASE;
However if I use "END;" in place of "END CASE;", the script executes as
expected. This leads me to believe the documentation for "CASE" statements
across all current versions of the documentation, are incorrect.
=====================================
Example CASE statement with END CASE;
-------------------------------------
DO LANGUAGE "plpgsql" $BODY$
DECLARE my_var INTEGER := 2; BEGIN
RAISE NOTICE
'%',
CASE
WHEN my_var = 1 THEN 'one'
WHEN my_var = 2 THEN 'two'
WHEN my_var = 3 THEN 'three'
END CASE;
END $BODY$;
=====================================
Results In Unexpected Behavior:
ERROR: syntax error at or near "CASE"
LINE 9: END CASE;
=====================================
Example CASE statement using END;
-------------------------------------
DO LANGUAGE "plpgsql" $BODY$
DECLARE my_var INTEGER := 2; BEGIN
RAISE NOTICE
'%',
CASE
WHEN my_var = 1 THEN 'one'
WHEN my_var = 2 THEN 'two'
WHEN my_var = 3 THEN 'three'
END;
END $BODY$;
-------------------------------------
Results In Expected Behavior:
NOTICE: two
I haven't checked, but this could also affect IF statements, specifically
"END IF;" vs. "END;" as well.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: joshuadburns@hotmail.com
Subject: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
In-Reply-To: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org>
References: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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