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

@ -1,5 +1,5 @@
<!--
$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"

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.72 2003/07/01 00:04:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.73 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -186,8 +186,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
ObjectIdGetDatum(functionId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "fmgr_info: function %u: cache lookup failed",
functionId);
elog(ERROR, "cache lookup failed for function %u", functionId);
procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
finfo->fn_nargs = procedureStruct->pronargs;
@ -219,8 +218,10 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
PointerGetDatum(&procedureStruct->prosrc)));
fbp = fmgr_lookupByName(prosrc);
if (fbp == NULL)
elog(ERROR, "fmgr_info: function %s not in internal table",
prosrc);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("internal function \"%s\" is not in table",
prosrc)));
pfree(prosrc);
/* Should we check that nargs, strict, retset match the table? */
finfo->fn_addr = fbp->func;
@ -266,15 +267,13 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
Anum_pg_proc_prosrc, &isnull);
if (isnull)
elog(ERROR, "fmgr: Could not extract prosrc for %u from pg_proc",
functionId);
elog(ERROR, "null prosrc for function %u", functionId);
prosrcstring = DatumGetCString(DirectFunctionCall1(textout, prosrcattr));
probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
Anum_pg_proc_probin, &isnull);
if (isnull)
elog(ERROR, "fmgr: Could not extract probin for %u from pg_proc",
functionId);
elog(ERROR, "null probin for function %u", functionId);
probinstring = DatumGetCString(DirectFunctionCall1(textout, probinattr));
/* Look up the function itself */
@ -306,7 +305,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
break;
default:
/* Shouldn't get here if fetch_finfo_record did its job */
elog(ERROR, "Unknown function API version %d",
elog(ERROR, "unrecognized function API version: %d",
inforec->api_version);
break;
}
@ -332,8 +331,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
ObjectIdGetDatum(language),
0, 0, 0);
if (!HeapTupleIsValid(languageTuple))
elog(ERROR, "fmgr_info: cache lookup for language %u failed",
language);
elog(ERROR, "cache lookup failed for language %u", language);
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
fmgr_info(languageStruct->lanplcallfoid, &plfinfo);
@ -345,8 +343,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
* oldstyle PL handlers.
*/
if (plfinfo.fn_extra != NULL)
elog(ERROR, "fmgr_info: language %u has old-style handler",
language);
elog(ERROR, "language %u has old-style handler", language);
ReleaseSysCache(languageTuple);
}
@ -393,7 +390,7 @@ fetch_finfo_record(void *filehandle, char *funcname)
/* Validate result as best we can */
if (inforec == NULL)
elog(ERROR, "Null result from %s", infofuncname);
elog(ERROR, "null result from info function \"%s\"", infofuncname);
switch (inforec->api_version)
{
case 0:
@ -401,8 +398,10 @@ fetch_finfo_record(void *filehandle, char *funcname)
/* OK, no additional fields to validate */
break;
default:
elog(ERROR, "Unknown version %d reported by %s",
inforec->api_version, infofuncname);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized API version %d reported by info function \"%s\"",
inforec->api_version, infofuncname)));
break;
}
@ -469,7 +468,7 @@ fmgr_oldstyle(PG_FUNCTION_ARGS)
char *returnValue;
if (fcinfo->flinfo == NULL || fcinfo->flinfo->fn_extra == NULL)
elog(ERROR, "Internal error: fmgr_oldstyle received NULL pointer");
elog(ERROR, "fmgr_oldstyle received NULL pointer");
fnextra = (Oldstyle_fnextra *) fcinfo->flinfo->fn_extra;
/*
@ -618,8 +617,10 @@ fmgr_oldstyle(PG_FUNCTION_ARGS)
* needed to support old-style functions with many arguments,
* but making 'em be new-style is probably a better idea.
*/
elog(ERROR, "fmgr_oldstyle: function %u: too many arguments (%d > %d)",
fcinfo->flinfo->fn_oid, n_arguments, 16);
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
errmsg("function %u has too many arguments (%d > %d)",
fcinfo->flinfo->fn_oid, n_arguments, 16)));
returnValue = NULL; /* keep compiler quiet */
break;
}
@ -663,9 +664,11 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
fmgr_info_cxt_security(fcinfo->flinfo->fn_oid, &fcache->flinfo,
fcinfo->flinfo->fn_mcxt, true);
tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(fcinfo->flinfo->fn_oid), 0, 0, 0);
tuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(fcinfo->flinfo->fn_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "fmgr_security_definer: function %u: cache lookup failed",
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
fcache->userid = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
ReleaseSysCache(tuple);
@ -727,8 +730,7 @@ DirectFunctionCall1(PGFunction func, Datum arg1)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall1: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -755,8 +757,7 @@ DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall2: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -778,8 +779,7 @@ DirectFunctionCall3(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall3: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -802,8 +802,7 @@ DirectFunctionCall4(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall4: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -827,8 +826,7 @@ DirectFunctionCall5(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall5: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -854,8 +852,7 @@ DirectFunctionCall6(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall6: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -882,8 +879,7 @@ DirectFunctionCall7(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall7: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -911,8 +907,7 @@ DirectFunctionCall8(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall8: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -942,8 +937,7 @@ DirectFunctionCall9(PGFunction func, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "DirectFunctionCall9: function %p returned NULL",
(void *) func);
elog(ERROR, "function %p returned NULL", (void *) func);
return result;
}
@ -973,8 +967,7 @@ FunctionCall1(FmgrInfo *flinfo, Datum arg1)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall1: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1001,8 +994,7 @@ FunctionCall2(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;
}
@ -1025,8 +1017,7 @@ FunctionCall3(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall3: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1050,8 +1041,7 @@ FunctionCall4(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall4: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1076,8 +1066,7 @@ FunctionCall5(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall5: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1104,8 +1093,7 @@ FunctionCall6(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall6: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1133,8 +1121,7 @@ FunctionCall7(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall7: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1163,8 +1150,7 @@ FunctionCall8(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall8: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1195,8 +1181,7 @@ FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "FunctionCall9: function %u returned NULL",
fcinfo.flinfo->fn_oid);
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
}
@ -1226,8 +1211,7 @@ OidFunctionCall1(Oid functionId, Datum arg1)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall1: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1251,8 +1235,7 @@ OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall2: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1278,8 +1261,7 @@ OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall3: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1306,8 +1288,7 @@ OidFunctionCall4(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall4: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1335,8 +1316,7 @@ OidFunctionCall5(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall5: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1366,8 +1346,7 @@ OidFunctionCall6(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall6: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1398,8 +1377,7 @@ OidFunctionCall7(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall7: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1431,8 +1409,7 @@ OidFunctionCall8(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall8: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1466,8 +1443,7 @@ OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "OidFunctionCall9: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return result;
}
@ -1505,8 +1481,10 @@ fmgr(Oid procedureId,...)
int i;
if (n_arguments > FUNC_MAX_ARGS)
elog(ERROR, "fmgr: function %u: too many arguments (%d > %d)",
flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS);
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
errmsg("function %u has too many arguments (%d > %d)",
flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS)));
va_start(pvar, procedureId);
for (i = 0; i < n_arguments; i++)
fcinfo.arg[i] = (Datum) va_arg(pvar, char *);
@ -1517,8 +1495,7 @@ fmgr(Oid procedureId,...)
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "fmgr: function %u returned NULL",
flinfo.fn_oid);
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
return (char *) result;
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.104 2003/06/27 19:08:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.105 2003/07/25 20:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -128,7 +128,9 @@ SetDataDir(const char *dir)
{
buf = malloc(buflen);
if (!buf)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
if (getcwd(buf, buflen))
break;
@ -141,13 +143,15 @@ SetDataDir(const char *dir)
else
{
free(buf);
elog(FATAL, "cannot get current working directory: %m");
elog(FATAL, "could not get current working directory: %m");
}
}
new = malloc(strlen(buf) + 1 + strlen(dir) + 1);
if (!new)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
sprintf(new, "%s/%s", buf, dir);
free(buf);
}
@ -155,7 +159,9 @@ SetDataDir(const char *dir)
{
new = strdup(dir);
if (!new)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
/*
@ -235,7 +241,7 @@ SetCharSet(void)
while (!feof(file) && buf[0])
{
next_token(file, buf, sizeof(buf));
elog(LOG, "SetCharSet: unknown tag %s in file %s",
elog(LOG, "unexpected token %s in file %s",
buf, filename);
}
}
@ -390,7 +396,7 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
else if (strcasecmp(buf, "RecodeTable") == 0)
key = KEY_TABLE;
else
elog(LOG, "GetCharSetByHost: unknown tag %s in file %s",
elog(LOG, "unknown tag %s in file %s",
buf, CHARSET_FILE);
switch (key)
@ -446,7 +452,7 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
while (!feof(file) && buf[0])
{
next_token(file, buf, sizeof(buf));
elog(LOG, "GetCharSetByHost: unknown tag %s in file %s",
elog(LOG, "unknown tag %s in file %s",
buf, CHARSET_FILE);
}
}
@ -544,7 +550,9 @@ InitializeSessionUserId(const char *username)
PointerGetDatum(username),
0, 0, 0);
if (!HeapTupleIsValid(userTup))
elog(FATAL, "user \"%s\" does not exist", username);
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("user \"%s\" does not exist", username)));
usesysid = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
@ -610,7 +618,9 @@ SetSessionAuthorization(AclId userid, bool is_superuser)
if (userid != AuthenticatedUserId &&
!AuthenticatedUserIsSuperuser)
elog(ERROR, "SET SESSION AUTHORIZATION: permission denied");
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied")));
SetSessionUserId(userid);
SetUserId(userid);
@ -634,7 +644,9 @@ GetUserNameFromId(AclId userid)
ObjectIdGetDatum(userid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "invalid user id %d", userid);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("invalid user id: %d", userid)));
result = pstrdup(NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename));
@ -716,7 +728,10 @@ CreateLockFile(const char *filename, bool amPostmaster,
* Couldn't create the pid file. Probably it already exists.
*/
if ((errno != EEXIST && errno != EACCES) || ntries > 100)
elog(FATAL, "Can't create lock file %s: %m", filename);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not create lock file \"%s\": %m",
filename)));
/*
* Read the file to get the old owner's PID. Note race condition
@ -727,10 +742,16 @@ CreateLockFile(const char *filename, bool amPostmaster,
{
if (errno == ENOENT)
continue; /* race condition; try again */
elog(FATAL, "Can't read lock file %s: %m", filename);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not open lock file \"%s\": %m",
filename)));
}
if ((len = read(fd, buffer, sizeof(buffer) - 1)) <= 0)
elog(FATAL, "Can't read lock file %s: %m", filename);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not read lock file \"%s\": %m",
filename)));
close(fd);
buffer[len] = '\0';
@ -740,7 +761,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
other_pid = (pid_t) (encoded_pid < 0 ? -encoded_pid : encoded_pid);
if (other_pid <= 0)
elog(FATAL, "Bogus data in lock file %s", filename);
elog(FATAL, "bogus data in lock file \"%s\"", filename);
/*
* Check to see if the other process still exists
@ -814,10 +835,13 @@ CreateLockFile(const char *filename, bool amPostmaster,
* against other would-be creators.
*/
if (unlink(filename) < 0)
elog(FATAL, "Can't remove old lock file %s: %m"
"\n\tThe file seems accidentally left, but I couldn't remove it."
"\n\tPlease remove the file by hand and try again.",
filename);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not remove old lock file \"%s\": %m",
filename),
errhint("The file seems accidentally left over, but "
"I couldn't remove it. Please remove the file "
"by hand and try again.")));
}
/*
@ -835,7 +859,9 @@ CreateLockFile(const char *filename, bool amPostmaster,
unlink(filename);
/* if write didn't set errno, assume problem is no disk space */
errno = save_errno ? save_errno : ENOSPC;
elog(FATAL, "Can't write lock file %s: %m", filename);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not write lock file \"%s\": %m", filename)));
}
close(fd);
@ -941,13 +967,19 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
fd = open(directoryLockFile, O_RDWR | PG_BINARY, 0);
if (fd < 0)
{
elog(LOG, "Failed to rewrite %s: %m", directoryLockFile);
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not rewrite \"%s\": %m",
directoryLockFile)));
return;
}
len = read(fd, buffer, sizeof(buffer) - 100);
if (len <= 0)
{
elog(LOG, "Failed to read %s: %m", directoryLockFile);
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not read \"%s\": %m",
directoryLockFile)));
close(fd);
return;
}
@ -960,7 +992,7 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
if (ptr == NULL ||
(ptr = strchr(ptr + 1, '\n')) == NULL)
{
elog(LOG, "Bogus data in %s", directoryLockFile);
elog(LOG, "bogus data in \"%s\"", directoryLockFile);
close(fd);
return;
}
@ -984,7 +1016,10 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
elog(LOG, "Failed to write %s: %m", directoryLockFile);
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not write \"%s\": %m",
directoryLockFile)));
close(fd);
return;
}
@ -1001,7 +1036,7 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
* Determine whether the PG_VERSION file in directory `path' indicates
* a data version compatible with the version of this program.
*
* If compatible, return. Otherwise, elog(FATAL).
* If compatible, return. Otherwise, ereport(FATAL).
*/
void
ValidatePgVersion(const char *path)
@ -1026,21 +1061,36 @@ ValidatePgVersion(const char *path)
if (!file)
{
if (errno == ENOENT)
elog(FATAL, "File %s is missing. This is not a valid data directory.", full_path);
ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is not a valid data directory",
path),
errdetail("File \"%s\" is missing.", full_path)));
else
elog(FATAL, "cannot open %s: %m", full_path);
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not open \"%s\": %m", full_path)));
}
ret = fscanf(file, "%ld.%ld", &file_major, &file_minor);
if (ret != 2)
elog(FATAL, "File %s does not contain valid data. You need to initdb.", full_path);
ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is not a valid data directory",
path),
errdetail("File \"%s\" does not contain valid data.",
full_path),
errhint("You may need to initdb.")));
FreeFile(file);
if (my_major != file_major || my_minor != file_minor)
elog(FATAL, "The data directory was initialized by PostgreSQL version %ld.%ld, "
"which is not compatible with this version %s.",
file_major, file_minor, version_string);
ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("database files are incompatible with server"),
errdetail("The data directory was initialized by PostgreSQL version %ld.%ld, "
"which is not compatible with this version %s.",
file_major, file_minor, version_string)));
}
/*-------------------------------------------------------------------------
@ -1077,7 +1127,10 @@ process_preload_libraries(char *preload_libraries_string)
/* syntax error in list */
pfree(rawstring);
freeList(elemlist);
elog(LOG, "invalid list syntax for preload_libraries configuration option");
ereport(LOG,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid list syntax for preload_libraries configuration option")));
return;
}
foreach(l, elemlist)
@ -1098,12 +1151,11 @@ process_preload_libraries(char *preload_libraries_string)
size_t funcname_len = strlen(tok) - filename_len - 1;
filename = (char *) palloc(filename_len + 1);
memset(filename, '\0', filename_len + 1);
snprintf(filename, filename_len + 1, "%s", tok);
memcpy(filename, tok, filename_len);
filename[filename_len] = '\0';
funcname = (char *) palloc(funcname_len + 1);
memset(funcname, '\0', funcname_len + 1);
snprintf(funcname, funcname_len + 1, "%s", sep + 1);
strcpy(funcname, sep + 1);
}
else
{
@ -1114,16 +1166,22 @@ process_preload_libraries(char *preload_libraries_string)
funcname = NULL;
}
initfunc = (func_ptr) load_external_function(filename, funcname, false, NULL);
initfunc = (func_ptr) load_external_function(filename, funcname,
false, NULL);
if (initfunc)
(*initfunc)();
elog(LOG, "preloaded library %s with initialization function %s", filename, funcname);
if (funcname)
ereport(LOG,
(errmsg("preloaded library \"%s\" with initialization function \"%s\"",
filename, funcname)));
else
ereport(LOG,
(errmsg("preloaded library \"%s\"",
filename)));
if (filename != NULL)
pfree(filename);
if (funcname != NULL)
pfree(filename);
if (funcname)
pfree(funcname);
}

View File

@ -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

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);

View File

@ -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);

View File

@ -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++)
{

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.138 2003/07/22 20:29:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.139 2003/07/25 20:17:56 tgl Exp $
*
*--------------------------------------------------------------------
*/
@ -52,7 +52,6 @@
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/elog.h"
#include "utils/pg_locale.h"
#include "pgstat.h"
@ -1580,7 +1579,9 @@ build_guc_variables(void)
guc_vars = (struct config_generic **)
malloc(num_vars * sizeof(struct config_generic *));
if (!guc_vars)
elog(PANIC, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
num_vars = 0;
@ -1688,10 +1689,6 @@ InitializeGUCOptions(void)
/*
* Load all variables with their compiled-in defaults, and initialize
* status fields as needed.
*
* Note: any errors here are reported with plain ol' printf, since we
* shouldn't assume that elog will work before we've initialized its
* config variables. An error here would be unexpected anyway...
*/
for (i = 0; i < num_guc_variables; i++)
{
@ -1711,8 +1708,8 @@ InitializeGUCOptions(void)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false))
fprintf(stderr, "Failed to initialize %s to %d\n",
conf->gen.name, (int) conf->reset_val);
elog(FATAL, "failed to initialize %s to %d",
conf->gen.name, (int) conf->reset_val);
*conf->variable = conf->reset_val;
conf->session_val = conf->reset_val;
break;
@ -1728,8 +1725,8 @@ InitializeGUCOptions(void)
strcmp(conf->gen.name, "log_min_duration_statement") == 0);
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false))
fprintf(stderr, "Failed to initialize %s to %d\n",
conf->gen.name, conf->reset_val);
elog(FATAL, "failed to initialize %s to %d",
conf->gen.name, conf->reset_val);
*conf->variable = conf->reset_val;
conf->session_val = conf->reset_val;
break;
@ -1743,8 +1740,8 @@ InitializeGUCOptions(void)
Assert(conf->gen.context != PGC_USERLIMIT);
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false))
fprintf(stderr, "Failed to initialize %s to %g\n",
conf->gen.name, conf->reset_val);
elog(FATAL, "failed to initialize %s to %g",
conf->gen.name, conf->reset_val);
*conf->variable = conf->reset_val;
conf->session_val = conf->reset_val;
break;
@ -1772,7 +1769,9 @@ InitializeGUCOptions(void)
str = strdup(conf->boot_val);
if (str == NULL)
elog(PANIC, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
conf->reset_val = str;
if (conf->assign_hook)
@ -1782,8 +1781,8 @@ InitializeGUCOptions(void)
newstr = (*conf->assign_hook) (str, true, false);
if (newstr == NULL)
{
fprintf(stderr, "Failed to initialize %s to '%s'\n",
conf->gen.name, str);
elog(FATAL, "failed to initialize %s to \"%s\"",
conf->gen.name, str);
}
else if (newstr != str)
{
@ -1874,7 +1873,7 @@ ResetAllOptions(void)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true))
elog(ERROR, "Failed to reset %s", conf->gen.name);
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val;
conf->gen.source = conf->gen.reset_source;
@ -1889,7 +1888,7 @@ ResetAllOptions(void)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true))
elog(ERROR, "Failed to reset %s", conf->gen.name);
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val;
conf->gen.source = conf->gen.reset_source;
@ -1904,7 +1903,7 @@ ResetAllOptions(void)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true))
elog(ERROR, "Failed to reset %s", conf->gen.name);
elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val;
conf->gen.source = conf->gen.reset_source;
@ -1933,7 +1932,7 @@ ResetAllOptions(void)
newstr = (*conf->assign_hook) (str, true, true);
if (newstr == NULL)
elog(ERROR, "Failed to reset %s", conf->gen.name);
elog(ERROR, "failed to reset %s", conf->gen.name);
else if (newstr != str)
{
/*
@ -1972,7 +1971,7 @@ AtEOXact_GUC(bool isCommit)
if (!guc_dirty)
return;
/* Prevent memory leak if elog during an assign_hook */
/* Prevent memory leak if ereport during an assign_hook */
if (guc_string_workspace)
{
free(guc_string_workspace);
@ -2007,7 +2006,8 @@ AtEOXact_GUC(bool isCommit)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val,
true, false))
elog(LOG, "Failed to commit %s", conf->gen.name);
elog(LOG, "failed to commit %s",
conf->gen.name);
*conf->variable = conf->session_val;
changed = true;
}
@ -2030,7 +2030,8 @@ AtEOXact_GUC(bool isCommit)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val,
true, false))
elog(LOG, "Failed to commit %s", conf->gen.name);
elog(LOG, "failed to commit %s",
conf->gen.name);
*conf->variable = conf->session_val;
changed = true;
}
@ -2053,7 +2054,8 @@ AtEOXact_GUC(bool isCommit)
if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val,
true, false))
elog(LOG, "Failed to commit %s", conf->gen.name);
elog(LOG, "failed to commit %s",
conf->gen.name);
*conf->variable = conf->session_val;
changed = true;
}
@ -2084,7 +2086,8 @@ AtEOXact_GUC(bool isCommit)
newstr = (*conf->assign_hook) (str, true, false);
if (newstr == NULL)
elog(LOG, "Failed to commit %s", conf->gen.name);
elog(LOG, "failed to commit %s",
conf->gen.name);
else if (newstr != str)
{
/*
@ -2287,10 +2290,10 @@ parse_real(const char *value, double *result)
* the checks to see if it would work.
*
* If there is an error (non-existing option, invalid value) then an
* elog(ERROR) is thrown *unless* this is called in a context where we
* don't want to elog (currently, startup or SIGHUP config file reread).
* In that case we write a suitable error message via elog(DEBUG) and
* return false. This is working around the deficiencies in the elog
* ereport(ERROR) is thrown *unless* this is called in a context where we
* don't want to ereport (currently, startup or SIGHUP config file reread).
* In that case we write a suitable error message via ereport(DEBUG) and
* return false. This is working around the deficiencies in the ereport
* mechanism, so don't blame me. In all other cases, the function
* returns true, including cases where the input is valid but we chose
* not to apply it because of context or source-priority considerations.
@ -2318,7 +2321,9 @@ set_config_option(const char *name, const char *value,
record = find_option(name);
if (record == NULL)
{
elog(elevel, "'%s' is not a valid option name", name);
ereport(elevel,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("\"%s\" is not a recognized option", name)));
return false;
}
@ -2335,8 +2340,10 @@ set_config_option(const char *name, const char *value,
return true;
if (context != PGC_INTERNAL)
{
elog(elevel, "'%s' cannot be changed",
name);
ereport(elevel,
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
errmsg("\"%s\" cannot be changed",
name)));
return false;
}
break;
@ -2345,15 +2352,20 @@ set_config_option(const char *name, const char *value,
return true;
if (context != PGC_POSTMASTER)
{
elog(elevel, "'%s' cannot be changed after server start",
name);
ereport(elevel,
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
errmsg("\"%s\" cannot be changed after server start",
name)));
return false;
}
break;
case PGC_SIGHUP:
if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
{
elog(elevel, "'%s' cannot be changed now", name);
ereport(elevel,
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
errmsg("\"%s\" cannot be changed now",
name)));
return false;
}
@ -2380,19 +2392,26 @@ set_config_option(const char *name, const char *value,
}
else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
{
elog(elevel, "'%s' cannot be set after connection start",
name);
ereport(elevel,
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
errmsg("\"%s\" cannot be set after connection start",
name)));
return false;
}
break;
case PGC_SUSET:
if (context == PGC_USERSET || context == PGC_BACKEND)
{
elog(elevel, "'%s': permission denied", name);
ereport(elevel,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"%s\": permission denied",
name)));
return false;
}
break;
case PGC_USERLIMIT: /* USERLIMIT permissions checked below */
case PGC_USERLIMIT:
/* USERLIMIT permissions checked below */
break;
case PGC_USERSET:
/* always okay */
break;
@ -2420,7 +2439,7 @@ set_config_option(const char *name, const char *value,
{
if (DoIt && !makeDefault)
{
elog(DEBUG3, "%s: setting ignored because previous source is higher priority",
elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
name);
return true;
}
@ -2441,8 +2460,10 @@ set_config_option(const char *name, const char *value,
{
if (!parse_bool(value, &newval))
{
elog(elevel, "option '%s' requires a boolean value",
name);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" requires a boolean value",
name)));
return false;
}
/* Limit non-super user changes */
@ -2451,9 +2472,11 @@ set_config_option(const char *name, const char *value,
newval < conf->session_val &&
!superuser())
{
elog(elevel, "'%s': permission denied\n"
"Only super-users can set this value to false.",
name);
ereport(elevel,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"%s\": permission denied",
name),
errhint("Must be superuser to change this value to false.")));
return false;
}
/* Allow admin to override non-super user setting */
@ -2473,8 +2496,10 @@ set_config_option(const char *name, const char *value,
if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, DoIt, interactive))
{
elog(elevel, "invalid value for option '%s': %d",
name, (int) newval);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for \"%s\": %d",
name, (int) newval)));
return false;
}
@ -2523,28 +2548,32 @@ set_config_option(const char *name, const char *value,
{
if (!parse_int(value, &newval))
{
elog(elevel, "option '%s' expects an integer value",
name);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" requires an integer value",
name)));
return false;
}
if (newval < conf->min || newval > conf->max)
{
elog(elevel, "option '%s' value %d is outside"
" of permissible range [%d .. %d]",
name, newval, conf->min, conf->max);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("%d is outside the valid range for \"%s\" (%d .. %d)",
newval, name, conf->min, conf->max)));
return false;
}
/* Limit non-super user changes */
if (record->context == PGC_USERLIMIT &&
source > PGC_S_USERSTART &&
conf->session_val != 0 &&
(newval > conf->session_val ||
newval == 0) &&
(newval > conf->session_val || newval == 0) &&
!superuser())
{
elog(elevel, "'%s': permission denied\n"
"Only super-users can increase this value "
"or set it to zero.", name);
ereport(elevel,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"%s\": permission denied",
name),
errhint("Must be superuser to increase this value or set it to zero.")));
return false;
}
/* Allow admin to override non-super user setting */
@ -2564,8 +2593,10 @@ set_config_option(const char *name, const char *value,
if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, DoIt, interactive))
{
elog(elevel, "invalid value for option '%s': %d",
name, newval);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for \"%s\": %d",
name, newval)));
return false;
}
@ -2614,15 +2645,18 @@ set_config_option(const char *name, const char *value,
{
if (!parse_real(value, &newval))
{
elog(elevel, "option '%s' expects a real number",
name);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" requires a numeric value",
name)));
return false;
}
if (newval < conf->min || newval > conf->max)
{
elog(elevel, "option '%s' value %g is outside"
" of permissible range [%g .. %g]",
name, newval, conf->min, conf->max);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("%g is outside the valid range for \"%s\" (%g .. %g)",
newval, name, conf->min, conf->max)));
return false;
}
/* Limit non-super user changes */
@ -2631,9 +2665,11 @@ set_config_option(const char *name, const char *value,
newval > conf->session_val &&
!superuser())
{
elog(elevel, "'%s': permission denied\n"
"Only super-users can increase this value.",
name);
ereport(elevel,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"%s\": permission denied",
name),
errhint("Must be superuser to increase this value.")));
return false;
}
/* Allow admin to override non-super user setting */
@ -2653,8 +2689,10 @@ set_config_option(const char *name, const char *value,
if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, DoIt, interactive))
{
elog(elevel, "invalid value for option '%s': %g",
name, newval);
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for \"%s\": %g",
name, newval)));
return false;
}
@ -2704,7 +2742,9 @@ set_config_option(const char *name, const char *value,
newval = strdup(value);
if (newval == NULL)
{
elog(elevel, "out of memory");
ereport(elevel,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return false;
}
@ -2720,9 +2760,11 @@ set_config_option(const char *name, const char *value,
new_int_value > old_int_value &&
!superuser())
{
elog(elevel, "'%s': permission denied\n"
"Only super-users can increase this value.",
name);
ereport(elevel,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("\"%s\": permission denied",
name),
errhint("Must be superuser to increase this value.")));
return false;
}
/* Allow admin to override non-super user setting */
@ -2744,7 +2786,9 @@ set_config_option(const char *name, const char *value,
newval = strdup(conf->reset_val);
if (newval == NULL)
{
elog(elevel, "out of memory");
ereport(elevel,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return false;
}
source = conf->gen.reset_source;
@ -2757,7 +2801,7 @@ set_config_option(const char *name, const char *value,
/*
* Remember string in workspace, so that we can free it
* and avoid a permanent memory leak if hook elogs.
* and avoid a permanent memory leak if hook ereports.
*/
if (guc_string_workspace)
free(guc_string_workspace);
@ -2773,8 +2817,10 @@ set_config_option(const char *name, const char *value,
if (hookresult == NULL)
{
free(newval);
elog(elevel, "invalid value for option '%s': '%s'",
name, value ? value : "");
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid value for \"%s\": \"%s\"",
name, value ? value : "")));
return false;
}
else if (hookresult != newval)
@ -2864,7 +2910,7 @@ SetConfigOption(const char *name, const char *value,
/*
* Fetch the current value of the option `name'. If the option doesn't exist,
* throw an elog and don't return.
* throw an ereport and don't return.
*
* The string is *not* allocated for modification and is really only
* valid until the next call to configuration related functions.
@ -2877,7 +2923,9 @@ GetConfigOption(const char *name)
record = find_option(name);
if (record == NULL)
elog(ERROR, "Option '%s' is not recognized", name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("\"%s\" is not a recognized option", name)));
switch (record->vartype)
{
@ -2911,7 +2959,9 @@ GetConfigOptionResetString(const char *name)
record = find_option(name);
if (record == NULL)
elog(ERROR, "Option '%s' is not recognized", name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("\"%s\" is not a recognized option", name)));
switch (record->vartype)
{
@ -2965,14 +3015,18 @@ flatten_set_variable_args(const char *name, List *args)
/* Else get flags for the variable */
record = find_option(name);
if (record == NULL)
elog(ERROR, "'%s' is not a valid option name", name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("\"%s\" is not a recognized option", name)));
flags = record->flags;
/* Complain if list input and non-list variable */
if ((flags & GUC_LIST_INPUT) == 0 &&
lnext(args) != NIL)
elog(ERROR, "SET %s takes only one argument", name);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("SET %s takes only one argument", name)));
initStringInfo(&buf);
@ -2985,7 +3039,7 @@ flatten_set_variable_args(const char *name, List *args)
appendStringInfo(&buf, ", ");
if (!IsA(arg, A_Const))
elog(ERROR, "flatten_set_variable_args: unexpected input");
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
switch (nodeTag(&arg->val))
{
@ -3034,7 +3088,8 @@ flatten_set_variable_args(const char *name, List *args)
}
break;
default:
elog(ERROR, "flatten_set_variable_args: unexpected input");
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(&arg->val));
break;
}
}
@ -3073,7 +3128,9 @@ set_config_by_name(PG_FUNCTION_ARGS)
text *result_text;
if (PG_ARGISNULL(0))
elog(ERROR, "SET variable name is required");
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("SET variable name is required")));
/* Get the GUC variable name */
name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
@ -3252,7 +3309,9 @@ GetConfigOptionByName(const char *name, const char **varname)
record = find_option(name);
if (record == NULL)
elog(ERROR, "Option '%s' is not recognized", name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("\"%s\" is not a recognized option", name)));
if (varname)
*varname = record->name;
@ -3538,7 +3597,9 @@ write_nondefault_variables(GucContext context)
filename = malloc(strlen(DataDir) + strlen(CONFIG_EXEC_PARAMS) + 2);
if (new_filename == NULL || filename == NULL)
{
elog(elevel, "out of memory");
ereport(elevel,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return;
}
sprintf(new_filename, "%s/" CONFIG_EXEC_PARAMS ".new", DataDir);
@ -3549,8 +3610,10 @@ write_nondefault_variables(GucContext context)
{
free(new_filename);
free(filename);
elog(elevel, "could not write exec config params file `"
CONFIG_EXEC_PARAMS "': %s", strerror(errno));
ereport(elevel,
(errcode_for_file_access(),
errmsg("could not write exec config params file \""
CONFIG_EXEC_PARAMS "\": %m")));
return;
}
@ -3613,7 +3676,6 @@ write_nondefault_variables(GucContext context)
rename(new_filename, filename);
free(new_filename);
free(filename);
return;
}
@ -3637,7 +3699,7 @@ read_string_with_null(FILE *fp)
if (i == 0)
return NULL;
else
elog(FATAL, "Invalid format of exec config params file");
elog(FATAL, "invalid format of exec config params file");
}
if (i == 0)
str = malloc(maxlen);
@ -3671,7 +3733,9 @@ read_nondefault_variables(void)
filename = malloc(strlen(DataDir) + strlen(CONFIG_EXEC_PARAMS) + 2);
if (filename == NULL)
{
elog(ERROR, "out of memory");
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return;
}
sprintf(filename, "%s/" CONFIG_EXEC_PARAMS, DataDir);
@ -3682,20 +3746,22 @@ read_nondefault_variables(void)
free(filename);
/* File not found is fine */
if (errno != ENOENT)
elog(FATAL, "could not read exec config params file `"
CONFIG_EXEC_PARAMS "': %s", strerror(errno));
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not read exec config params file \""
CONFIG_EXEC_PARAMS "\": %m")));
return;
}
while (1)
for (;;)
{
if ((varname = read_string_with_null(fp)) == NULL)
break;
if ((varvalue = read_string_with_null(fp)) == NULL)
elog(FATAL, "Invalid format of exec config params file");
elog(FATAL, "invalid format of exec config params file");
if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
elog(FATAL, "Invalid format of exec config params file");
elog(FATAL, "invalid format of exec config params file");
(void) set_config_option(varname, varvalue, PGC_POSTMASTER,
varsource, false, true);
@ -3733,20 +3799,26 @@ ParseLongOption(const char *string, char **name, char **value)
{
*name = malloc(equal_pos + 1);
if (!*name)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
strncpy(*name, string, equal_pos);
(*name)[equal_pos] = '\0';
*value = strdup(&string[equal_pos + 1]);
if (!*value)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
else
{
/* no equal sign in string */
*name = strdup(string);
if (!*name)
elog(FATAL, "out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
*value = NULL;
}
@ -3794,7 +3866,9 @@ ProcessGUCArray(ArrayType *array, GucSource source)
ParseLongOption(s, &name, &value);
if (!value)
{
elog(WARNING, "cannot parse setting \"%s\"", name);
ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot parse setting for \"%s\"", name)));
free(name);
continue;
}
@ -4139,7 +4213,9 @@ assign_phony_autocommit(bool newval, bool doit, bool interactive)
if (!newval)
{
if (doit && interactive)
elog(ERROR, "SET AUTOCOMMIT TO OFF is no longer supported");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
return false;
}
return true;

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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

View File

@ -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);
}

View File

@ -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) +

View File

@ -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;
}

View File

@ -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));

View File

@ -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')

View File

@ -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