75 dstshstats->
stats = *srcstats;
94 char relkind = rel->
rd_rel->relkind;
99 if (!RELKIND_HAS_STORAGE(relkind) && relkind != RELKIND_PARTITIONED_TABLE)
139 rel->
rd_rel->relisshared);
197 if (pgstat_info->
trans &&
228 dboid, tableoid,
false);
231 tabentry = &shtabentry->
stats;
302 rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
308 livetuples -=
trans->tuples_inserted -
trans->tuples_deleted;
309 deadtuples -=
trans->tuples_updated +
trans->tuples_deleted;
314 livetuples =
Max(livetuples, 0);
315 deadtuples =
Max(deadtuples, 0);
326 tabentry = &shtabentry->
stats;
377 Assert(!(hot && newpage));
504 *tablestatus = *tabentry;
511 tablestatus->
trans = NULL;
547 tabstat =
trans->parent;
559 if (
trans->truncdropped)
567 trans->tuples_inserted -
trans->tuples_deleted;
570 trans->tuples_updated +
trans->tuples_deleted;
573 trans->tuples_inserted +
trans->tuples_updated +
574 trans->tuples_deleted;
580 trans->tuples_inserted +
trans->tuples_updated;
583 tabstat->
trans = NULL;
604 next_trans =
trans->next;
606 tabstat =
trans->parent;
611 if (
trans->upper &&
trans->upper->nest_level == nestDepth - 1)
613 if (
trans->truncdropped)
618 trans->upper->tuples_inserted =
trans->tuples_inserted;
619 trans->upper->tuples_updated =
trans->tuples_updated;
620 trans->upper->tuples_deleted =
trans->tuples_deleted;
624 trans->upper->tuples_inserted +=
trans->tuples_inserted;
625 trans->upper->tuples_updated +=
trans->tuples_updated;
626 trans->upper->tuples_deleted +=
trans->tuples_deleted;
646 trans->nest_level = nestDepth - 1;
664 trans->tuples_inserted +
trans->tuples_updated;
687 tabstat =
trans->parent;
696 record.
id = tabstat->id;
697 record.
shared = tabstat->shared;
722 tabstat =
trans->parent;
723 tabstat->
trans = NULL;
819 if (memcmp(&lstats->
counts, &all_zeroes,
829 tabentry = &shtabstats->
stats;
907 pending->
id = rel_id;
908 pending->
shared = isshared;
932 trans->nest_level = nest_level;
934 trans->parent = pgstat_info;
948 if (pgstat_info->
trans == NULL ||
965 if (!
trans->truncdropped || is_drop)
967 trans->inserted_pre_truncdrop =
trans->tuples_inserted;
968 trans->updated_pre_truncdrop =
trans->tuples_updated;
969 trans->deleted_pre_truncdrop =
trans->tuples_deleted;
970 trans->truncdropped =
true;
980 if (
trans->truncdropped)
982 trans->tuples_inserted =
trans->inserted_pre_truncdrop;
983 trans->tuples_updated =
trans->updated_pre_truncdrop;
984 trans->tuples_deleted =
trans->deleted_pre_truncdrop;
TimestampTz GetCurrentTimestamp(void)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
bool IsSharedRelation(Oid relationId)
if(TABLE==NULL||TABLE_index==NULL)
MemoryContext TopTransactionContext
void pfree(void *pointer)
void * MemoryContextAllocZero(MemoryContext context, Size size)
#define AmAutoVacuumWorkerProcess()
PgStat_EntryRef * pgstat_fetch_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
#define pgstat_should_count_relation(rel)
#define PGSTAT_KIND_RELATION
PgStat_StatDBEntry * pgstat_prep_database_pending(Oid dboid)
void pgstat_flush_io(bool nowait)
struct TwoPhasePgStatRecord TwoPhasePgStatRecord
static void ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info)
void pgstat_copy_relation_stats(Relation dst, Relation src)
void pgstat_unlink_relation(Relation rel)
void pgstat_count_heap_update(Relation rel, bool hot, bool newpage)
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
static PgStat_TableStatus * pgstat_prep_relation_pending(Oid rel_id, bool isshared)
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
void pgstat_assoc_relation(Relation rel)
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
static void save_truncdrop_counters(PgStat_TableXactStatus *trans, bool is_drop)
void AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
void pgstat_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
static void add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level)
bool pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry_ext(bool shared, Oid reloid)
void pgstat_create_relation(Relation rel)
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
void pgstat_update_heap_dead_tuples(Relation rel, int delta)
void pgstat_count_heap_delete(Relation rel)
void pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
void AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples)
void PostPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
void pgstat_count_truncate(Relation rel)
static void restore_truncdrop_counters(PgStat_TableXactStatus *trans)
void pgstat_drop_relation(Relation rel)
void AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, int nestDepth)
void pgstat_init_relation(Relation rel)
void pgstat_relation_delete_pending_cb(PgStat_EntryRef *entry_ref)
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
PgStat_EntryRef * pgstat_get_entry_ref_locked(PgStat_Kind kind, Oid dboid, uint64 objid, bool nowait)
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
void pgstat_drop_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)
void pgstat_create_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)
PgStat_SubXactStatus * pgstat_get_xact_stack_level(int nest_level)
#define RelationGetRelid(relation)
PgStat_StatTabEntry stats
PgStatShared_Common * shared_stats
PgStatShared_HashEntry * shared_entry
PgStat_Counter tuples_updated
PgStat_Counter tuples_inserted
PgStat_Counter tuples_returned
PgStat_Counter blocks_hit
PgStat_Counter blocks_fetched
PgStat_Counter tuples_deleted
PgStat_Counter tuples_fetched
PgStat_Counter vacuum_count
PgStat_Counter tuples_fetched
PgStat_Counter ins_since_vacuum
PgStat_Counter blocks_hit
PgStat_Counter mod_since_analyze
TimestampTz last_autovacuum_time
PgStat_Counter analyze_count
PgStat_Counter tuples_deleted
PgStat_Counter tuples_hot_updated
PgStat_Counter tuples_updated
PgStat_Counter live_tuples
PgStat_Counter autovacuum_count
TimestampTz last_analyze_time
PgStat_Counter dead_tuples
PgStat_Counter autoanalyze_count
PgStat_Counter blocks_fetched
PgStat_Counter tuples_returned
TimestampTz last_autoanalyze_time
PgStat_Counter tuples_inserted
PgStat_Counter tuples_newpage_updated
TimestampTz last_vacuum_time
PgStat_TableXactStatus * first
PgStat_Counter blocks_hit
PgStat_Counter tuples_hot_updated
PgStat_Counter tuples_returned
PgStat_Counter tuples_inserted
PgStat_Counter delta_live_tuples
PgStat_Counter changed_tuples
PgStat_Counter tuples_updated
PgStat_Counter blocks_fetched
PgStat_Counter tuples_fetched
PgStat_Counter tuples_newpage_updated
PgStat_Counter delta_dead_tuples
PgStat_Counter tuples_deleted
PgStat_TableCounts counts
struct PgStat_TableXactStatus * trans
PgStat_Counter tuples_inserted
PgStat_Counter tuples_updated
PgStat_Counter tuples_deleted
struct PgStat_TableStatus * pgstat_info
PgStat_Counter deleted_pre_truncdrop
PgStat_Counter inserted_pre_truncdrop
PgStat_Counter updated_pre_truncdrop
PgStat_Counter tuples_deleted
PgStat_Counter tuples_inserted
PgStat_Counter tuples_updated
void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info, const void *data, uint32 len)
#define TWOPHASE_RM_PGSTAT_ID
int GetCurrentTransactionNestLevel(void)
TimestampTz GetCurrentTransactionStopTimestamp(void)
static zic_t trans[TZ_MAX_LEAPS]