<!--
-$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">
#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"
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*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;
}
}
cur_skey[0].sk_argument));
break;
default:
- elog(FATAL, "CCComputeHashValue: %d nkeys", nkeys);
+ elog(FATAL, "wrong number of hash keys: %d", nkeys);
break;
}
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;
}
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,
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,
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;
}
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);
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;
}
* 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 $
*
*-------------------------------------------------------------------------
*/
}
else
{
- elog(FATAL, "ExecuteInvalidationMessage: bogus message id %d",
- msg->id);
+ elog(FATAL, "unrecognized SI message id: %d", msg->id);
}
}
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;
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;
* 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.
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);
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;
/* 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);
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);
}
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);
}
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);
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);
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);
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);
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);
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;
}
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);
/*
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')
{
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;
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;
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;
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;
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 */
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 */
Anum_pg_statistic_stanumbers1 + i,
&isnull);
if (isnull)
- elog(ERROR, "get_attstatsslot: stanumbers is null");
+ elog(ERROR, "stanumbers is null");
statarray = DatumGetArrayTypeP(val);
/*
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;
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;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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, \
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))) \
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; \
} \
(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); \
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)
break;
default:
- elog(ERROR, "ScanPgRelation: bad buildinfo");
+ elog(ERROR, "unrecognized buildinfo type: %d",
+ buildinfo.infotype);
return NULL; /* keep compiler quiet */
}
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] =
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);
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);
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;
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],
(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)
{
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;
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] =
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);
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);
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);
/*
* 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
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);
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);
/*
{
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
}
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));
}
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,
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,
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));
}
* 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;
}
/* 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 */
/* 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 */
*/
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
*
*
* 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
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;
{
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);
}
* 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,
{
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);
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
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
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
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;
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 */
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;
}
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);
* 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);
}
/* 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:
/* 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;
}
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;
/*
* 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;
}
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);
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
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 *);
/* 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;
}
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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)
{
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 */
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
}
* 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 */
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*/
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;
}
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);
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
}
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;
}
*/
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;
{
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;
}
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;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
{
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;
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);
}
{
new = strdup(dir);
if (!new)
- elog(FATAL, "out of memory");
+ ereport(FATAL,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
/*
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);
}
}
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)
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);
}
}
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;
if (userid != AuthenticatedUserId &&
!AuthenticatedUserIsSuperuser)
- elog(ERROR, "SET SESSION AUTHORIZATION: permission denied");
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("permission denied")));
SetSessionUserId(userid);
SetUserId(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));
* 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
{
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';
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
* 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.")));
}
/*
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);
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;
}
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;
}
/* 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;
}
* 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)
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)));
}
/*-------------------------------------------------------------------------
/* 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)
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
{
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 (filename != NULL)
- pfree(filename);
+ if (funcname)
+ ereport(LOG,
+ (errmsg("preloaded library \"%s\" with initialization function \"%s\"",
+ filename, funcname)));
+ else
+ ereport(LOG,
+ (errmsg("preloaded library \"%s\"",
+ filename)));
- if (funcname != NULL)
+ pfree(filename);
+ if (funcname)
pfree(funcname);
}
*
*
* 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 $
*
*
*-------------------------------------------------------------------------
*/
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)));
}
/*
*/
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
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);
}
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.
{
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
{
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
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
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)
{
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)
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
* 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"
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);
* (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"
* 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())));
}
}
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;
}
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;
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
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
*
* 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 $
*/
%{
#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) */
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);
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;
}
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;
}
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++)
{
* 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 $
*
*--------------------------------------------------------------------
*/
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
-#include "utils/elog.h"
#include "utils/pg_locale.h"
#include "pgstat.h"
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;
/*
* 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++)
{
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;
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;
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;
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)
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)
{
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;
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;
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;
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)
{
/*
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);
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;
}
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;
}
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;
}
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)
{
/*
* 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.
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;
}
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;
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;
}
}
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;
{
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;
}
{
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 */
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 */
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;
}
{
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 */
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;
}
{
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 */
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 */
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;
}
newval = strdup(value);
if (newval == NULL)
{
- elog(elevel, "out of memory");
+ ereport(elevel,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
return false;
}
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 */
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;
/*
* 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);
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)
/*
* 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.
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)
{
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)
{
/* 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);
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))
{
}
break;
default:
- elog(ERROR, "flatten_set_variable_args: unexpected input");
+ elog(ERROR, "unrecognized node type: %d",
+ (int) nodeTag(&arg->val));
break;
}
}
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)));
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;
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);
{
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;
}
rename(new_filename, filename);
free(new_filename);
free(filename);
- return;
}
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);
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);
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);
{
*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;
}
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;
}
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;
* 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
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;
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;
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;
/* 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
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));
/* 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
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));
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;
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);
}
* 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);
/*
* 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;
}
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);
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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).
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);
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);
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);
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,
* 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 $
*
*-------------------------------------------------------------------------
*/
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; \
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;
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);
}
/* 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
* 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.
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* "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
{
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)));
}
/*
/*
* 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,
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++;
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)
{
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);
}
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);
}
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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:
dumptuples(state, false);
break;
default:
- elog(ERROR, "tuplesort_puttuple: invalid state");
+ elog(ERROR, "invalid tuplesort state");
break;
}
}
state->markpos_eof = false;
break;
default:
- elog(ERROR, "tuplesort_performsort: invalid state");
+ elog(ERROR, "invalid tuplesort state");
break;
}
}
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;
}
}
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;
return NULL;
default:
- elog(ERROR, "tuplesort_gettuple: invalid state");
+ elog(ERROR, "invalid tuplesort state");
return NULL; /* keep compiler quiet */
}
}
state->markpos_eof = false;
break;
default:
- elog(ERROR, "tuplesort_rescan: invalid state");
+ elog(ERROR, "invalid tuplesort state");
break;
}
}
state->markpos_eof = state->eof_reached;
break;
default:
- elog(ERROR, "tuplesort_markpos: invalid state");
+ elog(ERROR, "invalid tuplesort state");
break;
}
}
state->eof_reached = state->markpos_eof;
break;
default:
- elog(ERROR, "tuplesort_restorepos: invalid state");
+ elog(ERROR, "invalid tuplesort state");
break;
}
}
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;
}
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;
/* 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;
}
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 */
}
}
/* 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;
}
* 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;
}
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;
}
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) +
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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:
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;
}
}
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 */
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);
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 */
}
}
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;
}
}
&state->markpos_offset);
break;
default:
- elog(ERROR, "tuplestore_markpos: invalid state");
+ elog(ERROR, "invalid tuplestore state");
break;
}
}
elog(ERROR, "tuplestore_restorepos failed");
break;
default:
- elog(ERROR, "tuplestore_restorepos: invalid state");
+ elog(ERROR, "invalid tuplestore state");
break;
}
}
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;
}
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);
/* 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;
}
* 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 $
*
*-------------------------------------------------------------------------
*/
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));
* 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 $
*
*-------------------------------------------------------------------------
*/
#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')
#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')
-- 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
-- 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