summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2007-06-02 16:41:31 +0000
committerTom Lane2007-06-02 16:41:31 +0000
commit5f32030680020926e3cb6a476da23549d3563c97 (patch)
tree6fc71b7d1a4618254e51b3ed71294ac789fcdc50
parentbc7ccdfe461e9472f736a2809342135eea661692 (diff)
Fix erroneous error reporting for overlength input in text_date(),
text_time(), and text_timetz(). 7.4-vintage bug found by Greg Stark.
-rw-r--r--src/backend/utils/adt/date.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 3e8ab71af54..e0260b6b50d 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.104.4.3 2006/02/09 03:40:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.104.4.4 2007/06/02 16:41:31 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++)
@@ -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;