forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit53c6daf
committed
Fix two latent(?) bugs in equivclass.c.
get_eclass_for_sort_expr() computes expr_relids and nullable_relidsearly on, even though they won't be needed unless we make a newEquivalenceClass, which we often don't. Aside from the probably-minorinefficiency, there's a memory management problem: these bitmapsets willbe built in the caller's context, leading to dangling pointers if thatis shorter-lived than root->planner_cxt. This would be a live bug ifget_eclass_for_sort_expr() could be called with create_it = true duringGEQO join planning. So far as I can find, the core code never doesthat, but it's hard to be sure that no extensions do, especially sincethe comments make it clear that that's supposed to be a supported case.Fix by not computing these values until we've switched into planner_cxtto build the new EquivalenceClass.generate_join_implied_equalities() uses inner_rel->relids to look uprelevant eclasses, but it ought to be using nominal_inner_relids.This is presently harmless because a child RelOptInfo will always haveexactly the same eclass_indexes as its topmost parent; but that mightnot be true forever, and anyway it makes the code confusing.The first of these is old (introduced by me inf3b3b8d), so back-patchto all supported branches. The second only dates to v13, but we mightas well back-patch it to keep the code looking similar across branches.Discussion:https://postgr.es/m/1508010.1601832581@sss.pgh.pa.us1 parent9cc3d61 commit53c6daf
1 file changed
+8
-8
lines changedLines changed: 8 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
634 | 634 |
| |
635 | 635 |
| |
636 | 636 |
| |
637 |
| - | |
638 |
| - | |
639 |
| - | |
640 |
| - | |
641 |
| - | |
642 |
| - | |
643 | 637 |
| |
644 | 638 |
| |
645 | 639 |
| |
| |||
716 | 710 |
| |
717 | 711 |
| |
718 | 712 |
| |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
719 | 719 |
| |
720 | 720 |
| |
721 | 721 |
| |
| |||
1171 | 1171 |
| |
1172 | 1172 |
| |
1173 | 1173 |
| |
1174 |
| - | |
| 1174 | + | |
1175 | 1175 |
| |
1176 |
| - | |
| 1176 | + | |
1177 | 1177 |
| |
1178 | 1178 |
| |
1179 | 1179 |
| |
|
0 commit comments
Comments
(0)