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

src/backend/utils/adt/date.c

index 6a94674cf422de3f24205c1c61af7909235eba33..e83e145dd58e67594ea445e0685154c3acfa1bbc 100644 (file)
@@ -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++)
@@ -1578,7 +1579,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;
@@ -2334,8 +2336,9 @@ text_timetz(PG_FUNCTION_ARGS)
        if (VARSIZE(str) - VARHDRSZ > MAXDATELEN)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
-                                errmsg("invalid input syntax for type time with time zone: \"%s\"",
-                                               VARDATA(str))));
+                 errmsg("invalid input syntax for type time with time zone: \"%s\"",
+                                DatumGetCString(DirectFunctionCall1(textout, 
+                                                                                                        PointerGetDatum(str))))));
 
        sp = VARDATA(str);
        dp = dstr;