diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-09-12 12:52:37 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-09-12 12:57:43 +0200 |
commit | 23d0b48468b8971b35d713754f7d5ecf54e5f78f (patch) | |
tree | 30b2a90fb3d158c65cd51c9c3908f6ae7d18a167 /src/include | |
parent | 5bb9ba2739896d2977e7318658135ba7e356e169 (diff) |
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
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/pg_amproc.dat | 31 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.dat | 42 |
3 files changed, 58 insertions, 17 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 8bace2754c9..d09e47d05fa 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -57,6 +57,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202409102 +#define CATALOG_VERSION_NO 202409121 #endif diff --git a/src/include/catalog/pg_amproc.dat b/src/include/catalog/pg_amproc.dat index f639c3a6a51..1d97e12a050 100644 --- a/src/include/catalog/pg_amproc.dat +++ b/src/include/catalog/pg_amproc.dat @@ -304,9 +304,9 @@ { amprocfamily => 'hash/char_ops', amproclefttype => 'char', amprocrighttype => 'char', amprocnum => '2', amproc => 'hashcharextended' }, { amprocfamily => 'hash/date_ops', amproclefttype => 'date', - amprocrighttype => 'date', amprocnum => '1', amproc => 'hashint4' }, + amprocrighttype => 'date', amprocnum => '1', amproc => 'hashdate' }, { amprocfamily => 'hash/date_ops', amproclefttype => 'date', - amprocrighttype => 'date', amprocnum => '2', amproc => 'hashint4extended' }, + amprocrighttype => 'date', amprocnum => '2', amproc => 'hashdateextended' }, { amprocfamily => 'hash/array_ops', amproclefttype => 'anyarray', amprocrighttype => 'anyarray', amprocnum => '1', amproc => 'hash_array' }, { amprocfamily => 'hash/array_ops', amproclefttype => 'anyarray', @@ -376,10 +376,10 @@ amproc => 'hash_numeric_extended' }, { amprocfamily => 'hash/timestamptz_ops', amproclefttype => 'timestamptz', amprocrighttype => 'timestamptz', amprocnum => '1', - amproc => 'timestamp_hash' }, + amproc => 'timestamptz_hash' }, { amprocfamily => 'hash/timestamptz_ops', amproclefttype => 'timestamptz', amprocrighttype => 'timestamptz', amprocnum => '2', - amproc => 'timestamp_hash_extended' }, + amproc => 'timestamptz_hash_extended' }, { amprocfamily => 'hash/timetz_ops', amproclefttype => 'timetz', amprocrighttype => 'timetz', amprocnum => '1', amproc => 'timetz_hash' }, { amprocfamily => 'hash/timetz_ops', amproclefttype => 'timetz', @@ -392,26 +392,25 @@ amprocrighttype => 'timestamp', amprocnum => '2', amproc => 'timestamp_hash_extended' }, { amprocfamily => 'hash/bool_ops', amproclefttype => 'bool', - amprocrighttype => 'bool', amprocnum => '1', amproc => 'hashchar' }, + amprocrighttype => 'bool', amprocnum => '1', amproc => 'hashbool' }, { amprocfamily => 'hash/bool_ops', amproclefttype => 'bool', - amprocrighttype => 'bool', amprocnum => '2', amproc => 'hashcharextended' }, + amprocrighttype => 'bool', amprocnum => '2', amproc => 'hashboolextended' }, { amprocfamily => 'hash/bytea_ops', amproclefttype => 'bytea', - amprocrighttype => 'bytea', amprocnum => '1', amproc => 'hashvarlena' }, + amprocrighttype => 'bytea', amprocnum => '1', amproc => 'hashbytea' }, { amprocfamily => 'hash/bytea_ops', amproclefttype => 'bytea', - amprocrighttype => 'bytea', amprocnum => '2', - amproc => 'hashvarlenaextended' }, + amprocrighttype => 'bytea', amprocnum => '2', amproc => 'hashbyteaextended' }, { amprocfamily => 'hash/xid_ops', amproclefttype => 'xid', - amprocrighttype => 'xid', amprocnum => '1', amproc => 'hashint4' }, + amprocrighttype => 'xid', amprocnum => '1', amproc => 'hashxid' }, { amprocfamily => 'hash/xid_ops', amproclefttype => 'xid', - amprocrighttype => 'xid', amprocnum => '2', amproc => 'hashint4extended' }, + amprocrighttype => 'xid', amprocnum => '2', amproc => 'hashxidextended' }, { amprocfamily => 'hash/xid8_ops', amproclefttype => 'xid8', - amprocrighttype => 'xid8', amprocnum => '1', amproc => 'hashint8' }, + amprocrighttype => 'xid8', amprocnum => '1', amproc => 'hashxid8' }, { amprocfamily => 'hash/xid8_ops', amproclefttype => 'xid8', - amprocrighttype => 'xid8', amprocnum => '2', amproc => 'hashint8extended' }, + amprocrighttype => 'xid8', amprocnum => '2', amproc => 'hashxid8extended' }, { amprocfamily => 'hash/cid_ops', amproclefttype => 'cid', - amprocrighttype => 'cid', amprocnum => '1', amproc => 'hashint4' }, + amprocrighttype => 'cid', amprocnum => '1', amproc => 'hashcid' }, { amprocfamily => 'hash/cid_ops', amproclefttype => 'cid', - amprocrighttype => 'cid', amprocnum => '2', amproc => 'hashint4extended' }, + amprocrighttype => 'cid', amprocnum => '2', amproc => 'hashcidextended' }, { amprocfamily => 'hash/tid_ops', amproclefttype => 'tid', amprocrighttype => 'tid', amprocnum => '1', amproc => 'hashtid' }, { amprocfamily => 'hash/tid_ops', amproclefttype => 'tid', @@ -819,7 +818,7 @@ amprocrighttype => 'bytea', amprocnum => '5', amproc => 'brin_bloom_options' }, { amprocfamily => 'brin/bytea_bloom_ops', amproclefttype => 'bytea', - amprocrighttype => 'bytea', amprocnum => '11', amproc => 'hashvarlena' }, + amprocrighttype => 'bytea', amprocnum => '11', amproc => 'hashbytea' }, # minmax "char" { amprocfamily => 'brin/char_minmax_ops', amproclefttype => 'char', diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index ff5436acacf..9c4f8b58260 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -1225,6 +1225,12 @@ { oid => '772', descr => 'hash', proname => 'hashvarlenaextended', prorettype => 'int8', proargtypes => 'internal int8', prosrc => 'hashvarlenaextended' }, +{ oid => '9708', descr => 'hash', + proname => 'hashbytea', prorettype => 'int4', proargtypes => 'bytea', + prosrc => 'hashbytea' }, +{ oid => '9709', descr => 'hash', + proname => 'hashbyteaextended', prorettype => 'int8', + proargtypes => 'bytea int8', prosrc => 'hashbyteaextended' }, { oid => '457', descr => 'hash', proname => 'hashoidvector', prorettype => 'int4', proargtypes => 'oidvector', prosrc => 'hashoidvector' }, @@ -1261,6 +1267,36 @@ { oid => '781', descr => 'hash', proname => 'hashmacaddr8extended', prorettype => 'int8', proargtypes => 'macaddr8 int8', prosrc => 'hashmacaddr8extended' }, +{ oid => '9710', descr => 'hash', + proname => 'hashdate', prorettype => 'int4', proargtypes => 'date', + prosrc => 'hashdate' }, +{ oid => '9711', descr => 'hash', + proname => 'hashdateextended', prorettype => 'int8', + proargtypes => 'date int8', prosrc => 'hashdateextended' }, +{ oid => '9712', descr => 'hash', + proname => 'hashbool', prorettype => 'int4', proargtypes => 'bool', + prosrc => 'hashbool' }, +{ oid => '9713', descr => 'hash', + proname => 'hashboolextended', prorettype => 'int8', + proargtypes => 'bool int8', prosrc => 'hashboolextended' }, +{ oid => '9714', descr => 'hash', + proname => 'hashxid', prorettype => 'int4', proargtypes => 'xid', + prosrc => 'hashxid' }, +{ oid => '9715', descr => 'hash', + proname => 'hashxidextended', prorettype => 'int8', proargtypes => 'xid int8', + prosrc => 'hashxidextended' }, +{ oid => '9716', descr => 'hash', + proname => 'hashxid8', prorettype => 'int4', proargtypes => 'xid8', + prosrc => 'hashxid8' }, +{ oid => '9717', descr => 'hash', + proname => 'hashxid8extended', prorettype => 'int8', + proargtypes => 'xid8 int8', prosrc => 'hashxid8extended' }, +{ oid => '9718', descr => 'hash', + proname => 'hashcid', prorettype => 'int4', proargtypes => 'cid', + prosrc => 'hashcid' }, +{ oid => '9719', descr => 'hash', + proname => 'hashcidextended', prorettype => 'int8', proargtypes => 'cid int8', + prosrc => 'hashcidextended' }, { oid => '438', descr => 'count the number of NULL arguments', proname => 'num_nulls', provariadic => 'any', proisstrict => 'f', @@ -6180,6 +6216,12 @@ { oid => '3411', descr => 'hash', proname => 'timestamp_hash_extended', prorettype => 'int8', proargtypes => 'timestamp int8', prosrc => 'timestamp_hash_extended' }, +{ oid => '9720', descr => 'hash', + proname => 'timestamptz_hash', prorettype => 'int4', + proargtypes => 'timestamptz', prosrc => 'timestamptz_hash' }, +{ oid => '9721', descr => 'hash', + proname => 'timestamptz_hash_extended', prorettype => 'int8', + proargtypes => 'timestamptz int8', prosrc => 'timestamptz_hash_extended' }, { oid => '2041', descr => 'intervals overlap?', proname => 'overlaps', proisstrict => 'f', prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp timestamp', |