Re: "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>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
Subject: Re: "type with xxxx does not exist" when doing ExecMemoize()
Date: 2024-02-29 05:25:20
Message-ID: CAHewXN=mzgHyFR2c0Z1hYAozYHWTdrEW90=oh0_Jn9kZVp6fYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

I read Memoize code and how other node use ResetExprContext() recently.

The comments about per_tuple_memory said that :

* ecxt_per_tuple_memory is a short-term context for expression results.
* As the name suggests, it will typically be reset once per tuple,
* before we begin to evaluate expressions for that tuple. Each
* ExprContext normally has its very own per-tuple memory context.

So ResetExprContext() should called once per tuple, but not in Hash and
Equal function just as Richard said before.
In ExecResult() and ExecProjectSet(), they call ResetExprContext() once
when enter these functions.
So I think ExecMemoize() can do the same way.

The attached patch includes below modifications:
1.
When I read the code in nodeMemoize.c, I found a typos: outer should be
inner,
if I don't misunderstand the intend of Memoize.

2.
I found that almost executor node call CHECK_FOR_INTERRUPTS(), so I add it.
Is it right to add it for ExecMemoize()?

3.
I remove ResetExprContext() from Hash and Equal funciton. And I call it
when enter
ExecMemoize() just like ExecPrejectSet() does.
ExecQualAndReset() is replaed with ExecQual().

4.
This patch doesn't include test case. I use the Andrei's test case, but I
don't repeat the aboved issue.
I may need to spend some more time to think about how to repeat this issue
easily.

So, what do you think about the one proposed in v5? @Andrei Lepikhov
<a(dot)lepikhov(at)postgrespro(dot)ru> @Richard Guo <guofenglinux(at)gmail(dot)com> @David
Rowley <dgrowleyml(at)gmail(dot)com> .
I don't want to continue to do work based on v3 patch. As Andrei Lepikhov
said, using mstate->tableContext for probeslot
is not good. v5 looks more simple.

Attachment Content-Type Size
v5-0001-Fix-wrong-used-ResetExprContext-in-ExecMemoize.patch application/octet-stream 2.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2024-02-29 05:46:07 Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table
Previous Message Andrew Dunstan 2024-02-29 04:47:42 Re: Feature bug dumpall CREATE ROLE postgres

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2024-02-29 05:51:50 DOCS: Avoid using abbreviation "aka"
Previous Message Michael Paquier 2024-02-29 05:05:15 Re: Infinite loop in XLogPageRead() on standby