On Fri, Aug 9, 2024 at 6:16 AM Matthew Kim <matthewkm...@gmail.com> wrote: > > I've updated patch 0004 to check the return value of pg_mul_s32_overflow(). > Since tm.tm_year overflowed, the error message is hardcoded. >
--- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -257,7 +257,10 @@ make_date(PG_FUNCTION_ARGS) if (tm.tm_year < 0) { bc = true; - tm.tm_year = -tm.tm_year; + if (pg_mul_s32_overflow(tm.tm_year, -1, &tm.tm_year)) + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("date field value out of range"))); } Should the error about integers be out of range? SELECT make_date(-2147483648, 1, 1); "-2147483648" is not an allowed integer. \df make_date List of functions Schema | Name | Result data type | Argument data types | Type ------------+-----------+------------------+------------------------------------------+------ pg_catalog | make_date | date | year integer, month integer, day integer | func