Re: ERROR: XX000: could not find memoization table entry (reproducible) - Mailing list pgsql-bugs

From David Rowley
Subject Re: ERROR: XX000: could not find memoization table entry (reproducible)
Date
Msg-id CAApHDvpeEg2abJvNmHs9Lqtb_5QcC74j18S99fKvqGmjwzaPYg@mail.gmail.com
Whole thread Raw
In response to Re: ERROR: XX000: could not find memoization table entry (reproducible)  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: ERROR: XX000: could not find memoization table entry (reproducible)
List pgsql-bugs
On Thu, 23 Oct 2025 at 00:27, David Rowley <dgrowleyml@gmail.com> wrote:
> v_tmp_loaddata = LLVMBuildZExt(b, v_tmp_loaddata, TypeDatum, "");

> Will look more tomorrow.

This seems to be a 1 liner fix. Basically, the zero extend should be a
signed extend. i.e, use LLVMBuildSExt().

Using [1] to get the extra debug output.

set jit_Above_Cost=0;
drop table if exists b;
create table b (a char, b smallint, c int);
insert into b values('-100'::char,-123,-1234);
insert into b values('123'::char,1234,12345);
set jit=1;
select * from b where c <> 0;
set jit=0;
select * from b where c <> 0;

With the patch, I get:

NOTICE:  scan tuple = (a,b,c) (-,-123,-1234)
(124262785167352,18446744073709551493,18446744073709550382)
NOTICE:  scan tuple = (a,b,c) (1,1234,12345) (124262785167320,1234,12345)
 a |  b   |   c
---+------+-------
 - | -123 | -1234
 1 | 1234 | 12345
(2 rows)

SET
NOTICE:  scan tuple = (a,b,c) (-,-123,-1234)
(124262785167352,18446744073709551493,18446744073709550382)
NOTICE:  scan tuple = (a,b,c) (1,1234,12345) (124262785167320,1234,12345)
 a |  b   |   c
---+------+-------
 - | -123 | -1234
 1 | 1234 | 12345
(2 rows)

And without, I get:

NOTICE:  scan tuple = (a,b,c) (-,-123,-1234) (135890207272952,65413,4294966062)
NOTICE:  scan tuple = (a,b,c) (1,1234,12345) (135890207272920,1234,12345)
 a |  b   |   c
---+------+-------
 - | -123 | -1234
 1 | 1234 | 12345
(2 rows)

SET
NOTICE:  scan tuple = (a,b,c) (-,-123,-1234)
(135890207272952,18446744073709551493,18446744073709550382)
NOTICE:  scan tuple = (a,b,c) (1,1234,12345) (135890207272920,1234,12345)
 a |  b   |   c
---+------+-------
 - | -123 | -1234
 1 | 1234 | 12345
(2 rows)

David

[1] https://www.postgresql.org/message-id/attachment/183414/debug_scan_data.diff



pgsql-bugs by date:

Previous
From: Markus KARG
Date:
Subject: Re: Version 18.0 of postgres image in dockerhub - container crashes when starting up
Next
From: David Rowley
Date:
Subject: Re: ERROR: XX000: could not find memoization table entry (reproducible)