Skip to content

Commit 376ee15

Browse files
committed
Fix erroneous error reporting for overlength input in text_date(),
text_time(), and text_timetz(). 7.4-vintage bug found by Greg Stark.
1 parent 4e02337 commit 376ee15

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/utils/adt/date.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.130 2007/05/30 19:38:05 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.131 2007/06/02 16:41:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -918,8 +918,9 @@ text_date(PG_FUNCTION_ARGS)
918918
ereport(ERROR,
919919
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
920920
errmsg("invalid input syntax for type date: \"%s\"",
921-
VARDATA(str))));
922-
921+
DatumGetCString(DirectFunctionCall1(textout,
922+
PointerGetDatum(str))))));
923+
923924
sp = VARDATA(str);
924925
dp = dstr;
925926
for (i = 0; i < (VARSIZE(str) - VARHDRSZ); i++)
@@ -1659,7 +1660,8 @@ text_time(PG_FUNCTION_ARGS)
16591660
ereport(ERROR,
16601661
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
16611662
errmsg("invalid input syntax for type time: \"%s\"",
1662-
VARDATA(str))));
1663+
DatumGetCString(DirectFunctionCall1(textout,
1664+
PointerGetDatum(str))))));
16631665

16641666
len = VARSIZE(str) - VARHDRSZ;
16651667
memcpy(dstr, VARDATA(str), len);
@@ -2443,7 +2445,8 @@ text_timetz(PG_FUNCTION_ARGS)
24432445
ereport(ERROR,
24442446
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
24452447
errmsg("invalid input syntax for type time with time zone: \"%s\"",
2446-
VARDATA(str))));
2448+
DatumGetCString(DirectFunctionCall1(textout,
2449+
PointerGetDatum(str))))));
24472450

24482451
sp = VARDATA(str);
24492452
dp = dstr;

0 commit comments

Comments
 (0)