pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove hardcoded hash opclass function signature exceptions
Date: Thu, 12 Sep 2024 11:13:18 +0000
Message-ID: <E1sohlG-000jhw-Ar@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1sohlG-000jhw-Ar@gemulon.postgresql.org>
Permalink:  ../E1sohlG-000jhw-Ar@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sohlG-000jhw-Ar@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Remove hardcoded hash opclass function signature exceptions
  In-Reply-To: <E1sohlG-000jhw-Ar@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox