Commit 8693ebe
committed
Avoid some zero-divide hazards in the planner.
Although I think on all modern machines floating division by zero
results in Infinity not SIGFPE, we still don't want infinities
running around in the planner's costing estimates; too much risk
of that leading to insane behavior.
grouping_planner() failed to consider the possibility that final_rel
might be known dummy and hence have zero rowcount. (I wonder if it
would be better to set a rows estimate of 1 for dummy relations?
But at least in the back branches, changing this convention seems
like a bad idea, so I'll leave that for another day.)
Make certain that get_variable_numdistinct() produces a nonzero result.
The case that can be shown to be broken is with stadistinct < 0.0 and
small ntuples; we did not prevent the result from rounding to zero.
For good luck I applied clamp_row_est() to all the nonconstant return
values.
In ExecChooseHashTableSize(), Assert that we compute positive nbuckets
and nbatch. I know of no reason to think this isn't the case, but it
seems like a good safety check.
Per reports from Piotr Stefaniak. Back-patch to all active branches.1 parent 5515ec0 commit 8693ebe
File tree
3 files changed
+12
-7
lines changed- src/backend
- executor
- optimizer/plan
- utils/adt
3 files changed
+12
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
545 | 548 | | |
546 | 549 | | |
547 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1536 | 1536 | | |
1537 | 1537 | | |
1538 | 1538 | | |
1539 | | - | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1540 | 1542 | | |
1541 | | - | |
| 1543 | + | |
1542 | 1544 | | |
1543 | 1545 | | |
1544 | 1546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4632 | 4632 | | |
4633 | 4633 | | |
4634 | 4634 | | |
4635 | | - | |
4636 | | - | |
| 4635 | + | |
| 4636 | + | |
4637 | 4637 | | |
4638 | 4638 | | |
4639 | 4639 | | |
| |||
4709 | 4709 | | |
4710 | 4710 | | |
4711 | 4711 | | |
4712 | | - | |
| 4712 | + | |
4713 | 4713 | | |
4714 | 4714 | | |
4715 | 4715 | | |
| |||
4730 | 4730 | | |
4731 | 4731 | | |
4732 | 4732 | | |
4733 | | - | |
| 4733 | + | |
4734 | 4734 | | |
4735 | 4735 | | |
4736 | 4736 | | |
4737 | 4737 | | |
4738 | 4738 | | |
4739 | 4739 | | |
4740 | 4740 | | |
4741 | | - | |
| 4741 | + | |
4742 | 4742 | | |
4743 | 4743 | | |
4744 | 4744 | | |
| |||
0 commit comments