Content-Length: 259866 | pFad | http://github.com/postgrespro/postgres_cluster/commit/d65b665d524a67273b075f468bf3d60ce31f4040

FE Guard against zero vardata.rel->tuples in estimate_hash_bucketsize(). · postgrespro/postgres_cluster@d65b665 · GitHub
Skip to content

Commit d65b665

Browse files
committed
Guard against zero vardata.rel->tuples in estimate_hash_bucketsize().
If the referenced rel was proven empty, we'd compute 0/0 here, which results in the function returning NaN. That's a bit more serious than the other zero-divide case. Still, it only seems to be possible in HEAD, so no back-patch. Per report from Piotr Stefaniak. I looked through the rest of selfuncs.c and found no other likely trouble spots.
1 parent fa09f89 commit d65b665

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets)
35403540
* XXX Possibly better way, but much more expensive: multiply by
35413541
* selectivity of rel's restriction clauses that mention the target Var.
35423542
*/
3543-
if (vardata.rel)
3543+
if (vardata.rel && vardata.rel->tuples > 0)
35443544
{
35453545
ndistinct *= vardata.rel->rows / vardata.rel->tuples;
35463546
ndistinct = clamp_row_est(ndistinct);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/d65b665d524a67273b075f468bf3d60ce31f4040

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy