summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2004-05-21 05:08:06 +0000
committerTom Lane2004-05-21 05:08:06 +0000
commit63bd0db12199c5df043e1dea0f2b574f622b3a4c (patch)
treedbafdb6e4541162ad369dbfeca24cbd62aefddcc /src/include
parent260b513fc37b6ed2df51586c487d0832b89d0d70 (diff)
Integrate src/timezone library for all platforms. There is more we can
and should do now that we control our own destiny for timezone handling, but this commit gets the bulk of the picayune diffs in place. Magnus Hagander and Tom Lane.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/c.h14
-rw-r--r--src/include/catalog/pg_control.h5
-rw-r--r--src/include/commands/vacuum.h6
-rw-r--r--src/include/libpq/libpq-be.h5
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/pg_config_manual.h10
-rw-r--r--src/include/pgtime.h73
-rw-r--r--src/include/port.h36
-rw-r--r--src/include/utils/datetime.h26
-rw-r--r--src/include/utils/nabstime.h6
-rw-r--r--src/include/utils/timestamp.h14
11 files changed, 104 insertions, 94 deletions
diff --git a/src/include/c.h b/src/include/c.h
index d607677aa3f..17ec1855e18 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/c.h,v 1.164 2004/05/07 00:24:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.165 2004/05/21 05:08:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -309,18 +309,6 @@ typedef unsigned long int uint64;
#define HAVE_INT64_TIMESTAMP
#endif
-/* Global variable holding time zone information. */
-#if defined(USE_PGTZ) && !defined(FRONTEND)
-#define TIMEZONE_GLOBAL pg_timezone
-#else
-#ifndef HAVE_UNDERSCORE_TIMEZONE
-#define TIMEZONE_GLOBAL timezone
-#else
-#define TIMEZONE_GLOBAL _timezone
-#define tzname _tzname /* should be in time.h? */
-#endif
-#endif
-
/* sig_atomic_t is required by ANSI C, but may be missing on old platforms */
#ifndef HAVE_SIG_ATOMIC_T
typedef int sig_atomic_t;
diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h
index 8bc6e94d4d5..a4aba75985c 100644
--- a/src/include/catalog/pg_control.h
+++ b/src/include/catalog/pg_control.h
@@ -8,16 +8,15 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.13 2004/02/11 22:55:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.14 2004/05/21 05:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PG_CONTROL_H
#define PG_CONTROL_H
-#include <time.h>
-
#include "access/xlogdefs.h"
+#include "pgtime.h"
#include "utils/pg_crc.h"
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 9abb09948f6..a39e90a4a14 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -7,16 +7,13 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.51 2004/02/15 21:01:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.52 2004/05/21 05:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VACUUM_H
#define VACUUM_H
-#include <time.h>
-#include <sys/time.h>
-
#ifdef HAVE_GETRUSAGE
#include <sys/resource.h>
#else
@@ -28,6 +25,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "nodes/parsenodes.h"
+#include "pgtime.h"
#include "utils/rel.h"
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 718001c9b3a..45fc5bd76b3 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -11,16 +11,15 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.44 2004/04/05 03:16:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.45 2004/05/21 05:08:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_BE_H
#define LIBPQ_BE_H
-#ifndef _MSC_VER
#include <sys/time.h>
-#endif
+
#ifdef USE_SSL
#include <openssl/ssl.h>
#include <openssl/err.h>
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index e8158a678a3..69aee085f8c 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -615,9 +615,6 @@
/* Define to 1 to build with PAM support. (--with-pam) */
#undef USE_PAM
-/* Define to 1 to use our own timezone library */
-#undef USE_PGTZ
-
/* Define to 1 to build with Rendezvous support. (--with-rendezvous) */
#undef USE_RENDEZVOUS
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 87ddd1f1960..85e99950afb 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -6,7 +6,7 @@
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
- * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.12 2004/03/24 22:40:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.13 2004/05/21 05:08:03 tgl Exp $
*------------------------------------------------------------------------
*/
@@ -153,14 +153,6 @@
#endif
/*
- * Define this if your operating system has _timezone rather than timezone
- */
-#if defined(__CYGWIN__) || defined(WIN32)
-#define HAVE_INT_TIMEZONE /* has int _timezone */
-#define HAVE_UNDERSCORE_TIMEZONE 1
-#endif
-
-/*
* This is the default directory in which AF_UNIX socket files are
* placed. Caution: changing this risks breaking your existing client
* applications, which are likely to continue to look in the old
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
new file mode 100644
index 00000000000..8493c8c6f7a
--- /dev/null
+++ b/src/include/pgtime.h
@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ *
+ * pgtime.h
+ * PostgreSQL internal timezone library
+ *
+ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $PostgreSQL: pgsql/src/include/pgtime.h,v 1.1 2004/05/21 05:08:03 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef _PGTIME_H
+#define _PGTIME_H
+
+#ifdef FRONTEND
+
+/* Don't mess with anything for the frontends */
+#include <time.h>
+
+#else
+
+/*
+ * Redefine functions and defines we implement, so we cause an
+ * error if someone tries to use the "base functions"
+ */
+#ifndef NO_REDEFINE_TIMEFUNCS
+#define localtime DONOTUSETHIS_localtime
+#define gmtime DONOTUSETHIS_gmtime
+#define asctime DONOTUSETHIS_asctime
+#define ctime DONOTUSETHIS_ctime
+#define tzset DONOTUSETHIS_tzset
+#define mktime DONOTUSETHIS_mktime
+#define tzname DONOTUSETHIS_tzname
+#define daylight DONOTUSETHIS_daylight
+#define strftime DONOTUSETHIS_strftime
+#endif
+
+/* Then pull in default declarations, particularly time_t */
+#include <time.h>
+
+/*
+ * Now define prototype for our own timezone implementation
+ * structs and functions.
+ */
+struct pg_tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ long int tm_gmtoff;
+ const char *tm_zone;
+};
+
+extern struct pg_tm *pg_localtime(const time_t *);
+extern struct pg_tm *pg_gmtime(const time_t *);
+extern time_t pg_mktime(struct pg_tm *);
+extern bool pg_tzset(const char *tzname);
+extern size_t pg_strftime(char *s, size_t max, const char *format,
+ const struct pg_tm *tm);
+extern void pg_timezone_initialize(void);
+extern bool tz_acceptable(void);
+extern const char *select_default_timezone(void);
+extern const char *pg_get_current_timezone(void);
+
+#endif /* FRONTEND */
+
+#endif /* _PGTIME_H */
diff --git a/src/include/port.h b/src/include/port.h
index 65702b911b9..3c98955177c 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/port.h,v 1.35 2004/05/20 15:38:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.36 2004/05/21 05:08:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -220,37 +220,3 @@ extern int pqGethostbyname(const char *name,
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
#define WTERMSIG(w) ((w) & 0x7f)
#endif
-
-/*
- * Internal timezone library
- */
-#ifdef USE_PGTZ
-#ifndef FRONTEND
-#undef localtime
-#undef gmtime
-#undef asctime
-#undef ctime
-#undef difftime
-#undef mktime
-#undef tzset
-
-#define localtime(timep) pg_localtime(timep)
-#define gmtime(timep) pg_gmtime(timep)
-#define asctime(timep) pg_asctime(timep)
-#define ctime(timep) pg_ctime(timep)
-#define difftime(t1,t2) pg_difftime(t1,t2)
-#define mktime(tm) pg_mktime(tm)
-#define tzset pg_tzset
-
-
-extern struct tm *pg_localtime(const time_t *);
-extern struct tm *pg_gmtime(const time_t *);
-extern char *pg_asctime(const struct tm *);
-extern char *pg_ctime(const time_t *);
-extern double pg_difftime(const time_t, const time_t);
-extern time_t pg_mktime(struct tm *);
-extern void pg_tzset(void);
-extern time_t pg_timezone;
-
-#endif
-#endif
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index 34a98454acc..35eec95eeb1 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.47 2004/01/19 19:04:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.48 2004/05/21 05:08:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,8 +18,8 @@
#include <limits.h>
#include <math.h>
-#include <time.h>
+#include "pgtime.h"
#include "utils/timestamp.h"
@@ -289,8 +289,8 @@ extern int day_tab[2][13];
#define DTERR_TZDISP_OVERFLOW (-5)
-extern void GetCurrentDateTime(struct tm * tm);
-extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp);
+extern void GetCurrentDateTime(struct pg_tm * tm);
+extern void GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp);
extern void j2date(int jd, int *year, int *month, int *day);
extern int date2j(int year, int month, int day);
@@ -299,30 +299,28 @@ extern int ParseDateTime(const char *timestr, char *lowstr,
int maxfields, int *numfields);
extern int DecodeDateTime(char **field, int *ftype,
int nf, int *dtype,
- struct tm * tm, fsec_t *fsec, int *tzp);
+ struct pg_tm * tm, fsec_t *fsec, int *tzp);
extern int DecodeTimeOnly(char **field, int *ftype,
int nf, int *dtype,
- struct tm * tm, fsec_t *fsec, int *tzp);
+ struct pg_tm * tm, fsec_t *fsec, int *tzp);
extern int DecodeInterval(char **field, int *ftype,
int nf, int *dtype,
- struct tm * tm, fsec_t *fsec);
+ struct pg_tm * tm, fsec_t *fsec);
extern void DateTimeParseError(int dterr, const char *str,
const char *datatype);
-extern int DetermineLocalTimeZone(struct tm * tm);
+extern int DetermineLocalTimeZone(struct pg_tm * tm);
-extern int EncodeDateOnly(struct tm * tm, int style, char *str);
-extern int EncodeTimeOnly(struct tm * tm, fsec_t fsec, int *tzp, int style, char *str);
-extern int EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
-extern int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
+extern int EncodeDateOnly(struct pg_tm * tm, int style, char *str);
+extern int EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str);
+extern int EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
+extern int EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str);
extern int DecodeSpecial(int field, char *lowtoken, int *val);
extern int DecodeUnits(int field, char *lowtoken, int *val);
extern int j2day(int jd);
-extern int DecodePosixTimezone(char *str, int *tzp);
-
extern bool CheckDateTokenTables(void);
#endif /* DATETIME_H */
diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h
index dff548bc224..704e7de5834 100644
--- a/src/include/utils/nabstime.h
+++ b/src/include/utils/nabstime.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.41 2003/11/29 22:41:15 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.42 2004/05/21 05:08:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,9 +15,9 @@
#define NABSTIME_H
#include <limits.h>
-#include <time.h>
#include "fmgr.h"
+#include "pgtime.h"
#include "utils/timestamp.h"
#include "utils/datetime.h"
@@ -164,6 +164,6 @@ extern Datum timeofday(PG_FUNCTION_ARGS);
extern AbsoluteTime GetCurrentAbsoluteTime(void);
extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec);
extern TimestampTz AbsoluteTimeUsecToTimestampTz(AbsoluteTime sec, int usec);
-extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char **tzn);
+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 d514114ef96..32de318f946 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -6,19 +6,19 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.36 2004/05/01 19:25:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.37 2004/05/21 05:08:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef TIMESTAMP_H
#define TIMESTAMP_H
-#include <time.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#include "fmgr.h"
+#include "pgtime.h"
#ifdef HAVE_INT64_TIMESTAMP
#include "utils/int8.h"
#endif
@@ -251,16 +251,16 @@ extern Datum now(PG_FUNCTION_ARGS);
/* Internal routines (not fmgr-callable) */
-extern int tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
-extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
+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);
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);
-extern int interval2tm(Interval span, struct tm * tm, fsec_t *fsec);
-extern int tm2interval(struct tm * tm, fsec_t fsec, Interval *span);
+extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec);
+extern int tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span);
extern Timestamp SetEpochTimestamp(void);
-extern void GetEpochTime(struct tm * tm);
+extern void GetEpochTime(struct pg_tm * tm);
extern int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2);
/* timestamp comparison works for timestamptz also */