From f722bfbe7d5e0b15c1f5b8a692f04b9680cfcd69 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 12 Aug 2020 08:46:21 +0200 Subject: [PATCH v2 3/3] Change return type of EXTRACT to numeric Discussion: https://www.postgresql.org/message-id/flat/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu --- doc/src/sgml/func.sgml | 10 +- src/backend/utils/adt/date.c | 265 +++++++++++++++++-- src/backend/utils/adt/timestamp.c | 305 +++++++++++++++------- src/include/catalog/pg_proc.dat | 15 +- src/test/regress/expected/date.out | 100 ++----- src/test/regress/expected/interval.out | 24 +- src/test/regress/expected/timestamp.out | 268 +++++++++---------- src/test/regress/expected/timestamptz.out | 272 +++++++++---------- src/test/regress/sql/date.sql | 6 +- 9 files changed, 766 insertions(+), 499 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index f766c1bc67..f8d6ad62be 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -8626,7 +8626,7 @@ Date/Time Functions date_part date_part ( text, timestamp ) - double precision + numeric Get timestamp subfield (equivalent to extract); @@ -8641,7 +8641,7 @@ Date/Time Functions date_part ( text, interval ) - double precision + numeric Get interval subfield (equivalent to extract); @@ -8706,7 +8706,7 @@ Date/Time Functions extract extract ( field from timestamp ) - double precision + numeric Get timestamp subfield; see @@ -8720,7 +8720,7 @@ Date/Time Functions extract ( field from interval ) - double precision + numeric Get interval subfield; see @@ -9227,7 +9227,7 @@ <function>EXTRACT</function>, <function>date_part</function> well.) field is an identifier or string that selects what field to extract from the source value. The extract function returns values of type - double precision. + numeric. The following are valid field names: diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index eaaffa7137..b42fe6d1fc 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -31,6 +31,7 @@ #include "utils/builtins.h" #include "utils/date.h" #include "utils/datetime.h" +#include "utils/numeric.h" #include "utils/sortsupport.h" /* @@ -1092,6 +1093,180 @@ in_range_date_interval(PG_FUNCTION_ARGS) } +/* date_part() + * Extract specified field from date type. + */ +Datum +date_part(PG_FUNCTION_ARGS) +{ + text *units = PG_GETARG_TEXT_PP(0); + DateADT date = PG_GETARG_DATEADT(1); + int64 result; + int type, + val; + char *lowunits; + int year, mon, mday; + + lowunits = downcase_truncate_identifier(VARDATA_ANY(units), + VARSIZE_ANY_EXHDR(units), + false); + + type = DecodeUnits(0, lowunits, &val); + if (type == UNKNOWN_FIELD) + type = DecodeSpecial(0, lowunits, &val); + + if (DATE_NOT_FINITE(date) && (type == UNITS || type == RESERV)) + { + switch (val) + { + /* Oscillating units */ + case DTK_DAY: + case DTK_MONTH: + case DTK_QUARTER: + case DTK_WEEK: + case DTK_DOW: + case DTK_ISODOW: + case DTK_DOY: + PG_RETURN_NULL(); + break; + + /* Monotonically-increasing units */ + case DTK_YEAR: + case DTK_DECADE: + case DTK_CENTURY: + case DTK_MILLENNIUM: + case DTK_JULIAN: + case DTK_ISOYEAR: + case DTK_EPOCH: + if (DATE_IS_NOBEGIN(date)) + PG_RETURN_NUMERIC(DatumGetNumeric(DirectFunctionCall3(numeric_in, + CStringGetDatum("-Infinity"), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1)))); + else + PG_RETURN_NUMERIC(DatumGetNumeric(DirectFunctionCall3(numeric_in, + CStringGetDatum("Infinity"), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1)))); + default: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("date units \"%s\" not supported", + lowunits))); + } + } + else if (type == UNITS) + { + j2date(date + POSTGRES_EPOCH_JDATE, &year, &mon, &mday); + + switch (val) + { + case DTK_DAY: + result = mday; + break; + + case DTK_MONTH: + result = mon; + break; + + case DTK_QUARTER: + result = (mon - 1) / 3 + 1; + break; + + case DTK_WEEK: + result = date2isoweek(year, mon, mday); + break; + + case DTK_YEAR: + if (year > 0) + result = year; + else + /* there is no year 0, just 1 BC and 1 AD */ + result = year - 1; + break; + + case DTK_DECADE: + /* see comments in timestamp_part */ + if (year >= 0) + result = year / 10; + else + result = -((8 - (year - 1)) / 10); + break; + + case DTK_CENTURY: + /* see comments in timestamp_part */ + if (year > 0) + result = (year + 99) / 100; + else + result = -((99 - (year - 1)) / 100); + break; + + case DTK_MILLENNIUM: + /* see comments in timestamp_part */ + if (year > 0) + result = (year + 999) / 1000; + else + result = -((999 - (year - 1)) / 1000); + break; + + case DTK_JULIAN: + result = date + POSTGRES_EPOCH_JDATE; + break; + + case DTK_ISOYEAR: + result = date2isoyear(year, mon, mday); + /* Adjust BC years */ + if (result <= 0) + result -= 1; + break; + + case DTK_DOW: + case DTK_ISODOW: + result = j2day(date + POSTGRES_EPOCH_JDATE); + if (val == DTK_ISODOW && result == 0) + result = 7; + break; + + case DTK_DOY: + result = date2j(year, mon, mday) - date2j(year, 1, 1) + 1; + break; + + default: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("date units \"%s\" not supported", + lowunits))); + result = 0; + } + } + else if (type == RESERV) + { + switch (val) + { + case DTK_EPOCH: + result = ((int64) date + POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY; + break; + + default: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("date units \"%s\" not supported", + lowunits))); + result = 0; + } + } + else + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("date units \"%s\" not recognized", lowunits))); + result = 0; + } + + PG_RETURN_NUMERIC(int64_to_numeric(result)); +} + + /* Add an interval to a date, giving a new date. * Must handle both positive and negative intervals. * @@ -1986,7 +2161,7 @@ time_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_PP(0); TimeADT time = PG_GETARG_TIMEADT(1); - float8 result; + Numeric result; int type, val; char *lowunits; @@ -2010,23 +2185,39 @@ time_part(PG_FUNCTION_ARGS) switch (val) { case DTK_MICROSEC: - result = tm->tm_sec * 1000000.0 + fsec; + result = int64_to_numeric(tm->tm_sec * 1000000 + fsec); break; case DTK_MILLISEC: - result = tm->tm_sec * 1000.0 + fsec / 1000.0; + /* tm->tm_sec * 1000 + fsec / 1000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec * 1000), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(3))); break; case DTK_SECOND: - result = tm->tm_sec + fsec / 1000000.0; + /* tm->tm_sec + fsec / 1000000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; case DTK_MINUTE: - result = tm->tm_min; + result = int64_to_numeric(tm->tm_min); break; case DTK_HOUR: - result = tm->tm_hour; + result = int64_to_numeric(tm->tm_hour); break; case DTK_TZ: @@ -2050,7 +2241,12 @@ time_part(PG_FUNCTION_ARGS) } else if (type == RESERV && val == DTK_EPOCH) { - result = time / 1000000.0; + result = numeric_div_opt_error(int64_to_numeric(time), + int64_to_numeric(1000000), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); } else { @@ -2061,7 +2257,7 @@ time_part(PG_FUNCTION_ARGS) result = 0; } - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); } @@ -2723,7 +2919,7 @@ timetz_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_PP(0); TimeTzADT *time = PG_GETARG_TIMETZADT_P(1); - float8 result; + Numeric result; int type, val; char *lowunits; @@ -2738,7 +2934,6 @@ timetz_part(PG_FUNCTION_ARGS) if (type == UNITS) { - double dummy; int tz; fsec_t fsec; struct pg_tm tt, @@ -2749,38 +2944,54 @@ timetz_part(PG_FUNCTION_ARGS) switch (val) { case DTK_TZ: - result = -tz; + result = int64_to_numeric(-tz); break; case DTK_TZ_MINUTE: - result = -tz; - result /= SECS_PER_MINUTE; - FMODULO(result, dummy, (double) SECS_PER_MINUTE); + /* trunc(-tz / 60) % 60 */ + result = numeric_mod_opt_error(int64_to_numeric(-tz / SECS_PER_MINUTE), + int64_to_numeric(SECS_PER_MINUTE), + NULL); break; case DTK_TZ_HOUR: - dummy = -tz; - FMODULO(dummy, result, (double) SECS_PER_HOUR); + result = int64_to_numeric(-tz / SECS_PER_HOUR); break; case DTK_MICROSEC: - result = tm->tm_sec * 1000000.0 + fsec; + result = int64_to_numeric(tm->tm_sec * 1000000 + fsec); break; case DTK_MILLISEC: - result = tm->tm_sec * 1000.0 + fsec / 1000.0; + /* tm->tm_sec * 1000 + fsec / 1000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec * 1000), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(3))); break; case DTK_SECOND: - result = tm->tm_sec + fsec / 1000000.0; + /* tm->tm_sec + fsec / 1000000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; case DTK_MINUTE: - result = tm->tm_min; + result = int64_to_numeric(tm->tm_min); break; case DTK_HOUR: - result = tm->tm_hour; + result = int64_to_numeric(tm->tm_hour); break; case DTK_DAY: @@ -2800,7 +3011,15 @@ timetz_part(PG_FUNCTION_ARGS) } else if (type == RESERV && val == DTK_EPOCH) { - result = time->time / 1000000.0 + time->zone; + /* time->time / 1000000.0 + time->zone */ + result = numeric_add_opt_error(numeric_div_opt_error(int64_to_numeric(time->time), + int64_to_numeric(1000000), + NULL), + int64_to_numeric(time->zone), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); } else { @@ -2811,7 +3030,7 @@ timetz_part(PG_FUNCTION_ARGS) result = 0; } - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); } /* timetz_zone() diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 5fe304cea7..8bc522b26e 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -35,6 +35,7 @@ #include "utils/date.h" #include "utils/datetime.h" #include "utils/float.h" +#include "utils/numeric.h" /* * gcc's -ffast-math switch breaks routines that expect exact results from @@ -4436,13 +4437,13 @@ date2isoyearday(int year, int mon, int mday) * * Used by timestamp_part and timestamptz_part when extracting from infinite * timestamp[tz]. Returns +/-Infinity if that is the appropriate result, - * otherwise returns zero (which should be taken as meaning to return NULL). + * otherwise returns NULL (which should be taken as meaning to return SQL NULL). * * Errors thrown here for invalid units should exactly match those that * would be thrown in the calling functions, else there will be unexpected * discrepancies between finite- and infinite-input cases. */ -static float8 +static Numeric NonFiniteTimestampTzPart(int type, int unit, char *lowunits, bool isNegative, bool isTz) { @@ -4478,7 +4479,7 @@ NonFiniteTimestampTzPart(int type, int unit, char *lowunits, case DTK_TZ: case DTK_TZ_MINUTE: case DTK_TZ_HOUR: - return 0.0; + return NULL; /* Monotonically-increasing units */ case DTK_YEAR: @@ -4489,9 +4490,15 @@ NonFiniteTimestampTzPart(int type, int unit, char *lowunits, case DTK_ISOYEAR: case DTK_EPOCH: if (isNegative) - return -get_float8_infinity(); + return DatumGetNumeric(DirectFunctionCall3(numeric_in, + CStringGetDatum("-Infinity"), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); else - return get_float8_infinity(); + return DatumGetNumeric(DirectFunctionCall3(numeric_in, + CStringGetDatum("Infinity"), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); default: if (isTz) @@ -4504,7 +4511,7 @@ NonFiniteTimestampTzPart(int type, int unit, char *lowunits, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("timestamp units \"%s\" not supported", lowunits))); - return 0.0; /* keep compiler quiet */ + return NULL; /* keep compiler quiet */ } } @@ -4516,7 +4523,7 @@ timestamp_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_PP(0); Timestamp timestamp = PG_GETARG_TIMESTAMP(1); - float8 result; + Numeric result; Timestamp epoch; int type, val; @@ -4539,7 +4546,7 @@ timestamp_part(PG_FUNCTION_ARGS) TIMESTAMP_IS_NOBEGIN(timestamp), false); if (result) - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); else PG_RETURN_NULL(); } @@ -4554,47 +4561,63 @@ timestamp_part(PG_FUNCTION_ARGS) switch (val) { case DTK_MICROSEC: - result = tm->tm_sec * 1000000.0 + fsec; + result = int64_to_numeric(tm->tm_sec * 1000000 + fsec); break; case DTK_MILLISEC: - result = tm->tm_sec * 1000.0 + fsec / 1000.0; + /* tm->tm_sec * 1000 + fsec / 1000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec * 1000), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(3))); break; case DTK_SECOND: - result = tm->tm_sec + fsec / 1000000.0; + /* tm->tm_sec + fsec / 1000000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; case DTK_MINUTE: - result = tm->tm_min; + result = int64_to_numeric(tm->tm_min); break; case DTK_HOUR: - result = tm->tm_hour; + result = int64_to_numeric(tm->tm_hour); break; case DTK_DAY: - result = tm->tm_mday; + result = int64_to_numeric(tm->tm_mday); break; case DTK_MONTH: - result = tm->tm_mon; + result = int64_to_numeric(tm->tm_mon); break; case DTK_QUARTER: - result = (tm->tm_mon - 1) / 3 + 1; + result = int64_to_numeric((tm->tm_mon - 1) / 3 + 1); break; case DTK_WEEK: - result = (float8) date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); + result = int64_to_numeric(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday)); break; case DTK_YEAR: if (tm->tm_year > 0) - result = tm->tm_year; + result = int64_to_numeric(tm->tm_year); else /* there is no year 0, just 1 BC and 1 AD */ - result = tm->tm_year - 1; + result = int64_to_numeric(tm->tm_year - 1); break; case DTK_DECADE: @@ -4605,9 +4628,9 @@ timestamp_part(PG_FUNCTION_ARGS) * is 11 BC thru 2 BC... */ if (tm->tm_year >= 0) - result = tm->tm_year / 10; + result = int64_to_numeric(tm->tm_year / 10); else - result = -((8 - (tm->tm_year - 1)) / 10); + result = int64_to_numeric(-((8 - (tm->tm_year - 1)) / 10)); break; case DTK_CENTURY: @@ -4619,43 +4642,53 @@ timestamp_part(PG_FUNCTION_ARGS) * ---- */ if (tm->tm_year > 0) - result = (tm->tm_year + 99) / 100; + result = int64_to_numeric((tm->tm_year + 99) / 100); else /* caution: C division may have negative remainder */ - result = -((99 - (tm->tm_year - 1)) / 100); + result = int64_to_numeric(-((99 - (tm->tm_year - 1)) / 100)); break; case DTK_MILLENNIUM: /* see comments above. */ if (tm->tm_year > 0) - result = (tm->tm_year + 999) / 1000; + result = int64_to_numeric((tm->tm_year + 999) / 1000); else - result = -((999 - (tm->tm_year - 1)) / 1000); + result = int64_to_numeric(-((999 - (tm->tm_year - 1)) / 1000)); break; case DTK_JULIAN: - result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); - result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY; + result = numeric_add_opt_error( + int64_to_numeric(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)), + numeric_div_opt_error( + int64_to_numeric(((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) * 1000000LL + fsec), + int64_to_numeric(SECS_PER_DAY * 1000000LL), + NULL), + NULL); break; case DTK_ISOYEAR: - result = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday); + { + int tmp = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday); /* Adjust BC years */ - if (result <= 0) - result -= 1; + if (tmp <= 0) + tmp -= 1; + result = int64_to_numeric(tmp); break; + } case DTK_DOW: case DTK_ISODOW: - result = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); - if (val == DTK_ISODOW && result == 0) - result = 7; + { + int tmp = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); + if (val == DTK_ISODOW && tmp == 0) + tmp = 7; + result = int64_to_numeric(tmp); break; + } case DTK_DOY: - result = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - - date2j(tm->tm_year, 1, 1) + 1); + result = int64_to_numeric(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + - date2j(tm->tm_year, 1, 1) + 1); break; case DTK_TZ: @@ -4674,12 +4707,23 @@ timestamp_part(PG_FUNCTION_ARGS) switch (val) { case DTK_EPOCH: + /* (timestamp - epoch) / 1000000 */ epoch = SetEpochTimestamp(); - /* try to avoid precision loss in subtraction */ if (timestamp < (PG_INT64_MAX + epoch)) - result = (timestamp - epoch) / 1000000.0; + result = numeric_div_opt_error( + int64_to_numeric(timestamp - epoch), + int64_to_numeric(1000000), + NULL); else - result = ((float8) timestamp - epoch) / 1000000.0; + result = numeric_div_opt_error( + numeric_sub_opt_error(int64_to_numeric(timestamp), + int64_to_numeric(epoch), + NULL), + int64_to_numeric(1000000), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; default: @@ -4699,7 +4743,7 @@ timestamp_part(PG_FUNCTION_ARGS) result = 0; } - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); } /* timestamptz_part() @@ -4710,13 +4754,12 @@ timestamptz_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_PP(0); TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1); - float8 result; + Numeric result; Timestamp epoch; int tz; int type, val; char *lowunits; - double dummy; fsec_t fsec; struct pg_tm tt, *tm = &tt; @@ -4735,7 +4778,7 @@ timestamptz_part(PG_FUNCTION_ARGS) TIMESTAMP_IS_NOBEGIN(timestamp), true); if (result) - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); else PG_RETURN_NULL(); } @@ -4750,111 +4793,137 @@ timestamptz_part(PG_FUNCTION_ARGS) switch (val) { case DTK_TZ: - result = -tz; + result = int64_to_numeric(-tz); break; case DTK_TZ_MINUTE: - result = -tz; - result /= MINS_PER_HOUR; - FMODULO(result, dummy, (double) MINS_PER_HOUR); + /* trunc(-tz / 60) % 60 */ + result = numeric_mod_opt_error(int64_to_numeric(-tz / SECS_PER_MINUTE), + int64_to_numeric(SECS_PER_MINUTE), + NULL); break; case DTK_TZ_HOUR: - dummy = -tz; - FMODULO(dummy, result, (double) SECS_PER_HOUR); + result = int64_to_numeric(-tz / SECS_PER_HOUR); break; case DTK_MICROSEC: - result = tm->tm_sec * 1000000.0 + fsec; + result = int64_to_numeric(tm->tm_sec * 1000000 + fsec); break; case DTK_MILLISEC: - result = tm->tm_sec * 1000.0 + fsec / 1000.0; + /* tm->tm_sec * 1000 + fsec / 1000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec * 1000), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(3))); break; case DTK_SECOND: - result = tm->tm_sec + fsec / 1000000.0; + /* tm->tm_sec + fsec / 1000000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; case DTK_MINUTE: - result = tm->tm_min; + result = int64_to_numeric(tm->tm_min); break; case DTK_HOUR: - result = tm->tm_hour; + result = int64_to_numeric(tm->tm_hour); break; case DTK_DAY: - result = tm->tm_mday; + result = int64_to_numeric(tm->tm_mday); break; case DTK_MONTH: - result = tm->tm_mon; + result = int64_to_numeric(tm->tm_mon); break; case DTK_QUARTER: - result = (tm->tm_mon - 1) / 3 + 1; + result = int64_to_numeric((tm->tm_mon - 1) / 3 + 1); break; case DTK_WEEK: - result = (float8) date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); + result = int64_to_numeric(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday)); break; case DTK_YEAR: if (tm->tm_year > 0) - result = tm->tm_year; + result = int64_to_numeric(tm->tm_year); else /* there is no year 0, just 1 BC and 1 AD */ - result = tm->tm_year - 1; + result = int64_to_numeric(tm->tm_year - 1); break; case DTK_DECADE: /* see comments in timestamp_part */ - if (tm->tm_year > 0) - result = tm->tm_year / 10; + if (tm->tm_year >= 0) + result = int64_to_numeric(tm->tm_year / 10); else - result = -((8 - (tm->tm_year - 1)) / 10); + result = int64_to_numeric(-((8 - (tm->tm_year - 1)) / 10)); break; case DTK_CENTURY: /* see comments in timestamp_part */ if (tm->tm_year > 0) - result = (tm->tm_year + 99) / 100; + result = int64_to_numeric((tm->tm_year + 99) / 100); else - result = -((99 - (tm->tm_year - 1)) / 100); + result = int64_to_numeric(-((99 - (tm->tm_year - 1)) / 100)); break; case DTK_MILLENNIUM: /* see comments in timestamp_part */ if (tm->tm_year > 0) - result = (tm->tm_year + 999) / 1000; + result = int64_to_numeric((tm->tm_year + 999) / 1000); else - result = -((999 - (tm->tm_year - 1)) / 1000); + result = int64_to_numeric(-((999 - (tm->tm_year - 1)) / 1000)); break; case DTK_JULIAN: - result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); - result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY; + result = numeric_add_opt_error( + int64_to_numeric(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)), + numeric_div_opt_error( + int64_to_numeric(((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) * 1000000LL + fsec), + int64_to_numeric(SECS_PER_DAY * 1000000LL), + NULL), + NULL); break; case DTK_ISOYEAR: - result = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday); + { + int tmp = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday); /* Adjust BC years */ - if (result <= 0) - result -= 1; + if (tmp <= 0) + tmp -= 1; + result = int64_to_numeric(tmp); break; + } case DTK_DOW: case DTK_ISODOW: - result = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); - if (val == DTK_ISODOW && result == 0) - result = 7; + { + int tmp = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); + if (val == DTK_ISODOW && tmp == 0) + tmp = 7; + result = int64_to_numeric(tmp); break; + } case DTK_DOY: - result = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - - date2j(tm->tm_year, 1, 1) + 1); + result = int64_to_numeric(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + - date2j(tm->tm_year, 1, 1) + 1); break; default: @@ -4871,12 +4940,23 @@ timestamptz_part(PG_FUNCTION_ARGS) switch (val) { case DTK_EPOCH: + /* (timestamp - epoch) / 1000000 */ epoch = SetEpochTimestamp(); - /* try to avoid precision loss in subtraction */ if (timestamp < (PG_INT64_MAX + epoch)) - result = (timestamp - epoch) / 1000000.0; + result = numeric_div_opt_error( + int64_to_numeric(timestamp - epoch), + int64_to_numeric(1000000), + NULL); else - result = ((float8) timestamp - epoch) / 1000000.0; + result = numeric_div_opt_error( + numeric_sub_opt_error(int64_to_numeric(timestamp), + int64_to_numeric(epoch), + NULL), + int64_to_numeric(1000000), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; default: @@ -4897,7 +4977,7 @@ timestamptz_part(PG_FUNCTION_ARGS) result = 0; } - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); } @@ -4909,7 +4989,7 @@ interval_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_PP(0); Interval *interval = PG_GETARG_INTERVAL_P(1); - float8 result; + Numeric result; int type, val; char *lowunits; @@ -4932,54 +5012,71 @@ interval_part(PG_FUNCTION_ARGS) switch (val) { case DTK_MICROSEC: - result = tm->tm_sec * 1000000.0 + fsec; + /* tm->tm_sec * 1000000 + fsec */ + result = int64_to_numeric(tm->tm_sec * 1000000 + fsec); break; case DTK_MILLISEC: - result = tm->tm_sec * 1000.0 + fsec / 1000.0; + /* tm->tm_sec * 1000 + fsec / 1000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec * 1000), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(3))); break; case DTK_SECOND: - result = tm->tm_sec + fsec / 1000000.0; + /* tm->tm_sec + fsec / 1000000 */ + result = numeric_add_opt_error(int64_to_numeric(tm->tm_sec), + numeric_div_opt_error(int64_to_numeric(fsec), + int64_to_numeric(1000000), + NULL), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); break; case DTK_MINUTE: - result = tm->tm_min; + result = int64_to_numeric(tm->tm_min); break; case DTK_HOUR: - result = tm->tm_hour; + result = int64_to_numeric(tm->tm_hour); break; case DTK_DAY: - result = tm->tm_mday; + result = int64_to_numeric(tm->tm_mday); break; case DTK_MONTH: - result = tm->tm_mon; + result = int64_to_numeric(tm->tm_mon); break; case DTK_QUARTER: - result = (tm->tm_mon / 3) + 1; + result = int64_to_numeric((tm->tm_mon / 3) + 1); break; case DTK_YEAR: - result = tm->tm_year; + result = int64_to_numeric(tm->tm_year); break; case DTK_DECADE: /* caution: C division may have negative remainder */ - result = tm->tm_year / 10; + result = int64_to_numeric(tm->tm_year / 10); break; case DTK_CENTURY: /* caution: C division may have negative remainder */ - result = tm->tm_year / 100; + result = int64_to_numeric(tm->tm_year / 100); break; case DTK_MILLENNIUM: /* caution: C division may have negative remainder */ - result = tm->tm_year / 1000; + result = int64_to_numeric(tm->tm_year / 1000); break; default: @@ -4999,10 +5096,18 @@ interval_part(PG_FUNCTION_ARGS) } else if (type == RESERV && val == DTK_EPOCH) { - result = interval->time / 1000000.0; - result += ((double) DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR); - result += ((double) DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR); - result += ((double) SECS_PER_DAY) * interval->day; + result = + numeric_add_opt_error( + numeric_div_opt_error(int64_to_numeric(interval->time), + int64_to_numeric(1000000), + NULL), + int64_to_numeric(((int64) DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR) + + ((int64) DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR) + + ((int64) SECS_PER_DAY) * interval->day), + NULL); + result = DatumGetNumeric(DirectFunctionCall2(numeric_round, + NumericGetDatum(result), + Int32GetDatum(6))); } else { @@ -5013,7 +5118,7 @@ interval_part(PG_FUNCTION_ARGS) result = 0; } - PG_RETURN_FLOAT8(result); + PG_RETURN_NUMERIC(result); } diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 082a11f270..34fd06975c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -2315,10 +2315,10 @@ proname => 'interval_mi', prorettype => 'interval', proargtypes => 'interval interval', prosrc => 'interval_mi' }, { oid => '1171', descr => 'extract field from timestamp with time zone', - proname => 'date_part', provolatile => 's', prorettype => 'float8', + proname => 'date_part', provolatile => 's', prorettype => 'numeric', proargtypes => 'text timestamptz', prosrc => 'timestamptz_part' }, { oid => '1172', descr => 'extract field from interval', - proname => 'date_part', prorettype => 'float8', + proname => 'date_part', prorettype => 'numeric', proargtypes => 'text interval', prosrc => 'interval_part' }, { oid => '1174', descr => 'convert date to timestamp with time zone', proname => 'timestamptz', provolatile => 's', prorettype => 'timestamptz', @@ -2465,7 +2465,7 @@ proname => 'datetime_pl', prorettype => 'timestamp', proargtypes => 'date time', prosrc => 'datetime_timestamp' }, { oid => '1273', descr => 'extract field from time with time zone', - proname => 'date_part', prorettype => 'float8', proargtypes => 'text timetz', + proname => 'date_part', prorettype => 'numeric', proargtypes => 'text timetz', prosrc => 'timetz_part' }, { oid => '1274', proname => 'int84pl', prorettype => 'int8', proargtypes => 'int8 int4', @@ -2812,11 +2812,10 @@ prosrc => 'textlen' }, { oid => '1384', descr => 'extract field from date', - proname => 'date_part', prolang => 'sql', prorettype => 'float8', - proargtypes => 'text date', - prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' }, + proname => 'date_part', prorettype => 'numeric', proargtypes => 'text date', + prosrc => 'date_part' }, { oid => '1385', descr => 'extract field from time', - proname => 'date_part', prorettype => 'float8', proargtypes => 'text time', + proname => 'date_part', prorettype => 'numeric', proargtypes => 'text time', prosrc => 'time_part' }, { oid => '1386', descr => 'date difference from today preserving months and years', @@ -5721,7 +5720,7 @@ proname => 'date_trunc', prorettype => 'timestamp', proargtypes => 'text timestamp', prosrc => 'timestamp_trunc' }, { oid => '2021', descr => 'extract field from timestamp', - proname => 'date_part', prorettype => 'float8', + proname => 'date_part', prorettype => 'numeric', proargtypes => 'text timestamp', prosrc => 'timestamp_part' }, { oid => '2024', descr => 'convert date to timestamp', proname => 'timestamp', prorettype => 'timestamp', proargtypes => 'date', diff --git a/src/test/regress/expected/date.out b/src/test/regress/expected/date.out index d035fe1f1e..4d2115a4c6 100644 --- a/src/test/regress/expected/date.out +++ b/src/test/regress/expected/date.out @@ -974,13 +974,13 @@ SELECT EXTRACT(EPOCH FROM DATE '1970-01-01'); -- 0 SELECT EXTRACT(EPOCH FROM TIMESTAMP '1970-01-01'); -- 0 date_part ----------- - 0 + 0.000000 (1 row) SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '1970-01-01+00'); -- 0 date_part ----------- - 0 + 0.000000 (1 row) -- @@ -1157,35 +1157,15 @@ SELECT EXTRACT(CENTURY FROM TIMESTAMP '1970-03-20 04:30:00.00000'); -- 20 -- all possible fields -- SELECT EXTRACT(MICROSECONDS FROM DATE '2020-08-11'); - date_part ------------ - 0 -(1 row) - +ERROR: date units "microseconds" not supported SELECT EXTRACT(MILLISECONDS FROM DATE '2020-08-11'); - date_part ------------ - 0 -(1 row) - +ERROR: date units "milliseconds" not supported SELECT EXTRACT(SECOND FROM DATE '2020-08-11'); - date_part ------------ - 0 -(1 row) - +ERROR: date units "second" not supported SELECT EXTRACT(MINUTE FROM DATE '2020-08-11'); - date_part ------------ - 0 -(1 row) - +ERROR: date units "minute" not supported SELECT EXTRACT(HOUR FROM DATE '2020-08-11'); - date_part ------------ - 0 -(1 row) - +ERROR: date units "hour" not supported SELECT EXTRACT(DAY FROM DATE '2020-08-11'); date_part ----------- @@ -1259,14 +1239,11 @@ SELECT EXTRACT(DOY FROM DATE '2020-08-11'); (1 row) SELECT EXTRACT(TIMEZONE FROM DATE '2020-08-11'); -ERROR: timestamp units "timezone" not supported -CONTEXT: SQL function "date_part" statement 1 +ERROR: date units "timezone" not supported SELECT EXTRACT(TIMEZONE_M FROM DATE '2020-08-11'); -ERROR: timestamp units "timezone_m" not supported -CONTEXT: SQL function "date_part" statement 1 +ERROR: date units "timezone_m" not supported SELECT EXTRACT(TIMEZONE_H FROM DATE '2020-08-11'); -ERROR: timestamp units "timezone_h" not supported -CONTEXT: SQL function "date_part" statement 1 +ERROR: date units "timezone_h" not supported SELECT EXTRACT(EPOCH FROM DATE '2020-08-11'); date_part ------------ @@ -1372,13 +1349,13 @@ select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today' -- -- oscillating fields from non-finite date/timestamptz: -- -SELECT EXTRACT(HOUR FROM DATE 'infinity'); -- NULL +SELECT EXTRACT(DAY FROM DATE 'infinity'); -- NULL date_part ----------- (1 row) -SELECT EXTRACT(HOUR FROM DATE '-infinity'); -- NULL +SELECT EXTRACT(DAY FROM DATE '-infinity'); -- NULL date_part ----------- @@ -1410,35 +1387,15 @@ SELECT EXTRACT(HOUR FROM TIMESTAMPTZ '-infinity'); -- NULL -- all possible fields SELECT EXTRACT(MICROSECONDS FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "microseconds" not supported SELECT EXTRACT(MILLISECONDS FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "milliseconds" not supported SELECT EXTRACT(SECOND FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "second" not supported SELECT EXTRACT(MINUTE FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "minute" not supported SELECT EXTRACT(HOUR FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "hour" not supported SELECT EXTRACT(DAY FROM DATE 'infinity'); -- NULL date_part ----------- @@ -1482,23 +1439,11 @@ SELECT EXTRACT(DOY FROM DATE 'infinity'); -- NULL (1 row) SELECT EXTRACT(TIMEZONE FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "timezone" not supported SELECT EXTRACT(TIMEZONE_M FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "timezone_m" not supported SELECT EXTRACT(TIMEZONE_H FROM DATE 'infinity'); -- NULL - date_part ------------ - -(1 row) - +ERROR: date units "timezone_h" not supported -- -- monotonic fields from non-finite date/timestamptz: -- @@ -1584,9 +1529,8 @@ SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity -- -- wrong fields from non-finite date: -- -SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized -ERROR: timestamp units "microsec" not recognized -CONTEXT: SQL function "date_part" statement 1 +SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: date units "microsec" not recognized +ERROR: date units "microsec" not recognized -- test constructors select make_date(2013, 7, 15); make_date diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index fde4be5271..274a3714cf 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -948,18 +948,18 @@ SELECT f1, EXTRACT(MILLENNIUM FROM f1) AS MILLENNIUM, EXTRACT(EPOCH FROM f1) AS EPOCH FROM INTERVAL_TBL; - f1 | microsecond | millisecond | second | minute | hour | day | month | quarter | year | decade | century | millennium | epoch --------------------------------+-------------+-------------+--------+--------+------+-----+-------+---------+------+--------+---------+------------+------------ - @ 1 min | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 60 - @ 5 hours | 0 | 0 | 0 | 0 | 5 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 18000 - @ 10 days | 0 | 0 | 0 | 0 | 0 | 10 | 0 | 1 | 0 | 0 | 0 | 0 | 864000 - @ 34 years | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 34 | 3 | 0 | 0 | 1072958400 - @ 3 mons | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 2 | 0 | 0 | 0 | 0 | 7776000 - @ 14 secs ago | -14000000 | -14000 | -14 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | -14 - @ 1 day 2 hours 3 mins 4 secs | 4000000 | 4000 | 4 | 3 | 2 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 93784 - @ 6 years | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 6 | 0 | 0 | 0 | 189345600 - @ 5 mons | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 2 | 0 | 0 | 0 | 0 | 12960000 - @ 5 mons 12 hours | 0 | 0 | 0 | 0 | 12 | 0 | 5 | 2 | 0 | 0 | 0 | 0 | 13003200 + f1 | microsecond | millisecond | second | minute | hour | day | month | quarter | year | decade | century | millennium | epoch +-------------------------------+-------------+-------------+------------+--------+------+-----+-------+---------+------+--------+---------+------------+------------------- + @ 1 min | 0 | 0.000 | 0.000000 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 60.000000 + @ 5 hours | 0 | 0.000 | 0.000000 | 0 | 5 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 18000.000000 + @ 10 days | 0 | 0.000 | 0.000000 | 0 | 0 | 10 | 0 | 1 | 0 | 0 | 0 | 0 | 864000.000000 + @ 34 years | 0 | 0.000 | 0.000000 | 0 | 0 | 0 | 0 | 1 | 34 | 3 | 0 | 0 | 1072224000.000000 + @ 3 mons | 0 | 0.000 | 0.000000 | 0 | 0 | 0 | 3 | 2 | 0 | 0 | 0 | 0 | 7776000.000000 + @ 14 secs ago | -14000000 | -14000.000 | -14.000000 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | -14.000000 + @ 1 day 2 hours 3 mins 4 secs | 4000000 | 4000.000 | 4.000000 | 3 | 2 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 93784.000000 + @ 6 years | 0 | 0.000 | 0.000000 | 0 | 0 | 0 | 0 | 1 | 6 | 0 | 0 | 0 | 189216000.000000 + @ 5 mons | 0 | 0.000 | 0.000000 | 0 | 0 | 0 | 5 | 2 | 0 | 0 | 0 | 0 | 12960000.000000 + @ 5 mons 12 hours | 0 | 0.000 | 0.000000 | 0 | 12 | 0 | 5 | 2 | 0 | 0 | 0 | 0 | 13003200.000000 (10 rows) SELECT EXTRACT(FORTNIGHT FROM INTERVAL '2 days'); -- error diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out index 5f97505a30..1c3f0db1d1 100644 --- a/src/test/regress/expected/timestamp.out +++ b/src/test/regress/expected/timestamp.out @@ -615,146 +615,146 @@ SELECT d1 as "timestamp", date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second FROM TIMESTAMP_TBL; - timestamp | year | month | day | hour | minute | second ------------------------------+-----------+-------+-----+------+--------+-------- - -infinity | -Infinity | | | | | - infinity | Infinity | | | | | - Thu Jan 01 00:00:00 1970 | 1970 | 1 | 1 | 0 | 0 | 0 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:02 1997 | 1997 | 2 | 10 | 17 | 32 | 2 - Mon Feb 10 17:32:01.4 1997 | 1997 | 2 | 10 | 17 | 32 | 1.4 - Mon Feb 10 17:32:01.5 1997 | 1997 | 2 | 10 | 17 | 32 | 1.5 - Mon Feb 10 17:32:01.6 1997 | 1997 | 2 | 10 | 17 | 32 | 1.6 - Thu Jan 02 00:00:00 1997 | 1997 | 1 | 2 | 0 | 0 | 0 - Thu Jan 02 03:04:05 1997 | 1997 | 1 | 2 | 3 | 4 | 5 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Tue Jun 10 17:32:01 1997 | 1997 | 6 | 10 | 17 | 32 | 1 - Sat Sep 22 18:19:20 2001 | 2001 | 9 | 22 | 18 | 19 | 20 - Wed Mar 15 08:14:01 2000 | 2000 | 3 | 15 | 8 | 14 | 1 - Wed Mar 15 13:14:02 2000 | 2000 | 3 | 15 | 13 | 14 | 2 - Wed Mar 15 12:14:03 2000 | 2000 | 3 | 15 | 12 | 14 | 3 - Wed Mar 15 03:14:04 2000 | 2000 | 3 | 15 | 3 | 14 | 4 - Wed Mar 15 02:14:05 2000 | 2000 | 3 | 15 | 2 | 14 | 5 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:00 1997 | 1997 | 2 | 10 | 17 | 32 | 0 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Tue Jun 10 18:32:01 1997 | 1997 | 6 | 10 | 18 | 32 | 1 - Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1 - Tue Feb 11 17:32:01 1997 | 1997 | 2 | 11 | 17 | 32 | 1 - Wed Feb 12 17:32:01 1997 | 1997 | 2 | 12 | 17 | 32 | 1 - Thu Feb 13 17:32:01 1997 | 1997 | 2 | 13 | 17 | 32 | 1 - Fri Feb 14 17:32:01 1997 | 1997 | 2 | 14 | 17 | 32 | 1 - Sat Feb 15 17:32:01 1997 | 1997 | 2 | 15 | 17 | 32 | 1 - Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 0097 BC | -97 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 0097 | 97 | 2 | 16 | 17 | 32 | 1 - Thu Feb 16 17:32:01 0597 | 597 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 1097 | 1097 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 1697 | 1697 | 2 | 16 | 17 | 32 | 1 - Thu Feb 16 17:32:01 1797 | 1797 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 1897 | 1897 | 2 | 16 | 17 | 32 | 1 - Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 2097 | 2097 | 2 | 16 | 17 | 32 | 1 - Wed Feb 28 17:32:01 1996 | 1996 | 2 | 28 | 17 | 32 | 1 - Thu Feb 29 17:32:01 1996 | 1996 | 2 | 29 | 17 | 32 | 1 - Fri Mar 01 17:32:01 1996 | 1996 | 3 | 1 | 17 | 32 | 1 - Mon Dec 30 17:32:01 1996 | 1996 | 12 | 30 | 17 | 32 | 1 - Tue Dec 31 17:32:01 1996 | 1996 | 12 | 31 | 17 | 32 | 1 - Wed Jan 01 17:32:01 1997 | 1997 | 1 | 1 | 17 | 32 | 1 - Fri Feb 28 17:32:01 1997 | 1997 | 2 | 28 | 17 | 32 | 1 - Sat Mar 01 17:32:01 1997 | 1997 | 3 | 1 | 17 | 32 | 1 - Tue Dec 30 17:32:01 1997 | 1997 | 12 | 30 | 17 | 32 | 1 - Wed Dec 31 17:32:01 1997 | 1997 | 12 | 31 | 17 | 32 | 1 - Fri Dec 31 17:32:01 1999 | 1999 | 12 | 31 | 17 | 32 | 1 - Sat Jan 01 17:32:01 2000 | 2000 | 1 | 1 | 17 | 32 | 1 - Sun Dec 31 17:32:01 2000 | 2000 | 12 | 31 | 17 | 32 | 1 - Mon Jan 01 17:32:01 2001 | 2001 | 1 | 1 | 17 | 32 | 1 + timestamp | year | month | day | hour | minute | second +-----------------------------+-----------+-------+-----+------+--------+----------- + -infinity | -Infinity | | | | | + infinity | Infinity | | | | | + Thu Jan 01 00:00:00 1970 | 1970 | 1 | 1 | 0 | 0 | 0.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:02 1997 | 1997 | 2 | 10 | 17 | 32 | 2.000000 + Mon Feb 10 17:32:01.4 1997 | 1997 | 2 | 10 | 17 | 32 | 1.400000 + Mon Feb 10 17:32:01.5 1997 | 1997 | 2 | 10 | 17 | 32 | 1.500000 + Mon Feb 10 17:32:01.6 1997 | 1997 | 2 | 10 | 17 | 32 | 1.600000 + Thu Jan 02 00:00:00 1997 | 1997 | 1 | 2 | 0 | 0 | 0.000000 + Thu Jan 02 03:04:05 1997 | 1997 | 1 | 2 | 3 | 4 | 5.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Tue Jun 10 17:32:01 1997 | 1997 | 6 | 10 | 17 | 32 | 1.000000 + Sat Sep 22 18:19:20 2001 | 2001 | 9 | 22 | 18 | 19 | 20.000000 + Wed Mar 15 08:14:01 2000 | 2000 | 3 | 15 | 8 | 14 | 1.000000 + Wed Mar 15 13:14:02 2000 | 2000 | 3 | 15 | 13 | 14 | 2.000000 + Wed Mar 15 12:14:03 2000 | 2000 | 3 | 15 | 12 | 14 | 3.000000 + Wed Mar 15 03:14:04 2000 | 2000 | 3 | 15 | 3 | 14 | 4.000000 + Wed Mar 15 02:14:05 2000 | 2000 | 3 | 15 | 2 | 14 | 5.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:00 1997 | 1997 | 2 | 10 | 17 | 32 | 0.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Tue Jun 10 18:32:01 1997 | 1997 | 6 | 10 | 18 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Tue Feb 11 17:32:01 1997 | 1997 | 2 | 11 | 17 | 32 | 1.000000 + Wed Feb 12 17:32:01 1997 | 1997 | 2 | 12 | 17 | 32 | 1.000000 + Thu Feb 13 17:32:01 1997 | 1997 | 2 | 13 | 17 | 32 | 1.000000 + Fri Feb 14 17:32:01 1997 | 1997 | 2 | 14 | 17 | 32 | 1.000000 + Sat Feb 15 17:32:01 1997 | 1997 | 2 | 15 | 17 | 32 | 1.000000 + Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 0097 BC | -97 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 0097 | 97 | 2 | 16 | 17 | 32 | 1.000000 + Thu Feb 16 17:32:01 0597 | 597 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 1097 | 1097 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 1697 | 1697 | 2 | 16 | 17 | 32 | 1.000000 + Thu Feb 16 17:32:01 1797 | 1797 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 1897 | 1897 | 2 | 16 | 17 | 32 | 1.000000 + Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 2097 | 2097 | 2 | 16 | 17 | 32 | 1.000000 + Wed Feb 28 17:32:01 1996 | 1996 | 2 | 28 | 17 | 32 | 1.000000 + Thu Feb 29 17:32:01 1996 | 1996 | 2 | 29 | 17 | 32 | 1.000000 + Fri Mar 01 17:32:01 1996 | 1996 | 3 | 1 | 17 | 32 | 1.000000 + Mon Dec 30 17:32:01 1996 | 1996 | 12 | 30 | 17 | 32 | 1.000000 + Tue Dec 31 17:32:01 1996 | 1996 | 12 | 31 | 17 | 32 | 1.000000 + Wed Jan 01 17:32:01 1997 | 1997 | 1 | 1 | 17 | 32 | 1.000000 + Fri Feb 28 17:32:01 1997 | 1997 | 2 | 28 | 17 | 32 | 1.000000 + Sat Mar 01 17:32:01 1997 | 1997 | 3 | 1 | 17 | 32 | 1.000000 + Tue Dec 30 17:32:01 1997 | 1997 | 12 | 30 | 17 | 32 | 1.000000 + Wed Dec 31 17:32:01 1997 | 1997 | 12 | 31 | 17 | 32 | 1.000000 + Fri Dec 31 17:32:01 1999 | 1999 | 12 | 31 | 17 | 32 | 1.000000 + Sat Jan 01 17:32:01 2000 | 2000 | 1 | 1 | 17 | 32 | 1.000000 + Sun Dec 31 17:32:01 2000 | 2000 | 12 | 31 | 17 | 32 | 1.000000 + Mon Jan 01 17:32:01 2001 | 2001 | 1 | 1 | 17 | 32 | 1.000000 (65 rows) SELECT d1 as "timestamp", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, date_part( 'usec', d1) AS usec FROM TIMESTAMP_TBL; - timestamp | quarter | msec | usec ------------------------------+---------+-------+---------- - -infinity | | | - infinity | | | - Thu Jan 01 00:00:00 1970 | 1 | 0 | 0 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:02 1997 | 1 | 2000 | 2000000 - Mon Feb 10 17:32:01.4 1997 | 1 | 1400 | 1400000 - Mon Feb 10 17:32:01.5 1997 | 1 | 1500 | 1500000 - Mon Feb 10 17:32:01.6 1997 | 1 | 1600 | 1600000 - Thu Jan 02 00:00:00 1997 | 1 | 0 | 0 - Thu Jan 02 03:04:05 1997 | 1 | 5000 | 5000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Tue Jun 10 17:32:01 1997 | 2 | 1000 | 1000000 - Sat Sep 22 18:19:20 2001 | 3 | 20000 | 20000000 - Wed Mar 15 08:14:01 2000 | 1 | 1000 | 1000000 - Wed Mar 15 13:14:02 2000 | 1 | 2000 | 2000000 - Wed Mar 15 12:14:03 2000 | 1 | 3000 | 3000000 - Wed Mar 15 03:14:04 2000 | 1 | 4000 | 4000000 - Wed Mar 15 02:14:05 2000 | 1 | 5000 | 5000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:00 1997 | 1 | 0 | 0 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Tue Jun 10 18:32:01 1997 | 2 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000 - Tue Feb 11 17:32:01 1997 | 1 | 1000 | 1000000 - Wed Feb 12 17:32:01 1997 | 1 | 1000 | 1000000 - Thu Feb 13 17:32:01 1997 | 1 | 1000 | 1000000 - Fri Feb 14 17:32:01 1997 | 1 | 1000 | 1000000 - Sat Feb 15 17:32:01 1997 | 1 | 1000 | 1000000 - Sun Feb 16 17:32:01 1997 | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 0097 BC | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 0097 | 1 | 1000 | 1000000 - Thu Feb 16 17:32:01 0597 | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 1097 | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 1697 | 1 | 1000 | 1000000 - Thu Feb 16 17:32:01 1797 | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 1897 | 1 | 1000 | 1000000 - Sun Feb 16 17:32:01 1997 | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 2097 | 1 | 1000 | 1000000 - Wed Feb 28 17:32:01 1996 | 1 | 1000 | 1000000 - Thu Feb 29 17:32:01 1996 | 1 | 1000 | 1000000 - Fri Mar 01 17:32:01 1996 | 1 | 1000 | 1000000 - Mon Dec 30 17:32:01 1996 | 4 | 1000 | 1000000 - Tue Dec 31 17:32:01 1996 | 4 | 1000 | 1000000 - Wed Jan 01 17:32:01 1997 | 1 | 1000 | 1000000 - Fri Feb 28 17:32:01 1997 | 1 | 1000 | 1000000 - Sat Mar 01 17:32:01 1997 | 1 | 1000 | 1000000 - Tue Dec 30 17:32:01 1997 | 4 | 1000 | 1000000 - Wed Dec 31 17:32:01 1997 | 4 | 1000 | 1000000 - Fri Dec 31 17:32:01 1999 | 4 | 1000 | 1000000 - Sat Jan 01 17:32:01 2000 | 1 | 1000 | 1000000 - Sun Dec 31 17:32:01 2000 | 4 | 1000 | 1000000 - Mon Jan 01 17:32:01 2001 | 1 | 1000 | 1000000 + timestamp | quarter | msec | usec +-----------------------------+---------+-----------+---------- + -infinity | | | + infinity | | | + Thu Jan 01 00:00:00 1970 | 1 | 0.000 | 0 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:02 1997 | 1 | 2000.000 | 2000000 + Mon Feb 10 17:32:01.4 1997 | 1 | 1400.000 | 1400000 + Mon Feb 10 17:32:01.5 1997 | 1 | 1500.000 | 1500000 + Mon Feb 10 17:32:01.6 1997 | 1 | 1600.000 | 1600000 + Thu Jan 02 00:00:00 1997 | 1 | 0.000 | 0 + Thu Jan 02 03:04:05 1997 | 1 | 5000.000 | 5000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Tue Jun 10 17:32:01 1997 | 2 | 1000.000 | 1000000 + Sat Sep 22 18:19:20 2001 | 3 | 20000.000 | 20000000 + Wed Mar 15 08:14:01 2000 | 1 | 1000.000 | 1000000 + Wed Mar 15 13:14:02 2000 | 1 | 2000.000 | 2000000 + Wed Mar 15 12:14:03 2000 | 1 | 3000.000 | 3000000 + Wed Mar 15 03:14:04 2000 | 1 | 4000.000 | 4000000 + Wed Mar 15 02:14:05 2000 | 1 | 5000.000 | 5000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:00 1997 | 1 | 0.000 | 0 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Tue Jun 10 18:32:01 1997 | 2 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 | 1 | 1000.000 | 1000000 + Tue Feb 11 17:32:01 1997 | 1 | 1000.000 | 1000000 + Wed Feb 12 17:32:01 1997 | 1 | 1000.000 | 1000000 + Thu Feb 13 17:32:01 1997 | 1 | 1000.000 | 1000000 + Fri Feb 14 17:32:01 1997 | 1 | 1000.000 | 1000000 + Sat Feb 15 17:32:01 1997 | 1 | 1000.000 | 1000000 + Sun Feb 16 17:32:01 1997 | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 0097 BC | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 0097 | 1 | 1000.000 | 1000000 + Thu Feb 16 17:32:01 0597 | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 1097 | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 1697 | 1 | 1000.000 | 1000000 + Thu Feb 16 17:32:01 1797 | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 1897 | 1 | 1000.000 | 1000000 + Sun Feb 16 17:32:01 1997 | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 2097 | 1 | 1000.000 | 1000000 + Wed Feb 28 17:32:01 1996 | 1 | 1000.000 | 1000000 + Thu Feb 29 17:32:01 1996 | 1 | 1000.000 | 1000000 + Fri Mar 01 17:32:01 1996 | 1 | 1000.000 | 1000000 + Mon Dec 30 17:32:01 1996 | 4 | 1000.000 | 1000000 + Tue Dec 31 17:32:01 1996 | 4 | 1000.000 | 1000000 + Wed Jan 01 17:32:01 1997 | 1 | 1000.000 | 1000000 + Fri Feb 28 17:32:01 1997 | 1 | 1000.000 | 1000000 + Sat Mar 01 17:32:01 1997 | 1 | 1000.000 | 1000000 + Tue Dec 30 17:32:01 1997 | 4 | 1000.000 | 1000000 + Wed Dec 31 17:32:01 1997 | 4 | 1000.000 | 1000000 + Fri Dec 31 17:32:01 1999 | 4 | 1000.000 | 1000000 + Sat Jan 01 17:32:01 2000 | 1 | 1000.000 | 1000000 + Sun Dec 31 17:32:01 2000 | 4 | 1000.000 | 1000000 + Mon Jan 01 17:32:01 2001 | 1 | 1000.000 | 1000000 (65 rows) SELECT d1 as "timestamp", diff --git a/src/test/regress/expected/timestamptz.out b/src/test/regress/expected/timestamptz.out index 639b50308e..2420d433de 100644 --- a/src/test/regress/expected/timestamptz.out +++ b/src/test/regress/expected/timestamptz.out @@ -733,148 +733,148 @@ SELECT d1 as timestamptz, date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second FROM TIMESTAMPTZ_TBL; - timestamptz | year | month | day | hour | minute | second ----------------------------------+-----------+-------+-----+------+--------+-------- - -infinity | -Infinity | | | | | - infinity | Infinity | | | | | - Wed Dec 31 16:00:00 1969 PST | 1969 | 12 | 31 | 16 | 0 | 0 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:02 1997 PST | 1997 | 2 | 10 | 17 | 32 | 2 - Mon Feb 10 17:32:01.4 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.4 - Mon Feb 10 17:32:01.5 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.5 - Mon Feb 10 17:32:01.6 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.6 - Thu Jan 02 00:00:00 1997 PST | 1997 | 1 | 2 | 0 | 0 | 0 - Thu Jan 02 03:04:05 1997 PST | 1997 | 1 | 2 | 3 | 4 | 5 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Tue Jun 10 17:32:01 1997 PDT | 1997 | 6 | 10 | 17 | 32 | 1 - Sat Sep 22 18:19:20 2001 PDT | 2001 | 9 | 22 | 18 | 19 | 20 - Wed Mar 15 08:14:01 2000 PST | 2000 | 3 | 15 | 8 | 14 | 1 - Wed Mar 15 04:14:02 2000 PST | 2000 | 3 | 15 | 4 | 14 | 2 - Wed Mar 15 02:14:03 2000 PST | 2000 | 3 | 15 | 2 | 14 | 3 - Wed Mar 15 03:14:04 2000 PST | 2000 | 3 | 15 | 3 | 14 | 4 - Wed Mar 15 01:14:05 2000 PST | 2000 | 3 | 15 | 1 | 14 | 5 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:00 1997 PST | 1997 | 2 | 10 | 17 | 32 | 0 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1 - Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1 - Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1 - Mon Feb 10 14:32:01 1997 PST | 1997 | 2 | 10 | 14 | 32 | 1 - Thu Jul 10 14:32:01 1997 PDT | 1997 | 7 | 10 | 14 | 32 | 1 - Tue Jun 10 18:32:01 1997 PDT | 1997 | 6 | 10 | 18 | 32 | 1 - Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1 - Tue Feb 11 17:32:01 1997 PST | 1997 | 2 | 11 | 17 | 32 | 1 - Wed Feb 12 17:32:01 1997 PST | 1997 | 2 | 12 | 17 | 32 | 1 - Thu Feb 13 17:32:01 1997 PST | 1997 | 2 | 13 | 17 | 32 | 1 - Fri Feb 14 17:32:01 1997 PST | 1997 | 2 | 14 | 17 | 32 | 1 - Sat Feb 15 17:32:01 1997 PST | 1997 | 2 | 15 | 17 | 32 | 1 - Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 0097 PST BC | -97 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 0097 PST | 97 | 2 | 16 | 17 | 32 | 1 - Thu Feb 16 17:32:01 0597 PST | 597 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 1097 PST | 1097 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 1697 PST | 1697 | 2 | 16 | 17 | 32 | 1 - Thu Feb 16 17:32:01 1797 PST | 1797 | 2 | 16 | 17 | 32 | 1 - Tue Feb 16 17:32:01 1897 PST | 1897 | 2 | 16 | 17 | 32 | 1 - Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1 - Sat Feb 16 17:32:01 2097 PST | 2097 | 2 | 16 | 17 | 32 | 1 - Wed Feb 28 17:32:01 1996 PST | 1996 | 2 | 28 | 17 | 32 | 1 - Thu Feb 29 17:32:01 1996 PST | 1996 | 2 | 29 | 17 | 32 | 1 - Fri Mar 01 17:32:01 1996 PST | 1996 | 3 | 1 | 17 | 32 | 1 - Mon Dec 30 17:32:01 1996 PST | 1996 | 12 | 30 | 17 | 32 | 1 - Tue Dec 31 17:32:01 1996 PST | 1996 | 12 | 31 | 17 | 32 | 1 - Wed Jan 01 17:32:01 1997 PST | 1997 | 1 | 1 | 17 | 32 | 1 - Fri Feb 28 17:32:01 1997 PST | 1997 | 2 | 28 | 17 | 32 | 1 - Sat Mar 01 17:32:01 1997 PST | 1997 | 3 | 1 | 17 | 32 | 1 - Tue Dec 30 17:32:01 1997 PST | 1997 | 12 | 30 | 17 | 32 | 1 - Wed Dec 31 17:32:01 1997 PST | 1997 | 12 | 31 | 17 | 32 | 1 - Fri Dec 31 17:32:01 1999 PST | 1999 | 12 | 31 | 17 | 32 | 1 - Sat Jan 01 17:32:01 2000 PST | 2000 | 1 | 1 | 17 | 32 | 1 - Sun Dec 31 17:32:01 2000 PST | 2000 | 12 | 31 | 17 | 32 | 1 - Mon Jan 01 17:32:01 2001 PST | 2001 | 1 | 1 | 17 | 32 | 1 + timestamptz | year | month | day | hour | minute | second +---------------------------------+-----------+-------+-----+------+--------+----------- + -infinity | -Infinity | | | | | + infinity | Infinity | | | | | + Wed Dec 31 16:00:00 1969 PST | 1969 | 12 | 31 | 16 | 0 | 0.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:02 1997 PST | 1997 | 2 | 10 | 17 | 32 | 2.000000 + Mon Feb 10 17:32:01.4 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.400000 + Mon Feb 10 17:32:01.5 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.500000 + Mon Feb 10 17:32:01.6 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.600000 + Thu Jan 02 00:00:00 1997 PST | 1997 | 1 | 2 | 0 | 0 | 0.000000 + Thu Jan 02 03:04:05 1997 PST | 1997 | 1 | 2 | 3 | 4 | 5.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Tue Jun 10 17:32:01 1997 PDT | 1997 | 6 | 10 | 17 | 32 | 1.000000 + Sat Sep 22 18:19:20 2001 PDT | 2001 | 9 | 22 | 18 | 19 | 20.000000 + Wed Mar 15 08:14:01 2000 PST | 2000 | 3 | 15 | 8 | 14 | 1.000000 + Wed Mar 15 04:14:02 2000 PST | 2000 | 3 | 15 | 4 | 14 | 2.000000 + Wed Mar 15 02:14:03 2000 PST | 2000 | 3 | 15 | 2 | 14 | 3.000000 + Wed Mar 15 03:14:04 2000 PST | 2000 | 3 | 15 | 3 | 14 | 4.000000 + Wed Mar 15 01:14:05 2000 PST | 2000 | 3 | 15 | 1 | 14 | 5.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:00 1997 PST | 1997 | 2 | 10 | 17 | 32 | 0.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1.000000 + Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1.000000 + Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1.000000 + Mon Feb 10 14:32:01 1997 PST | 1997 | 2 | 10 | 14 | 32 | 1.000000 + Thu Jul 10 14:32:01 1997 PDT | 1997 | 7 | 10 | 14 | 32 | 1.000000 + Tue Jun 10 18:32:01 1997 PDT | 1997 | 6 | 10 | 18 | 32 | 1.000000 + Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.000000 + Tue Feb 11 17:32:01 1997 PST | 1997 | 2 | 11 | 17 | 32 | 1.000000 + Wed Feb 12 17:32:01 1997 PST | 1997 | 2 | 12 | 17 | 32 | 1.000000 + Thu Feb 13 17:32:01 1997 PST | 1997 | 2 | 13 | 17 | 32 | 1.000000 + Fri Feb 14 17:32:01 1997 PST | 1997 | 2 | 14 | 17 | 32 | 1.000000 + Sat Feb 15 17:32:01 1997 PST | 1997 | 2 | 15 | 17 | 32 | 1.000000 + Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 0097 PST BC | -97 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 0097 PST | 97 | 2 | 16 | 17 | 32 | 1.000000 + Thu Feb 16 17:32:01 0597 PST | 597 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 1097 PST | 1097 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 1697 PST | 1697 | 2 | 16 | 17 | 32 | 1.000000 + Thu Feb 16 17:32:01 1797 PST | 1797 | 2 | 16 | 17 | 32 | 1.000000 + Tue Feb 16 17:32:01 1897 PST | 1897 | 2 | 16 | 17 | 32 | 1.000000 + Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1.000000 + Sat Feb 16 17:32:01 2097 PST | 2097 | 2 | 16 | 17 | 32 | 1.000000 + Wed Feb 28 17:32:01 1996 PST | 1996 | 2 | 28 | 17 | 32 | 1.000000 + Thu Feb 29 17:32:01 1996 PST | 1996 | 2 | 29 | 17 | 32 | 1.000000 + Fri Mar 01 17:32:01 1996 PST | 1996 | 3 | 1 | 17 | 32 | 1.000000 + Mon Dec 30 17:32:01 1996 PST | 1996 | 12 | 30 | 17 | 32 | 1.000000 + Tue Dec 31 17:32:01 1996 PST | 1996 | 12 | 31 | 17 | 32 | 1.000000 + Wed Jan 01 17:32:01 1997 PST | 1997 | 1 | 1 | 17 | 32 | 1.000000 + Fri Feb 28 17:32:01 1997 PST | 1997 | 2 | 28 | 17 | 32 | 1.000000 + Sat Mar 01 17:32:01 1997 PST | 1997 | 3 | 1 | 17 | 32 | 1.000000 + Tue Dec 30 17:32:01 1997 PST | 1997 | 12 | 30 | 17 | 32 | 1.000000 + Wed Dec 31 17:32:01 1997 PST | 1997 | 12 | 31 | 17 | 32 | 1.000000 + Fri Dec 31 17:32:01 1999 PST | 1999 | 12 | 31 | 17 | 32 | 1.000000 + Sat Jan 01 17:32:01 2000 PST | 2000 | 1 | 1 | 17 | 32 | 1.000000 + Sun Dec 31 17:32:01 2000 PST | 2000 | 12 | 31 | 17 | 32 | 1.000000 + Mon Jan 01 17:32:01 2001 PST | 2001 | 1 | 1 | 17 | 32 | 1.000000 (66 rows) SELECT d1 as timestamptz, date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, date_part( 'usec', d1) AS usec FROM TIMESTAMPTZ_TBL; - timestamptz | quarter | msec | usec ----------------------------------+---------+-------+---------- - -infinity | | | - infinity | | | - Wed Dec 31 16:00:00 1969 PST | 4 | 0 | 0 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:02 1997 PST | 1 | 2000 | 2000000 - Mon Feb 10 17:32:01.4 1997 PST | 1 | 1400 | 1400000 - Mon Feb 10 17:32:01.5 1997 PST | 1 | 1500 | 1500000 - Mon Feb 10 17:32:01.6 1997 PST | 1 | 1600 | 1600000 - Thu Jan 02 00:00:00 1997 PST | 1 | 0 | 0 - Thu Jan 02 03:04:05 1997 PST | 1 | 5000 | 5000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Tue Jun 10 17:32:01 1997 PDT | 2 | 1000 | 1000000 - Sat Sep 22 18:19:20 2001 PDT | 3 | 20000 | 20000000 - Wed Mar 15 08:14:01 2000 PST | 1 | 1000 | 1000000 - Wed Mar 15 04:14:02 2000 PST | 1 | 2000 | 2000000 - Wed Mar 15 02:14:03 2000 PST | 1 | 3000 | 3000000 - Wed Mar 15 03:14:04 2000 PST | 1 | 4000 | 4000000 - Wed Mar 15 01:14:05 2000 PST | 1 | 5000 | 5000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:00 1997 PST | 1 | 0 | 0 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000 - Mon Feb 10 14:32:01 1997 PST | 1 | 1000 | 1000000 - Thu Jul 10 14:32:01 1997 PDT | 3 | 1000 | 1000000 - Tue Jun 10 18:32:01 1997 PDT | 2 | 1000 | 1000000 - Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000 - Tue Feb 11 17:32:01 1997 PST | 1 | 1000 | 1000000 - Wed Feb 12 17:32:01 1997 PST | 1 | 1000 | 1000000 - Thu Feb 13 17:32:01 1997 PST | 1 | 1000 | 1000000 - Fri Feb 14 17:32:01 1997 PST | 1 | 1000 | 1000000 - Sat Feb 15 17:32:01 1997 PST | 1 | 1000 | 1000000 - Sun Feb 16 17:32:01 1997 PST | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 0097 PST BC | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 0097 PST | 1 | 1000 | 1000000 - Thu Feb 16 17:32:01 0597 PST | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 1097 PST | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 1697 PST | 1 | 1000 | 1000000 - Thu Feb 16 17:32:01 1797 PST | 1 | 1000 | 1000000 - Tue Feb 16 17:32:01 1897 PST | 1 | 1000 | 1000000 - Sun Feb 16 17:32:01 1997 PST | 1 | 1000 | 1000000 - Sat Feb 16 17:32:01 2097 PST | 1 | 1000 | 1000000 - Wed Feb 28 17:32:01 1996 PST | 1 | 1000 | 1000000 - Thu Feb 29 17:32:01 1996 PST | 1 | 1000 | 1000000 - Fri Mar 01 17:32:01 1996 PST | 1 | 1000 | 1000000 - Mon Dec 30 17:32:01 1996 PST | 4 | 1000 | 1000000 - Tue Dec 31 17:32:01 1996 PST | 4 | 1000 | 1000000 - Wed Jan 01 17:32:01 1997 PST | 1 | 1000 | 1000000 - Fri Feb 28 17:32:01 1997 PST | 1 | 1000 | 1000000 - Sat Mar 01 17:32:01 1997 PST | 1 | 1000 | 1000000 - Tue Dec 30 17:32:01 1997 PST | 4 | 1000 | 1000000 - Wed Dec 31 17:32:01 1997 PST | 4 | 1000 | 1000000 - Fri Dec 31 17:32:01 1999 PST | 4 | 1000 | 1000000 - Sat Jan 01 17:32:01 2000 PST | 1 | 1000 | 1000000 - Sun Dec 31 17:32:01 2000 PST | 4 | 1000 | 1000000 - Mon Jan 01 17:32:01 2001 PST | 1 | 1000 | 1000000 + timestamptz | quarter | msec | usec +---------------------------------+---------+-----------+---------- + -infinity | | | + infinity | | | + Wed Dec 31 16:00:00 1969 PST | 4 | 0.000 | 0 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:02 1997 PST | 1 | 2000.000 | 2000000 + Mon Feb 10 17:32:01.4 1997 PST | 1 | 1400.000 | 1400000 + Mon Feb 10 17:32:01.5 1997 PST | 1 | 1500.000 | 1500000 + Mon Feb 10 17:32:01.6 1997 PST | 1 | 1600.000 | 1600000 + Thu Jan 02 00:00:00 1997 PST | 1 | 0.000 | 0 + Thu Jan 02 03:04:05 1997 PST | 1 | 5000.000 | 5000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Tue Jun 10 17:32:01 1997 PDT | 2 | 1000.000 | 1000000 + Sat Sep 22 18:19:20 2001 PDT | 3 | 20000.000 | 20000000 + Wed Mar 15 08:14:01 2000 PST | 1 | 1000.000 | 1000000 + Wed Mar 15 04:14:02 2000 PST | 1 | 2000.000 | 2000000 + Wed Mar 15 02:14:03 2000 PST | 1 | 3000.000 | 3000000 + Wed Mar 15 03:14:04 2000 PST | 1 | 4000.000 | 4000000 + Wed Mar 15 01:14:05 2000 PST | 1 | 5000.000 | 5000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:00 1997 PST | 1 | 0.000 | 0 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 09:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 09:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 09:32:01 1997 PST | 1 | 1000.000 | 1000000 + Mon Feb 10 14:32:01 1997 PST | 1 | 1000.000 | 1000000 + Thu Jul 10 14:32:01 1997 PDT | 3 | 1000.000 | 1000000 + Tue Jun 10 18:32:01 1997 PDT | 2 | 1000.000 | 1000000 + Mon Feb 10 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Tue Feb 11 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Wed Feb 12 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Thu Feb 13 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Fri Feb 14 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Sat Feb 15 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Sun Feb 16 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 0097 PST BC | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 0097 PST | 1 | 1000.000 | 1000000 + Thu Feb 16 17:32:01 0597 PST | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 1097 PST | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 1697 PST | 1 | 1000.000 | 1000000 + Thu Feb 16 17:32:01 1797 PST | 1 | 1000.000 | 1000000 + Tue Feb 16 17:32:01 1897 PST | 1 | 1000.000 | 1000000 + Sun Feb 16 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Sat Feb 16 17:32:01 2097 PST | 1 | 1000.000 | 1000000 + Wed Feb 28 17:32:01 1996 PST | 1 | 1000.000 | 1000000 + Thu Feb 29 17:32:01 1996 PST | 1 | 1000.000 | 1000000 + Fri Mar 01 17:32:01 1996 PST | 1 | 1000.000 | 1000000 + Mon Dec 30 17:32:01 1996 PST | 4 | 1000.000 | 1000000 + Tue Dec 31 17:32:01 1996 PST | 4 | 1000.000 | 1000000 + Wed Jan 01 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Fri Feb 28 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Sat Mar 01 17:32:01 1997 PST | 1 | 1000.000 | 1000000 + Tue Dec 30 17:32:01 1997 PST | 4 | 1000.000 | 1000000 + Wed Dec 31 17:32:01 1997 PST | 4 | 1000.000 | 1000000 + Fri Dec 31 17:32:01 1999 PST | 4 | 1000.000 | 1000000 + Sat Jan 01 17:32:01 2000 PST | 1 | 1000.000 | 1000000 + Sun Dec 31 17:32:01 2000 PST | 4 | 1000.000 | 1000000 + Mon Jan 01 17:32:01 2001 PST | 1 | 1000.000 | 1000000 (66 rows) SELECT d1 as timestamptz, diff --git a/src/test/regress/sql/date.sql b/src/test/regress/sql/date.sql index 488f5faa07..5c55abaf32 100644 --- a/src/test/regress/sql/date.sql +++ b/src/test/regress/sql/date.sql @@ -329,8 +329,8 @@ CREATE TABLE DATE_TBL (f1 date); -- -- oscillating fields from non-finite date/timestamptz: -- -SELECT EXTRACT(HOUR FROM DATE 'infinity'); -- NULL -SELECT EXTRACT(HOUR FROM DATE '-infinity'); -- NULL +SELECT EXTRACT(DAY FROM DATE 'infinity'); -- NULL +SELECT EXTRACT(DAY FROM DATE '-infinity'); -- NULL SELECT EXTRACT(HOUR FROM TIMESTAMP 'infinity'); -- NULL SELECT EXTRACT(HOUR FROM TIMESTAMP '-infinity'); -- NULL SELECT EXTRACT(HOUR FROM TIMESTAMPTZ 'infinity'); -- NULL @@ -371,7 +371,7 @@ CREATE TABLE DATE_TBL (f1 date); -- -- wrong fields from non-finite date: -- -SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: timestamp units "microsec" not recognized +SELECT EXTRACT(MICROSEC FROM DATE 'infinity'); -- ERROR: date units "microsec" not recognized -- test constructors select make_date(2013, 7, 15); -- 2.28.0