I have the problem to access modified data (updates and inserts) in a prepared statement before a commit/rollback. For example consider the following block:
BEGIN;
do some update;
do some insert;
PREPARE 'transaction1';
After executing the 'prepare' command (and before executing the 'commit' command), I neeed to fetch the data modified by the transaction 'transaction1'. I can fetch the rows with the old values that are modified by the transaction (using the xmax field), howewer I need also the values that the transaction will write into these rows when it commits.
Postgres needs to store these values somewhere in order to commit the transaction when it is required, so my question is: how can I access these values?
BEGIN; update tableA set columnA=10 where id=0; PREPARE transactionAnow in order to decide if commit or rollback the transactionA I need to know the new value of columnA in the row updated by transactionA. E.g. if transactionA update tableA.columnA to a value <= 10 then commit transactionA else rollback transactionA. The problem is that values updated by the transactionA are not visible before transactionA is committed. How can I fetch them? Thanks for your help - Pierpaolo Cincilla