forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4b31063
committed
Fix broken Bitmapset optimization in DiscreteKnapsack()
Some code in DiscreteKnapsack() attempted to zero all words in aBitmapset by performing bms_del_members() to delete all the members fromitself before replacing those members with members from another set.When that code was written, this was a valid way to manipulate the setin such a way to save from palloc having to be called to allocate a newBitmapset. However,00b4146 modified Bitmapsets so that an empty set is*always* represented as NULL and this breaks the optimization as theBitmapset code will always pfree the memory when the set becomes empty.Since DiscreteKnapsack() has been coded to avoid as many unneededallocations as possible, it seems risky to not fix this. Here we addbms_replace_members() to effectively perform an in-place copy of anotherset, reusing the memory of the existing set, when possible.This got broken in v16, but no backpatch for now as there've been nocomplaints.Reviewed-by: Richard GuoDiscussion:https://postgr.es/m/CAApHDvoTCBkBU2PJghNOFUiO0q=QP4WAWHi5sJP6_4=b2WodrA@mail.gmail.com1 parent57b440e commit4b31063
File tree
3 files changed
+46
-4
lines changed- src
- backend
- lib
- nodes
- include/nodes
3 files changed
+46
-4
lines changedLines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
92 |
| - | |
93 |
| - | |
94 |
| - | |
95 |
| - | |
| 92 | + | |
96 | 93 |
| |
97 | 94 |
| |
98 | 95 |
| |
|
Lines changed: 44 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
976 | 976 |
| |
977 | 977 |
| |
978 | 978 |
| |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
979 | 1023 |
| |
980 | 1024 |
| |
981 | 1025 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
| 112 | + | |
112 | 113 |
| |
113 | 114 |
| |
114 | 115 |
| |
|
0 commit comments
Comments
(0)