mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Add start time to pg_stat_activity
Neil Conway
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.239 2003/01/08 22:06:20 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.240 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -961,7 +961,8 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
|
||||
attStruct->attstattarget = 0;
|
||||
|
||||
/* Change the column name to something that isn't likely to conflict */
|
||||
snprintf(newattname, NAMEDATALEN, "........pg.dropped.%d........", attnum);
|
||||
snprintf(newattname, sizeof(newattname),
|
||||
"........pg.dropped.%d........", attnum);
|
||||
namestrcpy(&(attStruct->attname), newattname);
|
||||
|
||||
simple_heap_update(attr_rel, &tuple->t_self, tuple);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.48 2003/03/06 22:54:49 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.49 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1598,7 +1598,7 @@ InitTempTableNamespace(void)
|
||||
elog(ERROR, "%s: not authorized to create temp tables",
|
||||
DatabaseName);
|
||||
|
||||
snprintf(namespaceName, NAMEDATALEN, "pg_temp_%d", MyBackendId);
|
||||
snprintf(namespaceName, sizeof(namespaceName), "pg_temp_%d", MyBackendId);
|
||||
|
||||
namespaceId = GetSysCacheOid(NAMESPACENAME,
|
||||
CStringGetDatum(namespaceName),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.106 2003/03/03 04:37:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.107 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -405,7 +405,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid)
|
||||
* namespace from the old, or we will have problems with the TEMP
|
||||
* status of temp tables.
|
||||
*/
|
||||
snprintf(NewHeapName, NAMEDATALEN, "pg_temp_%u", tableOid);
|
||||
snprintf(NewHeapName, sizeof(NewHeapName), "pg_temp_%u", tableOid);
|
||||
|
||||
OIDNewHeap = make_new_heap(tableOid, NewHeapName);
|
||||
/*
|
||||
@@ -625,7 +625,8 @@ rebuild_indexes(Oid OIDOldHeap, List *indexes)
|
||||
Relation pg_index;
|
||||
|
||||
/* Create the new index under a temporary name */
|
||||
snprintf(newIndexName, NAMEDATALEN, "pg_temp_%u", attrs->indexOID);
|
||||
snprintf(newIndexName, sizeof(newIndexName),
|
||||
"pg_temp_%u", attrs->indexOID);
|
||||
|
||||
/*
|
||||
* The new index will have primary and constraint status set to
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.91 2003/02/13 05:25:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.92 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -406,7 +406,7 @@ nextval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, maxv);
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, maxv);
|
||||
elog(ERROR, "%s.nextval: reached MAXVALUE (%s)",
|
||||
sequence->relname, buf);
|
||||
}
|
||||
@@ -427,7 +427,7 @@ nextval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, minv);
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, minv);
|
||||
elog(ERROR, "%s.nextval: reached MINVALUE (%s)",
|
||||
sequence->relname, buf);
|
||||
}
|
||||
@@ -569,9 +569,9 @@ do_setval(RangeVar *sequence, int64 next, bool iscalled)
|
||||
bufm[100],
|
||||
bufx[100];
|
||||
|
||||
snprintf(bufv, 100, INT64_FORMAT, next);
|
||||
snprintf(bufm, 100, INT64_FORMAT, seq->min_value);
|
||||
snprintf(bufx, 100, INT64_FORMAT, seq->max_value);
|
||||
snprintf(bufv, sizeof(bufv), INT64_FORMAT, next);
|
||||
snprintf(bufm, sizeof(bufm), INT64_FORMAT, seq->min_value);
|
||||
snprintf(bufx, sizeof(bufx), INT64_FORMAT, seq->max_value);
|
||||
elog(ERROR, "%s.setval: value %s is out of bounds (%s,%s)",
|
||||
sequence->relname, bufv, bufm, bufx);
|
||||
}
|
||||
@@ -861,8 +861,8 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
||||
char bufm[100],
|
||||
bufx[100];
|
||||
|
||||
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
|
||||
snprintf(bufx, 100, INT64_FORMAT, new->max_value);
|
||||
snprintf(bufm, sizeof(bufm), INT64_FORMAT, new->min_value);
|
||||
snprintf(bufx, sizeof(bufx), INT64_FORMAT, new->max_value);
|
||||
elog(ERROR, "DefineSequence: MINVALUE (%s) must be less than MAXVALUE (%s)",
|
||||
bufm, bufx);
|
||||
}
|
||||
@@ -882,8 +882,8 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
||||
char bufs[100],
|
||||
bufm[100];
|
||||
|
||||
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
|
||||
snprintf(bufm, 100, INT64_FORMAT, new->min_value);
|
||||
snprintf(bufs, sizeof(bufs), INT64_FORMAT, new->last_value);
|
||||
snprintf(bufm, sizeof(bufm), INT64_FORMAT, new->min_value);
|
||||
elog(ERROR, "DefineSequence: START value (%s) can't be less than MINVALUE (%s)",
|
||||
bufs, bufm);
|
||||
}
|
||||
@@ -892,8 +892,8 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
||||
char bufs[100],
|
||||
bufm[100];
|
||||
|
||||
snprintf(bufs, 100, INT64_FORMAT, new->last_value);
|
||||
snprintf(bufm, 100, INT64_FORMAT, new->max_value);
|
||||
snprintf(bufs, sizeof(bufs), INT64_FORMAT, new->last_value);
|
||||
snprintf(bufm, sizeof(bufm), INT64_FORMAT, new->max_value);
|
||||
elog(ERROR, "DefineSequence: START value (%s) can't be greater than MAXVALUE (%s)",
|
||||
bufs, bufm);
|
||||
}
|
||||
@@ -904,7 +904,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, new->cache_value);
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, new->cache_value);
|
||||
elog(ERROR, "DefineSequence: CACHE (%s) can't be <= 0",
|
||||
buf);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.67 2003/02/13 05:19:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.68 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -3875,8 +3875,8 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
|
||||
/*
|
||||
* Create the toast table and its index
|
||||
*/
|
||||
snprintf(toast_relname, NAMEDATALEN, "pg_toast_%u", relOid);
|
||||
snprintf(toast_idxname, NAMEDATALEN, "pg_toast_%u_index", relOid);
|
||||
snprintf(toast_relname, sizeof(toast_relname), "pg_toast_%u", relOid);
|
||||
snprintf(toast_idxname, sizeof(toast_idxname), "pg_toast_%u_index", relOid);
|
||||
|
||||
/* this is pretty painful... need a tuple descriptor */
|
||||
tupdesc = CreateTemplateTupleDesc(3, false);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.202 2003/03/11 19:40:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.203 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -603,7 +603,7 @@ InitPlan(QueryDesc *queryDesc)
|
||||
erm = (execRowMark *) palloc(sizeof(execRowMark));
|
||||
erm->relation = relation;
|
||||
erm->rti = rti;
|
||||
snprintf(erm->resname, 32, "ctid%u", rti);
|
||||
snprintf(erm->resname, sizeof(erm->resname), "ctid%u", rti);
|
||||
estate->es_rowMark = lappend(estate->es_rowMark, erm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.94 2003/03/15 16:18:25 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.95 2003/03/20 03:34:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1162,7 +1162,7 @@ ident_inet(const struct in_addr remote_ip_addr,
|
||||
char ident_query[80];
|
||||
|
||||
/* The query we send to the Ident server */
|
||||
snprintf(ident_query, 80, "%d,%d\n",
|
||||
snprintf(ident_query, sizeof(ident_query), "%d,%d\n",
|
||||
ntohs(remote_port), ntohs(local_port));
|
||||
/* loop in case send is interrupted */
|
||||
do
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* Copyright (c) 2001, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.31 2002/10/24 23:19:13 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.32 2003/03/20 03:34:56 momjian Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@@ -1757,6 +1757,8 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
|
||||
beentry->databaseid = msg->m_databaseid;
|
||||
beentry->procpid = msg->m_procpid;
|
||||
beentry->userid = msg->m_userid;
|
||||
beentry->activity_start_sec = 0;
|
||||
beentry->activity_start_usec = 0;
|
||||
MemSet(beentry->activity, 0, PGSTAT_ACTIVITY_SIZE);
|
||||
|
||||
/*
|
||||
@@ -2460,6 +2462,8 @@ pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len)
|
||||
static void
|
||||
pgstat_recv_activity(PgStat_MsgActivity *msg, int len)
|
||||
{
|
||||
PgStat_StatBeEntry *entry;
|
||||
|
||||
/*
|
||||
* Here we check explicitly for 0 return, since we don't want to
|
||||
* mangle the activity of an active backend by a delayed packed from a
|
||||
@@ -2468,8 +2472,12 @@ pgstat_recv_activity(PgStat_MsgActivity *msg, int len)
|
||||
if (pgstat_add_backend(&msg->m_hdr) != 0)
|
||||
return;
|
||||
|
||||
strncpy(pgStatBeTable[msg->m_hdr.m_backendid - 1].activity,
|
||||
msg->m_what, PGSTAT_ACTIVITY_SIZE);
|
||||
entry = &(pgStatBeTable[msg->m_hdr.m_backendid - 1]);
|
||||
|
||||
strncpy(entry->activity, msg->m_what, PGSTAT_ACTIVITY_SIZE);
|
||||
|
||||
entry->activity_start_sec =
|
||||
GetCurrentAbsoluteTimeUsec(&entry->activity_start_usec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.104 2003/02/22 05:57:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.105 2003/03/20 03:34:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -82,10 +82,13 @@ static int istinterval(char *i_string,
|
||||
AbsoluteTime *i_end);
|
||||
|
||||
|
||||
/* GetCurrentAbsoluteTime()
|
||||
* Get the current system time.
|
||||
/*
|
||||
* GetCurrentAbsoluteTime()
|
||||
*
|
||||
* Get the current system time. Set timezone parameters if not specified
|
||||
* elsewhere. Define HasCTZSet to allow clients to specify the default
|
||||
* timezone.
|
||||
*
|
||||
* Returns the number of seconds since epoch (January 1 1970 GMT).
|
||||
*/
|
||||
AbsoluteTime
|
||||
GetCurrentAbsoluteTime(void)
|
||||
@@ -127,9 +130,14 @@ GetCurrentDateTime(struct tm * tm)
|
||||
abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL);
|
||||
}
|
||||
|
||||
/* GetCurrentTimeUsec()
|
||||
* Get the transaction start time ("now()") broken down as a struct tm,
|
||||
* plus fractional-second and timezone info.
|
||||
/*
|
||||
* GetCurrentAbsoluteTimeUsec()
|
||||
*
|
||||
* Get the current system time. Set timezone parameters if not specified
|
||||
* elsewhere. Define HasCTZSet to allow clients to specify the default
|
||||
* timezone.
|
||||
*
|
||||
* Returns the number of seconds since epoch (January 1 1970 GMT)
|
||||
*/
|
||||
void
|
||||
GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp)
|
||||
|
||||
@@ -25,6 +25,7 @@ extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS);
|
||||
@@ -221,7 +222,6 @@ pg_backend_pid(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* Built-in function for resetting the counters
|
||||
*
|
||||
*/
|
||||
Datum
|
||||
pg_stat_reset(PG_FUNCTION_ARGS)
|
||||
@@ -301,6 +301,50 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PgStat_StatBeEntry *beentry;
|
||||
int32 beid;
|
||||
AbsoluteTime sec;
|
||||
int usec;
|
||||
Timestamp result;
|
||||
|
||||
beid = PG_GETARG_INT32(0);
|
||||
|
||||
if (!superuser())
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
sec = beentry->activity_start_sec;
|
||||
usec = beentry->activity_start_usec;
|
||||
|
||||
/*
|
||||
* No time recorded for start of current query -- this is the case
|
||||
* if the user hasn't enabled query-level stats collection.
|
||||
*/
|
||||
if (sec == 0 && usec == 0)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
/*
|
||||
* This method of converting "Unix time" (sec/usec since epoch) to a
|
||||
* PostgreSQL timestamp is an ugly hack -- if you fix it, be sure to
|
||||
* fix the similar hackery in timestamp.c
|
||||
*/
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
result = (((sec - ((date2j(2000, 1, 1) - date2j(1970, 1, 1)) * 86400))
|
||||
* INT64CONST(1000000)) + usec);
|
||||
#else
|
||||
result = (sec + (usec * 1.0e-6) - ((date2j(2000, 1, 1) -
|
||||
date2j(1970, 1, 1)) * 86400));
|
||||
#endif
|
||||
|
||||
PG_RETURN_TIMESTAMP(result);
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.106 2003/01/07 22:23:17 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.107 2003/03/20 03:34:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -215,7 +215,8 @@ elog(int lev, const char *fmt,...)
|
||||
* Prints the failure line of the COPY. Wow, what a hack! bjm
|
||||
* Translator: Error message will be truncated at 31 characters.
|
||||
*/
|
||||
snprintf(copylineno_buf, 32, gettext("copy: line %d, "), copy_lineno);
|
||||
snprintf(copylineno_buf, sizeof(copylineno_buf),
|
||||
gettext("copy: line %d, "), copy_lineno);
|
||||
space_needed += strlen(copylineno_buf);
|
||||
}
|
||||
|
||||
@@ -787,8 +788,8 @@ useful_strerror(int errnum)
|
||||
* translator: This string will be truncated at 47 characters
|
||||
* expanded.
|
||||
*/
|
||||
snprintf(errorstr_buf, 48, gettext("operating system error %d"),
|
||||
errnum);
|
||||
snprintf(errorstr_buf, sizeof(errorstr_buf),
|
||||
gettext("operating system error %d"), errnum);
|
||||
str = errorstr_buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.185 2003/03/19 16:08:59 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.186 2003/03/20 03:34:56 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -953,7 +953,8 @@ CREATE VIEW pg_stat_activity AS \
|
||||
pg_stat_get_backend_pid(S.backendid) AS procpid, \
|
||||
pg_stat_get_backend_userid(S.backendid) AS usesysid, \
|
||||
U.usename AS usename, \
|
||||
pg_stat_get_backend_activity(S.backendid) AS current_query \
|
||||
pg_stat_get_backend_activity(S.backendid) AS current_query, \
|
||||
pg_stat_get_backend_activity_start(S.backendid) AS query_start \
|
||||
FROM pg_database D, \
|
||||
(SELECT pg_stat_get_backend_idset() AS backendid) AS S, \
|
||||
pg_shadow U \
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.34 2003/02/01 19:29:16 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.35 2003/03/20 03:34:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1044,8 +1044,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
||||
char buf1[100],
|
||||
buf2[100];
|
||||
|
||||
snprintf(buf1, 100, INT64_FORMAT, (int64) len);
|
||||
snprintf(buf2, 100, INT64_FORMAT, (int64) th->pos);
|
||||
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
|
||||
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->pos);
|
||||
die_horribly(AH, modulename, "actual file length (%s) does not match expected (%s)\n",
|
||||
buf1, buf2);
|
||||
}
|
||||
@@ -1081,8 +1081,8 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
|
||||
char buf1[100],
|
||||
buf2[100];
|
||||
|
||||
snprintf(buf1, 100, INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||
snprintf(buf2, 100, INT64_FORMAT, (int64) ctx->tarNextMember);
|
||||
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ctx->tarNextMember);
|
||||
ahlog(AH, 4, "moving from position %s to next member at file position %s\n",
|
||||
buf1, buf2);
|
||||
|
||||
@@ -1093,7 +1093,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, (int64) ctx->tarFHpos);
|
||||
ahlog(AH, 4, "now at file position %s\n", buf);
|
||||
}
|
||||
|
||||
@@ -1163,8 +1163,8 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
||||
char buf1[100],
|
||||
buf2[100];
|
||||
|
||||
snprintf(buf1, 100, INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||
snprintf(buf2, 100, INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
|
||||
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
|
||||
die_horribly(AH, modulename,
|
||||
"mismatch in actual vs. predicted file position (%s vs. %s)\n",
|
||||
buf1, buf2);
|
||||
@@ -1215,7 +1215,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, (int64) hPos);
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, (int64) hPos);
|
||||
ahlog(AH, 3, "TOC Entry %s at %s (length %lu, checksum %d)\n",
|
||||
tag, buf, (unsigned long) len, sum);
|
||||
}
|
||||
@@ -1224,7 +1224,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, 100, INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, (int64) ftello(ctx->tarFH));
|
||||
die_horribly(AH, modulename,
|
||||
"corrupt tar header found in %s "
|
||||
"(expected %d, computed %d) file position %s\n",
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: catversion.h,v 1.180 2003/03/10 03:53:51 tgl Exp $
|
||||
* $Id: catversion.h,v 1.181 2003/03/20 03:34:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 200303091
|
||||
#define CATALOG_VERSION_NO 200303191
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_proc.h,v 1.287 2003/03/14 04:43:52 tgl Exp $
|
||||
* $Id: pg_proc.h,v 1.288 2003/03/20 03:34:56 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The script catalog/genbki.sh reads this file and generates .bki
|
||||
@@ -2741,6 +2741,8 @@ DATA(insert OID = 1939 ( pg_stat_get_backend_userid PGNSP PGUID 12 f f t f s 1
|
||||
DESCR("Statistics: User ID of backend");
|
||||
DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGNSP PGUID 12 f f t f s 1 25 "23" pg_stat_get_backend_activity - _null_ ));
|
||||
DESCR("Statistics: Current query of backend");
|
||||
DATA(insert OID = 2094 ( pg_stat_get_backend_activity_start PGNSP PGUID 12 f f t f s 1 1114 "23" pg_stat_get_backend_activity_start - _null_));
|
||||
DESCR("Statistics: Start time for current query of backend");
|
||||
DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGNSP PGUID 12 f f t f s 1 23 "26" pg_stat_get_db_numbackends - _null_ ));
|
||||
DESCR("Statistics: Number of backends in database");
|
||||
DATA(insert OID = 1942 ( pg_stat_get_db_xact_commit PGNSP PGUID 12 f f t f s 1 20 "26" pg_stat_get_db_xact_commit - _null_ ));
|
||||
@@ -2750,7 +2752,7 @@ DESCR("Statistics: Transactions rolled back");
|
||||
DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGNSP PGUID 12 f f t f s 1 20 "26" pg_stat_get_db_blocks_fetched - _null_ ));
|
||||
DESCR("Statistics: Blocks fetched for database");
|
||||
DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" pg_stat_get_db_blocks_hit - _null_ ));
|
||||
DESCR("Statistics: Block found in cache for database");
|
||||
DESCR("Statistics: Blocks found in cache for database");
|
||||
|
||||
DATA(insert OID = 1946 ( encode PGNSP PGUID 12 f f t f i 2 25 "17 25" binary_encode - _null_ ));
|
||||
DESCR("Convert bytea value into some ascii-only text string");
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
*
|
||||
* Copyright (c) 2001, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Id: pgstat.h,v 1.12 2003/01/09 18:00:24 tgl Exp $
|
||||
* $Id: pgstat.h,v 1.13 2003/03/20 03:34:56 momjian Exp $
|
||||
* ----------
|
||||
*/
|
||||
#ifndef PGSTAT_H
|
||||
#define PGSTAT_H
|
||||
|
||||
#include "utils/nabstime.h"
|
||||
|
||||
/* ----------
|
||||
* Paths for the statistics files. The %s is replaced with the
|
||||
* installations $PGDATA.
|
||||
@@ -111,6 +113,8 @@ typedef struct PgStat_StatBeEntry
|
||||
Oid userid;
|
||||
int procpid;
|
||||
char activity[PGSTAT_ACTIVITY_SIZE];
|
||||
AbsoluteTime activity_start_sec;
|
||||
int activity_start_usec;
|
||||
} PgStat_StatBeEntry;
|
||||
|
||||
|
||||
|
||||
@@ -1274,7 +1274,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
|
||||
pg_locks | SELECT l.relation, l."database", l."transaction", l.pid, l."mode", l.granted FROM pg_lock_status() l(relation oid, "database" oid, "transaction" xid, pid integer, "mode" text, granted boolean);
|
||||
pg_rules | SELECT n.nspname AS schemaname, c.relname AS tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);
|
||||
pg_settings | SELECT a.name, a.setting FROM pg_show_all_settings() a(name text, setting text);
|
||||
pg_stat_activity | SELECT d.oid AS datid, d.datname, pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_userid(s.backendid) AS usesysid, u.usename, pg_stat_get_backend_activity(s.backendid) AS current_query FROM pg_database d, (SELECT pg_stat_get_backend_idset() AS backendid) s, pg_shadow u WHERE ((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND (pg_stat_get_backend_userid(s.backendid) = u.usesysid));
|
||||
pg_stat_activity | SELECT d.oid AS datid, d.datname, pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_userid(s.backendid) AS usesysid, u.usename, pg_stat_get_backend_activity(s.backendid) AS current_query, pg_stat_get_backend_activity_start(s.backendid) AS query_start FROM pg_database d, (SELECT pg_stat_get_backend_idset() AS backendid) s, pg_shadow u WHERE ((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND (pg_stat_get_backend_userid(s.backendid) = u.usesysid));
|
||||
pg_stat_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'r'::"char");
|
||||
pg_stat_all_tables | SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid)) AS idx_scan, sum(pg_stat_get_tuples_fetched(i.indexrelid)) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del FROM ((pg_class c LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'r'::"char") GROUP BY c.oid, n.nspname, c.relname;
|
||||
pg_stat_database | SELECT d.oid AS datid, d.datname, pg_stat_get_db_numbackends(d.oid) AS numbackends, pg_stat_get_db_xact_commit(d.oid) AS xact_commit, pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback, (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read, pg_stat_get_db_blocks_hit(d.oid) AS blks_hit FROM pg_database d;
|
||||
|
||||
Reference in New Issue
Block a user