Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7ae2ccb

Browse files
committed
Reject out-of-range dates in date_in().
Kris Jurka
1 parent 3cb312d commit 7ae2ccb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

doc/src/sgml/datatype.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.164 2005/12/22 21:45:19 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.165 2006/02/09 03:39:16 tgl Exp $
33
-->
44

55
<chapter id="datatype">
@@ -1360,7 +1360,7 @@ SELECT b, char_length(b) FROM test2;
13601360
<entry>4 bytes</entry>
13611361
<entry>dates only</entry>
13621362
<entry>4713 BC</entry>
1363-
<entry>32767 AD</entry>
1363+
<entry>5874897 AD</entry>
13641364
<entry>1 day</entry>
13651365
</row>
13661366
<row>

src/backend/utils/adt/date.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.122 2005/10/15 02:49:28 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.123 2006/02/09 03:39:17 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -97,6 +97,11 @@ date_in(PG_FUNCTION_ARGS)
9797
break;
9898
}
9999

100+
if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
101+
ereport(ERROR,
102+
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
103+
errmsg("date out of range: \"%s\"", str)));
104+
100105
date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
101106

102107
PG_RETURN_DATEADT(date);

0 commit comments

Comments
 (0)