mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Add a function pg_stat_clear_snapshot() that discards any statistics snapshot
already collected in the current transaction; this allows plpgsql functions to watch for stats updates even though they are confined to a single transaction. Use this instead of the previous kluge involving pg_stat_file() to wait for the stats collector to update in the stats regression test. Internally, decouple storage of stats snapshots from transaction boundaries; they'll now stick around until someone calls pgstat_clear_snapshot --- which xact.c still does at transaction end, to maintain the previous behavior. This makes the logic a lot cleaner, at the price of a couple dozen cycles per transaction exit.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.232 2007/02/01 19:10:25 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.233 2007/02/07 23:11:29 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1628,6 +1628,7 @@ CommitTransaction(void)
|
||||
AtEOXact_Namespace(true);
|
||||
/* smgrcommit already done */
|
||||
AtEOXact_Files();
|
||||
pgstat_clear_snapshot();
|
||||
pgstat_count_xact_commit();
|
||||
pgstat_report_txn_timestamp(0);
|
||||
|
||||
@ -1844,6 +1845,7 @@ PrepareTransaction(void)
|
||||
AtEOXact_Namespace(true);
|
||||
/* smgrcommit already done */
|
||||
AtEOXact_Files();
|
||||
pgstat_clear_snapshot();
|
||||
|
||||
CurrentResourceOwner = NULL;
|
||||
ResourceOwnerDelete(TopTransactionResourceOwner);
|
||||
@ -1995,6 +1997,7 @@ AbortTransaction(void)
|
||||
AtEOXact_Namespace(false);
|
||||
smgrabort();
|
||||
AtEOXact_Files();
|
||||
pgstat_clear_snapshot();
|
||||
pgstat_count_xact_rollback();
|
||||
pgstat_report_txn_timestamp(0);
|
||||
|
||||
|
Reference in New Issue
Block a user