The function table_tuple_fetch_row_version is designed within ivm_visible_in_prestate to retrieve a specific version of a tuple. Why not use the snapshot obtained during the IVM_immediate_before phase and directly utilize this snapshot in refresh_matview_datafill?
/* Create a QueryDesc, redirecting output to our tuple receiver */
queryDesc = CreateQueryDesc(plan, queryString,
GetActiveSnapshot(), InvalidSnapshot,
dest, NULL, queryEnv ? queryEnv: NULL, 0);
/* call ExecutorStart to prepare the plan for execution */
ExecutorStart(queryDesc, 0);
/* run the plan */
ExecutorRun(queryDesc, ForwardScanDirection, 0L, true);
processed = queryDesc->estate->es_processed;
if (resultTupleDesc)
*resultTupleDesc = CreateTupleDescCopy(queryDesc->tupDesc);
/* and clean up */
ExecutorFinish(queryDesc);
ExecutorEnd(queryDesc);
FreeQueryDesc(queryDesc);
The function
table_tuple_fetch_row_version
is designed withinivm_visible_in_prestate
to retrieve a specific version of a tuple. Why not use the snapshot obtained during theIVM_immediate_before
phase and directly utilize this snapshot inrefresh_matview_datafill
?GetActiveSnapshot
replace asentry->snapshot
?