Here's v0.5. (Why did you use that weird decimal versioning scheme? You could just say "v4" and save a couple of keystrokes). This patch makes perfect sense to me now. I was ready to commit, but I checked the regression test you added and noticed that you're only reading results for the last set of operations because they all use the same table and so each new set clobbers the values for the previous one. So I modified them to use one table for each set, and report the counters for all tables. In doing this I noticed that the one for trunc_stats_test3 is at odds with what your comment in the .sql file says; would you review it please? Thanks.
(I didn't update the expected file.)
BTW you forgot to update expected/prepared_xact_1.out, for the case when prep xacts are disabled.
If some other committer decides to give this a go, please remember to bump catversion before pushing.
Alex, this patch seems nicely backed. Could you review the changes of Alvaro? This thread is waiting for your input for 3 weeks. --