Re: Replace magic numbers with strategy numbers for B-tree indexes

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Replace magic numbers with strategy numbers for B-tree indexes
Дата
Msg-id 3bb2d82c-33ea-427f-b756-9777f070d2c8@eisentraut.org
обсуждение исходный текст
Список pgsql-hackers
On 30.06.25 05:21, Daniil Davydov wrote:
> Hi,
> I noticed that some asserts and cycles use magic numbers 1 and 0
> instead of BTLessStrategyNumber and InvalidStrategy.
> At the same time, the BTMaxStrategyNumber macro is used there.
> I suggest using appropriate macros for 1 and 0 values.

This code, both the original and your changes, make a lot of assumptions 
about the btree strategy numbers, such as that BTLessStrategyNumber is 
the smallest valid one, that InvalidStrategy is smaller than all of 
them, and that all numbers between the smallest and BTMaxStrategyNumber 
are assigned.

However, some of the code actually does require that, because it fills 
in array fields for consecutive strategy numbers.  So hiding that fact 
by changing 1 to BTLessStrategyNumber introduces more mystery.

I think if we want to abstract all that away, this would need a deeper 
approach somehow.




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