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/include | |
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/include')
-rw-r--r-- | src/include/access/xact.h | 7 | ||||
-rw-r--r-- | src/include/pgstat.h | 10 | ||||
-rw-r--r-- | src/include/utils/nabstime.h | 4 | ||||
-rw-r--r-- | src/include/utils/timestamp.h | 10 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 0c6b5580688..ae5722ecb4b 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.77 2005/06/17 22:32:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.78 2005/06/29 22:51:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ #include "access/xlog.h" #include "storage/relfilenode.h" #include "nodes/pg_list.h" -#include "utils/nabstime.h" +#include "utils/timestamp.h" /* @@ -140,8 +140,7 @@ extern TransactionId GetCurrentTransactionId(void); extern TransactionId GetCurrentTransactionIdIfAny(void); extern SubTransactionId GetCurrentSubTransactionId(void); extern CommandId GetCurrentCommandId(void); -extern AbsoluteTime GetCurrentTransactionStartTime(void); -extern AbsoluteTime GetCurrentTransactionStartTimeUsec(int *usec); +extern TimestampTz GetCurrentTransactionStartTimestamp(void); extern int GetCurrentTransactionNestLevel(void); extern bool TransactionIdIsCurrentTransactionId(TransactionId xid); extern void CommandCounterIncrement(void); diff --git a/src/include/pgstat.h b/src/include/pgstat.h index b6015f536c0..5612d912909 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -5,7 +5,7 @@ * * Copyright (c) 2001-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.31 2005/06/28 05:09:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.32 2005/06/29 22:51:57 tgl Exp $ * ---------- */ #ifndef PGSTAT_H @@ -13,8 +13,8 @@ #include "libpq/pqcomm.h" #include "utils/hsearch.h" -#include "utils/nabstime.h" #include "utils/rel.h" +#include "utils/timestamp.h" /* ---------- * The types of backend/postmaster -> collector messages @@ -233,10 +233,8 @@ typedef struct PgStat_StatBeEntry { /* An entry is non-empty iff procpid > 0 */ int procpid; - AbsoluteTime start_sec; - int start_usec; - AbsoluteTime activity_start_sec; - int activity_start_usec; + TimestampTz start_timestamp; + TimestampTz activity_start_timestamp; char activity[PGSTAT_ACTIVITY_SIZE]; /* diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index 4c7f1fe2d42..200004517b7 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.45 2004/12/31 22:03:46 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.46 2005/06/29 22:51:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -162,8 +162,6 @@ extern Datum timeofday(PG_FUNCTION_ARGS); /* non-fmgr-callable support routines */ extern AbsoluteTime GetCurrentAbsoluteTime(void); -extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec); -extern TimestampTz AbsoluteTimeUsecToTimestampTz(AbsoluteTime sec, int usec); extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm * tm, char **tzn); #endif /* NABSTIME_H */ diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index 7475dacbe7c..1cd591326c7 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.45 2005/06/15 00:34:10 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.46 2005/06/29 22:51:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -156,6 +156,10 @@ typedef double fsec_t; #define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK) +/* Set at postmaster start */ +extern TimestampTz PgStartTime; + + /* * timestamp.c prototypes */ @@ -258,10 +262,10 @@ extern Datum now(PG_FUNCTION_ARGS); extern Datum pgsql_postmaster_start_time(PG_FUNCTION_ARGS); -extern TimestampTz StartTime; - /* Internal routines (not fmgr-callable) */ +extern TimestampTz GetCurrentTimestamp(void); + extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt); extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn, pg_tz *attimezone); |