Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJK7-0006ud-EA for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Oct 2013 00:07:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VbJK6-0004Fn-Ph for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Oct 2013 00:07:46 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJK5-0004Fg-ON for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:07:45 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJK3-0004iE-Bk for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:07:45 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJK3-0006Tw-3Y for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:07:43 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VbJJx-0003T6-KN for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:07:37 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8568: PLPGSQL Documentation For CASE Is incorrect To: pgsql-bugs@postgresql.org From: joshuadburns@hotmail.com Message-Id: Date: Wed, 30 Oct 2013 00:07:37 +0000 X-Pg-Spam-Score: 0.4 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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