I am working on adding some functionality to pgTAP, in order to detect unintended data modification side-effects.
The idea is to,
1. store the insert/update counts for all tables in a temporary table,
2. then run the test unit in a subtransaction,
3. then compare the new insert/update counts for all tables,
4. in addition to all the normal tests in the test unit, I will also keep a lookup table of how many inserts/updates to expect per table for each test unit.
I noticed pg_stat_clear_snapshot() doesn't affect pg_stat_get_tuples_inserted() within the same transaction.
Is there some other clever way of figuring out how many tuples were updated/inserted per table by the current transaction?
Alternatively, some way to force the top level transaction system to report the statistics for the current transaction?
I understand the clear benefits of making sure all the stat functions always return the same results in the same transaction, this is of course what you usually want to happen, but in my case I want the ability to override this.
Thankful for any ideas.
--
Best regards,
Joel Jacobson
Glue Finance
E: jj@xxxxxxxxxxxxxxx
T: +46 70 360 38 01
Postal address:
Glue Finance AB
Box 549
114 11 Stockholm
Sweden
Visiting address:
Glue Finance AB
Birger Jarlsgatan 14
114 34 Stockholm
Sweden
Joel Jacobson
Glue Finance
E: jj@xxxxxxxxxxxxxxx
T: +46 70 360 38 01
Postal address:
Glue Finance AB
Box 549
114 11 Stockholm
Sweden
Visiting address:
Glue Finance AB
Birger Jarlsgatan 14
114 34 Stockholm
Sweden