Thread: BUG #5794: 'explain' fails, but executing sql is ok.
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;
"Peter Speck" <speck@vitality.dk> writes: > 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 Fixed, thanks for the report! As a temporary workaround you could just omit "TRUE" from "CASE TRUE WHEN" ... it's a pretty redundant way to write the expression. regards, tom lane