Commit 791359fe authored by Tom Lane's avatar Tom Lane

Fix EncodeSpecialTimestamp to throw error on unrecognized input, rather than

returning a failure code that none of its callers bothered to check for.
parent f346a232
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.192 2008/09/11 15:27:30 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.193 2008/10/14 15:44:29 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -64,7 +64,7 @@ typedef struct ...@@ -64,7 +64,7 @@ typedef struct
static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec); static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec);
static int EncodeSpecialTimestamp(Timestamp dt, char *str); static void EncodeSpecialTimestamp(Timestamp dt, char *str);
static Timestamp dt2local(Timestamp dt, int timezone); static Timestamp dt2local(Timestamp dt, int timezone);
static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod); static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod);
static void AdjustIntervalForTypmod(Interval *interval, int32 typmod); static void AdjustIntervalForTypmod(Interval *interval, int32 typmod);
...@@ -1150,18 +1150,16 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) ...@@ -1150,18 +1150,16 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
/* EncodeSpecialTimestamp() /* EncodeSpecialTimestamp()
* Convert reserved timestamp data type to string. * Convert reserved timestamp data type to string.
*/ */
static int static void
EncodeSpecialTimestamp(Timestamp dt, char *str) EncodeSpecialTimestamp(Timestamp dt, char *str)
{ {
if (TIMESTAMP_IS_NOBEGIN(dt)) if (TIMESTAMP_IS_NOBEGIN(dt))
strcpy(str, EARLY); strcpy(str, EARLY);
else if (TIMESTAMP_IS_NOEND(dt)) else if (TIMESTAMP_IS_NOEND(dt))
strcpy(str, LATE); strcpy(str, LATE);
else else /* shouldn't happen */
return FALSE; elog(ERROR, "invalid argument for EncodeSpecialTimestamp");
}
return TRUE;
} /* EncodeSpecialTimestamp() */
Datum Datum
now(PG_FUNCTION_ARGS) now(PG_FUNCTION_ARGS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment