pgsql: Fix broken Bitmapset optimization in DiscreteKnapsack()
От | David Rowley |
---|---|
Тема | pgsql: Fix broken Bitmapset optimization in DiscreteKnapsack() |
Дата | |
Msg-id | E1rQaCL-0023mm-M2@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Fix broken Bitmapset optimization in DiscreteKnapsack() Some code in DiscreteKnapsack() attempted to zero all words in a Bitmapset by performing bms_del_members() to delete all the members from itself before replacing those members with members from another set. When that code was written, this was a valid way to manipulate the set in such a way to save from palloc having to be called to allocate a new Bitmapset. However, 00b41463c modified Bitmapsets so that an empty set is *always* represented as NULL and this breaks the optimization as the Bitmapset code will always pfree the memory when the set becomes empty. Since DiscreteKnapsack() has been coded to avoid as many unneeded allocations as possible, it seems risky to not fix this. Here we add bms_replace_members() to effectively perform an in-place copy of another set, reusing the memory of the existing set, when possible. This got broken in v16, but no backpatch for now as there've been no complaints. Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAApHDvoTCBkBU2PJghNOFUiO0q=QP4WAWHi5sJP6_4=b2WodrA@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4b310636439da432c473e0e85de661b3342bb745 Modified Files -------------- src/backend/lib/knapsack.c | 5 +---- src/backend/nodes/bitmapset.c | 44 +++++++++++++++++++++++++++++++++++++++++++ src/include/nodes/bitmapset.h | 1 + 3 files changed, 46 insertions(+), 4 deletions(-)
В списке pgsql-committers по дате отправления: