diff options
Diffstat (limited to 'src/include/utils')
-rw-r--r-- | src/include/utils/builtins.h | 5 | ||||
-rw-r--r-- | src/include/utils/date.h | 13 | ||||
-rw-r--r-- | src/include/utils/datetime.h | 12 | ||||
-rw-r--r-- | src/include/utils/formatting.h | 3 | ||||
-rw-r--r-- | src/include/utils/nabstime.h | 8 | ||||
-rw-r--r-- | src/include/utils/timestamp.h | 79 |
6 files changed, 64 insertions, 56 deletions
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 671d72684d5..0f0c9e15a8a 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.164 2001/09/14 17:46:40 momjian Exp $ + * $Id: builtins.h,v 1.165 2001/09/28 08:09:14 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "fmgr.h" #include "nodes/primnodes.h" - +#include "storage/itemptr.h" /* for setLastTid() */ /* * Defined in adt/ @@ -345,6 +345,7 @@ extern char *deparse_expression(Node *expr, List *dpcontext, extern List *deparse_context_for(char *relname, Oid relid); /* tid.c */ +extern void setLastTid(const ItemPointer tid); extern Datum tidin(PG_FUNCTION_ARGS); extern Datum tidout(PG_FUNCTION_ARGS); extern Datum tideq(PG_FUNCTION_ARGS); diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 5aeb87ee00e..cc58cf97470 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: date.h,v 1.11 2001/03/22 04:01:11 momjian Exp $ + * $Id: date.h,v 1.12 2001/09/28 08:09:14 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -68,6 +68,8 @@ extern Datum date_pli(PG_FUNCTION_ARGS); extern Datum date_mii(PG_FUNCTION_ARGS); extern Datum date_timestamp(PG_FUNCTION_ARGS); extern Datum timestamp_date(PG_FUNCTION_ARGS); +extern Datum date_timestamptz(PG_FUNCTION_ARGS); +extern Datum timestamptz_date(PG_FUNCTION_ARGS); extern Datum datetime_timestamp(PG_FUNCTION_ARGS); extern Datum abstime_date(PG_FUNCTION_ARGS); extern Datum text_date(PG_FUNCTION_ARGS); @@ -85,6 +87,7 @@ extern Datum time_cmp(PG_FUNCTION_ARGS); extern Datum overlaps_time(PG_FUNCTION_ARGS); extern Datum time_larger(PG_FUNCTION_ARGS); extern Datum time_smaller(PG_FUNCTION_ARGS); +extern Datum time_mi_time(PG_FUNCTION_ARGS); extern Datum timestamp_time(PG_FUNCTION_ARGS); extern Datum time_interval(PG_FUNCTION_ARGS); extern Datum interval_time(PG_FUNCTION_ARGS); @@ -107,10 +110,14 @@ extern Datum timetz_hash(PG_FUNCTION_ARGS); extern Datum overlaps_timetz(PG_FUNCTION_ARGS); extern Datum timetz_larger(PG_FUNCTION_ARGS); extern Datum timetz_smaller(PG_FUNCTION_ARGS); -extern Datum timestamp_timetz(PG_FUNCTION_ARGS); -extern Datum datetimetz_timestamp(PG_FUNCTION_ARGS); +extern Datum timetz_time(PG_FUNCTION_ARGS); +extern Datum time_timetz(PG_FUNCTION_ARGS); +extern Datum timestamptz_timetz(PG_FUNCTION_ARGS); +extern Datum datetimetz_timestamptz(PG_FUNCTION_ARGS); extern Datum text_timetz(PG_FUNCTION_ARGS); extern Datum timetz_text(PG_FUNCTION_ARGS); +extern Datum timetz_zone(PG_FUNCTION_ARGS); +extern Datum timetz_izone(PG_FUNCTION_ARGS); extern Datum timetz_pl_interval(PG_FUNCTION_ARGS); extern Datum timetz_mi_interval(PG_FUNCTION_ARGS); diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index d299c042eb1..f2102a21e55 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.21 2001/08/27 20:02:10 tgl Exp $ + * $Id: datetime.h,v 1.22 2001/09/28 08:09:14 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -86,7 +86,7 @@ #define MONTH 1 #define YEAR 2 #define DAY 3 -#define TIMES 4 /* not used - thomas 1997-07-14 */ +#define JULIAN 4 #define TZ 5 #define DTZ 6 #define DTZMOD 7 @@ -103,6 +103,8 @@ #define AGO 17 #define ABS_BEFORE 18 #define ABS_AFTER 19 +/* reserved for unrecognized string values */ +#define UNKNOWN_FIELD 31 /* * Token field definitions for time parsing and decoding. @@ -149,12 +151,17 @@ #define DTK_MILLENNIUM 28 #define DTK_MILLISEC 29 #define DTK_MICROSEC 30 +#define DTK_JULIAN 31 #define DTK_DOW 32 #define DTK_DOY 33 #define DTK_TZ_HOUR 34 #define DTK_TZ_MINUTE 35 +#define DTK_ISO_DATE 36 +#define DTK_ISO_TIME 37 + + /* * Bit mask definitions for time parsing. */ @@ -238,6 +245,7 @@ extern int day_tab[2][13]; extern void GetCurrentTime(struct tm * tm); +extern void GetCurrentTimeUsec(struct tm * tm, double *fsec); extern void j2date(int jd, int *year, int *month, int *day); extern int date2j(int year, int month, int day); diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h index 424bcf0fcba..14d3f578ab3 100644 --- a/src/include/utils/formatting.h +++ b/src/include/utils/formatting.h @@ -2,7 +2,7 @@ /* ----------------------------------------------------------------------- * formatting.h * - * $Id: formatting.h,v 1.8 2001/09/06 03:22:42 momjian Exp $ + * $Id: formatting.h,v 1.9 2001/09/28 08:09:14 thomas Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group @@ -22,6 +22,7 @@ extern Datum timestamp_to_char(PG_FUNCTION_ARGS); +extern Datum timestamptz_to_char(PG_FUNCTION_ARGS); extern Datum interval_to_char(PG_FUNCTION_ARGS); extern Datum to_timestamp(PG_FUNCTION_ARGS); extern Datum to_date(PG_FUNCTION_ARGS); diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index d5343e5a14c..299c7dbc604 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.h,v 1.30 2001/05/03 19:00:37 tgl Exp $ + * $Id: nabstime.h,v 1.31 2001/09/28 08:09:14 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -74,11 +74,8 @@ typedef TimeIntervalData *TimeInterval; * These were chosen as special 32-bit bit patterns, * so redefine them explicitly using these bit patterns. - tgl 97/02/24 */ -#define EPOCH_ABSTIME ((AbsoluteTime) 0) #define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */ -#define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD) /* 2147483646 (2^31 - 2) */ #define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 (2^31 - 3) */ -#define BIG_ABSTIME ((AbsoluteTime) 0x7FFFFFFB) /* 2147483644 (2^31 - 4) */ #define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN) /* -2147483648 */ #define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */ @@ -116,6 +113,8 @@ extern Datum abstime_finite(PG_FUNCTION_ARGS); extern Datum timestamp_abstime(PG_FUNCTION_ARGS); extern Datum abstime_timestamp(PG_FUNCTION_ARGS); +extern Datum timestamptz_abstime(PG_FUNCTION_ARGS); +extern Datum abstime_timestamptz(PG_FUNCTION_ARGS); extern Datum reltimein(PG_FUNCTION_ARGS); extern Datum reltimeout(PG_FUNCTION_ARGS); @@ -158,6 +157,7 @@ extern Datum timeofday(PG_FUNCTION_ARGS); /* non-fmgr-callable support routines */ extern AbsoluteTime GetCurrentAbsoluteTime(void); +extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec); extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn); #endif /* NABSTIME_H */ diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index 11b650c88ac..51189ec4013 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: timestamp.h,v 1.17 2001/09/06 03:22:42 momjian Exp $ + * $Id: timestamp.h,v 1.18 2001/09/28 08:09:14 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -33,12 +33,12 @@ typedef double Timestamp; +typedef double TimestampTz; + typedef struct { - double time; /* all time units other than months and - * years */ - int32 month; /* months and years, after time for - * alignment */ + double time; /* all time units other than months and years */ + int32 month; /* months and years, after time for alignment */ } Interval; @@ -49,23 +49,22 @@ typedef struct * Therefore Timestamp is pass-by-reference if and only if float8 is! */ #define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X)) +#define DatumGetTimestampTz(X) ((Timestamp) DatumGetFloat8(X)) #define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X)) -#define TimestampGetDatum(X) Float8GetDatum(X) -#define IntervalPGetDatum(X) PointerGetDatum(X) +#define TimestampGetDatum(X) Float8GetDatum(X) +#define TimestampTzGetDatum(X) Float8GetDatum(X) +#define IntervalPGetDatum(X) PointerGetDatum(X) -#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n)) +#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n)) +#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n)) #define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n)) -#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x) +#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x) +#define PG_RETURN_TIMESTAMPTZ(x) return TimestampTzGetDatum(x) #define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x) -#ifdef NAN -#define DT_INVALID (NAN) -#else -#define DT_INVALID (DBL_MIN+DBL_MIN) -#endif #ifdef HUGE_VAL #define DT_NOBEGIN (-HUGE_VAL) #define DT_NOEND (HUGE_VAL) @@ -73,15 +72,6 @@ typedef struct #define DT_NOBEGIN (-DBL_MAX) #define DT_NOEND (DBL_MAX) #endif -#define DT_CURRENT (DBL_MIN) -#define DT_EPOCH (-DBL_MIN) - -#define TIMESTAMP_INVALID(j) do {j = DT_INVALID;} while (0) -#ifdef NAN -#define TIMESTAMP_IS_INVALID(j) (isnan(j)) -#else -#define TIMESTAMP_IS_INVALID(j) ((j) == DT_INVALID) -#endif #define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0) #define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN) @@ -89,24 +79,7 @@ typedef struct #define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0) #define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND) -#define TIMESTAMP_CURRENT(j) do {j = DT_CURRENT;} while (0) -#define TIMESTAMP_IS_CURRENT(j) ((j) == DT_CURRENT) - -#define TIMESTAMP_EPOCH(j) do {j = DT_EPOCH;} while (0) -#define TIMESTAMP_IS_EPOCH(j) ((j) == DT_EPOCH) - -#define TIMESTAMP_IS_RELATIVE(j) (TIMESTAMP_IS_CURRENT(j) || TIMESTAMP_IS_EPOCH(j)) -#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_INVALID(j) \ - || TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) -#define TIMESTAMP_IS_RESERVED(j) (TIMESTAMP_IS_RELATIVE(j) || TIMESTAMP_NOT_FINITE(j)) - -#define INTERVAL_INVALID(j) do {(j).time = DT_INVALID;} while (0) -#ifdef NAN -#define INTERVAL_IS_INVALID(j) (isnan((j).time)) -#else -#define INTERVAL_IS_INVALID(j) ((j).time == DT_INVALID) -#endif -#define INTERVAL_NOT_FINITE(j) INTERVAL_IS_INVALID(j) +#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) #define TIME_PREC_INV 1000000.0 #define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV) @@ -153,6 +126,14 @@ extern Datum timestamp_part(PG_FUNCTION_ARGS); extern Datum interval_part(PG_FUNCTION_ARGS); extern Datum timestamp_zone(PG_FUNCTION_ARGS); extern Datum timestamp_izone(PG_FUNCTION_ARGS); +extern Datum timestamp_timestamptz(PG_FUNCTION_ARGS); + +extern Datum timestamptz_in(PG_FUNCTION_ARGS); +extern Datum timestamptz_out(PG_FUNCTION_ARGS); +extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS); +extern Datum timestamptz_zone(PG_FUNCTION_ARGS); +extern Datum timestamptz_izone(PG_FUNCTION_ARGS); +extern Datum timestamptz_timestamptz(PG_FUNCTION_ARGS); extern Datum interval_um(PG_FUNCTION_ARGS); extern Datum interval_pl(PG_FUNCTION_ARGS); @@ -169,18 +150,28 @@ extern Datum timestamp_mi_span(PG_FUNCTION_ARGS); extern Datum timestamp_age(PG_FUNCTION_ARGS); extern Datum overlaps_timestamp(PG_FUNCTION_ARGS); +extern Datum timestamptz_text(PG_FUNCTION_ARGS); +extern Datum text_timestamptz(PG_FUNCTION_ARGS); +extern Datum timestamptz_pl_span(PG_FUNCTION_ARGS); +extern Datum timestamptz_mi_span(PG_FUNCTION_ARGS); +extern Datum timestamptz_age(PG_FUNCTION_ARGS); +extern Datum timestamptz_trunc(PG_FUNCTION_ARGS); +extern Datum timestamptz_part(PG_FUNCTION_ARGS); + extern Datum now(PG_FUNCTION_ARGS); /* Internal routines (not fmgr-callable) */ extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt); -extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, - double *fsec, char **tzn); +extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, + double *fsec, char **tzn); +extern void dt2time(Timestamp dt, int *hour, int *min, double *sec); extern int interval2tm(Interval span, struct tm * tm, float8 *fsec); extern int tm2interval(struct tm * tm, double fsec, Interval *span); -extern Timestamp SetTimestamp(Timestamp timestamp); +extern Timestamp SetEpochTimestamp(void); +extern void GetEpochTime(struct tm * tm); extern void isoweek2date(int woy, int *year, int *mon, int *mday); extern int date2isoweek(int year, int mon, int mday); |