Commit 7ae2ccbc authored by Tom Lane's avatar Tom Lane

Reject out-of-range dates in date_in().

Kris Jurka
parent 3cb312d8
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.164 2005/12/22 21:45:19 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.165 2006/02/09 03:39:16 tgl Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
...@@ -1360,7 +1360,7 @@ SELECT b, char_length(b) FROM test2; ...@@ -1360,7 +1360,7 @@ SELECT b, char_length(b) FROM test2;
<entry>4 bytes</entry> <entry>4 bytes</entry>
<entry>dates only</entry> <entry>dates only</entry>
<entry>4713 BC</entry> <entry>4713 BC</entry>
<entry>32767 AD</entry> <entry>5874897 AD</entry>
<entry>1 day</entry> <entry>1 day</entry>
</row> </row>
<row> <row>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -97,6 +97,11 @@ date_in(PG_FUNCTION_ARGS)
break; 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; date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
PG_RETURN_DATEADT(date); PG_RETURN_DATEADT(date);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment