Commit 689eb53e authored by Tom Lane's avatar Tom Lane

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

parent 9fecf302
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.69 2003/06/22 22:04:54 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.70 2003/07/25 20:17:49 tgl Exp $
-->
<sect1 id="xfunc">
......@@ -2162,7 +2162,6 @@ CREATE FUNCTION test(int, int) RETURNS int
#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
#include "utils/elog.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "utils/syscache.h"
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.104 2003/06/22 22:04:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.105 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -158,8 +158,7 @@ GetCCHashEqFuncs(Oid keytype, PGFunction *hashfunc, RegProcedure *eqfunc)
*eqfunc = F_OIDVECTOREQ;
break;
default:
elog(FATAL, "GetCCHashEqFuncs: type %u unsupported as catcache key",
keytype);
elog(FATAL, "type %u not supported as catcache key", keytype);
break;
}
}
......@@ -202,7 +201,7 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys, ScanKey cur_skey)
cur_skey[0].sk_argument));
break;
default:
elog(FATAL, "CCComputeHashValue: %d nkeys", nkeys);
elog(FATAL, "wrong number of hash keys: %d", nkeys);
break;
}
......@@ -267,8 +266,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
Assert(!isNull);
break;
default:
elog(FATAL, "CCComputeTupleHashValue: %d cc_nkeys",
cache->cc_nkeys);
elog(FATAL, "wrong number of hash keys: %d", cache->cc_nkeys);
break;
}
......@@ -291,14 +289,14 @@ CatCachePrintStats(void)
long cc_lsearches = 0;
long cc_lhits = 0;
elog(DEBUG2, "Catcache stats dump: %d/%d tuples in catcaches",
elog(DEBUG2, "catcache stats dump: %d/%d tuples in catcaches",
CacheHdr->ch_ntup, CacheHdr->ch_maxtup);
for (cache = CacheHdr->ch_caches; cache; cache = cache->cc_next)
{
if (cache->cc_ntup == 0 && cache->cc_searches == 0)
continue; /* don't print unused caches */
elog(DEBUG2, "Catcache %s/%s: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
elog(DEBUG2, "catcache %s/%s: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
cache->cc_relname,
cache->cc_indname,
cache->cc_ntup,
......@@ -322,7 +320,7 @@ CatCachePrintStats(void)
cc_lsearches += cache->cc_lsearches;
cc_lhits += cache->cc_lhits;
}
elog(DEBUG2, "Catcache totals: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
elog(DEBUG2, "catcache totals: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
CacheHdr->ch_ntup,
cc_searches,
cc_hits,
......@@ -557,7 +555,7 @@ AtEOXact_CatCache(bool isCommit)
if (cl->refcount != 0)
{
if (isCommit)
elog(WARNING, "Cache reference leak: cache %s (%d), list %p has count %d",
elog(WARNING, "cache reference leak: cache %s (%d), list %p has count %d",
ccp->cc_relname, ccp->id, cl, cl->refcount);
cl->refcount = 0;
}
......@@ -580,7 +578,7 @@ AtEOXact_CatCache(bool isCommit)
if (ct->refcount != 0)
{
if (isCommit)
elog(WARNING, "Cache reference leak: cache %s (%d), tuple %u has count %d",
elog(WARNING, "cache reference leak: cache %s (%d), tuple %u has count %d",
ct->my_cache->cc_relname, ct->my_cache->id,
HeapTupleGetOid(&ct->tuple),
ct->refcount);
......@@ -947,7 +945,7 @@ CatalogCacheInitializeCache(CatCache *cache)
else
{
if (cache->cc_key[i] != ObjectIdAttributeNumber)
elog(FATAL, "CatalogCacheInit: only sys attr supported is OID");
elog(FATAL, "only sys attr supported in caches is OID");
keytype = OIDOID;
}
......
......@@ -74,7 +74,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.55 2002/09/04 20:31:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.56 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -450,8 +450,7 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
}
else
{
elog(FATAL, "ExecuteInvalidationMessage: bogus message id %d",
msg->id);
elog(FATAL, "unrecognized SI message id: %d", msg->id);
}
}
......@@ -705,7 +704,7 @@ CacheRegisterSyscacheCallback(int cacheid,
Datum arg)
{
if (cache_callback_count >= MAX_CACHE_CALLBACKS)
elog(FATAL, "Out of cache_callback_list slots");
elog(FATAL, "out of cache_callback_list slots");
cache_callback_list[cache_callback_count].id = cacheid;
cache_callback_list[cache_callback_count].function = func;
......@@ -728,7 +727,7 @@ CacheRegisterRelcacheCallback(CacheCallbackFunction func,
Datum arg)
{
if (cache_callback_count >= MAX_CACHE_CALLBACKS)
elog(FATAL, "Out of cache_callback_list slots");
elog(FATAL, "out of cache_callback_list slots");
cache_callback_list[cache_callback_count].id = SHAREDINVALRELCACHE_ID;
cache_callback_list[cache_callback_count].function = func;
......
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.88 2003/05/13 04:38:58 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.89 2003/07/25 20:17:52 tgl Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
......@@ -475,7 +475,7 @@ InitCatalogCache(void)
cacheinfo[cacheId].nkeys,
cacheinfo[cacheId].key);
if (!PointerIsValid(SysCache[cacheId]))
elog(ERROR, "InitCatalogCache: Can't init cache %s (%d)",
elog(ERROR, "could not initialize cache %s (%d)",
cacheinfo[cacheId].name, cacheId);
}
CacheInitialized = true;
......@@ -531,7 +531,7 @@ SearchSysCache(int cacheId,
{
if (cacheId < 0 || cacheId >= SysCacheSize ||
!PointerIsValid(SysCache[cacheId]))
elog(ERROR, "SearchSysCache: Bad cache id %d", cacheId);
elog(ERROR, "invalid cache id: %d", cacheId);
return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4);
}
......@@ -712,10 +712,10 @@ SysCacheGetAttr(int cacheId, HeapTuple tup,
* then it should be.
*/
if (cacheId < 0 || cacheId >= SysCacheSize)
elog(ERROR, "SysCacheGetAttr: Bad cache id %d", cacheId);
elog(ERROR, "invalid cache id: %d", cacheId);
if (!PointerIsValid(SysCache[cacheId]) ||
!PointerIsValid(SysCache[cacheId]->cc_tupdesc))
elog(ERROR, "SysCacheGetAttr: missing cache data for id %d", cacheId);
elog(ERROR, "missing cache data for cache id %d", cacheId);
return heap_getattr(tup, attributeNumber,
SysCache[cacheId]->cc_tupdesc,
......@@ -731,7 +731,7 @@ SearchSysCacheList(int cacheId, int nkeys,
{
if (cacheId < 0 || cacheId >= SysCacheSize ||
!PointerIsValid(SysCache[cacheId]))
elog(ERROR, "SearchSysCacheList: Bad cache id %d", cacheId);
elog(ERROR, "invalid cache id: %d", cacheId);
return SearchCatCacheList(SysCache[cacheId], nkeys,
key1, key2, key3, key4);
......
......@@ -311,7 +311,7 @@ the target function); they will just set it NULL. This is unlikely to
bother any built-in function that could be called this way. Note also
that this style of coding cannot pass a NULL input value nor cope with
a NULL result (it couldn't before, either!). We can make the helper
routines elog an error if they see that the function returns a NULL.
routines ereport an error if they see that the function returns a NULL.
When invoking a function that has a known argument signature, we have
usually written either
......@@ -395,7 +395,7 @@ to a bitmask that's the OR of the modes the caller can support. The actual
mode used by the function is returned in another field "returnMode". For
backwards-compatibility reasons, returnMode is initialized to value-per-call
and need only be changed if the function wants to use a different mode.
The function should elog() if it cannot use any of the modes the caller is
The function should ereport() if it cannot use any of the modes the caller is
willing to support.
Value-per-call mode works like this: ReturnSetInfo contains a field
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Copyright (c) 2002, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.6 2002/09/04 20:31:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.7 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -33,7 +33,9 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
* Bail if we're called in the wrong context
*/
if (fcinfo->resultinfo == NULL || !IsA(fcinfo->resultinfo, ReturnSetInfo))
elog(ERROR, "function called in context that does not accept a set result");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("set function called in context that does not accept a set result")));
if (fcinfo->flinfo->fn_extra == NULL)
{
......@@ -63,8 +65,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
fcinfo->flinfo->fn_extra = retval;
}
else
/* second and subsequent calls */
{
/* second and subsequent calls */
elog(ERROR, "init_MultiFuncCall may not be called more than once");
/* never reached, but keep compiler happy */
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.45 2002/10/31 21:59:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.46 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -659,7 +659,7 @@ hash_search(HTAB *hashp,
return (void *) ELEMENTKEY(currBucket);
}
elog(ERROR, "hash_search: bogus action %d", (int) action);
elog(ERROR, "unrecognized hash action code: %d", (int) action);
return NULL; /* keep compiler quiet */
}
......@@ -932,9 +932,9 @@ hash_corrupted(HTAB *hashp)
* systemwide restart. Otherwise, just shut down this one backend.
*/
if (hashp->isshared)
elog(PANIC, "Hash table '%s' corrupted", hashp->tabname);
elog(PANIC, "hash table \"%s\" corrupted", hashp->tabname);
else
elog(FATAL, "Hash table '%s' corrupted", hashp->tabname);
elog(FATAL, "hash table \"%s\" corrupted", hashp->tabname);
}
/* calculate ceil(log base 2) of num */
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.34 2003/05/27 17:49:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.35 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -62,13 +62,13 @@ ValidateBinary(char *path)
*/
if (stat(path, &buf) < 0)
{
elog(DEBUG3, "ValidateBinary: can't stat \"%s\"", path);
elog(DEBUG3, "could not stat \"%s\": %m", path);
return -1;
}
if ((buf.st_mode & S_IFMT) != S_IFREG)
{
elog(DEBUG3, "ValidateBinary: \"%s\" is not a regular file", path);
elog(DEBUG3, "\"%s\" is not a regular file", path);
return -1;
}
......@@ -95,7 +95,7 @@ ValidateBinary(char *path)
is_r = buf.st_mode & S_IRUSR;
is_x = buf.st_mode & S_IXUSR;
if (!(is_r && is_x))
elog(DEBUG3, "ValidateBinary: \"%s\" is not user read/execute", path);
elog(DEBUG3, "\"%s\" is not user read/execute", path);
return is_x ? (is_r ? 0 : -2) : -1;
}
pwp = getpwuid(euid);
......@@ -121,16 +121,14 @@ ValidateBinary(char *path)
is_r = buf.st_mode & S_IRGRP;
is_x = buf.st_mode & S_IXGRP;
if (!(is_r && is_x))
elog(DEBUG3, "ValidateBinary: \"%s\" is not group read/execute",
path);
elog(DEBUG3, "\"%s\" is not group read/execute", path);
return is_x ? (is_r ? 0 : -2) : -1;
}
}
is_r = buf.st_mode & S_IROTH;
is_x = buf.st_mode & S_IXOTH;
if (!(is_r && is_x))
elog(DEBUG3, "ValidateBinary: \"%s\" is not other read/execute",
path);
elog(DEBUG3, "\"%s\" is not other read/execute", path);
return is_x ? (is_r ? 0 : -2) : -1;
#endif
}
......@@ -179,10 +177,10 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
if (ValidateBinary(buf) == 0)
{
strncpy(full_path, buf, MAXPGPATH);
elog(DEBUG2, "FindExec: found \"%s\" using argv[0]", full_path);
elog(DEBUG2, "found \"%s\" using argv[0]", full_path);
return 0;
}
elog(LOG, "FindExec: invalid binary \"%s\"", buf);
elog(DEBUG2, "invalid binary \"%s\"", buf);
return -1;
}
......@@ -192,7 +190,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
*/
if ((p = getenv("PATH")) && *p)
{
elog(DEBUG2, "FindExec: searching PATH ...");
elog(DEBUG2, "searching PATH for executable");
path = strdup(p); /* make a modifiable copy */
for (startp = path, endp = strchr(path, ':');
startp && *startp;
......@@ -213,14 +211,13 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
{
case 0: /* found ok */
strncpy(full_path, buf, MAXPGPATH);
elog(DEBUG2, "FindExec: found \"%s\" using PATH",
full_path);
elog(DEBUG2, "found \"%s\" using PATH", full_path);
free(path);
return 0;
case -1: /* wasn't even a candidate, keep looking */
break;
case -2: /* found but disqualified */
elog(LOG, "FindExec: could not read binary \"%s\"", buf);
elog(DEBUG2, "could not read binary \"%s\"", buf);
free(path);
return -1;
}
......@@ -230,6 +227,6 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
free(path);
}
elog(LOG, "FindExec: could not find a %s to execute", binary_name);
elog(DEBUG2, "could not find a \"%s\" to execute", binary_name);
return -1;
}
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.123 2003/07/14 20:00:22 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.124 2003/07/25 20:17:52 tgl Exp $
*
*
*-------------------------------------------------------------------------
......@@ -111,8 +111,10 @@ ReverifyMyDatabase(const char *name)
*/
DropBuffers(MyDatabaseId);
/* Now I can commit hara-kiri with a clear conscience... */
elog(FATAL, "Database \"%s\", OID %u, has disappeared from pg_database",
name, MyDatabaseId);
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\", OID %u, has disappeared from pg_database",
name, MyDatabaseId)));
}
/*
......@@ -120,8 +122,10 @@ ReverifyMyDatabase(const char *name)
*/
dbform = (Form_pg_database) GETSTRUCT(tup);
if (!dbform->datallowconn)
elog(FATAL, "Database \"%s\" is not currently accepting connections",
name);
ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database \"%s\" is not currently accepting connections",
name)));
/*
* OK, we're golden. Only other to-do item is to save the encoding
......@@ -252,23 +256,38 @@ InitPostgres(const char *dbname, const char *username)
GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath);
if (!OidIsValid(MyDatabaseId))
elog(FATAL,
"Database \"%s\" does not exist in the system catalog.",
dbname);
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist",
dbname)));
fullpath = GetDatabasePath(MyDatabaseId);
/* Verify the database path */
if (access(fullpath, F_OK) == -1)
elog(FATAL, "Database \"%s\" does not exist.\n\t"
"The database subdirectory '%s' is missing.",
dbname, fullpath);
{
if (errno == ENOENT)
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist",
dbname),
errdetail("The database subdirectory \"%s\" is missing.",
fullpath)));
else
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not access directory \"%s\": %m",
fullpath)));
}
ValidatePgVersion(fullpath);
if (chdir(fullpath) == -1)
elog(FATAL, "Unable to change directory to '%s': %m", fullpath);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not change directory to \"%s\": %m",
fullpath)));
SetDatabasePath(fullpath);
}
......@@ -297,7 +316,7 @@ InitPostgres(const char *dbname, const char *username)
InitBackendSharedInvalidationState();
if (MyBackendId > MaxBackends || MyBackendId <= 0)
elog(FATAL, "InitPostgres: bad backend id %d", MyBackendId);
elog(FATAL, "bad backend id: %d", MyBackendId);
/*
* Initialize the transaction system override state.
......@@ -347,11 +366,11 @@ InitPostgres(const char *dbname, const char *username)
{
InitializeSessionUserIdStandalone();
if (!ThereIsAtLeastOneUser())
{
elog(WARNING, "There are currently no users defined in this database system.");
elog(WARNING, "You should immediately run 'CREATE USER \"%s\" WITH SYSID %d CREATEUSER;'.",
username, BOOTSTRAP_USESYSID);
}
ereport(WARNING,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("no users are defined in this database system"),
errhint("You should immediately run 'CREATE USER \"%s\" WITH SYSID %d CREATEUSER;'.",
username, BOOTSTRAP_USESYSID)));
}
else
{
......@@ -384,7 +403,9 @@ InitPostgres(const char *dbname, const char *username)
if (ReservedBackends > 0 &&
CountEmptyBackendSlots() < ReservedBackends &&
!superuser())
elog(FATAL, "Non-superuser connection limit exceeded");
ereport(FATAL,
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
errmsg("connection limit exceeded for non-superusers")));
/*
* Initialize various default states that can't be set up until we've
......
......@@ -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)
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.56 2003/04/04 20:42:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.57 2003/07/25 20:17:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -144,7 +144,9 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
dbfname = relpath(rnode);
if ((dbfd = open(dbfname, O_RDONLY | PG_BINARY, 0)) < 0)
elog(FATAL, "cannot open %s: %m", dbfname);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m", dbfname)));
pfree(dbfname);
......
......@@ -4,7 +4,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.16 2003/05/29 22:30:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.17 2003/07/25 20:17:56 tgl Exp $
*/
%{
......@@ -18,7 +18,6 @@
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/elog.h"
#include "utils/guc.h"
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
......@@ -147,7 +146,9 @@ ProcessConfigFile(GucContext context)
filename = malloc(strlen(DataDir) + strlen(CONFIG_FILENAME) + 2);
if (filename == NULL)
{
elog(elevel, "out of memory");
ereport(elevel,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return;
}
sprintf(filename, "%s/" CONFIG_FILENAME, DataDir);
......@@ -158,7 +159,9 @@ ProcessConfigFile(GucContext context)
free(filename);
/* File not found is fine */
if (errno != ENOENT)
elog(elevel, "could not read configuration file `" CONFIG_FILENAME "': %s", strerror(errno));
ereport(elevel,
(errcode_for_file_access(),
errmsg("could not read configuration file \"" CONFIG_FILENAME "\": %m")));
return;
}
......@@ -259,15 +262,19 @@ ProcessConfigFile(GucContext context)
FreeFile(fp);
free(filename);
free_name_value_list(head);
elog(elevel, CONFIG_FILENAME ":%u: syntax error, token=\"%s\"",
ConfigFileLineno,yytext);
ereport(elevel,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error in \"" CONFIG_FILENAME "\" line %u, near token \"%s\"",
ConfigFileLineno, yytext)));
return;
out_of_memory:
FreeFile(fp);
free(filename);
free_name_value_list(head);
elog(elevel, "out of memory");
ereport(elevel,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return;
}
......@@ -294,15 +301,17 @@ GUC_scanstr(char *s)
if (s == NULL || s[0] == '\0')
{
if (s != NULL) free (s);
if (s != NULL)
free(s);
return strdup("");
}
len = strlen(s);
newStr = malloc(len + 1); /* string cannot get longer */
if (newStr == NULL)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
for (i = 0, j = 0; i < len; i++)
{
......
This diff is collapsed.
......@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.49 2002/12/15 21:01:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.50 2003/07/25 20:17:56 tgl Exp $
*
* NOTE:
* This is a new (Feb. 05, 1999) implementation of the allocation set
......@@ -330,8 +330,11 @@ AllocSetContextCreate(MemoryContext parent,
if (block == NULL)
{
MemoryContextStats(TopMemoryContext);
elog(ERROR, "Memory exhausted in AllocSetContextCreate(%lu)",
(unsigned long) minContextSize);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed while creating memory context \"%s\".",
name)));
}
block->aset = context;
block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ;
......@@ -493,8 +496,11 @@ AllocSetAlloc(MemoryContext context, Size size)
if (block == NULL)
{
MemoryContextStats(TopMemoryContext);
elog(ERROR, "Memory exhausted in AllocSetAlloc(%lu)",
(unsigned long) size);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed on request of size %lu.",
(unsigned long) size)));
}
block->aset = set;
block->freeptr = block->endptr = ((char *) block) + blksize;
......@@ -690,8 +696,11 @@ AllocSetAlloc(MemoryContext context, Size size)
if (block == NULL)
{
MemoryContextStats(TopMemoryContext);
elog(ERROR, "Memory exhausted in AllocSetAlloc(%lu)",
(unsigned long) size);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed on request of size %lu.",
(unsigned long) size)));
}
block->aset = set;
......@@ -754,7 +763,7 @@ AllocSetFree(MemoryContext context, void *pointer)
/* Test for someone scribbling on unused space in chunk */
if (chunk->requested_size < chunk->size)
if (((char *) pointer)[chunk->requested_size] != 0x7E)
elog(WARNING, "AllocSetFree: detected write past chunk end in %s %p",
elog(WARNING, "detected write past chunk end in %s %p",
set->header.name, chunk);
#endif
......@@ -775,8 +784,7 @@ AllocSetFree(MemoryContext context, void *pointer)
block = block->next;
}
if (block == NULL)
elog(ERROR, "AllocSetFree: cannot find block containing chunk %p",
chunk);
elog(ERROR, "could not find block containing chunk %p", chunk);
/* let's just make sure chunk is the only one in the block */
Assert(block->freeptr == ((char *) block) +
(chunk->size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ));
......@@ -829,7 +837,7 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
/* Test for someone scribbling on unused space in chunk */
if (chunk->requested_size < oldsize)
if (((char *) pointer)[chunk->requested_size] != 0x7E)
elog(WARNING, "AllocSetRealloc: detected write past chunk end in %s %p",
elog(WARNING, "detected write past chunk end in %s %p",
set->header.name, chunk);
#endif
......@@ -869,8 +877,7 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
block = block->next;
}
if (block == NULL)
elog(ERROR, "AllocSetRealloc: cannot find block containing chunk %p",
chunk);
elog(ERROR, "could not find block containing chunk %p", chunk);
/* let's just make sure chunk is the only one in the block */
Assert(block->freeptr == ((char *) block) +
(chunk->size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ));
......@@ -882,8 +889,11 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
if (block == NULL)
{
MemoryContextStats(TopMemoryContext);
elog(ERROR, "Memory exhausted in AllocSetReAlloc(%lu)",
(unsigned long) size);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed on request of size %lu.",
(unsigned long) size)));
}
block->freeptr = block->endptr = ((char *) block) + blksize;
......@@ -1052,7 +1062,7 @@ AllocSetCheck(MemoryContext context)
if (!blk_used)
{
if (set->keeper != block)
elog(WARNING, "AllocSetCheck: %s: empty block %p",
elog(WARNING, "problem in alloc set %s: empty block %p",
name, block);
}
......@@ -1074,16 +1084,16 @@ AllocSetCheck(MemoryContext context)
* Check chunk size
*/
if (dsize > chsize)
elog(WARNING, "AllocSetCheck: %s: req size > alloc size for chunk %p in block %p",
elog(WARNING, "problem in alloc set %s: req size > alloc size for chunk %p in block %p",
name, chunk, block);
if (chsize < (1 << ALLOC_MINBITS))
elog(WARNING, "AllocSetCheck: %s: bad size %lu for chunk %p in block %p",
elog(WARNING, "problem in alloc set %s: bad size %lu for chunk %p in block %p",
name, (unsigned long) chsize, chunk, block);
/* single-chunk block? */
if (chsize > ALLOC_CHUNK_LIMIT &&
chsize + ALLOC_CHUNKHDRSZ != blk_used)
elog(WARNING, "AllocSetCheck: %s: bad single-chunk %p in block %p",
elog(WARNING, "problem in alloc set %s: bad single-chunk %p in block %p",
name, chunk, block);
/*
......@@ -1092,14 +1102,14 @@ AllocSetCheck(MemoryContext context)
* check as easily...)
*/
if (dsize > 0 && chunk->aset != (void *) set)
elog(WARNING, "AllocSetCheck: %s: bogus aset link in block %p, chunk %p",
elog(WARNING, "problem in alloc set %s: bogus aset link in block %p, chunk %p",
name, block, chunk);
/*
* Check for overwrite of "unallocated" space in chunk
*/
if (dsize > 0 && dsize < chsize && *chdata_end != 0x7E)
elog(WARNING, "AllocSetCheck: %s: detected write past chunk end in block %p, chunk %p",
elog(WARNING, "problem in alloc set %s: detected write past chunk end in block %p, chunk %p",
name, block, chunk);
blk_data += chsize;
......@@ -1109,7 +1119,7 @@ AllocSetCheck(MemoryContext context)
}
if ((blk_data + (nchunks * ALLOC_CHUNKHDRSZ)) != blk_used)
elog(WARNING, "AllocSetCheck: %s: found inconsistent memory block %p",
elog(WARNING, "problem in alloc set %s: found inconsistent memory block %p",
name, block);
}
}
......
......@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.40 2003/05/02 20:54:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.41 2003/07/25 20:17:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -385,7 +385,7 @@ MemoryContextContains(MemoryContext context, void *pointer)
* pointer will ordinarily point to statically allocated data).
* The parent and name parameters usually come from the caller.
* 2. MemoryContextCreate() attempts to allocate the context node,
* plus space for the name. If this fails we can elog() with no
* plus space for the name. If this fails we can ereport() with no
* damage done.
* 3. We fill in all of the type-independent MemoryContext fields.
* 4. We call the type-specific init routine (using the methods pointer).
......@@ -478,7 +478,7 @@ MemoryContextAlloc(MemoryContext context, Size size)
AssertArg(MemoryContextIsValid(context));
if (!AllocSizeIsValid(size))
elog(ERROR, "MemoryContextAlloc: invalid request size %lu",
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
return (*context->methods->alloc) (context, size);
......@@ -499,7 +499,7 @@ MemoryContextAllocZero(MemoryContext context, Size size)
AssertArg(MemoryContextIsValid(context));
if (!AllocSizeIsValid(size))
elog(ERROR, "MemoryContextAlloc: invalid request size %lu",
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
ret = (*context->methods->alloc) (context, size);
......@@ -524,7 +524,7 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
AssertArg(MemoryContextIsValid(context));
if (!AllocSizeIsValid(size))
elog(ERROR, "MemoryContextAlloc: invalid request size %lu",
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
ret = (*context->methods->alloc) (context, size);
......@@ -588,7 +588,7 @@ repalloc(void *pointer, Size size)
AssertArg(MemoryContextIsValid(header->context));
if (!AllocSizeIsValid(size))
elog(ERROR, "repalloc: invalid request size %lu",
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
return (*header->context->methods->realloc) (header->context,
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.58 2003/05/06 20:26:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.59 2003/07/25 20:17:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -70,9 +70,11 @@ do { \
hentry = (PortalHashEnt*)hash_search(PortalHashTable, \
key, HASH_ENTER, &found); \
if (hentry == NULL) \
elog(ERROR, "out of memory in PortalHashTable"); \
ereport(ERROR, \
(errcode(ERRCODE_OUT_OF_MEMORY), \
errmsg("out of memory"))); \
if (found) \
elog(WARNING, "trying to insert a portal name that exists."); \
elog(ERROR, "duplicate portal name"); \
hentry->portal = PORTAL; \
/* To avoid duplicate storage, make PORTAL->name point to htab entry */ \
PORTAL->name = hentry->portalname; \
......@@ -87,7 +89,7 @@ do { \
hentry = (PortalHashEnt*)hash_search(PortalHashTable, \
key, HASH_REMOVE, NULL); \
if (hentry == NULL) \
elog(WARNING, "trying to delete portal name that does not exist."); \
elog(WARNING, "trying to delete portal name that does not exist"); \
} while(0)
static MemoryContext PortalMemory = NULL;
......@@ -163,9 +165,14 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent)
if (PortalIsValid(portal))
{
if (!allowDup)
elog(ERROR, "Portal \"%s\" already exists", name);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_CURSOR),
errmsg("portal \"%s\" already exists", name)));
if (!dupSilent)
elog(WARNING, "Closing pre-existing portal \"%s\"", name);
ereport(WARNING,
(errcode(ERRCODE_DUPLICATE_CURSOR),
errmsg("closing pre-existing portal \"%s\"",
name)));
PortalDrop(portal, false);
}
......@@ -295,7 +302,7 @@ PortalDrop(Portal portal, bool isError)
/* Not sure if this case can validly happen or not... */
if (portal->portalActive)
elog(ERROR, "PortalDrop: can't drop active portal");
elog(ERROR, "cannot drop active portal");
/*
* Remove portal from hash table. Because we do this first, we will
......
......@@ -56,7 +56,7 @@
* Since all the bookkeeping and buffer memory is allocated with palloc(),
* and the underlying file(s) are made with OpenTemporaryFile, all resources
* for a logical tape set are certain to be cleaned up even if processing
* is aborted by elog(ERROR). To avoid confusion, the caller should take
* is aborted by ereport(ERROR). To avoid confusion, the caller should take
* care that all calls for a single LogicalTapeSet are made in the same
* palloc context.
*
......@@ -64,7 +64,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.9 2003/03/27 16:51:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.10 2003/07/25 20:17:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -189,21 +189,25 @@ static void ltsDumpBuffer(LogicalTapeSet *lts, LogicalTape *lt);
* "holes" in file), since BufFile doesn't allow that. The first write pass
* must write blocks sequentially.
*
* No need for an error return convention; we elog() on any error.
* No need for an error return convention; we ereport() on any error.
*/
static void
ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
{
if (BufFileSeekBlock(lts->pfile, blocknum) != 0 ||
BufFileWrite(lts->pfile, buffer, BLCKSZ) != BLCKSZ)
elog(ERROR, "ltsWriteBlock: failed to write block %ld of temporary file\n\t\tPerhaps out of disk space?",
blocknum);
ereport(ERROR,
/* XXX is it okay to assume errno is correct? */
(errcode_for_file_access(),
errmsg("could not write block %ld of temporary file: %m",
blocknum),
errhint("Perhaps out of disk space?")));
}
/*
* Read a block-sized buffer from the specified block of the underlying file.
*
* No need for an error return convention; we elog() on any error. This
* No need for an error return convention; we ereport() on any error. This
* module should never attempt to read a block it doesn't know is there.
*/
static void
......@@ -211,8 +215,11 @@ ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
{
if (BufFileSeekBlock(lts->pfile, blocknum) != 0 ||
BufFileRead(lts->pfile, buffer, BLCKSZ) != BLCKSZ)
elog(ERROR, "ltsReadBlock: failed to read block %ld of temporary file",
blocknum);
ereport(ERROR,
/* XXX is it okay to assume errno is correct? */
(errcode_for_file_access(),
errmsg("could not read block %ld of temporary file: %m",
blocknum)));
}
/*
......@@ -543,7 +550,7 @@ ltsDumpBuffer(LogicalTapeSet *lts, LogicalTape *lt)
/*
* Write to a logical tape.
*
* There are no error returns; we elog() on failure.
* There are no error returns; we ereport() on failure.
*/
void
LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
......@@ -566,7 +573,7 @@ LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
else
{
/* Hmm, went directly from reading to writing? */
elog(ERROR, "LogicalTapeWrite: impossible state");
elog(ERROR, "invalid logtape state: should be dirty");
}
lt->numFullBlocks++;
lt->curBlockNumber++;
......@@ -828,7 +835,7 @@ LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size)
long datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
if (datablocknum == -1L)
elog(ERROR, "LogicalTapeBackspace: unexpected end of tape");
elog(ERROR, "unexpected end of tape");
lt->curBlockNumber--;
if (nblocks == 0)
{
......@@ -885,7 +892,7 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
long datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
if (datablocknum == -1L)
elog(ERROR, "LogicalTapeSeek: unexpected end of tape");
elog(ERROR, "unexpected end of tape");
if (--lt->curBlockNumber == blocknum)
ltsReadBlock(lts, datablocknum, (void *) lt->buffer);
}
......@@ -895,7 +902,7 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
lt->frozen);
if (datablocknum == -1L)
elog(ERROR, "LogicalTapeSeek: unexpected end of tape");
elog(ERROR, "unexpected end of tape");
if (++lt->curBlockNumber == blocknum)
ltsReadBlock(lts, datablocknum, (void *) lt->buffer);
}
......
......@@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.33 2003/05/13 04:38:58 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.34 2003/07/25 20:17:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -319,7 +319,7 @@ struct Tuplesortstate
* stored in the Tuplesortstate record, if needed. They are also expected
* to adjust state->availMem by the amount of memory space (not tape space!)
* released or consumed. There is no error return from either writetup
* or readtup; they should elog() on failure.
* or readtup; they should ereport() on failure.
*
*
* NOTES about memory consumption calculations:
......@@ -691,7 +691,7 @@ puttuple_common(Tuplesortstate *state, void *tuple)
dumptuples(state, false);
break;
default:
elog(ERROR, "tuplesort_puttuple: invalid state");
elog(ERROR, "invalid tuplesort state");
break;
}
}
......@@ -738,7 +738,7 @@ tuplesort_performsort(Tuplesortstate *state)
state->markpos_eof = false;
break;
default:
elog(ERROR, "tuplesort_performsort: invalid state");
elog(ERROR, "invalid tuplesort state");
break;
}
}
......@@ -856,7 +856,7 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
if (!LogicalTapeBackspace(state->tapeset,
state->result_tape,
tuplen + sizeof(unsigned int)))
elog(ERROR, "tuplesort_gettuple: bogus tuple len in backward scan");
elog(ERROR, "bogus tuple length in backward scan");
return NULL;
}
}
......@@ -871,7 +871,7 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
if (!LogicalTapeBackspace(state->tapeset,
state->result_tape,
tuplen))
elog(ERROR, "tuplesort_gettuple: bogus tuple len in backward scan");
elog(ERROR, "bogus tuple length in backward scan");
tup = READTUP(state, state->result_tape, tuplen);
return tup;
......@@ -923,7 +923,7 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
return NULL;
default:
elog(ERROR, "tuplesort_gettuple: invalid state");
elog(ERROR, "invalid tuplesort state");
return NULL; /* keep compiler quiet */
}
}
......@@ -1483,7 +1483,7 @@ tuplesort_rescan(Tuplesortstate *state)
state->markpos_eof = false;
break;
default:
elog(ERROR, "tuplesort_rescan: invalid state");
elog(ERROR, "invalid tuplesort state");
break;
}
}
......@@ -1510,7 +1510,7 @@ tuplesort_markpos(Tuplesortstate *state)
state->markpos_eof = state->eof_reached;
break;
default:
elog(ERROR, "tuplesort_markpos: invalid state");
elog(ERROR, "invalid tuplesort state");
break;
}
}
......@@ -1539,7 +1539,7 @@ tuplesort_restorepos(Tuplesortstate *state)
state->eof_reached = state->markpos_eof;
break;
default:
elog(ERROR, "tuplesort_restorepos: invalid state");
elog(ERROR, "invalid tuplesort state");
break;
}
}
......@@ -1662,9 +1662,9 @@ getlen(Tuplesortstate *state, int tapenum, bool eofOK)
if (LogicalTapeRead(state->tapeset, tapenum, (void *) &len,
sizeof(len)) != sizeof(len))
elog(ERROR, "tuplesort: unexpected end of tape");
elog(ERROR, "unexpected end of tape");
if (len == 0 && !eofOK)
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
return len;
}
......@@ -1779,8 +1779,7 @@ SelectSortFunction(Oid sortOperator,
ObjectIdGetDatum(sortOperator),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "SelectSortFunction: cache lookup failed for operator %u",
sortOperator);
elog(ERROR, "cache lookup failed for operator %u", sortOperator);
optup = (Form_pg_operator) GETSTRUCT(tuple);
if (strcmp(NameStr(optup->oprname), ">") == 0)
*kind = SORTFUNC_REVLT;
......@@ -1817,8 +1816,7 @@ myFunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall2: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
......@@ -1891,7 +1889,7 @@ inlineApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind,
datum1, datum2));
default:
elog(ERROR, "Invalid SortFunctionKind %d", (int) kind);
elog(ERROR, "unrecognized SortFunctionKind: %d", (int) kind);
return 0; /* can't get here, but keep compiler quiet */
}
}
......@@ -2000,11 +1998,11 @@ readtup_heap(Tuplesortstate *state, int tapenum, unsigned int len)
/* read in the tuple proper */
if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple->t_data,
tuple->t_len) != tuple->t_len)
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
if (state->randomAccess) /* need trailing length word? */
if (LogicalTapeRead(state->tapeset, tapenum, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
return (void *) tuple;
}
......@@ -2079,7 +2077,10 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
* a bogus error in that case.
*/
if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
elog(ERROR, "Cannot create unique index. Table contains non-unique values");
ereport(ERROR,
(errcode(ERRCODE_UNIQUE_VIOLATION),
errmsg("could not create unique index"),
errdetail("Table contains duplicated values.")));
return 0;
}
......@@ -2127,11 +2128,11 @@ readtup_index(Tuplesortstate *state, int tapenum, unsigned int len)
USEMEM(state, GetMemoryChunkSpace(tuple));
if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple,
tuplen) != tuplen)
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
if (state->randomAccess) /* need trailing length word? */
if (LogicalTapeRead(state->tapeset, tapenum, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
return (void *) tuple;
}
......@@ -2199,11 +2200,11 @@ readtup_datum(Tuplesortstate *state, int tapenum, unsigned int len)
USEMEM(state, GetMemoryChunkSpace(tuple));
if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple,
tuplen) != tuplen)
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
if (state->randomAccess) /* need trailing length word? */
if (LogicalTapeRead(state->tapeset, tapenum, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplesort: unexpected end of data");
elog(ERROR, "unexpected end of data");
if (!tuple->isNull && !state->datumTypeByVal)
tuple->val = PointerGetDatum(((char *) tuple) +
......
......@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.13 2003/04/29 03:21:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.14 2003/07/25 20:18:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -171,7 +171,7 @@ struct Tuplestorestate
* stored in the Tuplestorestate record, if needed. They are also expected
* to adjust state->availMem by the amount of memory space (not tape space!)
* released or consumed. There is no error return from either writetup
* or readtup; they should elog() on failure.
* or readtup; they should ereport() on failure.
*
*
* NOTES about memory consumption calculations:
......@@ -361,12 +361,12 @@ tuplestore_puttuple(Tuplestorestate *state, void *tuple)
if (BufFileSeek(state->myfile,
state->writepos_file, state->writepos_offset,
SEEK_SET) != 0)
elog(ERROR, "tuplestore_puttuple: seek(EOF) failed");
elog(ERROR, "seek to EOF failed");
state->status = TSS_WRITEFILE;
WRITETUP(state, tuple);
break;
default:
elog(ERROR, "tuplestore_puttuple: invalid state");
elog(ERROR, "invalid tuplestore state");
break;
}
}
......@@ -430,7 +430,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
if (BufFileSeek(state->myfile,
state->readpos_file, state->readpos_offset,
SEEK_SET) != 0)
elog(ERROR, "tuplestore_gettuple: seek() failed");
elog(ERROR, "seek failed");
state->status = TSS_READFILE;
/* FALL THRU into READFILE case */
......@@ -488,7 +488,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
if (BufFileSeek(state->myfile, 0,
-(long) (tuplen + sizeof(unsigned int)),
SEEK_CUR) != 0)
elog(ERROR, "tuplestore_gettuple: bogus tuple len in backward scan");
elog(ERROR, "bogus tuple length in backward scan");
return NULL;
}
tuplen = getlen(state, false);
......@@ -502,12 +502,12 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
if (BufFileSeek(state->myfile, 0,
-(long) tuplen,
SEEK_CUR) != 0)
elog(ERROR, "tuplestore_gettuple: bogus tuple len in backward scan");
elog(ERROR, "bogus tuple length in backward scan");
tup = READTUP(state, tuplen);
return tup;
default:
elog(ERROR, "tuplestore_gettuple: invalid state");
elog(ERROR, "invalid tuplestore state");
return NULL; /* keep compiler quiet */
}
}
......@@ -559,10 +559,10 @@ tuplestore_rescan(Tuplestorestate *state)
case TSS_READFILE:
state->eof_reached = false;
if (BufFileSeek(state->myfile, 0, 0L, SEEK_SET) != 0)
elog(ERROR, "tuplestore_rescan: seek(0) failed");
elog(ERROR, "seek to start failed");
break;
default:
elog(ERROR, "tuplestore_rescan: invalid state");
elog(ERROR, "invalid tuplestore state");
break;
}
}
......@@ -598,7 +598,7 @@ tuplestore_markpos(Tuplestorestate *state)
&state->markpos_offset);
break;
default:
elog(ERROR, "tuplestore_markpos: invalid state");
elog(ERROR, "invalid tuplestore state");
break;
}
}
......@@ -630,7 +630,7 @@ tuplestore_restorepos(Tuplestorestate *state)
elog(ERROR, "tuplestore_restorepos failed");
break;
default:
elog(ERROR, "tuplestore_restorepos: invalid state");
elog(ERROR, "invalid tuplestore state");
break;
}
}
......@@ -650,9 +650,9 @@ getlen(Tuplestorestate *state, bool eofOK)
if (nbytes == sizeof(len))
return len;
if (nbytes != 0)
elog(ERROR, "tuplestore: unexpected end of tape");
elog(ERROR, "unexpected end of tape");
if (!eofOK)
elog(ERROR, "tuplestore: unexpected end of data");
elog(ERROR, "unexpected end of data");
return 0;
}
......@@ -684,14 +684,14 @@ writetup_heap(Tuplestorestate *state, void *tup)
tuplen = tuple->t_len + sizeof(tuplen);
if (BufFileWrite(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplestore: write failed");
elog(ERROR, "write failed");
if (BufFileWrite(state->myfile, (void *) tuple->t_data,
tuple->t_len) != (size_t) tuple->t_len)
elog(ERROR, "tuplestore: write failed");
elog(ERROR, "write failed");
if (state->randomAccess) /* need trailing length word? */
if (BufFileWrite(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplestore: write failed");
elog(ERROR, "write failed");
FREEMEM(state, GetMemoryChunkSpace(tuple));
heap_freetuple(tuple);
......@@ -712,10 +712,10 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
/* read in the tuple proper */
if (BufFileRead(state->myfile, (void *) tuple->t_data,
tuple->t_len) != (size_t) tuple->t_len)
elog(ERROR, "tuplestore: unexpected end of data");
elog(ERROR, "unexpected end of data");
if (state->randomAccess) /* need trailing length word? */
if (BufFileRead(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
elog(ERROR, "tuplestore: unexpected end of data");
elog(ERROR, "unexpected end of data");
return (void *) tuple;
}
......@@ -16,7 +16,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.64 2003/06/25 01:08:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.65 2003/07/25 20:18:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -989,7 +989,7 @@ CopyQuerySnapshot(void)
Snapshot snapshot;
if (QuerySnapshot == NULL) /* should be set beforehand */
elog(ERROR, "CopyQuerySnapshot: no snapshot has been set");
elog(ERROR, "no snapshot has been set");
snapshot = (Snapshot) palloc(sizeof(SnapshotData));
memcpy(snapshot, QuerySnapshot, sizeof(SnapshotData));
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.57 2003/07/24 22:04:15 tgl Exp $
* $Id: elog.h,v 1.58 2003/07/25 20:18:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -160,6 +160,7 @@
#define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2','2', 'P','0','1')
#define ERRCODE_INVALID_BINARY_REPRESENTATION MAKE_SQLSTATE('2','2', 'P','0','2')
#define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2','2', 'P','0','3')
#define ERRCODE_UNTRANSLATABLE_CHARACTER MAKE_SQLSTATE('2','2', 'P','0','4')
/* Class 23 - Integrity Constraint Violation */
#define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','0')
......@@ -317,6 +318,7 @@
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_CANT_CHANGE_RUNTIME_PARAM MAKE_SQLSTATE('5','5', 'P','0','2')
/* Class 57 - Operator Intervention (class borrowed from DB2) */
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
......
......@@ -491,7 +491,8 @@ insert into atacc1 (test) values (2);
-- add a unique constraint (fails)
alter table atacc1 add constraint atacc_test1 unique (test);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1"
ERROR: Cannot create unique index. Table contains non-unique values
ERROR: could not create unique index
DETAIL: Table contains duplicated values.
insert into atacc1 (test) values (3);
drop table atacc1;
-- let's do one where the unique constraint fails
......@@ -558,7 +559,8 @@ insert into atacc1 (test) values (2);
-- add a primary key (fails)
alter table atacc1 add constraint atacc_test1 primary key (test);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
ERROR: Cannot create unique index. Table contains non-unique values
ERROR: could not create unique index
DETAIL: Table contains duplicated values.
insert into atacc1 (test) values (3);
drop table atacc1;
-- let's do another one where the primary key constraint fails when added
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment