|
|
|
@ -13,7 +13,7 @@ |
|
|
|
|
* |
|
|
|
|
* Copyright (c) 2001-2010, PostgreSQL Global Development Group |
|
|
|
|
* |
|
|
|
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.198 2010/01/19 14:11:30 mha Exp $ |
|
|
|
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.199 2010/01/28 14:25:41 mha Exp $ |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
#include "postgres.h" |
|
|
|
@ -271,6 +271,7 @@ static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len); |
|
|
|
|
static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len); |
|
|
|
|
static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len); |
|
|
|
|
static void pgstat_recv_resetsharedcounter(PgStat_MsgResetsharedcounter *msg, int len); |
|
|
|
|
static void pgstat_recv_resetsinglecounter(PgStat_MsgResetsinglecounter *msg, int len); |
|
|
|
|
static void pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len); |
|
|
|
|
static void pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len); |
|
|
|
|
static void pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len); |
|
|
|
@ -1187,6 +1188,32 @@ pgstat_reset_shared_counters(const char *target) |
|
|
|
|
pgstat_send(&msg, sizeof(msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_reset_single_counter() - |
|
|
|
|
* |
|
|
|
|
* Tell the statistics collector to reset a single counter. |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
void pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type) |
|
|
|
|
{ |
|
|
|
|
PgStat_MsgResetsinglecounter msg; |
|
|
|
|
|
|
|
|
|
if (pgStatSock < 0) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (!superuser()) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
|
|
|
|
errmsg("must be superuser to reset statistics counters"))); |
|
|
|
|
|
|
|
|
|
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSINGLECOUNTER); |
|
|
|
|
msg.m_databaseid = MyDatabaseId; |
|
|
|
|
msg.m_resettype = type; |
|
|
|
|
msg.m_objectid = objoid; |
|
|
|
|
|
|
|
|
|
pgstat_send(&msg, sizeof(msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_report_autovac() - |
|
|
|
|
* |
|
|
|
@ -2954,6 +2981,12 @@ PgstatCollectorMain(int argc, char *argv[]) |
|
|
|
|
len); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PGSTAT_MTYPE_RESETSINGLECOUNTER: |
|
|
|
|
pgstat_recv_resetsinglecounter( |
|
|
|
|
(PgStat_MsgResetsinglecounter *) &msg, |
|
|
|
|
len); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PGSTAT_MTYPE_AUTOVAC_START: |
|
|
|
|
pgstat_recv_autovac((PgStat_MsgAutovacStart *) &msg, len); |
|
|
|
|
break; |
|
|
|
@ -3928,6 +3961,30 @@ pgstat_recv_resetsharedcounter(PgStat_MsgResetsharedcounter *msg, int len) |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_recv_resetsinglecounter() - |
|
|
|
|
* |
|
|
|
|
* Reset a statistics for a single object |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
static void |
|
|
|
|
pgstat_recv_resetsinglecounter(PgStat_MsgResetsinglecounter *msg, int len) |
|
|
|
|
{ |
|
|
|
|
PgStat_StatDBEntry *dbentry; |
|
|
|
|
|
|
|
|
|
dbentry = pgstat_get_db_entry(msg->m_databaseid, false); |
|
|
|
|
|
|
|
|
|
if (!dbentry) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Remove object if it exists, ignore it if not */ |
|
|
|
|
if (msg->m_resettype == RESET_TABLE) |
|
|
|
|
(void) hash_search(dbentry->tables, (void *) &(msg->m_objectid), HASH_REMOVE, NULL); |
|
|
|
|
else if (msg->m_resettype == RESET_FUNCTION) |
|
|
|
|
(void) hash_search(dbentry->functions, (void *)&(msg->m_objectid), HASH_REMOVE, NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_recv_autovac() - |
|
|
|
|
* |
|
|
|
|