mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Manual cleanup and pgindent of pgstat and bufmgr related code
This is in preparation for commiting a larger patch series in the area. Discussion: https://postgr.es/m/CAAKRu_bHwGEbzNxxy+MQDkrsgog6aO6iUvajJ4d6PD98gFU7+w@mail.gmail.com
This commit is contained in:
parent
d46a9792a8
commit
250c8ee07e
@ -516,7 +516,7 @@ PrefetchSharedBuffer(SMgrRelation smgr_reln,
|
|||||||
|
|
||||||
/* create a tag so we can lookup the buffer */
|
/* create a tag so we can lookup the buffer */
|
||||||
InitBufferTag(&newTag, &smgr_reln->smgr_rlocator.locator,
|
InitBufferTag(&newTag, &smgr_reln->smgr_rlocator.locator,
|
||||||
forkNum, blockNum);
|
forkNum, blockNum);
|
||||||
|
|
||||||
/* determine its hash code and partition lock ID */
|
/* determine its hash code and partition lock ID */
|
||||||
newHash = BufTableHashCode(&newTag);
|
newHash = BufTableHashCode(&newTag);
|
||||||
@ -3297,8 +3297,8 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelationBuffers, an unlocked precheck should be
|
* As in DropRelationBuffers, an unlocked precheck should be safe and
|
||||||
* safe and saves some cycles.
|
* saves some cycles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!use_bsearch)
|
if (!use_bsearch)
|
||||||
@ -3425,8 +3425,8 @@ DropDatabaseBuffers(Oid dbid)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelationBuffers, an unlocked precheck should be
|
* As in DropRelationBuffers, an unlocked precheck should be safe and
|
||||||
* safe and saves some cycles.
|
* saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (bufHdr->tag.dbOid != dbid)
|
if (bufHdr->tag.dbOid != dbid)
|
||||||
continue;
|
continue;
|
||||||
@ -3572,8 +3572,8 @@ FlushRelationBuffers(Relation rel)
|
|||||||
bufHdr = GetBufferDescriptor(i);
|
bufHdr = GetBufferDescriptor(i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelationBuffers, an unlocked precheck should be
|
* As in DropRelationBuffers, an unlocked precheck should be safe and
|
||||||
* safe and saves some cycles.
|
* saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (!BufTagMatchesRelFileLocator(&bufHdr->tag, &rel->rd_locator))
|
if (!BufTagMatchesRelFileLocator(&bufHdr->tag, &rel->rd_locator))
|
||||||
continue;
|
continue;
|
||||||
@ -3645,8 +3645,8 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelationBuffers, an unlocked precheck should be
|
* As in DropRelationBuffers, an unlocked precheck should be safe and
|
||||||
* safe and saves some cycles.
|
* saves some cycles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!use_bsearch)
|
if (!use_bsearch)
|
||||||
@ -3880,8 +3880,8 @@ FlushDatabaseBuffers(Oid dbid)
|
|||||||
bufHdr = GetBufferDescriptor(i);
|
bufHdr = GetBufferDescriptor(i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelationBuffers, an unlocked precheck should be
|
* As in DropRelationBuffers, an unlocked precheck should be safe and
|
||||||
* safe and saves some cycles.
|
* saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (bufHdr->tag.dbOid != dbid)
|
if (bufHdr->tag.dbOid != dbid)
|
||||||
continue;
|
continue;
|
||||||
|
@ -610,8 +610,8 @@ AtProcExit_LocalBuffers(void)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We shouldn't be holding any remaining pins; if we are, and assertions
|
* We shouldn't be holding any remaining pins; if we are, and assertions
|
||||||
* aren't enabled, we'll fail later in DropRelationBuffers while
|
* aren't enabled, we'll fail later in DropRelationBuffers while trying to
|
||||||
* trying to drop the temp rels.
|
* drop the temp rels.
|
||||||
*/
|
*/
|
||||||
CheckForLocalBufferLeaks();
|
CheckForLocalBufferLeaks();
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ pgstat_discard_stats(void)
|
|||||||
ereport(DEBUG2,
|
ereport(DEBUG2,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg_internal("unlinked permanent statistics file \"%s\"",
|
errmsg_internal("unlinked permanent statistics file \"%s\"",
|
||||||
PGSTAT_STAT_PERMANENT_FILENAME)));
|
PGSTAT_STAT_PERMANENT_FILENAME)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -986,6 +986,7 @@ pgstat_build_snapshot(void)
|
|||||||
|
|
||||||
entry->data = MemoryContextAlloc(pgStatLocal.snapshot.context,
|
entry->data = MemoryContextAlloc(pgStatLocal.snapshot.context,
|
||||||
kind_info->shared_size);
|
kind_info->shared_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Acquire the LWLock directly instead of using
|
* Acquire the LWLock directly instead of using
|
||||||
* pg_stat_lock_entry_shared() which requires a reference.
|
* pg_stat_lock_entry_shared() which requires a reference.
|
||||||
|
@ -783,6 +783,7 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
|
|||||||
if (lstats->t_counts.t_numscans)
|
if (lstats->t_counts.t_numscans)
|
||||||
{
|
{
|
||||||
TimestampTz t = GetCurrentTransactionStopTimestamp();
|
TimestampTz t = GetCurrentTransactionStopTimestamp();
|
||||||
|
|
||||||
if (t > tabentry->lastscan)
|
if (t > tabentry->lastscan)
|
||||||
tabentry->lastscan = t;
|
tabentry->lastscan = t;
|
||||||
}
|
}
|
||||||
|
@ -906,7 +906,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
|
|||||||
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
||||||
|
|
||||||
PG_RETURN_DATUM(DirectFunctionCall1(inet_in,
|
PG_RETURN_DATUM(DirectFunctionCall1(inet_in,
|
||||||
CStringGetDatum(remote_host)));
|
CStringGetDatum(remote_host)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
|
@ -476,6 +476,7 @@ extern void pgstat_report_connect(Oid dboid);
|
|||||||
|
|
||||||
extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dboid);
|
extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dboid);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions in pgstat_function.c
|
* Functions in pgstat_function.c
|
||||||
*/
|
*/
|
||||||
|
@ -626,6 +626,7 @@ extern void pgstat_wal_snapshot_cb(void);
|
|||||||
extern bool pgstat_subscription_flush_cb(PgStat_EntryRef *entry_ref, bool nowait);
|
extern bool pgstat_subscription_flush_cb(PgStat_EntryRef *entry_ref, bool nowait);
|
||||||
extern void pgstat_subscription_reset_timestamp_cb(PgStatShared_Common *header, TimestampTz ts);
|
extern void pgstat_subscription_reset_timestamp_cb(PgStatShared_Common *header, TimestampTz ts);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions in pgstat_xact.c
|
* Functions in pgstat_xact.c
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user