Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls

Поиск
Список
Период
Сортировка
От Nicholas White
Тема Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls
Дата
Msg-id CA+=vxNZPKG65vsEWcv1dOKgRsRj5m2ZfjufBmwJEY9ow8Vnw0Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
I've fixed the problems you mentioned (see attached) - sorry, I was a bit careless with the docs.


> +               null_values = (Bitmapset *) WinGetPartitionLocalMemory(
> +                       winobj,
> +                       BITMAPSET_SIZE(words_needed));
> +               Assert(null_values);
>
> This certainly seems ugly - isn't there a way to accomplish this
> without having to violate the Bitmapset abstraction?

Indeed, it's ugly. I've revised it slightly to:

> null_values = (Bitmapset *) WinGetPartitionLocalMemory(
>    winobj,
>    BITMAPSET_SIZE(words_needed));
> null_values->nwords = (int) words_needed;

...which gives a proper bitmap. It's hard to break this into a factory method like bms_make_singleton as I'm getting the (zero'ed) partition local memory from one call, then forcing a correct bitmap's structure on it. Maybe bitmapset.h needs an bms_initialise(void *, int num_words) factory method? You'd still have to use the BITMAPSET_SIZE macro to get the correct amount of memory for the void*. Maybe the factory method could take a function pointer that would allocate memory of the given size (e.g. Bitmapset* initialize(void* (allocator)(Size_t), int num_words) ) - this means I could still use the partition's local memory.

I don't think the solution would be tidier if I re-instated the leadlag_context struct with a single Bitmapset member. Other Bitmapset usage seems to just call bms_make_singleton then bms_add_member over and over again - which afaict will call palloc every BITS_PER_BITMAPWORD calls, which is not really what I want.

Thanks -

Nick
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: New regression test time
Следующее
От: Robins Tharakan
Дата:
Сообщение: Re: Add some regression tests for SEQUENCE