public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Rowley <[email protected]>
To: Tender Wang <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Fix "could not find memoization table entry"
Date: Tue, 24 Mar 2026 13:12:17 +1300
Message-ID: <CAApHDvrSSeLNWzQWWcLfZKWwHd=XocVs3abmTmvaSD_sx-dkNQ@mail.gmail.com> (raw)
In-Reply-To: <CAHewXNmcXVFdB9_WwA8Ez0P+m_TQy_KzYk5Ri5dvg+fuwjD_yw@mail.gmail.com>
References: <CAHewXNmcXVFdB9_WwA8Ez0P+m_TQy_KzYk5Ri5dvg+fuwjD_yw@mail.gmail.com>
On Mon, 23 Mar 2026 at 19:30, Tender Wang <[email protected]> wrote:
> Recently, I encountered an error: could not find memoization table
> The hkeys returned by datum_image_hash() are different, so we can't
> find the entry in the hash table.
>
> In the datum_image_hash(), if typByVal is true, calling
> result = hash_bytes((unsigned char *) &value, sizeof(Datum));
>
> I think we should use typLen here, not sizeof(Datum).
> I tried this way and didn't encounter any errors again.
The Datum values should be the same. You can't just compare the lowest
attlen bytes of a Datum.
It looks to me like the bug is in hash_numeric(). Seems like it has no
idea what type it's meant to return. hash_numeric_extended() doesn't
seem to be much better.
Do you still get the ERROR after patching with the attached?
David
Attachments:
[application/octet-stream] numeric.patch (899B, 2-numeric.patch)
download | inline diff:
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index d25b8ad505d..00f92d1dc7d 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -2724,7 +2724,7 @@ hash_numeric(PG_FUNCTION_ARGS)
/* If it's NaN or infinity, don't try to hash the rest of the fields */
if (NUMERIC_IS_SPECIAL(key))
- PG_RETURN_UINT32(0);
+ PG_RETURN_INT32(0);
weight = NUMERIC_WEIGHT(key);
start_offset = 0;
@@ -2756,7 +2756,7 @@ hash_numeric(PG_FUNCTION_ARGS)
* regardless of any other fields.
*/
if (NUMERIC_NDIGITS(key) == start_offset)
- PG_RETURN_UINT32(-1);
+ PG_RETURN_INT32(-1);
for (i = NUMERIC_NDIGITS(key) - 1; i >= 0; i--)
{
@@ -2782,7 +2782,7 @@ hash_numeric(PG_FUNCTION_ARGS)
/* Mix in the weight, via XOR */
result = digit_hash ^ weight;
- PG_RETURN_DATUM(result);
+ PG_RETURN_INT32(DatumGetInt32(result));
}
/*
view thread (9+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Fix "could not find memoization table entry"
In-Reply-To: <CAApHDvrSSeLNWzQWWcLfZKWwHd=XocVs3abmTmvaSD_sx-dkNQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox