Repair 7.3 breakage in timestamp-to-date conversion for dates before 2000.
This commit is contained in:
parent
2d9a001c9e
commit
47f14e7ddf
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.84 2003/07/17 00:55:37 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.85 2003/07/24 00:21:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -348,17 +348,17 @@ timestamp_date(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
|
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
|
||||||
DateADT result;
|
DateADT result;
|
||||||
|
struct tm tt,
|
||||||
|
*tm = &tt;
|
||||||
|
double fsec;
|
||||||
|
|
||||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
|
||||||
/* Microseconds to days */
|
elog(ERROR, "Unable to convert timestamp to date");
|
||||||
result = (timestamp / INT64CONST(86400000000));
|
|
||||||
#else
|
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
||||||
/* Seconds to days */
|
|
||||||
result = (timestamp / 86400.0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PG_RETURN_DATEADT(result);
|
PG_RETURN_DATEADT(result);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user