From: Tom Lane Date: Tue, 14 Oct 2008 15:44:29 +0000 (+0000) Subject: Fix EncodeSpecialTimestamp to throw error on unrecognized input, rather than X-Git-Tag: recoveryinfrav9~530 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=87c1e25825d59476fcdf5f9aab816a55268e52c3;p=users%2Fsimon%2Fpostgres.git Fix EncodeSpecialTimestamp to throw error on unrecognized input, rather than returning a failure code that none of its callers bothered to check for. --- diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 80cf4265a1..dc87bd3d9b 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -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)