aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r--src/backend/utils/cache/catcache.c22
-rw-r--r--src/backend/utils/cache/inval.c9
-rw-r--r--src/backend/utils/cache/lsyscache.c99
-rw-r--r--src/backend/utils/cache/relcache.c125
-rw-r--r--src/backend/utils/cache/syscache.c12
5 files changed, 148 insertions, 119 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 8c0df3dfc2c..2ebc0a949ba 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -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;
}
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 6aa5ab62f25..080338a77be 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -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;
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 879d2ba57a7..e2a5a02af79 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.101 2003/07/01 19:10:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.102 2003/07/25 20:17:52 tgl Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -74,7 +74,7 @@ op_requires_recheck(Oid opno, Oid opclass)
ObjectIdGetDatum(opclass),
0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "op_requires_recheck: op %u is not a member of opclass %u",
+ elog(ERROR, "operator %u is not a member of opclass %u",
opno, opclass);
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
@@ -487,7 +487,7 @@ op_mergejoin_crossops(Oid opno, Oid *ltop, Oid *gtop,
ObjectIdGetDatum(opno),
0, 0, 0);
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
- elog(ERROR, "op_mergejoin_crossops: operator %u not found", opno);
+ elog(ERROR, "cache lookup failed for operator %u", opno);
optup = (Form_pg_operator) GETSTRUCT(tp);
*ltop = optup->oprltcmpop;
*gtop = optup->oprgtcmpop;
@@ -495,14 +495,14 @@ op_mergejoin_crossops(Oid opno, Oid *ltop, Oid *gtop,
/* Check < op provided */
if (!OidIsValid(*ltop))
- elog(ERROR, "op_mergejoin_crossops: mergejoin operator %u has no matching < operator",
+ elog(ERROR, "mergejoin operator %u has no matching < operator",
opno);
if (ltproc)
*ltproc = get_opcode(*ltop);
/* Check > op provided */
if (!OidIsValid(*gtop))
- elog(ERROR, "op_mergejoin_crossops: mergejoin operator %u has no matching > operator",
+ elog(ERROR, "mergejoin operator %u has no matching > operator",
opno);
if (gtproc)
*gtproc = get_opcode(*gtop);
@@ -543,7 +543,7 @@ op_strict(Oid opno)
RegProcedure funcid = get_opcode(opno);
if (funcid == (RegProcedure) InvalidOid)
- elog(ERROR, "Operator OID %u does not exist", opno);
+ elog(ERROR, "operator %u does not exist", opno);
return func_strict((Oid) funcid);
}
@@ -559,7 +559,7 @@ op_volatile(Oid opno)
RegProcedure funcid = get_opcode(opno);
if (funcid == (RegProcedure) InvalidOid)
- elog(ERROR, "Operator OID %u does not exist", opno);
+ elog(ERROR, "operator %u does not exist", opno);
return func_volatile((Oid) funcid);
}
@@ -711,7 +711,7 @@ get_func_rettype(Oid funcid)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "Function OID %u does not exist", funcid);
+ elog(ERROR, "cache lookup failed for function %u", funcid);
result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
ReleaseSysCache(tp);
@@ -736,7 +736,7 @@ get_func_signature(Oid funcid, Oid *argtypes, int *nargs)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "Function OID %u does not exist", funcid);
+ elog(ERROR, "cache lookup failed for function %u", funcid);
procstruct = (Form_pg_proc) GETSTRUCT(tp);
@@ -762,7 +762,7 @@ get_func_retset(Oid funcid)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "Function OID %u does not exist", funcid);
+ elog(ERROR, "cache lookup failed for function %u", funcid);
result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
ReleaseSysCache(tp);
@@ -783,7 +783,7 @@ func_strict(Oid funcid)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "Function OID %u does not exist", funcid);
+ elog(ERROR, "cache lookup failed for function %u", funcid);
result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
ReleaseSysCache(tp);
@@ -804,7 +804,7 @@ func_volatile(Oid funcid)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "Function OID %u does not exist", funcid);
+ elog(ERROR, "cache lookup failed for function %u", funcid);
result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
ReleaseSysCache(tp);
@@ -842,7 +842,7 @@ get_system_catalog_relid(const char *catname)
ObjectIdGetDatum(PG_CATALOG_NAMESPACE),
0, 0);
if (!OidIsValid(relid))
- elog(ERROR, "get_system_catalog_relid: cannot find %s", catname);
+ elog(ERROR, "cache lookup failed for system relation %s", catname);
return relid;
}
@@ -1264,7 +1264,7 @@ get_typdefault(Oid typid)
ObjectIdGetDatum(typid),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "get_typdefault: failed to lookup type %u", typid);
+ elog(ERROR, "cache lookup failed for type %u", typid);
type = (Form_pg_type) GETSTRUCT(typeTuple);
/*
@@ -1343,7 +1343,7 @@ getBaseType(Oid typid)
ObjectIdGetDatum(typid),
0, 0, 0);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getBaseType: failed to lookup type %u", typid);
+ elog(ERROR, "cache lookup failed for type %u", typid);
typTup = (Form_pg_type) GETSTRUCT(tup);
if (typTup->typtype != 'd')
{
@@ -1593,15 +1593,19 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem)
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "Cache lookup of type %u failed", type);
+ elog(ERROR, "cache lookup failed for type %u", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
if (!pt->typisdefined)
- elog(ERROR, "Type %s is only a shell",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("type %s is only a shell",
+ format_type_be(type))));
if (!OidIsValid(pt->typinput))
- elog(ERROR, "No input function available for type %s",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("no input function available for type %s",
+ format_type_be(type))));
*typInput = pt->typinput;
*typElem = pt->typelem;
@@ -1625,15 +1629,19 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "Cache lookup of type %u failed", type);
+ elog(ERROR, "cache lookup failed for type %u", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
if (!pt->typisdefined)
- elog(ERROR, "Type %s is only a shell",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("type %s is only a shell",
+ format_type_be(type))));
if (!OidIsValid(pt->typoutput))
- elog(ERROR, "No output function available for type %s",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("no output function available for type %s",
+ format_type_be(type))));
*typOutput = pt->typoutput;
*typElem = pt->typelem;
@@ -1657,15 +1665,19 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem)
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "Cache lookup of type %u failed", type);
+ elog(ERROR, "cache lookup failed for type %u", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
if (!pt->typisdefined)
- elog(ERROR, "Type %s is only a shell",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("type %s is only a shell",
+ format_type_be(type))));
if (!OidIsValid(pt->typreceive))
- elog(ERROR, "No binary input function available for type %s",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("no binary input function available for type %s",
+ format_type_be(type))));
*typReceive = pt->typreceive;
*typElem = pt->typelem;
@@ -1689,15 +1701,19 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typElem,
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "Cache lookup of type %u failed", type);
+ elog(ERROR, "cache lookup failed for type %u", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
if (!pt->typisdefined)
- elog(ERROR, "Type %s is only a shell",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("type %s is only a shell",
+ format_type_be(type))));
if (!OidIsValid(pt->typsend))
- elog(ERROR, "No binary output function available for type %s",
- format_type_be(type));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("no binary output function available for type %s",
+ format_type_be(type))));
*typSend = pt->typsend;
*typElem = pt->typelem;
@@ -1791,7 +1807,7 @@ get_attstatsslot(HeapTuple statstuple,
Anum_pg_statistic_stavalues1 + i,
&isnull);
if (isnull)
- elog(ERROR, "get_attstatsslot: stavalues is null");
+ elog(ERROR, "stavalues is null");
statarray = DatumGetArrayTypeP(val);
/* Need to get info about the array element type */
@@ -1799,8 +1815,7 @@ get_attstatsslot(HeapTuple statstuple,
ObjectIdGetDatum(atttype),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "get_attstatsslot: Cache lookup failed for type %u",
- atttype);
+ elog(ERROR, "cache lookup failed for type %u", atttype);
typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
/* Deconstruct array into Datum elements */
@@ -1841,7 +1856,7 @@ get_attstatsslot(HeapTuple statstuple,
Anum_pg_statistic_stanumbers1 + i,
&isnull);
if (isnull)
- elog(ERROR, "get_attstatsslot: stanumbers is null");
+ elog(ERROR, "stanumbers is null");
statarray = DatumGetArrayTypeP(val);
/*
@@ -1852,7 +1867,7 @@ get_attstatsslot(HeapTuple statstuple,
narrayelem = ARR_DIMS(statarray)[0];
if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
ARR_ELEMTYPE(statarray) != FLOAT4OID)
- elog(ERROR, "get_attstatsslot: stanumbers is not a 1-D float4 array");
+ elog(ERROR, "stanumbers is not a 1-D float4 array");
*numbers = (float4 *) palloc(narrayelem * sizeof(float4));
memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4));
*nnumbers = narrayelem;
@@ -1939,7 +1954,9 @@ get_usesysid(const char *username)
PointerGetDatum(username),
0, 0, 0);
if (!HeapTupleIsValid(userTup))
- elog(ERROR, "user \"%s\" does not exist", username);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("user \"%s\" does not exist", username)));
result = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 14899e2968b..c9a56c0072a 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.185 2003/05/28 16:03:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.186 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -167,7 +167,9 @@ do { \
HASH_ENTER, \
&found); \
if (idhentry == NULL) \
- elog(ERROR, "out of memory for relation descriptor cache"); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_OUT_OF_MEMORY), \
+ errmsg("out of memory"))); \
/* used to give notice if found -- now just keep quiet */ \
idhentry->reldesc = RELATION; \
nodentry = (RelNodeCacheEnt*)hash_search(RelationNodeCache, \
@@ -175,7 +177,9 @@ do { \
HASH_ENTER, \
&found); \
if (nodentry == NULL) \
- elog(ERROR, "out of memory for relation descriptor cache"); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_OUT_OF_MEMORY), \
+ errmsg("out of memory"))); \
/* used to give notice if found -- now just keep quiet */ \
nodentry->reldesc = RELATION; \
if (IsSystemNamespace(RelationGetNamespace(RELATION))) \
@@ -187,7 +191,9 @@ do { \
HASH_ENTER, \
&found); \
if (namehentry == NULL) \
- elog(ERROR, "out of memory for relation descriptor cache"); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_OUT_OF_MEMORY), \
+ errmsg("out of memory"))); \
/* used to give notice if found -- now just keep quiet */ \
namehentry->reldesc = RELATION; \
} \
@@ -233,12 +239,12 @@ do { \
(void *)&(RELATION->rd_id), \
HASH_REMOVE, NULL); \
if (idhentry == NULL) \
- elog(WARNING, "trying to delete a rd_id reldesc that does not exist."); \
+ elog(WARNING, "trying to delete a rd_id reldesc that does not exist"); \
nodentry = (RelNodeCacheEnt*)hash_search(RelationNodeCache, \
(void *)&(RELATION->rd_node), \
HASH_REMOVE, NULL); \
if (nodentry == NULL) \
- elog(WARNING, "trying to delete a rd_node reldesc that does not exist."); \
+ elog(WARNING, "trying to delete a rd_node reldesc that does not exist"); \
if (IsSystemNamespace(RelationGetNamespace(RELATION))) \
{ \
char *relname = RelationGetRelationName(RELATION); \
@@ -247,7 +253,7 @@ do { \
relname, \
HASH_REMOVE, NULL); \
if (namehentry == NULL) \
- elog(WARNING, "trying to delete a relname reldesc that does not exist."); \
+ elog(WARNING, "trying to delete a relname reldesc that does not exist"); \
} \
} while(0)
@@ -353,7 +359,8 @@ ScanPgRelation(RelationBuildDescInfo buildinfo)
break;
default:
- elog(ERROR, "ScanPgRelation: bad buildinfo");
+ elog(ERROR, "unrecognized buildinfo type: %d",
+ buildinfo.infotype);
return NULL; /* keep compiler quiet */
}
@@ -507,7 +514,7 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
if (attp->attnum <= 0 ||
attp->attnum > relation->rd_rel->relnatts)
- elog(ERROR, "Bogus attribute number %d for %s",
+ elog(ERROR, "invalid attribute number %d for %s",
attp->attnum, RelationGetRelationName(relation));
relation->rd_att->attrs[attp->attnum - 1] =
@@ -961,7 +968,7 @@ RelationInitIndexAccessInfo(Relation relation)
ObjectIdGetDatum(RelationGetRelid(relation)),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "RelationInitIndexAccessInfo: no pg_index entry for index %u",
+ elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
oldcontext = MemoryContextSwitchTo(CacheMemoryContext);
relation->rd_indextuple = heap_copytuple(tuple);
@@ -976,7 +983,7 @@ RelationInitIndexAccessInfo(Relation relation)
ObjectIdGetDatum(relation->rd_rel->relam),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "RelationInitIndexAccessInfo: cache lookup failed for AM %u",
+ elog(ERROR, "cache lookup failed for access method %u",
relation->rd_rel->relam);
aform = (Form_pg_am) MemoryContextAlloc(CacheMemoryContext, sizeof *aform);
memcpy(aform, GETSTRUCT(tuple), sizeof *aform);
@@ -985,7 +992,7 @@ RelationInitIndexAccessInfo(Relation relation)
natts = relation->rd_rel->relnatts;
if (natts != relation->rd_index->indnatts)
- elog(ERROR, "RelationInitIndexAccessInfo: relnatts disagrees with indnatts for index %u",
+ elog(ERROR, "relnatts disagrees with indnatts for index %u",
RelationGetRelid(relation));
amstrategies = aform->amstrategies;
amsupport = aform->amsupport;
@@ -1099,7 +1106,7 @@ IndexSupportInitialize(Form_pg_index iform,
OpClassCacheEnt *opcentry;
if (!OidIsValid(iform->indclass[attIndex]))
- elog(ERROR, "IndexSupportInitialize: bogus pg_index tuple");
+ elog(ERROR, "bogus pg_index tuple");
/* look up the info for this opclass, using a cache */
opcentry = LookupOpclassInfo(iform->indclass[attIndex],
@@ -1206,7 +1213,9 @@ LookupOpclassInfo(Oid operatorClassOid,
(void *) &operatorClassOid,
HASH_ENTER, &found);
if (opcentry == NULL)
- elog(ERROR, "out of memory for operator class cache");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
if (found && opcentry->valid)
{
@@ -1280,7 +1289,7 @@ LookupOpclassInfo(Oid operatorClassOid,
if (amopform->amopstrategy <= 0 ||
(StrategyNumber) amopform->amopstrategy > numStrats)
- elog(ERROR, "Bogus amopstrategy number %d for opclass %u",
+ elog(ERROR, "invalid amopstrategy number %d for opclass %u",
amopform->amopstrategy, operatorClassOid);
opcentry->operatorOids[amopform->amopstrategy - 1] =
amopform->amopopr;
@@ -1315,7 +1324,7 @@ LookupOpclassInfo(Oid operatorClassOid,
if (amprocform->amprocnum <= 0 ||
(StrategyNumber) amprocform->amprocnum > numSupport)
- elog(ERROR, "Bogus amproc number %d for opclass %u",
+ elog(ERROR, "invalid amproc number %d for opclass %u",
amprocform->amprocnum, operatorClassOid);
opcentry->supportProcs[amprocform->amprocnum - 1] =
@@ -1659,10 +1668,8 @@ RelationReloadClassinfo(Relation relation)
buildinfo.i.info_id = relation->rd_id;
pg_class_tuple = ScanPgRelation(buildinfo);
if (!HeapTupleIsValid(pg_class_tuple))
- {
- elog(ERROR, "RelationReloadClassinfo system relation id=%d doesn't exist", relation->rd_id);
- return;
- }
+ elog(ERROR, "could not find tuple for system relation %u",
+ relation->rd_id);
RelationCacheDelete(relation);
relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE);
@@ -1787,7 +1794,7 @@ RelationClearRelation(Relation relation, bool rebuild)
if (old_rulescxt)
MemoryContextDelete(old_rulescxt);
pfree(relation);
- elog(ERROR, "RelationClearRelation: relation %u deleted while still in use",
+ elog(ERROR, "relation %u deleted while still in use",
buildinfo.i.info_id);
}
RelationSetReferenceCount(relation, old_refcnt);
@@ -1870,7 +1877,7 @@ RelationForgetRelation(Oid rid)
return; /* not in cache, nothing to do */
if (!RelationHasReferenceCountZero(relation))
- elog(ERROR, "RelationForgetRelation: relation %u is still open", rid);
+ elog(ERROR, "relation %u is still open", rid);
/* Unconditionally destroy the relcache entry */
RelationClearRelation(relation, false);
@@ -2008,7 +2015,7 @@ AtEOXact_RelationCache(bool commit)
/*
* During transaction abort, we must also reset relcache entry ref
* counts to their normal not-in-a-transaction state. A ref count
- * may be too high because some routine was exited by elog()
+ * may be too high because some routine was exited by ereport()
* between incrementing and decrementing the count.
*
* During commit, we should not have to do this, but it's still
@@ -2027,7 +2034,7 @@ AtEOXact_RelationCache(bool commit)
if (relation->rd_refcnt != expected_refcnt &&
!IsBootstrapProcessingMode())
{
- elog(WARNING, "Relcache reference leak: relation \"%s\" has refcnt %d instead of %d",
+ elog(WARNING, "relcache reference leak: relation \"%s\" has refcnt %d instead of %d",
RelationGetRelationName(relation),
relation->rd_refcnt, expected_refcnt);
RelationSetReferenceCount(relation, expected_refcnt);
@@ -2324,8 +2331,8 @@ RelationCacheInitializePhase2(void)
ObjectIdGetDatum(RelationGetRelid(relation)),
0, 0, 0);
if (!HeapTupleIsValid(htup))
- elog(FATAL, "RelationCacheInitializePhase2: no pg_class entry for %s",
- RelationGetRelationName(relation));
+ elog(FATAL, "cache lookup failed for relation %u",
+ RelationGetRelid(relation));
relp = (Form_pg_class) GETSTRUCT(htup);
/*
@@ -2466,21 +2473,22 @@ AttrDefaultFetch(Relation relation)
{
Form_pg_attrdef adform = (Form_pg_attrdef) GETSTRUCT(htup);
- found++;
for (i = 0; i < ndef; i++)
{
if (adform->adnum != attrdef[i].adnum)
continue;
if (attrdef[i].adbin != NULL)
- elog(WARNING, "AttrDefaultFetch: second record found for attr %s in rel %s",
+ elog(WARNING, "multiple attrdef records found for attr %s of rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
+ else
+ found++;
val = fastgetattr(htup,
Anum_pg_attrdef_adbin,
adrel->rd_att, &isnull);
if (isnull)
- elog(WARNING, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
+ elog(WARNING, "null adbin for attr %s of rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
else
@@ -2491,16 +2499,15 @@ AttrDefaultFetch(Relation relation)
}
if (i >= ndef)
- elog(WARNING, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
- adform->adnum,
- RelationGetRelationName(relation));
+ elog(WARNING, "unexpected attrdef record found for attr %d of rel %s",
+ adform->adnum, RelationGetRelationName(relation));
}
systable_endscan(adscan);
heap_close(adrel, AccessShareLock);
if (found != ndef)
- elog(WARNING, "AttrDefaultFetch: %d record(s) not found for rel %s",
+ elog(WARNING, "%d attrdef record(s) missing for rel %s",
ndef - found, RelationGetRelationName(relation));
}
@@ -2533,8 +2540,8 @@ CheckConstraintFetch(Relation relation)
if (conform->contype != CONSTRAINT_CHECK)
continue;
- if (found == ncheck)
- elog(ERROR, "CheckConstraintFetch: unexpected record found for rel %s",
+ if (found >= ncheck)
+ elog(ERROR, "unexpected constraint record found for rel %s",
RelationGetRelationName(relation));
check[found].ccname = MemoryContextStrdup(CacheMemoryContext,
@@ -2545,7 +2552,7 @@ CheckConstraintFetch(Relation relation)
Anum_pg_constraint_conbin,
conrel->rd_att, &isnull);
if (isnull)
- elog(ERROR, "CheckConstraintFetch: conbin IS NULL for rel %s",
+ elog(ERROR, "null conbin for rel %s",
RelationGetRelationName(relation));
check[found].ccbin = MemoryContextStrdup(CacheMemoryContext,
@@ -2558,7 +2565,7 @@ CheckConstraintFetch(Relation relation)
heap_close(conrel, AccessShareLock);
if (found != ncheck)
- elog(ERROR, "CheckConstraintFetch: %d record(s) not found for rel %s",
+ elog(ERROR, "%d constraint record(s) missing for rel %s",
ncheck - found, RelationGetRelationName(relation));
}
@@ -3172,7 +3179,11 @@ write_relcache_init_file(void)
* We used to consider this a fatal error, but we might as well
* continue with backend startup ...
*/
- elog(WARNING, "Cannot create init file %s: %m\n\tContinuing anyway, but there's something wrong.", tempfilename);
+ ereport(WARNING,
+ (errcode_for_file_access(),
+ errmsg("could not create init file \"%s\": %m",
+ tempfilename),
+ errdetail("Continuing anyway, but there's something wrong.")));
return;
}
@@ -3196,28 +3207,28 @@ write_relcache_init_file(void)
/* first, write the relation descriptor length */
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- descriptor length");
+ elog(FATAL, "could not write init file");
/* next, write out the Relation structure */
if (fwrite(rel, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- reldesc");
+ elog(FATAL, "could not write init file");
/* next write the relation tuple form */
len = sizeof(FormData_pg_class);
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- relation tuple form length");
+ elog(FATAL, "could not write init file");
if (fwrite(relform, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- relation tuple form");
+ elog(FATAL, "could not write init file");
/* next, do all the attribute tuple form data entries */
for (i = 0; i < relform->relnatts; i++)
{
len = ATTRIBUTE_TUPLE_SIZE;
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- length of attdesc %d", i);
+ elog(FATAL, "could not write init file");
if (fwrite(rel->rd_att->attrs[i], 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- attdesc %d", i);
+ elog(FATAL, "could not write init file");
}
/* If it's an index, there's more to do */
@@ -3229,43 +3240,43 @@ write_relcache_init_file(void)
/* we assume this was created by heap_copytuple! */
len = HEAPTUPLESIZE + rel->rd_indextuple->t_len;
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- index tuple length");
+ elog(FATAL, "could not write init file");
if (fwrite(rel->rd_indextuple, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- index tuple");
+ elog(FATAL, "could not write init file");
/* next, write the access method tuple form */
len = sizeof(FormData_pg_am);
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- am tuple form length");
+ elog(FATAL, "could not write init file");
if (fwrite(am, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- am tuple form");
+ elog(FATAL, "could not write init file");
/* next, write the index strategy map */
len = AttributeNumberGetIndexStrategySize(relform->relnatts,
am->amstrategies);
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- strategy map length");
+ elog(FATAL, "could not write init file");
if (fwrite(rel->rd_istrat, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- strategy map");
+ elog(FATAL, "could not write init file");
/* next, write the vector of operator OIDs */
len = relform->relnatts * (am->amstrategies * sizeof(Oid));
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- operator vector length");
+ elog(FATAL, "could not write init file");
if (fwrite(rel->rd_operator, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- operator vector");
+ elog(FATAL, "could not write init file");
/* finally, write the vector of support procedures */
len = relform->relnatts * (am->amsupport * sizeof(RegProcedure));
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
- elog(FATAL, "cannot write init file -- support vector length");
+ elog(FATAL, "could not write init file");
if (fwrite(rel->rd_support, 1, len, fp) != len)
- elog(FATAL, "cannot write init file -- support vector");
+ elog(FATAL, "could not write init file");
}
/* also make a list of their OIDs, for RelationIdIsInInitFile */
@@ -3309,7 +3320,11 @@ write_relcache_init_file(void)
*/
if (rename(tempfilename, finalfilename) < 0)
{
- elog(WARNING, "Cannot rename init file %s to %s: %m\n\tContinuing anyway, but there's something wrong.", tempfilename, finalfilename);
+ ereport(WARNING,
+ (errcode_for_file_access(),
+ errmsg("could not rename init file \"%s\" to \"%s\": %m",
+ tempfilename, finalfilename),
+ errdetail("Continuing anyway, but there's something wrong.")));
/*
* If we fail, try to clean up the useless temp file; don't
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 1e435f9f3ab..f5f1d1f874a 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -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);