@ -38,9 +38,9 @@ typedef struct TwoPhasePgStatRecord
PgStat_Counter inserted_pre_truncdrop ;
PgStat_Counter updated_pre_truncdrop ;
PgStat_Counter deleted_pre_truncdrop ;
Oid t_ id; /* table's OID */
bool t_ shared; /* is it a shared catalog? */
bool t_truncdropped ; /* was the relation truncated/dropped? */
Oid id ; /* table's OID */
bool shared ; /* is it a shared catalog? */
bool truncdropped ; /* was the relation truncated/dropped? */
} TwoPhasePgStatRecord ;
@ -310,7 +310,7 @@ pgstat_report_analyze(Relation rel,
deadtuples - = trans - > tuples_updated + trans - > tuples_deleted ;
}
/* count stuff inserted by already-aborted subxacts, too */
deadtuples - = rel - > pgstat_info - > t_ counts. t_ delta_dead_tuples;
deadtuples - = rel - > pgstat_info - > counts . delta_dead_tuples ;
/* Since ANALYZE's counts are estimates, we could have underflowed */
livetuples = Max ( livetuples , 0 ) ;
deadtuples = Max ( deadtuples , 0 ) ;
@ -385,13 +385,13 @@ pgstat_count_heap_update(Relation rel, bool hot, bool newpage)
pgstat_info - > trans - > tuples_updated + + ;
/*
* t_t uples_hot_updated and t_ tuples_newpage_updated counters are
* tuples_hot_updated and tuples_newpage_updated counters are
* nontransactional , so just advance them
*/
if ( hot )
pgstat_info - > t_ counts. t_ tuples_hot_updated+ + ;
pgstat_info - > counts . tuples_hot_updated + + ;
else if ( newpage )
pgstat_info - > t_ counts. t_ tuples_newpage_updated+ + ;
pgstat_info - > counts . tuples_newpage_updated + + ;
}
}
@ -432,7 +432,7 @@ pgstat_count_truncate(Relation rel)
* update dead - tuples count
*
* The semantics of this are that we are reporting the nontransactional
* recovery of " delta " dead tuples ; so t_ delta_dead_tuples decreases
* recovery of " delta " dead tuples ; so delta_dead_tuples decreases
* rather than increasing , and the change goes straight into the per - table
* counter , not into transactional state .
*/
@ -443,7 +443,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
{
PgStat_TableStatus * pgstat_info = rel - > pgstat_info ;
pgstat_info - > t_ counts. t_ delta_dead_tuples - = delta ;
pgstat_info - > counts . delta_dead_tuples - = delta ;
}
}
@ -519,33 +519,33 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
if ( ! isCommit )
restore_truncdrop_counters ( trans ) ;
/* count attempted actions regardless of commit/abort */
tabstat - > t_ counts. t_ tuples_inserted + = trans - > tuples_inserted ;
tabstat - > t_ counts. t_ tuples_updated + = trans - > tuples_updated ;
tabstat - > t_ counts. t_ tuples_deleted + = trans - > tuples_deleted ;
tabstat - > counts . tuples_inserted + = trans - > tuples_inserted ;
tabstat - > counts . tuples_updated + = trans - > tuples_updated ;
tabstat - > counts . tuples_deleted + = trans - > tuples_deleted ;
if ( isCommit )
{
tabstat - > t_ counts. t_ truncdropped = trans - > truncdropped ;
tabstat - > counts . truncdropped = trans - > truncdropped ;
if ( trans - > truncdropped )
{
/* forget live/dead stats seen by backend thus far */
tabstat - > t_ counts. t_ delta_live_tuples = 0 ;
tabstat - > t_ counts. t_ delta_dead_tuples = 0 ;
tabstat - > counts . delta_live_tuples = 0 ;
tabstat - > counts . delta_dead_tuples = 0 ;
}
/* insert adds a live tuple, delete removes one */
tabstat - > t_ counts. t_ delta_live_tuples + =
tabstat - > counts . delta_live_tuples + =
trans - > tuples_inserted - trans - > tuples_deleted ;
/* update and delete each create a dead tuple */
tabstat - > t_ counts. t_ delta_dead_tuples + =
tabstat - > counts . delta_dead_tuples + =
trans - > tuples_updated + trans - > tuples_deleted ;
/* insert, update, delete each count as one change event */
tabstat - > t_ counts. t_ changed_tuples + =
tabstat - > counts . changed_tuples + =
trans - > tuples_inserted + trans - > tuples_updated +
trans - > tuples_deleted ;
}
else
{
/* inserted tuples are dead, deleted tuples are unaffected */
tabstat - > t_ counts. t_ delta_dead_tuples + =
tabstat - > counts . delta_dead_tuples + =
trans - > tuples_inserted + trans - > tuples_updated ;
/* an aborted xact generates no changed_tuple events */
}
@ -625,11 +625,11 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
/* first restore values obliterated by truncate/drop */
restore_truncdrop_counters ( trans ) ;
/* count attempted actions regardless of commit/abort */
tabstat - > t_ counts. t_ tuples_inserted + = trans - > tuples_inserted ;
tabstat - > t_ counts. t_ tuples_updated + = trans - > tuples_updated ;
tabstat - > t_ counts. t_ tuples_deleted + = trans - > tuples_deleted ;
tabstat - > counts . tuples_inserted + = trans - > tuples_inserted ;
tabstat - > counts . tuples_updated + = trans - > tuples_updated ;
tabstat - > counts . tuples_deleted + = trans - > tuples_deleted ;
/* inserted tuples are dead, deleted tuples are unaffected */
tabstat - > t_ counts. t_ delta_dead_tuples + =
tabstat - > counts . delta_dead_tuples + =
trans - > tuples_inserted + trans - > tuples_updated ;
tabstat - > trans = trans - > upper ;
pfree ( trans ) ;
@ -662,9 +662,9 @@ AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
record . inserted_pre_truncdrop = trans - > inserted_pre_truncdrop ;
record . updated_pre_truncdrop = trans - > updated_pre_truncdrop ;
record . deleted_pre_truncdrop = trans - > deleted_pre_truncdrop ;
record . t_ id = tabstat - > t_ id;
record . t_ shared = tabstat - > t_ shared;
record . t_t runcdropped = trans - > truncdropped ;
record . id = tabstat - > id ;
record . shared = tabstat - > shared ;
record . truncdropped = trans - > truncdropped ;
RegisterTwoPhaseRecord ( TWOPHASE_RM_PGSTAT_ID , 0 ,
& record , sizeof ( TwoPhasePgStatRecord ) ) ;
@ -706,24 +706,24 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
PgStat_TableStatus * pgstat_info ;
/* Find or create a tabstat entry for the rel */
pgstat_info = pgstat_prep_relation_pending ( rec - > t_ id, rec - > t_ shared) ;
pgstat_info = pgstat_prep_relation_pending ( rec - > id , rec - > shared ) ;
/* Same math as in AtEOXact_PgStat, commit case */
pgstat_info - > t_ counts. t_ tuples_inserted + = rec - > tuples_inserted ;
pgstat_info - > t_ counts. t_ tuples_updated + = rec - > tuples_updated ;
pgstat_info - > t_ counts. t_ tuples_deleted + = rec - > tuples_deleted ;
pgstat_info - > t_ counts. t_ truncdropped = rec - > t_ truncdropped;
if ( rec - > t_t runcdropped )
pgstat_info - > counts . tuples_inserted + = rec - > tuples_inserted ;
pgstat_info - > counts . tuples_updated + = rec - > tuples_updated ;
pgstat_info - > counts . tuples_deleted + = rec - > tuples_deleted ;
pgstat_info - > counts . truncdropped = rec - > truncdropped ;
if ( rec - > truncdropped )
{
/* forget live/dead stats seen by backend thus far */
pgstat_info - > t_ counts. t_ delta_live_tuples = 0 ;
pgstat_info - > t_ counts. t_ delta_dead_tuples = 0 ;
pgstat_info - > counts . delta_live_tuples = 0 ;
pgstat_info - > counts . delta_dead_tuples = 0 ;
}
pgstat_info - > t_ counts. t_ delta_live_tuples + =
pgstat_info - > counts . delta_live_tuples + =
rec - > tuples_inserted - rec - > tuples_deleted ;
pgstat_info - > t_ counts. t_ delta_dead_tuples + =
pgstat_info - > counts . delta_dead_tuples + =
rec - > tuples_updated + rec - > tuples_deleted ;
pgstat_info - > t_ counts. t_ changed_tuples + =
pgstat_info - > counts . changed_tuples + =
rec - > tuples_inserted + rec - > tuples_updated +
rec - > tuples_deleted ;
}
@ -742,19 +742,19 @@ pgstat_twophase_postabort(TransactionId xid, uint16 info,
PgStat_TableStatus * pgstat_info ;
/* Find or create a tabstat entry for the rel */
pgstat_info = pgstat_prep_relation_pending ( rec - > t_ id, rec - > t_ shared) ;
pgstat_info = pgstat_prep_relation_pending ( rec - > id , rec - > shared ) ;
/* Same math as in AtEOXact_PgStat, abort case */
if ( rec - > t_t runcdropped )
if ( rec - > truncdropped )
{
rec - > tuples_inserted = rec - > inserted_pre_truncdrop ;
rec - > tuples_updated = rec - > updated_pre_truncdrop ;
rec - > tuples_deleted = rec - > deleted_pre_truncdrop ;
}
pgstat_info - > t_ counts. t_ tuples_inserted + = rec - > tuples_inserted ;
pgstat_info - > t_ counts. t_ tuples_updated + = rec - > tuples_updated ;
pgstat_info - > t_ counts. t_ tuples_deleted + = rec - > tuples_deleted ;
pgstat_info - > t_ counts. t_ delta_dead_tuples + =
pgstat_info - > counts . tuples_inserted + = rec - > tuples_inserted ;
pgstat_info - > counts . tuples_updated + = rec - > tuples_updated ;
pgstat_info - > counts . tuples_deleted + = rec - > tuples_deleted ;
pgstat_info - > counts . delta_dead_tuples + =
rec - > tuples_inserted + rec - > tuples_updated ;
}
@ -785,7 +785,7 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
* Ignore entries that didn ' t accumulate any actual counts , such as
* indexes that were opened by the planner but not used .
*/
if ( memcmp ( & lstats - > t_ counts, & all_zeroes ,
if ( memcmp ( & lstats - > counts , & all_zeroes ,
sizeof ( PgStat_TableCounts ) ) = = 0 )
{
return true ;
@ -797,38 +797,38 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* add the values to the shared entry. */
tabentry = & shtabstats - > stats ;
tabentry - > numscans + = lstats - > t_ counts. t_ numscans;
if ( lstats - > t_ counts. t_ numscans)
tabentry - > numscans + = lstats - > counts . numscans ;
if ( lstats - > counts . numscans )
{
TimestampTz t = GetCurrentTransactionStopTimestamp ( ) ;
if ( t > tabentry - > lastscan )
tabentry - > lastscan = t ;
}
tabentry - > tuples_returned + = lstats - > t_ counts. t_ tuples_returned;
tabentry - > tuples_fetched + = lstats - > t_ counts. t_ tuples_fetched;
tabentry - > tuples_inserted + = lstats - > t_ counts. t_ tuples_inserted;
tabentry - > tuples_updated + = lstats - > t_ counts. t_ tuples_updated;
tabentry - > tuples_deleted + = lstats - > t_ counts. t_ tuples_deleted;
tabentry - > tuples_hot_updated + = lstats - > t_ counts. t_ tuples_hot_updated;
tabentry - > tuples_newpage_updated + = lstats - > t_ counts. t_ tuples_newpage_updated;
tabentry - > tuples_returned + = lstats - > counts . tuples_returned ;
tabentry - > tuples_fetched + = lstats - > counts . tuples_fetched ;
tabentry - > tuples_inserted + = lstats - > counts . tuples_inserted ;
tabentry - > tuples_updated + = lstats - > counts . tuples_updated ;
tabentry - > tuples_deleted + = lstats - > counts . tuples_deleted ;
tabentry - > tuples_hot_updated + = lstats - > counts . tuples_hot_updated ;
tabentry - > tuples_newpage_updated + = lstats - > counts . tuples_newpage_updated ;
/*
* If table was truncated / dropped , first reset the live / dead counters .
*/
if ( lstats - > t_ counts. t_ truncdropped)
if ( lstats - > counts . truncdropped )
{
tabentry - > live_tuples = 0 ;
tabentry - > dead_tuples = 0 ;
tabentry - > ins_since_vacuum = 0 ;
}
tabentry - > live_tuples + = lstats - > t_ counts. t_ delta_live_tuples;
tabentry - > dead_tuples + = lstats - > t_ counts. t_ delta_dead_tuples;
tabentry - > mod_since_analyze + = lstats - > t_ counts. t_ changed_tuples;
tabentry - > ins_since_vacuum + = lstats - > t_ counts. t_ tuples_inserted;
tabentry - > blocks_fetched + = lstats - > t_ counts. t_ blocks_fetched;
tabentry - > blocks_hit + = lstats - > t_ counts. t_ blocks_hit;
tabentry - > live_tuples + = lstats - > counts . delta_live_tuples ;
tabentry - > dead_tuples + = lstats - > counts . delta_dead_tuples ;
tabentry - > mod_since_analyze + = lstats - > counts . changed_tuples ;
tabentry - > ins_since_vacuum + = lstats - > counts . tuples_inserted ;
tabentry - > blocks_fetched + = lstats - > counts . blocks_fetched ;
tabentry - > blocks_hit + = lstats - > counts . blocks_hit ;
/* Clamp live_tuples in case of negative delta_live_tuples */
tabentry - > live_tuples = Max ( tabentry - > live_tuples , 0 ) ;
@ -839,13 +839,13 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* The entry was successfully flushed, add the same to database stats */
dbentry = pgstat_prep_database_pending ( dboid ) ;
dbentry - > tuples_returned + = lstats - > t_ counts. t_ tuples_returned;
dbentry - > tuples_fetched + = lstats - > t_ counts. t_ tuples_fetched;
dbentry - > tuples_inserted + = lstats - > t_ counts. t_ tuples_inserted;
dbentry - > tuples_updated + = lstats - > t_ counts. t_ tuples_updated;
dbentry - > tuples_deleted + = lstats - > t_ counts. t_ tuples_deleted;
dbentry - > blocks_fetched + = lstats - > t_ counts. t_ blocks_fetched;
dbentry - > blocks_hit + = lstats - > t_ counts. t_ blocks_hit;
dbentry - > tuples_returned + = lstats - > counts . tuples_returned ;
dbentry - > tuples_fetched + = lstats - > counts . tuples_fetched ;
dbentry - > tuples_inserted + = lstats - > counts . tuples_inserted ;
dbentry - > tuples_updated + = lstats - > counts . tuples_updated ;
dbentry - > tuples_deleted + = lstats - > counts . tuples_deleted ;
dbentry - > blocks_fetched + = lstats - > counts . blocks_fetched ;
dbentry - > blocks_hit + = lstats - > counts . blocks_hit ;
return true ;
}
@ -873,8 +873,8 @@ pgstat_prep_relation_pending(Oid rel_id, bool isshared)
isshared ? InvalidOid : MyDatabaseId ,
rel_id , NULL ) ;
pending = entry_ref - > pending ;
pending - > t_ id = rel_id ;
pending - > t_ shared = isshared ;
pending - > id = rel_id ;
pending - > shared = isshared ;
return pending ;
}