Index: src/backend/utils/adt/char.c =================================================================== --- src/backend/utils/adt/char.c (revision 1156) +++ src/backend/utils/adt/char.c (working copy) @@ -34,6 +34,11 @@ { char *ch = PG_GETARG_CSTRING(0); + if (ch[0] != '\0' && ch[1] != '\0') + ereport(ERROR, + (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), + errmsg("value too long for type \"char\""))); + PG_RETURN_CHAR(ch[0]); } @@ -67,6 +72,11 @@ { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + if (buf->len > 1) + ereport(ERROR, + (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), + errmsg("value too long for type \"char\""))); + PG_RETURN_CHAR(pq_getmsgbyte(buf)); }