pgsql: Remove hardcoded hash opclass function signature exceptions - Mailing list pgsql-committers

From Peter Eisentraut
Subject pgsql: Remove hardcoded hash opclass function signature exceptions
Date
Msg-id E1sohlG-000jhw-Ar@gemulon.postgresql.org
Whole thread Raw
List 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@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/29c3b746-69e7-482a-b37c-dbbf7e5b009b@eisentraut.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(-)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Doc: alphabetize aggregate function table
Next
From: Fujii Masao
Date:
Subject: pgsql: Add has_largeobject_privilege function.