forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit76281aa
committed
Avoid a couple of zero-divide scenarios in the planner.
cost_subplan() supposed that the given subplan must have plan_rows > 0,which as far as I can tell was true until recent refactoring of thecode in createplan.c; but now that code allows the Result for a provablyempty subquery to have plan_rows = 0. Rather than undo that change,put in a clamp to prevent zero divide.get_cheapest_fractional_path() likewise supposed that best_path->rows > 0.This assumption has been wrong for longer. It's actually harmless givenIEEE float math, because a positive value divided by zero gives +Infinityand compare_fractional_path_costs() will do the right thing with that.Still, best not to assume that.final_cost_nestloop() also seems to have some risks in this area, soborrow the clamping logic already present in the mergejoin cost functions.Lastly, remove unnecessary clamp_row_est() in planner.c's calls toget_number_of_groups(). The only thing that function does with path_rowsis pass it to estimate_num_groups() which already has an internal clamp,so we don't need the extra call; and if we did, the callers are arguablythe wrong place for it anyway.First two items reported by Piotr Stefaniak, the others are productsof my nosing around for similar problems. No back-patch since there'sno evidence that problems arise in the back branches.1 parent676265e commit76281aa
2 files changed
+17
-12
lines changedLines changed: 12 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
49 |
| - | |
50 |
| - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
| |||
1991 | 1992 |
| |
1992 | 1993 |
| |
1993 | 1994 |
| |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
1994 | 2001 |
| |
1995 | 2002 |
| |
1996 | 2003 |
| |
| |||
3025 | 3032 |
| |
3026 | 3033 |
| |
3027 | 3034 |
| |
3028 |
| - | |
3029 |
| - | |
| 3035 | + | |
| 3036 | + | |
3030 | 3037 |
| |
3031 | 3038 |
| |
3032 | 3039 |
| |
|
Lines changed: 5 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3346 | 3346 |
| |
3347 | 3347 |
| |
3348 | 3348 |
| |
3349 |
| - | |
3350 |
| - | |
3351 |
| - | |
| 3349 | + | |
3352 | 3350 |
| |
3353 | 3351 |
| |
3354 |
| - | |
| 3352 | + | |
3355 | 3353 |
| |
3356 | 3354 |
| |
3357 | 3355 |
| |
| |||
3415 | 3413 |
| |
3416 | 3414 |
| |
3417 | 3415 |
| |
3418 |
| - | |
| 3416 | + | |
3419 | 3417 |
| |
3420 | 3418 |
| |
3421 | 3419 |
| |
| |||
4840 | 4838 |
| |
4841 | 4839 |
| |
4842 | 4840 |
| |
4843 |
| - | |
4844 |
| - | |
| 4841 | + | |
| 4842 | + | |
4845 | 4843 |
| |
4846 | 4844 |
| |
4847 | 4845 |
| |
|
0 commit comments
Comments
(0)