Re: "type with xxxx does not exist" when doing ExecMemoize() - Mailing list pgsql-hackers

From Tender Wang
Subject Re: "type with xxxx does not exist" when doing ExecMemoize()
Date
Msg-id CAHewXN=mzgHyFR2c0Z1hYAozYHWTdrEW90=oh0_Jn9kZVp6fYQ@mail.gmail.com
Whole thread Raw
In response to Re: "type with xxxx does not exist" when doing ExecMemoize()  (Andrei Lepikhov <a.lepikhov@postgrespro.ru>)
Responses Re: "type with xxxx does not exist" when doing ExecMemoize()
List 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  @Richard Guo @David Rowley .
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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Infinite loop in XLogPageRead() on standby
Next
From: Peter Smith
Date:
Subject: DOCS: Avoid using abbreviation "aka"