pgsql: Remove hardcoded hash opclass function signature exceptions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove hardcoded hash opclass function signature exceptions
Date: 2024-09-12 11:13:18
Message-ID: E1sohlG-000jhw-Ar@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove hardcoded hash opclass function signature exceptions

hashvalidate(), which validates the signatures of support functions
for the hash AM, contained several hardcoded exceptions. For example,
hash/date_ops support function 1 was 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.

This patch removes those exceptions by providing new support functions
that have the proper declared signatures. They internally share most
of the 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().

hashvarlena() and hashvarlenaextended() are kept in pg_proc.dat
because some extensions currently use them to build hash functions for
their own types, and we need to keep exposing these functions as
"LANGUAGE internal" functions for that to continue to work.

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://www.postgresql.org/message-id/flat/29c3b746-69e7-482a-b37c-dbbf7e5b009b(at)eisentraut(dot)org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/23d0b48468b8971b35d713754f7d5ecf54e5f78f

Modified Files
--------------
src/backend/access/hash/hashfunc.c | 17 +++++
src/backend/access/hash/hashvalidate.c | 130 +++++++--------------------------
src/backend/utils/adt/bool.c | 13 ++++
src/backend/utils/adt/date.c | 12 +++
src/backend/utils/adt/timestamp.c | 12 +++
src/backend/utils/adt/xid.c | 37 ++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_amproc.dat | 31 ++++----
src/include/catalog/pg_proc.dat | 42 +++++++++++
9 files changed, 174 insertions(+), 122 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2024-09-12 12:55:37 pgsql: Deduplicate code in LargeObjectExists and myLargeObjectExists.
Previous Message David Rowley 2024-09-12 10:38:11 pgsql: Doc: alphabetize aggregate function table