postgresql/src/backend
David Rowley 1bd90c8879 Fix datum_image_*()'s inability to detect sign-extension variations
Functions such as hash_numeric() are not careful to use the correct
PG_RETURN_*() macro according to the return type of that function as
defined in pg_proc.  Because that function is meant to return int32,
when the hashed value exceeds 2^31, the 64-bit Datum value won't wrap to
a negative number, which means the Datum won't have the same value as it
would have had it been cast to int32 on a two's complement machine.  This
isn't harmless as both datum_image_eq() and datum_image_hash() may receive
a Datum that's been formed and deformed from a tuple in some cases, and
not in other cases.  When formed into a tuple, the Datum value will be
coerced into an integer according to the attlen as specified by the
TupleDesc.  This can result in two Datums that should be equal being
classed as not equal, which could result in (but not limited to) an error
such as:

ERROR:  could not find memoization table entry

Here we fix this by ensuring we cast the Datum value to a signed integer
according to the typLen specified in the datum_image_eq/datum_image_hash
function call before comparing or hashing.

Author: David Rowley <dgrowleyml@gmail.com>
Reported-by: Tender Wang <tndrwang@gmail.com>
Backpatch-through: 14
Discussion: https://postgr.es/m/CAHewXNmcXVFdB9_WwA8Ez0P+m_TQy_KzYk5Ri5dvg+fuwjD_yw@mail.gmail.com
2026-03-30 16:17:14 +13:00
..
access Fix multixact backwards-compatibility with CHECKPOINT race condition 2026-03-23 12:02:27 +02:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Fix error message related to end TLI in backup manifest 2026-01-18 17:25:01 +09:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
commands Fix dependency on FDW handler. 2026-03-19 15:00:58 -07:00
executor Tighten asserts on ParallelWorkerNumber 2026-03-14 15:31:29 +01:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:28 -07:00
jit Use CXXFLAGS instead of CFLAGS for linking C++ code 2026-02-26 12:06:58 -05:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix build breakage on Solaris-alikes with late-model GCC. 2025-07-23 15:44:29 -04:00
main Avoid possible crash within libsanitizer. 2025-11-05 11:09:30 -05:00
nodes Build whole-row Vars the same way during parsing and planning. 2025-03-12 11:47:19 -04:00
optimizer Fix computation of varnullingrels when translating appendrel Var 2026-02-20 18:04:26 +09:00
parser Fix possible incorrect column reference in ERROR message 2026-01-09 11:03:48 +13:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2026-02-23 14:02:22 +01:00
port Don't treat EINVAL from semget() as a hard failure. 2025-08-13 11:59:47 -04:00
postmaster Fix snapshot handling bug in recent BRIN fix 2025-11-04 20:31:43 +01:00
regex Avoid assertion due to disconnected NFA sub-graphs in regex parsing. 2024-11-15 18:23:38 -05:00
replication Fix premature NULL lag reporting in pg_stat_replication 2026-03-26 20:50:33 +09:00
rewrite Avoid rewriting data-modifying CTEs more than once. 2025-11-29 12:33:04 +00:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:23:59 -05:00
statistics Fix set of issues with extended statistics on expressions 2026-03-02 09:38:44 +09:00
storage Fix ProcWakeup() resetting wrong waitStart field. 2026-02-26 08:50:56 +09:00
tcop Check for CREATE privilege on the schema in CREATE STATISTICS. 2025-11-10 09:00:00 -06:00
tsearch Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
utils Fix datum_image_*()'s inability to detect sign-extension variations 2026-03-30 16:17:14 +13:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Fix make headerscheck 2024-04-27 11:38:41 +07:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00