diff options
| author | Thomas G. Lockhart <lockhart@fourpalms.org> | 2002-04-21 19:52:18 +0000 |
|---|---|---|
| committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 2002-04-21 19:52:18 +0000 |
| commit | 547df0cc853c3fe70dbf33e241cbe46f5e441b3e (patch) | |
| tree | 1cc84e876fb28cae976d53ad64e6fab4a5c22e66 /src/include/utils/date.h | |
| parent | 3fab49325de7924b051ea25ee8d1436d3aff6b28 (diff) | |
| download | postgresql-547df0cc853c3fe70dbf33e241cbe46f5e441b3e.tar.gz | |
Support alternate storage scheme of 64-bit integer for date/time types.
Use "--enable-integer-datetimes" in configuration to use this rather
than the original float8 storage. I would recommend the integer-based
storage for any platform on which it is available. We perhaps should
make this the default for the production release.
Change timezone(timestamptz) results to return timestamp rather than
a character string. Formerly, we didn't have a way to represent
timestamps with an explicit time zone other than freezing the info into
a string. Now, we can reasonably omit the explicit time zone from the
result and return a timestamp with values appropriate for the specified
time zone. Much cleaner, and if you need the time zone in the result
you can put it into a character string pretty easily anyway.
Allow fractional seconds in date/time types even for dates prior to 1BC.
Limit timestamp data types to 6 decimal places of precision. Just right
for a micro-second storage of int8 date/time types, and reduces the
number of places ad-hoc rounding was occuring for the float8-based types.
Use lookup tables for precision/rounding calculations for timestamp and
interval types. Formerly used pow() to calculate the desired value but
with a more limited range there is no reason to not type in a lookup
table. Should be *much* better performance, though formerly there were
some optimizations to help minimize the number of times pow() was called.
Define a HAVE_INT64_TIMESTAMP variable. Based on the configure option
"--enable-integer-datetimes" and the existing internal INT64_IS_BUSTED.
Add explicit date/interval operators and functions for addition and
subtraction. Formerly relied on implicit type promotion from date to
timestamp with time zone.
Change timezone conversion functions for the timetz type from "timetz()"
to "timezone()". This is consistant with other time zone coersion
functions for other types.
Bump the catalog version to 200204201.
Fix up regression tests to reflect changes in fractional seconds
representation for date/times in BC eras.
All regression tests pass on my Linux box.
Diffstat (limited to 'src/include/utils/date.h')
| -rw-r--r-- | src/include/utils/date.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/include/utils/date.h b/src/include/utils/date.h index ca911c0f7f..209dd74d9d 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -7,27 +7,41 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: date.h,v 1.17 2001/11/05 17:46:36 momjian Exp $ + * $Id: date.h,v 1.18 2002/04/21 19:48:31 thomas Exp $ * *------------------------------------------------------------------------- */ #ifndef DATE_H #define DATE_H +#include "c.h" #include "fmgr.h" typedef int32 DateADT; +#ifdef HAVE_INT64_TIMESTAMP +typedef int64 TimeADT; +#else typedef float8 TimeADT; +#endif typedef struct { - double time; /* all time units other than months and - * years */ - int32 zone; /* numeric time zone, in seconds */ +#ifdef HAVE_INT64_TIMESTAMP + int64 time; /* all time units other than months and years */ +#else + double time; /* all time units other than months and years */ +#endif + int32 zone; /* numeric time zone, in seconds */ } TimeTzADT; +#ifdef HAVE_INT64_TIMESTAMP +#define MAX_TIME_PRECISION 6 +#else +#define MAX_TIME_PRECISION 13 +#endif + /* * Macros for fmgr-callable functions. * @@ -90,6 +104,7 @@ 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 timestamptz_time(PG_FUNCTION_ARGS); extern Datum time_interval(PG_FUNCTION_ARGS); extern Datum interval_time(PG_FUNCTION_ARGS); extern Datum text_time(PG_FUNCTION_ARGS); @@ -97,6 +112,7 @@ extern Datum time_text(PG_FUNCTION_ARGS); extern Datum time_pl_interval(PG_FUNCTION_ARGS); extern Datum time_mi_interval(PG_FUNCTION_ARGS); extern Datum interval_pl_time(PG_FUNCTION_ARGS); +extern Datum time_part(PG_FUNCTION_ARGS); extern Datum timetz_in(PG_FUNCTION_ARGS); extern Datum timetz_out(PG_FUNCTION_ARGS); |
