aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/bool.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-09-12 12:52:37 +0200
committerPeter Eisentraut <peter@eisentraut.org>2024-09-12 12:57:43 +0200
commit23d0b48468b8971b35d713754f7d5ecf54e5f78f (patch)
tree30b2a90fb3d158c65cd51c9c3908f6ae7d18a167 /src/backend/utils/adt/bool.c
parent5bb9ba2739896d2977e7318658135ba7e356e169 (diff)
downloadpostgresql-23d0b48468b8971b35d713754f7d5ecf54e5f78f.tar.gz
postgresql-23d0b48468b8971b35d713754f7d5ecf54e5f78f.zip
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/backend/utils/adt/bool.c')
-rw-r--r--src/backend/utils/adt/bool.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c
index 85e6786563e..a68a112d900 100644
--- a/src/backend/utils/adt/bool.c
+++ b/src/backend/utils/adt/bool.c
@@ -17,6 +17,7 @@
#include <ctype.h>
+#include "common/hashfn.h"
#include "libpq/pqformat.h"
#include "utils/builtins.h"
@@ -273,6 +274,18 @@ boolge(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(arg1 >= arg2);
}
+Datum
+hashbool(PG_FUNCTION_ARGS)
+{
+ return hash_uint32((int32) PG_GETARG_BOOL(0));
+}
+
+Datum
+hashboolextended(PG_FUNCTION_ARGS)
+{
+ return hash_uint32_extended((int32) PG_GETARG_BOOL(0), PG_GETARG_INT64(1));
+}
+
/*
* boolean-and and boolean-or aggregates.
*/