Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b350600

Browse files
committed
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.
1 parent d61de58 commit b350600

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.71 2002/09/02 02:47:04 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.72 2002/09/03 22:55:54 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2871,7 +2871,11 @@ timestamp_part(PG_FUNCTION_ARGS)
28712871
switch (val)
28722872
{
28732873
case DTK_EPOCH:
2874+
#ifdef HAVE_INT64_TIMESTAMP
28742875
result = ((timestamp - SetEpochTimestamp()) / 1000000e0);
2876+
#else
2877+
result = timestamp - SetEpochTimestamp();
2878+
#endif
28752879
break;
28762880

28772881
case DTK_DOW:
@@ -3052,7 +3056,7 @@ timestamptz_part(PG_FUNCTION_ARGS)
30523056
{
30533057
case DTK_EPOCH:
30543058
#ifdef HAVE_INT64_TIMESTAMP
3055-
result = ((timestamp - SetEpochTimestamp()) / 100000e0);
3059+
result = ((timestamp - SetEpochTimestamp()) / 1000000e0);
30563060
#else
30573061
result = timestamp - SetEpochTimestamp();
30583062
#endif

0 commit comments

Comments
 (0)