aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-15 17:45:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-15 17:46:50 -0400
commit72826fb362c4aada6d2431df0b706df448806c02 (patch)
tree59805e2d8e32a9ef1f7a0091e08fed960fa2008c
parentd5a7bf8c11c8b66c822bbb1a6c90e1a14425bd6e (diff)
downloadpostgresql-72826fb362c4aada6d2431df0b706df448806c02.tar.gz
postgresql-72826fb362c4aada6d2431df0b706df448806c02.zip
Guard against incoming rowcount estimate of NaN in cost_mergejoin().
Although rowcount estimates really ought not be NaN, a bug elsewhere could perhaps result in that, and that would cause Assert failure in cost_mergejoin, which I believe to be the explanation for bug #5977 from Anton Kuznetsov. Seems like a good idea to expend a couple more cycles to prevent that, even though the real bug is elsewhere. Not back-patching, though, because we don't encourage running production systems with Asserts on.
-rw-r--r--src/backend/optimizer/path/costsize.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index e200dcf4728..d3455228660 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -1704,10 +1704,10 @@ cost_mergejoin(MergePath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo)
innerendsel;
Path sort_path; /* dummy for result of cost_sort */
- /* Protect some assumptions below that rowcounts aren't zero */
- if (outer_path_rows <= 0)
+ /* Protect some assumptions below that rowcounts aren't zero or NaN */
+ if (outer_path_rows <= 0 || isnan(outer_path_rows))
outer_path_rows = 1;
- if (inner_path_rows <= 0)
+ if (inner_path_rows <= 0 || isnan(inner_path_rows))
inner_path_rows = 1;
if (!enable_mergejoin)