How to access insert/update counts for aborted subtransaction (or current transaction)

From: Joel Jacobson <joel(at)gluefinance(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to access insert/update counts for aborted subtransaction (or current transaction)
Date: 2010-05-04 16:04:40
Message-ID: l2n8bdec0841005040904ne85899deg9527e21dc6d642fe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

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(at)gluefinance(dot)com
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

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-05-04 16:05:02 Re: GeSHi module for Postgresql?
Previous Message Alvaro Herrera 2010-05-04 16:02:56 Re: GeSHi module for Postgresql?