提交 7ae2ccbc 编写于 作者: T Tom Lane

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

Kris Jurka
上级 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">
......@@ -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>
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册