Remove hardcoded hash opclass function signature exceptions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Remove hardcoded hash opclass function signature exceptions
Date: 2024-08-06 10:23:03
Message-ID: 29c3b746-69e7-482a-b37c-dbbf7e5b009b@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hashvalidate(), which validates the signatures of support functions for
the hash AM, contains several hardcoded exceptions. For example,
hash/date_ops support function 1 is hashint4(), which would ordinarily
fail validation because the function argument is int4, not date. But
this works internally because int4 and date are of the same size. There
are several more exceptions like this that happen to work and were
allowed historically but would now fail the function signature validation.

AFAICT, these exceptions were just carried over from before the current
index AM API and validation functions were added. The code contains
comments like "For the moment, fix it by having a list of allowed
cases.", so it probably wasn't meant as the ideal state.

This patch removes those exceptions by providing new support functions
that have the proper declared signatures. They internally share most of
the C code with the "wrong" functions they replace, so the behavior is
still the same.

With the exceptions gone, hashvalidate() is now simplified and relies
fully on check_amproc_signature(), similar to other index AMs.

I'm also fixing one case where a brin opclass used hashvarlena() for
bytea, even though in that case, there is no function signature
validation done, so it doesn't matter that much.

Not done here, but maybe hashvarlena() and hashvarlenaextended() should
be removed from pg_proc.dat, since their use as opclass support
functions is now dubious. They could continue to exist in the C code as
internal support functions.

Attachment Content-Type Size
0001-Remove-hardcoded-hash-opclass-function-signature-exc.patch text/plain 18.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2024-08-06 10:23:35 Re: [HACKERS] make async slave to wait for lsn to be replayed
Previous Message Melih Mutlu 2024-08-06 09:35:54 Vectored IO in XLogWrite()