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

Daniil Davydov <3danissimo@gmail.com>

From: Daniil Davydov <3danissimo@gmail.com>
To: Nikita Malakhov <hukutoc@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-01T14:04:04Z
Lists: pgsql-hackers
Hi,

On Mon, Sep 1, 2025 at 3:27 PM Nikita Malakhov <hukutoc@gmail.com> wrote:
>
> Please correct if I'm wrong, but it seems Peter had another approach in mind -
> magic numbers in separate macros could be easily replaced with enums and
> validation functions, which would make code more readable and less 'magical'.
> Please check the POC patch in attach.
> I've made this just for BT strategies macros and touched only 2 source files
> to make a correct but simple example.
>

I don't think that we can just create different enums for each index strategies.
We have (for example) ScanKey functionality, which can work with different
indexes (and such a functions has a uint16 argument for strategy number).

Or are you talking about a single huge enum for all index types? I don't
mind trying to do something like this, but I'm not sure how
"beautiful" it will be.

--
Best regards,
Daniil Davydov