Re: Can I assume relation would not be invalid during from ExecutorRun to ExecutorEnd

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Can I assume relation would not be invalid during from ExecutorRun to ExecutorEnd
Date: 2021-11-30 06:52:25
Message-ID: CAFiTN-uPp5MTcUfU_MPXjSoy3zhOrYiErwMNuhKYrxN5AxnJoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 30, 2021 at 12:12 PM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
>>
>>
>> You will see there are many pointers also in
>> RelationData but we ensure before we access them they are initialized,
>
>
> The initialized values are not much helpful in the cases I provided here.
>
> What do you think about this question?
>
> 2. _If_ the relation can be reset after we open it during Executor code, then would the
> relation (RelationData *) pointed memory still validated after the relcache reset? For example
>
> CREATE TABLE t(a int);
> INSERT INTO t VALUES(1), (2);
>
> UPDATE t set a = 100;
>
> We need to update 2 tuples in the update statement, if the relcache is reset after the first tuple is
> updated, can we still use the previous (RelationData *) to do the 2nd update? This is just
> a common example. If you would say, in this case the relcache can't be reset, then the question
> come back to what situation the relcache can be reset between the first time I open it during execution
> code and the end of execution code. I think we have some talks about this at [1].

IMHO, if you are doing an update then you must be already holding the
relation lock, so even if you call some UDF (e.g. UPDATE t set a = 100
WHERE x= UDF()) and it accepts the invalidation it wont affect your
RelationData because you are already holding the lock so parallelly
there could not be any DDL on this particular relation so this recache
entry should not be invalidated at least in the example you have
given.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2021-11-30 07:00:41 Update stale code comment in CheckpointerMain()
Previous Message Andy Fan 2021-11-30 06:42:37 Re: Can I assume relation would not be invalid during from ExecutorRun to ExecutorEnd