diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-29 22:51:57 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-29 22:51:57 +0000 |
commit | b5f7cff84f57a189ed5c9dd59efe8d2568649d0d (patch) | |
tree | 77b5a25a7c4a62145ba89a578018121b3246b82d /src/backend/utils/adt/pgstatfuncs.c | |
parent | c33d575899593a46a5b9a76e4e0ef6f9d81e55dd (diff) | |
download | postgresql-b5f7cff84f57a189ed5c9dd59efe8d2568649d0d.tar.gz postgresql-b5f7cff84f57a189ed5c9dd59efe8d2568649d0d.zip |
Clean up the rather historically encumbered interface to now() and
current time: provide a GetCurrentTimestamp() function that returns
current time in the form of a TimestampTz, instead of separate time_t
and microseconds fields. This is what all the callers really want
anyway, and it eliminates low-level dependencies on AbsoluteTime,
which is a deprecated datatype that will have to disappear eventually.
Diffstat (limited to 'src/backend/utils/adt/pgstatfuncs.c')
-rw-r--r-- | src/backend/utils/adt/pgstatfuncs.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 870513fb9d5..b1bd11c9c20 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.23 2005/06/28 05:09:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.24 2005/06/29 22:51:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -341,13 +341,9 @@ 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; + int32 beid = PG_GETARG_INT32(0); TimestampTz result; - - beid = PG_GETARG_INT32(0); + PgStat_StatBeEntry *beentry; if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -355,31 +351,24 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS) if (!superuser() && beentry->userid != GetUserId()) PG_RETURN_NULL(); - sec = beentry->activity_start_sec; - usec = beentry->activity_start_usec; + result = beentry->activity_start_timestamp; /* * 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) + if (result == 0) PG_RETURN_NULL(); - result = AbsoluteTimeUsecToTimestampTz(sec, usec); - PG_RETURN_TIMESTAMPTZ(result); } Datum pg_stat_get_backend_start(PG_FUNCTION_ARGS) { - PgStat_StatBeEntry *beentry; - int32 beid; - AbsoluteTime sec; - int usec; + int32 beid = PG_GETARG_INT32(0); TimestampTz result; - - beid = PG_GETARG_INT32(0); + PgStat_StatBeEntry *beentry; if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -387,14 +376,11 @@ pg_stat_get_backend_start(PG_FUNCTION_ARGS) if (!superuser() && beentry->userid != GetUserId()) PG_RETURN_NULL(); - sec = beentry->start_sec; - usec = beentry->start_usec; + result = beentry->start_timestamp; - if (sec == 0 && usec == 0) + if (result == 0) /* probably can't happen? */ PG_RETURN_NULL(); - result = AbsoluteTimeUsecToTimestampTz(sec, usec); - PG_RETURN_TIMESTAMPTZ(result); } |