1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

While perusing SQL92 I realized that we are delivering the wrong SQLSTATE

error code for string-too-long errors.  It should be STRING_DATA_RIGHT_TRUNCATION
not STRING_DATA_LENGTH_MISMATCH.  The latter probably should only be
applied to cases where a string must be exactly so many bits --- there are
no cases at all where it applies to character strings, only bit strings.
This commit is contained in:
Tom Lane
2004-08-02 16:51:10 +00:00
parent 630bfcd10c
commit d529989149
2 changed files with 8 additions and 8 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.104 2004/02/01 06:27:48 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.105 2004/08/02 16:51:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -101,7 +101,7 @@ bpcharin(PG_FUNCTION_ARGS)
len = mbmaxlen;
else
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character(%d)",
(int) maxlen)));
@ -221,7 +221,7 @@ bpchar(PG_FUNCTION_ARGS)
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character(%d)",
maxlen - VARHDRSZ)));
}
@ -379,7 +379,7 @@ varcharin(PG_FUNCTION_ARGS)
len = mbmaxlen;
else
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character varying(%d)",
(int) maxlen)));
}
@ -471,7 +471,7 @@ varchar(PG_FUNCTION_ARGS)
for (i = maxmblen; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character varying(%d)",
maxlen - VARHDRSZ)));
}