On Sat, 3 Dec 2005, Michael Fuhr wrote:
On Sat, Dec 03, 2005 at 07:53:23PM -0500, Kris Jurka wrote:
I'm seeing some date input overflows here.
Yep, I noticed this a few days ago while looking at another problem.
I probably should have started a new thread.
This seems to fix it.
Kris Jurka
Index: doc/src/sgml/datatype.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/datatype.sgml,v
retrieving revision 1.163
diff -c -r1.163 datatype.sgml
*** doc/src/sgml/datatype.sgml 22 Oct 2005 19:33:57 -0000 1.163
--- doc/src/sgml/datatype.sgml 5 Dec 2005 08:30:22 -0000
***************
*** 1360,1366 ****
<entry>4 bytes</entry>
<entry>dates only</entry>
<entry>4713 BC</entry>
! <entry>32767 AD</entry>
<entry>1 day</entry>
</row>
<row>
--- 1360,1366 ----
<entry>4 bytes</entry>
<entry>dates only</entry>
<entry>4713 BC</entry>
! <entry>5874897 AD</entry>
<entry>1 day</entry>
</row>
<row>
Index: src/backend/utils/adt/date.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/date.c,v
retrieving revision 1.122
diff -c -r1.122 date.c
*** src/backend/utils/adt/date.c 15 Oct 2005 02:49:28 -0000 1.122
--- src/backend/utils/adt/date.c 5 Dec 2005 08:30:22 -0000
***************
*** 97,102 ****
--- 97,107 ----
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);
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match