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

src/backend/utils/adt/date.c

index 441205e321fb798396272da7315f8270cbbbe11f..82d048f1c80c128fdb52b364f6969b0352efd9a5 100644 (file)
@@ -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;