https://github.com/postgres/postgres
Revision c26bc6919efedd0d1e8d9550a05c111dac0830fe authored by Tom Lane on 12 November 2010, 20:14:51 UTC, committed by Tom Lane on 12 November 2010, 20:18:54 UTC
Once we have found a non-null constant argument, there is no need to
examine additional arguments of the COALESCE.  The previous coding got it
right only if the constant was in the first argument position; otherwise
it tried to simplify following arguments too, leading to unexpected
behavior like this:

regression=# select coalesce(f1, 42, 1/0) from int4_tbl;
ERROR:  division by zero

It's a minor corner case, but a bug is a bug, so back-patch all the way.
1 parent 3ef6ea3
History
Tip revision: c26bc6919efedd0d1e8d9550a05c111dac0830fe authored by Tom Lane on 12 November 2010, 20:14:51 UTC
Fix old oversight in const-simplification of COALESCE() expressions.
Tip revision: c26bc69
File Mode Size
config
contrib
doc
src
.gitignore -rw-r--r-- 233 bytes
COPYRIGHT -rw-r--r-- 1.2 KB
GNUmakefile.in -rw-r--r-- 3.7 KB
Makefile -rw-r--r-- 1.4 KB
README -rw-r--r-- 2.0 KB
README.git -rw-r--r-- 820 bytes
aclocal.m4 -rw-r--r-- 445 bytes
configure -rwxr-xr-x 693.8 KB
configure.in -rw-r--r-- 47.0 KB

README

back to top