postgresql/src/include
Tom Lane 06e94eccfd Fix missed checks for hashability of container-type equality.
The operators for array_eq, record_eq, range_eq, and multirange_eq
are all marked oprcanhash, but there's a pitfall: their hash functions
can fail at runtime if the contained type(s) are not hashable.
Therefore, the planner has to check hashability of the contained types
before deciding it can use hashing in these cases.  Not every place
had gotten this memo, and noplace at all had considered the issue
for ranges or multiranges.  In particular we could attempt to use
hashing for a ScalarArrayOpExpr on a container type when it won't
actually work, leading to "could not identify a hash function ..."
runtime failures.

For the most part we should fix this in the lookup functions provided
by lsyscache.c, to wit get_op_hash_functions and op_hashjoinable.
But there's a problem: get_op_hash_functions is not passed the input
data type it would need to check.  We mustn't change the API of that
exported function in a back-patched fix, and even if we wanted to,
its call sites in the executor mostly don't have easy access to the
required data type OID.  Fortunately, the executor call sites don't
actually need fixing, because it's expected that the planner verified
hashability before building a plan that requires it.  Therefore,
leave get_op_hash_functions as-is and invent a wrapper function
get_op_hash_functions_ext that does the additional checking needed
in the planner's uses.

We also need to fix hash_ok_operator (extending the fix in 647889667).

While at it, neaten up a couple of places in lookup_type_cache where
relevant code for multirange cases was written differently from the
code for other container types.

Note: while this touches pg_operator.dat, it's only to add oid_symbol
macros.  So there's no on-disk data change and no need for a
catversion bump.

Reported-by: Andrei Lepikhov <lepihov@gmail.com>
Author: Andrei Lepikhov <lepihov@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/ed221f95-f09b-4a9c-b05b-e1fed621ec87@gmail.com
Backpatch-through: 14
2026-06-08 11:48:16 -04:00
..
access Fix calculation of members_size in pg_get_multixact_stats() 2026-05-26 13:49:04 +09:00
archive Update copyright for 2026 2026-01-01 13:24:10 -05:00
backup Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
bootstrap Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
catalog Fix missed checks for hashability of container-type equality. 2026-06-08 11:48:16 -04:00
commands Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
common Don't accept length of -1 in pg_locale.h APIs. 2026-05-15 11:09:15 -07:00
datatype Update copyright for 2026 2026-01-01 13:24:10 -05:00
executor Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
fe_utils Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
foreign Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
jit Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
lib Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
libpq Set notice receiver before libpq connection startup completes 2026-05-23 00:25:48 +09:00
mb Remove MULE_INTERNAL encoding. 2026-04-08 17:40:06 +12:00
nodes Consider collation when proving subquery uniqueness 2026-05-05 10:23:31 +09:00
optimizer Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
parser Mark JumbleState as a const in the post_parse_analyze hook 2026-04-07 15:22:49 +09:00
partitioning Update copyright for 2026 2026-01-01 13:24:10 -05:00
pch Update copyright for 2026 2026-01-01 13:24:10 -05:00
port Remove support for 8 byte tear free read/write on 32-bit 2026-05-18 08:59:59 -07:00
portability pg_test_timing: Show additional TSC clock source debug info 2026-05-16 11:51:34 -04:00
postmaster Constistent naming for datacheckusms processes 2026-05-29 21:26:25 +02:00
regex Harden our regex engine against integer overflow in size calculations. 2026-05-11 05:13:46 -07:00
replication Disable logical decoding after REPACK (CONCURRENTLY) 2026-05-27 20:11:29 +02:00
rewrite Fix bogus calls in remove_self_join_rel() 2026-04-27 10:40:37 +09:00
snowball Update to latest Snowball sources. 2026-01-05 15:22:37 -05:00
statistics Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
storage Revert "Allow logical replication snapshots to be database-specific" 2026-05-23 21:33:19 -07:00
tcop Avoid blocking indefinitely while finishing walsender shutdown 2026-05-01 12:12:44 +09:00
tsearch Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
utils Fix missed checks for hashability of container-type equality. 2026-06-08 11:48:16 -04:00
.gitignore Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
c.h Ensure USE_AVX... symbols are not defined if not building for x86_64. 2026-06-04 10:37:25 -04:00
fmgr.h Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
funcapi.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
getopt_long.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
Makefile Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:02:39 +09:00
meson.build Ensure that all three build methods install the same set of files. 2026-02-16 15:20:15 -05:00
miscadmin.h Revert "Allow logical replication snapshots to be database-specific" 2026-05-23 21:33:19 -07:00
pg_config.h.in Add errdetail() with PID and UID about source of termination signal. 2026-04-07 10:22:33 -04:00
pg_config_manual.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_getopt.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_trace.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgstat.h Fix double-free in pg_stat_autovacuum_scores. 2026-04-09 13:07:06 -05:00
pgtar.h Harden astreamer tar parsing logic against archives it can't handle. 2026-04-02 12:20:36 -04:00
pgtime.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
port.h Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
postgres.h Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
postgres_ext.h Move pg_int64 back to postgres_ext.h 2025-09-16 10:48:56 +02:00
postgres_fe.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
varatt.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
windowapi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00