Fix mis-display of negative fractional seconds in interval values for
--enable-integer-datetimes case. Per report from Oliver Siegmar.
This commit is contained in:
parent
9d64632144
commit
a8ac7d8713
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.138 2005/04/19 03:13:59 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.139 2005/04/20 17:14:50 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3884,17 +3884,25 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
|
|||||||
/* fractional seconds? */
|
/* fractional seconds? */
|
||||||
if (fsec != 0)
|
if (fsec != 0)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
|
||||||
if (is_before || ((!is_nonzero) && (tm->tm_sec < 0)))
|
|
||||||
tm->tm_sec = -tm->tm_sec;
|
|
||||||
sprintf(cp, "%s%d.%02d secs", (is_nonzero ? " " : ""),
|
|
||||||
tm->tm_sec, (((int) fsec) / 10000));
|
|
||||||
cp += strlen(cp);
|
|
||||||
if (!is_nonzero)
|
|
||||||
is_before = (fsec < 0);
|
|
||||||
#else
|
|
||||||
fsec_t sec;
|
fsec_t sec;
|
||||||
|
|
||||||
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
|
sec = fsec;
|
||||||
|
if (is_before || ((!is_nonzero) && (tm->tm_sec < 0)))
|
||||||
|
{
|
||||||
|
tm->tm_sec = -tm->tm_sec;
|
||||||
|
sec = -sec;
|
||||||
|
is_before = TRUE;
|
||||||
|
}
|
||||||
|
else if ((!is_nonzero) && (tm->tm_sec == 0) && (fsec < 0))
|
||||||
|
{
|
||||||
|
sec = -sec;
|
||||||
|
is_before = TRUE;
|
||||||
|
}
|
||||||
|
sprintf(cp, "%s%d.%02d secs", (is_nonzero ? " " : ""),
|
||||||
|
tm->tm_sec, (((int) sec) / 10000));
|
||||||
|
cp += strlen(cp);
|
||||||
|
#else
|
||||||
fsec += tm->tm_sec;
|
fsec += tm->tm_sec;
|
||||||
sec = fsec;
|
sec = fsec;
|
||||||
if (is_before || ((!is_nonzero) && (fsec < 0)))
|
if (is_before || ((!is_nonzero) && (fsec < 0)))
|
||||||
@ -3906,9 +3914,8 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
|
|||||||
is_before = (fsec < 0);
|
is_before = (fsec < 0);
|
||||||
#endif
|
#endif
|
||||||
is_nonzero = TRUE;
|
is_nonzero = TRUE;
|
||||||
|
|
||||||
/* otherwise, integer seconds only? */
|
|
||||||
}
|
}
|
||||||
|
/* otherwise, integer seconds only? */
|
||||||
else if (tm->tm_sec != 0)
|
else if (tm->tm_sec != 0)
|
||||||
{
|
{
|
||||||
int sec = tm->tm_sec;
|
int sec = tm->tm_sec;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user