Fix erroneous error reporting for overlength input in text_date(),
authorTom Lane
Sat, 2 Jun 2007 16:41:09 +0000 (16:41 +0000)
committerTom Lane
Sat, 2 Jun 2007 16:41:09 +0000 (16:41 +0000)
text_time(), and text_timetz().  7.4-vintage bug found by Greg Stark.

src/backend/utils/adt/date.c

index 9ead120245fb30d7797adf03cf76df904bd5ba29..7e4b461f8f18c8a16a0f9d30b8962f7e7376e9ef 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.130 2007/05/30 19:38:05 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.131 2007/06/02 16:41:09 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -918,8 +918,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++)
@@ -1659,7 +1660,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))))));
 
    len = VARSIZE(str) - VARHDRSZ;
    memcpy(dstr, VARDATA(str), len); 
@@ -2443,7 +2445,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;