aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-09-03 22:55:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-09-03 22:55:54 +0000
commitb3506006b56487cc7ec440703ebc5d5835c55629 (patch)
tree4051f91c9e2e9c35af1e6fff4dac45b02ee8f466 /src
parentd61de58906249e8fb8e44d1ef454d029325526a3 (diff)
downloadpostgresql-b3506006b56487cc7ec440703ebc5d5835c55629.tar.gz
postgresql-b3506006b56487cc7ec440703ebc5d5835c55629.zip
EXTRACT(EPOCH FROM timestamp) gave wrong answers in the int64-timestamp
case for timestamptz input, and differently wrong answers in the float- timestamp case for timestamp input.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/timestamp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index a511e34410e..a381fd47cd6 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.71 2002/09/02 02:47:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.72 2002/09/03 22:55:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2871,7 +2871,11 @@ timestamp_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_EPOCH:
+#ifdef HAVE_INT64_TIMESTAMP
result = ((timestamp - SetEpochTimestamp()) / 1000000e0);
+#else
+ result = timestamp - SetEpochTimestamp();
+#endif
break;
case DTK_DOW:
@@ -3052,7 +3056,7 @@ timestamptz_part(PG_FUNCTION_ARGS)
{
case DTK_EPOCH:
#ifdef HAVE_INT64_TIMESTAMP
- result = ((timestamp - SetEpochTimestamp()) / 100000e0);
+ result = ((timestamp - SetEpochTimestamp()) / 1000000e0);
#else
result = timestamp - SetEpochTimestamp();
#endif