From 7ae2ccbc857f6b3a65866d44c255fba673dae414 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 9 Feb 2006 03:39:17 +0000 Subject: [PATCH] Reject out-of-range dates in date_in(). Kris Jurka --- doc/src/sgml/datatype.sgml | 4 ++-- src/backend/utils/adt/date.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 811033cb59..4007cc2d20 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ @@ -1360,7 +1360,7 @@ SELECT b, char_length(b) FROM test2; 4 bytes dates only 4713 BC - 32767 AD + 5874897 AD 1 day diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 619a099b65..c070f00cf6 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.122 2005/10/15 02:49:28 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.123 2006/02/09 03:39:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -97,6 +97,11 @@ date_in(PG_FUNCTION_ARGS) break; } + if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday)) + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("date out of range: \"%s\"", str))); + date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE; PG_RETURN_DATEADT(date); -- 2.40.0