1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Error message editing in backend/utils (except /adt).

This commit is contained in:
Tom Lane
2003-07-25 20:18:01 +00:00
parent 9fecf302f7
commit 689eb53e47
29 changed files with 739 additions and 521 deletions

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.45 2003/04/12 07:53:57 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.46 2003/07/25 20:17:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -371,7 +371,10 @@ UtfToLocal(unsigned char *utf, unsigned char *iso,
sizeof(pg_utf_to_local), compare1);
if (p == NULL)
{
elog(WARNING, "UtfToLocal: could not convert UTF-8 (0x%04x). Ignored", iutf);
ereport(WARNING,
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
errmsg("ignoring unconvertible UTF-8 character 0x%04x",
iutf)));
continue;
}
if (p->code & 0xff000000)
@@ -398,7 +401,9 @@ LocalToUtf(unsigned char *iso, unsigned char *utf,
pg_local_to_utf *p;
if (!PG_VALID_ENCODING(encoding))
elog(ERROR, "Invalid encoding number %d", encoding);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid encoding number: %d", encoding)));
for (; len > 0 && *iso; len -= l)
{
@@ -435,8 +440,10 @@ LocalToUtf(unsigned char *iso, unsigned char *utf,
sizeof(pg_local_to_utf), compare2);
if (p == NULL)
{
elog(WARNING, "LocalToUtf: could not convert (0x%04x) %s to UTF-8. Ignored",
iiso, (&pg_enc2name_tbl[encoding])->name);
ereport(WARNING,
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
errmsg("ignoring unconvertible %s character 0x%04x",
(&pg_enc2name_tbl[encoding])->name, iiso)));
continue;
}
if (p->utf & 0xff000000)

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.5 2002/10/26 15:01:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.6 2003/07/25 20:17:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -84,7 +84,8 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
len -= 2;
}
else if ((c & 0xe0) == 0xe0)
elog(ERROR, "Could not convert UTF-8 to ISO8859-1");
elog(ERROR, "could not convert UTF-8 character 0x%04x to ISO8859-1",
c);
else
{
*dest++ = c;

View File

@@ -2,7 +2,7 @@
* Encoding names and routines for work with it. All
* in this file is shared bedween FE and BE.
*
* $Id: encnames.c,v 1.16 2003/06/12 08:15:28 momjian Exp $
* $Id: encnames.c,v 1.17 2003/07/25 20:17:55 tgl Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
@@ -437,10 +437,12 @@ pg_char_to_encname_struct(const char *name)
if (strlen(name) > NAMEDATALEN)
{
#ifdef FRONTEND
fprintf(stderr, "pg_char_to_encname_struct(): encoding name too long");
fprintf(stderr, "encoding name too long\n");
return NULL;
#else
elog(ERROR, "pg_char_to_encname_struct(): encoding name too long");
ereport(ERROR,
(errcode(ERRCODE_NAME_TOO_LONG),
errmsg("encoding name too long")));
#endif
}
key = clean_encoding_name((char *) name, buff);

View File

@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
*
* $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.41 2003/04/27 18:01:46 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.42 2003/07/25 20:17:55 tgl Exp $
*/
#include "postgres.h"
@@ -183,9 +183,11 @@ InitializeClientEncoding(void)
* Oops, the requested conversion is not available.
* We couldn't fail before, but we can now.
*/
elog(FATAL, "Conversion between %s and %s is not supported",
pg_enc2name_tbl[pending_client_encoding].name,
GetDatabaseEncodingName());
ereport(FATAL,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conversion between %s and %s is not supported",
pg_enc2name_tbl[pending_client_encoding].name,
GetDatabaseEncodingName())));
}
}
@@ -245,23 +247,24 @@ pg_do_encoding_conversion(unsigned char *src, int len,
proc = FindDefaultConversionProc(src_encoding, dest_encoding);
if (!OidIsValid(proc))
{
elog(LOG, "default conversion proc for %s to %s not found",
pg_encoding_to_char(src_encoding), pg_encoding_to_char(dest_encoding));
ereport(LOG,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("default conversion proc for %s to %s does not exist",
pg_encoding_to_char(src_encoding),
pg_encoding_to_char(dest_encoding))));
return src;
}
/*
* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise we
* are going into inifinite loop! So we have to make sure that the
* XXX we should avoid throwing errors in OidFunctionCall. Otherwise we
* are going into infinite loop! So we have to make sure that the
* function exists before calling OidFunctionCall.
*/
if (!SearchSysCacheExists(PROCOID,
ObjectIdGetDatum(proc),
0, 0, 0))
{
elog(LOG, "default conversion proc %u for %s to %s not found in pg_proc",
proc,
pg_encoding_to_char(src_encoding), pg_encoding_to_char(dest_encoding));
elog(LOG, "cache lookup failed for function %u", proc);
return src;
}
@@ -318,9 +321,15 @@ pg_convert2(PG_FUNCTION_ARGS)
int len;
if (src_encoding < 0)
elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid source encoding name \"%s\"",
src_encoding_name)));
if (dest_encoding < 0)
elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid destination encoding name \"%s\"",
dest_encoding_name)));
/* make sure that source string is null terminated */
len = VARSIZE(string) - VARHDRSZ;
@@ -330,7 +339,7 @@ pg_convert2(PG_FUNCTION_ARGS)
result = pg_do_encoding_conversion(str, len, src_encoding, dest_encoding);
if (result == NULL)
elog(ERROR, "Encoding conversion failed");
elog(ERROR, "encoding conversion failed");
/*
* build text data type structure. we cannot use textin() here, since
@@ -551,7 +560,7 @@ void
SetDatabaseEncoding(int encoding)
{
if (!PG_VALID_BE_ENCODING(encoding))
elog(ERROR, "SetDatabaseEncoding(): invalid database encoding");
elog(ERROR, "invalid database encoding");
DatabaseEncoding = &pg_enc2name_tbl[encoding];
Assert(DatabaseEncoding->encoding == encoding);