postgres/src
David Rowley 6911f80379 Fix incorrect zero extension of Datum in JIT tuple deform code
When JIT deformed tuples (controlled via the jit_tuple_deforming GUC),
types narrower than sizeof(Datum) would be zero-extended up to Datum
width.  This wasn't the same as what fetch_att() does in the standard
tuple deforming code.  Logically the values are the same when fetching
via the DatumGet*() marcos, but negative numbers are not the same in
binary form.

In the report, the problem was manifesting itself with:

ERROR: could not find memoization table entry

in a query which had a "Cache Mode: binary" Memoize node. However, it's
currently unclear what else is affected.  Anything that uses
datum_image_eq() or datum_image_hash() on a Datum from a tuple deformed by
JIT could be affected, but it may not be limited to that.

The fix for this is simple: use signed extension instead of zero
extension.

Many thanks to Emmanuel Touzery for reporting this issue and providing
steps and backup which allowed the problem to easily be recreated.

Reported-by: Emmanuel Touzery <emmanuel.touzery@plandela.si>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/DB8P194MB08532256D5BAF894F241C06393F3A@DB8P194MB0853.EURP194.PROD.OUTLOOK.COM
Backpatch-through: 13
2025-10-23 13:11:02 +13:00
..
backend Fix incorrect zero extension of Datum in JIT tuple deform code 2025-10-23 13:11:02 +13:00
bin Fix memory leaks in scripts/vacuuming.c. 2025-10-22 15:19:19 -04:00
common Fix compiler warnings around _CRT_glob 2025-10-01 17:13:52 +02:00
fe_utils Introduce frontend API able to retrieve the contents of PG_VERSION 2025-10-14 16:20:42 +09:00
include Fix type of infomask parameter in htup_details.h functions. 2025-10-22 16:47:38 -05:00
interfaces ecpg: check return value of replace_variables() 2025-10-17 10:03:15 +02:00
makefiles Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
pl Remove useless pstrdup() calls. 2025-10-22 16:22:52 -04:00
port Fix POSIX compliance in pgwin32_unsetenv() for "name" argument 2025-10-21 08:05:28 +09:00
template Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
test Add error_on_null(), checking if the input is the null value 2025-10-22 09:55:17 +09:00
timezone Generate GUC tables from .dat file 2025-09-03 09:45:17 +02:00
tools Add reminder to create .abi-compliance-history. 2025-10-21 12:23:23 -05:00
tutorial Fix compile of src/tutorial/funcs.c 2025-10-07 10:45:57 +02:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
Makefile.shlib Use exported symbols list on macOS for loadable modules as well 2025-06-10 07:04:43 +02:00
meson.build
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00