Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 99293133616B for ; Sun, 19 Dec 2010 13:27:49 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 81659-06 for ; Sun, 19 Dec 2010 17:27:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id E64091337B2F for ; Sun, 19 Dec 2010 13:27:48 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id oBJHRlVX009882 for ; Sun, 19 Dec 2010 17:27:47 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id oBJHRlkg009881; Sun, 19 Dec 2010 17:27:47 GMT (envelope-from www) Date: Sun, 19 Dec 2010 17:27:47 GMT Message-Id: <201012191727.oBJHRlkg009881@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5794: 'explain' fails, but executing sql is ok. From: "Peter Speck" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201012/137 X-Sequence-Number: 28943 The following bug has been logged online: Bug reference: 5794 Logged by: Peter Speck Email address: speck@vitality.dk PostgreSQL version: 9.0.2 Operating system: Mac OS X Server 10.6.5 Description: 'explain' fails, but executing sql is ok. Details: The following SQL succeeds when executed as-is, but when the SELECT is prepended with 'EXPLAIN', it fails with: ERROR: XX000: unexpected CASE WHEN clause: 314 LOCATION: get_rule_expr, ruleutils.c:4939 CREATE TABLE z (tag VARCHAR(30)); -- empty SELECT t.* FROM ( SELECT CASE tag WHEN 'a' THEN 'a' ELSE CASE TRUE WHEN (tag LIKE 'abc%' OR tag LIKE 'def%' ) THEN 'b' ELSE 'c' END END AS stuff FROM z ) AS t ORDER BY CASE TRUE WHEN t.stuff LIKE 'ghi%' THEN t.stuff ELSE 'z' END;