We have to add three more functions to eXtensible Transaction Manager API (XTM):
/* * Calculate transaction state size. This method is invoked by EstimateTransactionStateSpace to copy transaction * state to parallel workers */ size_t (*GetTransactionStateSize)(void);
/* * Serialize transaction state */ void (*SerializeTransactionState)(void* ctx);
/* * Deserialize transaction state */ void (*DeserializeTransactionState)(void* ctx);
In above proposal, are you suggesting to change the existing API's as well, because the parameters of function pointers don't match with exiting API's. I think it is better to consider this along with the overall XTM API.
Sorry, but right now I have not replaced existed functions EstimateTransactionStateSpace/SerializeTransactionState/StartParallelWorkerTransaction with XTM indirect calls. If was my original intention, but these functions access static variable CurrentTransactionState defined in xact.c. So if user-defined TM wants to override this functions, it will have to invoke original functions to save/restore CurrentTransactionState. It is not convenient. This is why three XTM functions above are now called by existed xact funcations to save additional state, for example:
Sounds reasonable, although one might want to have a hook for EndParallelWorkerTransaction as well. I think here larger question is whether there is a consensus on getting XTM API in core.