"type with xxxx does not exist" when doing ExecMemoize()

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: "type with xxxx does not exist" when doing ExecMemoize()
Date: 2024-02-25 13:32:43
Message-ID: CAHewXNnT6N6UJkya0z-jLFzVxcwGfeRQSfhiwA+NyLg-x8iGew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

I met Memoize node failed When I used sqlancer test postgres.
database0=# explain select t0.c0 from t0 join t5 on t0.c0 = (t5.c0 - t5.c0);
QUERY PLAN
--------------------------------------------------------------------------------------
Nested Loop (cost=0.17..21.20 rows=4 width=32)
-> Seq Scan on t5 (cost=0.00..1.04 rows=4 width=14)
-> Memoize (cost=0.17..6.18 rows=1 width=32)
Cache Key: (t5.c0 - t5.c0)
Cache Mode: logical
-> Index Only Scan using t0_c0_key on t0 (cost=0.15..6.17 rows=1
width=32)
Index Cond: (c0 = (t5.c0 - t5.c0))
(7 rows)

database0=# select t0.c0 from t0 join t5 on t0.c0 = (t5.c0 - t5.c0);
ERROR: type with OID 2139062143 does not exist

How to repeat:
The attached database0.log (created by sqlancer) included statements to
repeat this issue.
Firstly, create database test;
then;
psql postgres
\i /xxx/database0.log

I analyzed aboved issue this weekend. And I found that
After called ResetExprContext() in MemoizeHash_hash(), the data in
mstate->probeslot was corrputed.

in prepare_probe_slot: the data as below:
(gdb) p *(DatumGetRangeTypeP(pslot->tts_values[0]))
$1 = {vl_len_ = 36, rangetypid = 3904}
after called ResetExprContext() in MemoizeHash_hash:
(gdb) p *(DatumGetRangeTypeP(pslot->tts_values[0]))
$3 = {vl_len_ = 264, rangetypid = 2139062143}

I think in prepare_probe_slot(), should called datumCopy as the attached
patch does.

Any thoughts? Thanks.
--
Tender Wang
OpenPie: https://en.openpie.com/

Attachment Content-Type Size
database0.log application/octet-stream 14.5 KB
0001-Fix-RangeType-oid-not-found-when-doing-Memoize.patch application/octet-stream 1.6 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-02-25 18:00:01 BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table
Previous Message Gena Makhomed 2024-02-25 08:50:15 systemd[1]: postgresql-16.service: Killing process 25992 (postgres) with signal SIGKILL.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-02-25 13:52:47 Re: Optimize planner memory consumption for huge arrays
Previous Message Julien Rouhaud 2024-02-25 12:48:59 Re: RangeTblEntry jumble omissions