postgresql/src/backend
Tom Lane 554b00cdab Fix up handling of simple-form CASE with constant test expression.
eval_const_expressions() can replace CaseTestExprs with constants when
the surrounding CASE's test expression is a constant.  This confuses
ruleutils.c's heuristic for deparsing simple-form CASEs, leading to
Assert failures or "unexpected CASE WHEN clause" errors.  I had put in
a hack solution for that years ago (see commit
514ce7a331 of 2006-10-01), but bug #5794
from Peter Speck shows that that solution failed to cover all cases.

Fortunately, there's a much better way, which came to me upon reflecting
that Peter's "CASE TRUE WHEN" seemed pretty redundant: we can "simplify"
the simple-form CASE to the general form of CASE, by simply omitting the
constant test expression from the rebuilt CASE construct.  This is
intuitively valid because there is no need for the executor to evaluate
the test expression at runtime; it will never be referenced, because any
CaseTestExprs that would have referenced it are now replaced by constants.
This won't save a whole lot of cycles, since evaluating a Const is pretty
cheap, but a cycle saved is a cycle earned.  In any case it beats kluging
ruleutils.c still further.  So this patch improves const-simplification
and reverts the previous change in ruleutils.c.

Back-patch to all supported branches.  The bug exists in 8.1 too, but it's
out of warranty.
2010-12-19 15:31:51 -05:00
..
access Reduce spurious Hot Standby conflicts from never-visible records. 2010-12-10 06:59:33 +00:00
bootstrap Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
catalog Add missing support for removing foreign data wrapper / server privileges 2010-11-12 15:30:19 +02:00
commands Repair memory leakage while ANALYZE-ing complex index expressions. 2010-11-09 11:55:54 -05:00
executor Prevent inlining a SQL function with multiple OUT parameters. 2010-12-01 00:53:23 -05:00
foreign Wrap calls to SearchSysCache and related functions using macros. 2010-02-14 18:42:19 +00:00
lib pgindent run for 9.0, second run 2010-07-06 19:19:02 +00:00
libpq Fix low-risk potential denial of service against RADIUS login. 2010-10-15 16:59:12 +02:00
main Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
nodes Add a stack overflow check to copyObject(). 2010-12-06 22:55:51 -05:00
optimizer Fix up handling of simple-form CASE with constant test expression. 2010-12-19 15:31:51 -05:00
parser Add semicolon, missed in previous patch. And update the keyword list in 2010-10-22 18:39:43 +03:00
po Translation updates for release 9.0.2 2010-12-13 23:20:00 +02:00
port Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
postmaster Remove optreset from src/port/ implementations of getopt and getopt_long. 2010-12-16 16:22:12 -05:00
regex pgindent run for 9.0 2010-02-26 02:01:40 +00:00
replication Bootstrap WAL to begin at segment logid=0 logseg=1 (000000010000000000000001) 2010-11-02 11:36:32 +02:00
rewrite pgindent run for 9.0 2010-02-26 02:01:40 +00:00
snowball Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
storage Force default wal_sync_method to be fdatasync on Linux. 2010-12-08 20:01:14 -05:00
tcop Remove optreset from src/port/ implementations of getopt and getopt_long. 2010-12-16 16:22:12 -05:00
tsearch Tweak tsmatchsel() so that it examines the structure of the tsquery whenever 2010-07-31 03:27:48 +00:00
utils Fix up handling of simple-form CASE with constant test expression. 2010-12-19 15:31:51 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
common.mk Expand test coverage support to entire tree 2009-08-07 20:50:22 +00:00
Makefile Split the LDFLAGS make variable into two parts: LDFLAGS is now used for 2010-07-05 18:54:38 +00:00
nls.mk Translation updates for release 9.0.2 2010-12-13 23:20:00 +02:00