mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add deadlock counter to pg_stat_database
Adds a counter that tracks number of deadlocks that occurred in each database to pg_stat_database. Magnus Hagander, reviewed by Jaime Casanova
This commit is contained in:
@@ -78,6 +78,7 @@ extern Datum pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_temp_files(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_temp_bytes(PG_FUNCTION_ARGS);
|
||||
@@ -1341,6 +1342,21 @@ pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_deadlocks);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user