1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-18 12:22:09 +03:00

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

Kris Jurka
This commit is contained in:
Tom Lane
2006-02-09 03:40:42 +00:00
parent f9ce97c5a1
commit a14302080f
2 changed files with 8 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.154.4.1 2005/01/22 23:05:47 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.154.4.2 2006/02/09 03:40:42 tgl Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
@@ -1358,7 +1358,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>

View File

@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.104.4.2 2005/05/26 02:10:02 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.104.4.3 2006/02/09 03:40:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@@ -96,6 +96,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);