Reject out-of-range dates in date_in().
authorTom Lane <[email protected]>
Thu, 9 Feb 2006 03:40:30 +0000 (03:40 +0000)
committerTom Lane <[email protected]>
Thu, 9 Feb 2006 03:40:30 +0000 (03:40 +0000)
Kris Jurka

doc/src/sgml/datatype.sgml
src/backend/utils/adt/date.c

index 76c578a361fde99857a2a58de299c55bf1e877be..b629b3ee6439777d768990b5ed8958a79de665c5 100644 (file)
@@ -1360,7 +1360,7 @@ SELECT b, char_length(b) FROM test2;
         <entry>4 bytes</entry>
         <entry>dates only</entry>
         <entry>4713 BC</entry>
-        <entry>32767 AD</entry>
+        <entry>5874897 AD</entry>
         <entry>1 day</entry>
        </row>
        <row>
index de420c748483bc90ddac368a57a89477bad0ab69..68ed433a1f4f18bae3dc50914b6c66d4d373f7e1 100644 (file)
@@ -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);