postgresql/src/include
Tom Lane 64778fac72 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:18 -04:00
..
access Fix multixact backwards-compatibility with CHECKPOINT race condition 2026-03-23 12:03:30 +02:00
bootstrap Update copyright for 2021 2021-01-02 13:06:25 -05:00
catalog Fix missed checks for hashability of container-type equality. 2026-06-08 11:48:18 -04:00
commands Harden _int_matchsel() against being attached to the wrong operator. 2026-02-09 10:14:22 -05:00
common Unify src/common/'s definitions of MaxAllocSize. 2026-05-11 05:13:51 -07:00
datatype Avoid using timezone Asia/Manila in regression tests. 2025-01-20 15:47:53 -05:00
executor Fix incorrect logic for hashed IN / NOT IN with non-strict operators 2026-04-24 14:05:23 +12:00
fe_utils Specify the encoding of input to fmtId() 2025-02-10 10:03:40 -05:00
foreign Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
jit jit: No backport::SectionMemoryManager for LLVM 22. 2026-04-03 15:03:10 +13:00
lib simplehash: Free collisions array in SH_STAT 2024-04-07 19:09:05 -07:00
libpq Make dblink interruptible, via new libpqsrv APIs. 2025-04-03 09:34:01 -07:00
mb Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:39:01 +13:00
nodes Fix incorrect IndexOptInfo header comment 2025-11-24 17:02:24 +13:00
optimizer Disallow collecting transition tuples from child foreign tables. 2025-08-08 10:50:04 +09:00
parser Handle default NULL insertion a little better. 2025-01-29 15:31:55 -05:00
partitioning Fix relcache inconsistency hazard in partition detach 2021-04-22 15:13:25 -04:00
port Fix generic read and write barriers for Clang. 2025-11-08 12:32:42 +13:00
portability Fix another portability bug in recent pgbench commit. 2021-03-10 23:20:41 +13:00
postmaster Backpatch critical performance fixes to pgarch.c 2024-12-12 16:21:18 +01:00
regex Harden our regex engine against integer overflow in size calculations. 2026-05-11 05:13:51 -07:00
replication Make invalid primary_slot_name follow standard GUC error reporting. 2025-10-22 20:14:02 +09:00
rewrite Fix calculation of which GENERATED columns need to be updated. 2023-01-05 14:12:17 -05:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Extended statistics on expressions 2021-03-27 00:01:11 +01:00
storage Make palloc_array() and friends safe against integer overflow. 2026-05-11 05:13:51 -07:00
tcop Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
tsearch Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:39:01 +13:00
utils Fix missed checks for hashability of container-type equality. 2026-06-08 11:48:18 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Allow PG_PRINTF_ATTRIBUTE to be different in C and C++ code. 2026-02-25 11:57:26 -05:00
fmgr.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
funcapi.h Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
getaddrinfo.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
getopt_long.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Avoid mixing void and integer in a conditional expression. 2025-11-02 12:31:22 -05:00
pg_config.h.in Add timingsafe_bcmp(), for constant-time memory comparison 2026-05-11 05:13:51 -07:00
pg_config_ext.h.in
pg_config_manual.h Rename debug_invalidate_system_caches_always to debug_discard_caches. 2021-07-13 15:01:01 -04:00
pg_getopt.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_trace.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgstat.h Fix performance regression from session statistics. 2021-09-16 02:10:57 -07:00
pgtar.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgtime.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
port.h Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:51 -07:00
postgres.h Fix misleading comments about TOAST access macros. 2021-09-08 14:11:35 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
rusagestub.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
windowapi.h Update copyright for 2021 2021-01-02 13:06:25 -05:00