Thanks for everyone's insight so far!
my exception should be that the relcache should not be invalidated _after the first relation open_
in the executor (not the beginning of executorRun)。
s/exception/expectation.
To be more accurate, my expectation is for a single sql statement, after the first time I write data into
the relation, until the statement is completed or "aborted and RelationClose is called in ResourceOwnerRelease",
the relcache reset should never happen.
Since there are many places the write table access methods can be called like COPY, CAST, REFRESH MATVIEW,
VACUUM and ModifyNode, and it is possible that we can get error in each place, so I think RelationClose
should be a great places for exceptional case(at the same time, we should remember to destroy properly for non
exceptional case).
This might be not very professional since I bind some executor related data into a relcache related struct.
But it should be workable in my modified user case. The most professional method I can think out is adding
another resource type in ResourceOwner and let ResourceOwnerRelease to handle the exceptional cases.