]> granicus.if.org Git - postgresql/commitdiff
Fix erroneous error reporting for overlength input in text_date(),
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 2 Jun 2007 16:41:23 +0000 (16:41 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 2 Jun 2007 16:41:23 +0000 (16:41 +0000)
text_time(), and text_timetz().  7.4-vintage bug found by Greg Stark.

src/backend/utils/adt/date.c

index 075f106b4c04eafbc13cb613e23e6b5701347db3..6daeff9da7f0e33ee8df31b2ef10e45f0e23aac5 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.122.2.1 2006/02/09 03:40:30 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.122.2.2 2007/06/02 16:41:23 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -864,8 +864,9 @@ text_date(PG_FUNCTION_ARGS)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
                                 errmsg("invalid input syntax for type date: \"%s\"",
-                                               VARDATA(str))));
-
+                                               DatumGetCString(DirectFunctionCall1(textout,
+                                                                                                       PointerGetDatum(str))))));
+       
        sp = VARDATA(str);
        dp = dstr;
        for (i = 0; i < (VARSIZE(str) - VARHDRSZ); i++)
@@ -1591,7 +1592,8 @@ text_time(PG_FUNCTION_ARGS)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
                                 errmsg("invalid input syntax for type time: \"%s\"",
-                                               VARDATA(str))));
+                                               DatumGetCString(DirectFunctionCall1(textout, 
+                                                                                                       PointerGetDatum(str))))));
 
        sp = VARDATA(str);
        dp = dstr;
@@ -2360,7 +2362,8 @@ text_timetz(PG_FUNCTION_ARGS)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
                  errmsg("invalid input syntax for type time with time zone: \"%s\"",
-                                VARDATA(str))));
+                                DatumGetCString(DirectFunctionCall1(textout, 
+                                                                                                        PointerGetDatum(str))))));
 
        sp = VARDATA(str);
        dp = dstr;