sraoss / pgsql-ivm

IVM (Incremental View Maintenance) development for PostgreSQL
Other
127 stars 12 forks source link

ivm_visible_in_prestate usage #156

Closed yjhjstz closed 12 months ago

yjhjstz commented 1 year ago

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);

GetActiveSnapshot replace as entry->snapshot ?