On 2020-05-25 15:28, Peter Eisentraut wrote:
On 2019-12-02 23:52, Thomas Munro wrote:
I'm not an expert in floating point math but hopefully it means that no
type change is required - double precision can handle it.
Me neither, but the SQL standard requires us to use an exact numeric
type, so it's wrong on that level by definition.
I looked into this (changing the return types of date_part()/extract()
from float8 to numeric).
One problem (other than perhaps performance, tbd.) is that this would no
longer allow processing infinite timestamps, since numeric does not
support infinity. It could be argued that running extract() on infinite
timestamps isn't very useful, but it's something to consider explicitly.
Now that numeric supports infinity, here is a patch that changes the
return types of date_part() to numeric. It's not meant to be a final
version, but it is useful for discussing a few things.
The internal implementation could be made a bit more elegant if we had
variants of int4_numeric() and int8_numeric() that don't have to go
through fmgr. This would also help in other areas of the code. There
are probably also other ways in which the internals could be made more
compact; I just converted them fairly directly.
When extracting seconds or microseconds, I made it always produce 6 or 3
decimal places, even if they are zero. I don't know if we want that or
what behavior we want. That's what all the changes in the regression
tests are about. Everything else passes unchanged.
The 'julian' field is a bit of a mystery. First of all it's not
documented. The regression tests only test the rounded output, perhaps
to avoid floating point differences. When you do date_part('julian',
date), then you get a correct Julian Day. But date_part('julian',
timestamp[tz]) gives incorrect Julian Date values that are off by 12
hours. My patch doesn't change that, I just noticed when I took away
the round() call in the regression tests. Those calls now produce a
different number of decimal places.
It might make sense to make date_part(..., date) a separate C function
instead of an SQL wrapper around date_part(..., timestamp). That could
return integer and could reject nonsensical fields such as "minute".
Then we could also make a less contorted implementation of
date_part('julian', date) that matches to_char(date, 'J') and remove the
incorrect implementation of date_part('julian', timestamp).
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 823563feefef8d9a658fd0d586676c3aa2e3ca74 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 4 Aug 2020 15:46:51 +0200
Subject: [PATCH v1] Change return type of EXTRACT to numeric
Discussion:
https://www.postgresql.org/message-id/flat/42b73d2d-da12-ba9f-570a-420e0cce1...@phystech.edu
---
doc/src/sgml/func.sgml | 10 +-
src/backend/utils/adt/date.c | 113 ++++++--
src/backend/utils/adt/timestamp.c | 339 +++++++++++++++-------
src/include/catalog/pg_proc.dat | 14 +-
src/test/regress/expected/date.out | 4 +-
src/test/regress/expected/interval.out | 24 +-
src/test/regress/expected/timestamp.out | 268 ++++++++---------
src/test/regress/expected/timestamptz.out | 272 ++++++++---------
8 files changed, 619 insertions(+), 425 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 @@ <title>Date/Time Functions</title>
<primary>date_part</primary>
</indexterm>
<function>date_part</function> ( <type>text</type>,
<type>timestamp</type> )
- <returnvalue>double precision</returnvalue>
+ <returnvalue>numeric</returnvalue>
</para>
<para>
Get timestamp subfield (equivalent to <function>extract</function>);
@@ -8641,7 +8641,7 @@ <title>Date/Time Functions</title>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>date_part</function> ( <type>text</type>,
<type>interval</type> )
- <returnvalue>double precision</returnvalue>
+ <returnvalue>numeric</returnvalue>
</para>
<para>
Get interval subfield (equivalent to <function>extract</function>);
@@ -8706,7 +8706,7 @@ <title>Date/Time Functions</title>
<primary>extract</primary>
</indexterm>
<function>extract</function> ( <parameter>field</parameter>
<literal>from</literal> <type>timestamp</type> )
- <returnvalue>double precision</returnvalue>
+ <returnvalue>numeric</returnvalue>
</para>
<para>
Get timestamp subfield; see <xref
linkend="functions-datetime-extract"/>
@@ -8720,7 +8720,7 @@ <title>Date/Time Functions</title>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>extract</function> ( <parameter>field</parameter>
<literal>from</literal> <type>interval</type> )
- <returnvalue>double precision</returnvalue>
+ <returnvalue>numeric</returnvalue>
</para>
<para>
Get interval subfield; see <xref
linkend="functions-datetime-extract"/>
@@ -9227,7 +9227,7 @@ <title><function>EXTRACT</function>,
<function>date_part</function></title>
well.) <replaceable>field</replaceable> is an identifier or
string that selects what field to extract from the source value.
The <function>extract</function> function returns values of type
- <type>double precision</type>.
+ <type>numeric</type>.
The following are valid field names:
<!-- alphabetical -->
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index eaaffa7137..8027930c8f 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"
/*
@@ -1986,7 +1987,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 +2011,49 @@ time_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
+ /* tm->tm_sec * 1000000 + fsec */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(fsec))),
+ NULL);
break;
case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
+ /* tm->tm_sec * 1000 + fsec / 1000 */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000))),
+
NULL),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_sec))),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
case DTK_MINUTE:
- result = tm->tm_min;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_min)));
break;
case DTK_HOUR:
- result = tm->tm_hour;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_hour)));
break;
case DTK_TZ:
@@ -2050,7 +2077,12 @@ time_part(PG_FUNCTION_ARGS)
}
else if (type == RESERV && val == DTK_EPOCH)
{
- result = time / 1000000.0;
+ result =
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum(time))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL);
+ result = DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
}
else
{
@@ -2061,7 +2093,7 @@ time_part(PG_FUNCTION_ARGS)
result = 0;
}
- PG_RETURN_FLOAT8(result);
+ PG_RETURN_NUMERIC(result);
}
@@ -2723,7 +2755,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 +2770,6 @@ timetz_part(PG_FUNCTION_ARGS)
if (type == UNITS)
{
- double dummy;
int tz;
fsec_t fsec;
struct pg_tm tt,
@@ -2749,38 +2780,65 @@ timetz_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_TZ:
- result = -tz;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-tz /
SECS_PER_MINUTE))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(SECS_PER_MINUTE))),
+ NULL);
break;
case DTK_TZ_HOUR:
- dummy = -tz;
- FMODULO(dummy, result, (double) SECS_PER_HOUR);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-tz /
SECS_PER_HOUR)));
break;
case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
+ /* tm->tm_sec * 1000000 + fsec */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(fsec))),
+ NULL);
break;
case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
+ /* tm->tm_sec * 1000 + fsec / 1000 */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000))),
+
NULL),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_sec))),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
case DTK_MINUTE:
- result = tm->tm_min;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_min)));
break;
case DTK_HOUR:
- result = tm->tm_hour;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_hour)));
break;
case DTK_DAY:
@@ -2800,7 +2858,16 @@ 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(DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum(time->time))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+ NULL),
+ DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(time->zone))),
+ NULL);
+ result = DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
}
else
{
@@ -2811,7 +2878,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..51a2aa1819 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,73 @@ timestamp_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
+ /* tm->tm_sec * 1000000 + fsec */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(fsec))),
+ NULL);
break;
case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
+ /* tm->tm_sec * 1000 + fsec / 1000 */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000))),
+
NULL),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_sec))),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
case DTK_MINUTE:
- result = tm->tm_min;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_min)));
break;
case DTK_HOUR:
- result = tm->tm_hour;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_hour)));
break;
case DTK_DAY:
- result = tm->tm_mday;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mday)));
break;
case DTK_MONTH:
- result = tm->tm_mon;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mon)));
break;
case DTK_QUARTER:
- result = (tm->tm_mon - 1) / 3 + 1;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_mon -
1) / 3 + 1)));
break;
case DTK_WEEK:
- result = (float8) date2isoweek(tm->tm_year,
tm->tm_mon, tm->tm_mday);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday))));
break;
case DTK_YEAR:
if (tm->tm_year > 0)
- result = tm->tm_year;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year)));
else
/* there is no year 0, just 1 BC and 1
AD */
- result = tm->tm_year - 1;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year -
1)));
break;
case DTK_DECADE:
@@ -4605,9 +4638,9 @@ timestamp_part(PG_FUNCTION_ARGS)
* is 11 BC thru 2 BC...
*/
if (tm->tm_year >= 0)
- result = tm->tm_year / 10;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year /
10)));
else
- result = -((8 - (tm->tm_year - 1)) /
10);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((8 -
(tm->tm_year - 1)) / 10))));
break;
case DTK_CENTURY:
@@ -4619,44 +4652,57 @@ timestamp_part(PG_FUNCTION_ARGS)
* ----
*/
if (tm->tm_year > 0)
- result = (tm->tm_year + 99) / 100;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_year +
99) / 100)));
else
/* caution: C division may have
negative remainder */
- result = -((99 - (tm->tm_year - 1)) /
100);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_year +
999) / 1000)));
else
- result = -((999 - (tm->tm_year - 1)) /
1000);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)))),
+ numeric_div_opt_error(
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum((((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) *
SECS_PER_MINUTE) + tm->tm_sec) * 1000000LL + fsec)))),
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(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 =
DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tmp)));
break;
+ }
case DTK_DOY:
- result = (date2j(tm->tm_year, tm->tm_mon,
tm->tm_mday)
- - date2j(tm->tm_year, 1, 1) +
1);
+ {
+ int tmp = (date2j(tm->tm_year, tm->tm_mon,
tm->tm_mday)
+ - date2j(tm->tm_year, 1, 1)
+ 1);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tmp)));
break;
+ }
case DTK_TZ:
case DTK_TZ_MINUTE:
@@ -4675,11 +4721,16 @@ timestamp_part(PG_FUNCTION_ARGS)
{
case DTK_EPOCH:
epoch = SetEpochTimestamp();
- /* try to avoid precision loss in subtraction */
- if (timestamp < (PG_INT64_MAX + epoch))
- result = (timestamp - epoch) /
1000000.0;
- else
- result = ((float8) timestamp - epoch) /
1000000.0;
+ /* (timestamp - epoch) / 1000000 */
+ result = numeric_div_opt_error(
+
numeric_sub_opt_error(DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum(timestamp))),
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(epoch))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
default:
@@ -4699,7 +4750,7 @@ timestamp_part(PG_FUNCTION_ARGS)
result = 0;
}
- PG_RETURN_FLOAT8(result);
+ PG_RETURN_NUMERIC(result);
}
/* timestamptz_part()
@@ -4710,13 +4761,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 +4785,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,112 +4800,152 @@ timestamptz_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_TZ:
- result = -tz;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-tz /
SECS_PER_MINUTE))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(SECS_PER_MINUTE))),
+ NULL);
break;
case DTK_TZ_HOUR:
- dummy = -tz;
- FMODULO(dummy, result, (double) SECS_PER_HOUR);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-tz /
SECS_PER_HOUR)));
break;
case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
+ /* tm->tm_sec * 1000000 + fsec */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(fsec))),
+ NULL);
break;
case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
+ /* tm->tm_sec * 1000 + fsec / 1000 */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000))),
+
NULL),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_sec))),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+
NULL),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
case DTK_MINUTE:
- result = tm->tm_min;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_min)));
break;
case DTK_HOUR:
- result = tm->tm_hour;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_hour)));
break;
case DTK_DAY:
- result = tm->tm_mday;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mday)));
break;
case DTK_MONTH:
- result = tm->tm_mon;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mon)));
break;
case DTK_QUARTER:
- result = (tm->tm_mon - 1) / 3 + 1;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_mon -
1) / 3 + 1)));
break;
case DTK_WEEK:
- result = (float8) date2isoweek(tm->tm_year,
tm->tm_mon, tm->tm_mday);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday))));
break;
case DTK_YEAR:
if (tm->tm_year > 0)
- result = tm->tm_year;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year)));
else
/* there is no year 0, just 1 BC and 1
AD */
- result = tm->tm_year - 1;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year -
1)));
break;
case DTK_DECADE:
/* see comments in timestamp_part */
if (tm->tm_year > 0)
- result = tm->tm_year / 10;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year /
10)));
else
- result = -((8 - (tm->tm_year - 1)) /
10);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_year +
99) / 100)));
else
- result = -((99 - (tm->tm_year - 1)) /
100);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_year +
999) / 1000)));
else
- result = -((999 - (tm->tm_year - 1)) /
1000);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(-((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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)))),
+ numeric_div_opt_error(
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum((((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) *
SECS_PER_MINUTE) + tm->tm_sec) * 1000000LL + fsec)))),
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(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 =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tmp)));
break;
+ }
case DTK_DOY:
- result = (date2j(tm->tm_year, tm->tm_mon,
tm->tm_mday)
- - date2j(tm->tm_year, 1, 1) +
1);
+ {
+ int tmp = (date2j(tm->tm_year, tm->tm_mon,
tm->tm_mday)
+ - date2j(tm->tm_year, 1, 1)
+ 1);
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tmp)));
break;
+ }
default:
ereport(ERROR,
@@ -4872,11 +4962,16 @@ timestamptz_part(PG_FUNCTION_ARGS)
{
case DTK_EPOCH:
epoch = SetEpochTimestamp();
- /* try to avoid precision loss in subtraction */
- if (timestamp < (PG_INT64_MAX + epoch))
- result = (timestamp - epoch) /
1000000.0;
- else
- result = ((float8) timestamp - epoch) /
1000000.0;
+ /* (timestamp - epoch) / 1000000 */
+ result = numeric_div_opt_error(
+
numeric_sub_opt_error(DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum(timestamp))),
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric, Int64GetDatum(epoch))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
default:
@@ -4897,7 +4992,7 @@ timestamptz_part(PG_FUNCTION_ARGS)
result = 0;
}
- PG_RETURN_FLOAT8(result);
+ PG_RETURN_NUMERIC(result);
}
@@ -4909,7 +5004,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 +5027,77 @@ interval_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
+ /* tm->tm_sec * 1000000 + fsec */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(1000000))),
+
NULL),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(fsec))),
+ NULL);
break;
case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec /
1000.0;
+ /* tm->tm_sec * 1000 + fsec / 1000 */
+ result = numeric_add_opt_error(
+
numeric_mul_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(tm->tm_sec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(1000))),
+
NULL),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(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(
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_sec))),
+
numeric_div_opt_error(DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(fsec))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(1000000))),
+
NULL),
+ NULL);
+ result =
DatumGetNumeric(DirectFunctionCall2(numeric_round,
+
NumericGetDatum(result),
+
Int32GetDatum(6)));
break;
case DTK_MINUTE:
- result = tm->tm_min;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_min)));
break;
case DTK_HOUR:
- result = tm->tm_hour;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_hour)));
break;
case DTK_DAY:
- result = tm->tm_mday;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mday)));
break;
case DTK_MONTH:
- result = tm->tm_mon;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_mon)));
break;
case DTK_QUARTER:
- result = (tm->tm_mon / 3) + 1;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum((tm->tm_mon /
3) + 1)));
break;
case DTK_YEAR:
- result = tm->tm_year;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year)));
break;
case DTK_DECADE:
- /* caution: C division may have
negative remainder */
- result = tm->tm_year / 10;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year /
10)));
break;
case DTK_CENTURY:
- /* caution: C division may have
negative remainder */
- result = tm->tm_year / 100;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year /
100)));
break;
case DTK_MILLENNIUM:
- /* caution: C division may have
negative remainder */
- result = tm->tm_year / 1000;
+ result =
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(tm->tm_year /
1000)));
break;
default:
@@ -4999,10 +5117,19 @@ 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(DatumGetNumeric(DirectFunctionCall1(int8_numeric,
Int64GetDatum(interval->time))),
+
DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(1000000))),
+ NULL),
+
DatumGetNumeric(DirectFunctionCall1(int8_numeric,
+
Int64GetDatum(((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 +5140,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..96c9d7bc0d 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,11 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'sql', prorettype => 'numeric',
proargtypes => 'text date',
- prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time
zone))' },
+ prosrc => 'select round(pg_catalog.date_part($1, cast($2 as timestamp
without time zone)), 0)' },
{ 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 +5721,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 4cdf1635f2..281212aefe 100644
--- a/src/test/regress/expected/date.out
+++ b/src/test/regress/expected/date.out
@@ -932,13 +932,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)
--
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,
--
2.28.0