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

From: Daniil Davydov <3danissimo(at)gmail(dot)com>
To: Nikita Malakhov <hukutoc(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Replace magic numbers with strategy numbers for B-tree indexes
Date: 2025-09-01 14:04:04
Message-ID: CAJDiXgh9QuLmkGQKA7sh-=4Aqp9_Opmc74X-Kn8BXcxwQsfX9g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Sep 1, 2025 at 3:27 PM Nikita Malakhov <hukutoc(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacques Combrink 2025-09-01 14:06:58 Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue
Previous Message Euler Taveira 2025-09-01 13:35:37 Re: split func.sgml to separated individual sgml files