Fix EncodeSpecialTimestamp to throw error on unrecognized input, rather than
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Oct 2008 15:44:29 +0000 (15:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Oct 2008 15:44:29 +0000 (15:44 +0000)
returning a failure code that none of its callers bothered to check for.

src/backend/utils/adt/timestamp.c

index 80cf4265a16ff1108bcf620a5dd1b8db1d4a2a0e..dc87bd3d9bf04bf1c8de6f5d49e5aa936a6870f9 100644 (file)
@@ -64,7 +64,7 @@ typedef struct
 
 
 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 void AdjustTimestampForTypmod(Timestamp *time, int32 typmod);
 static void AdjustIntervalForTypmod(Interval *interval, int32 typmod);
@@ -1150,18 +1150,16 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
 /* EncodeSpecialTimestamp()
  * Convert reserved timestamp data type to string.
  */
-static int
+static void
 EncodeSpecialTimestamp(Timestamp dt, char *str)
 {
        if (TIMESTAMP_IS_NOBEGIN(dt))
                strcpy(str, EARLY);
        else if (TIMESTAMP_IS_NOEND(dt))
                strcpy(str, LATE);
-       else
-               return FALSE;
-
-       return TRUE;
-}      /* EncodeSpecialTimestamp() */
+       else                                            /* shouldn't happen */
+               elog(ERROR, "invalid argument for EncodeSpecialTimestamp");
+}
 
 Datum
 now(PG_FUNCTION_ARGS)