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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy