On Tue, Nov 30, 2021 at 12:12 PM Andy Fan <zhihui.fan1...@gmail.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