]> granicus.if.org Git - postgresql/commit
Make decompilation of optimized CASE constructs more robust.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 May 2011 23:25:19 +0000 (19:25 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 May 2011 23:26:04 +0000 (19:26 -0400)
commitf014211849e405b1784f0bfc9d4f6bd7d06f269f
treec8d6ef210deff08cdf7dc7942801bb919d1beb03
parent9a57eafe9d29280fa65c5912df38fc8650507035
Make decompilation of optimized CASE constructs more robust.

We had some hacks in ruleutils.c to cope with various odd transformations
that the optimizer could do on a CASE foo WHEN "CaseTestExpr = RHS" clause.
However, the fundamental impossibility of covering all cases was exposed
by Heikki, who pointed out that the "=" operator could get replaced by an
inlined SQL function, which could contain nearly anything at all.  So give
up on the hacks and just print the expression as-is if we fail to recognize
it as "CaseTestExpr = RHS".  (We must cover that case so that decompiled
rules print correctly; but we are not under any obligation to make EXPLAIN
output be 100% valid SQL in all cases, and already could not do so in some
other cases.)  This approach requires that we have some printable
representation of the CaseTestExpr node type; I used "CASE_TEST_EXPR".

Back-patch to all supported branches, since the problem case fails in all.
src/backend/utils/adt/ruleutils.c