Error message editing in backend/access.

This commit is contained in:
Tom Lane 2003-07-21 20:29:40 +00:00
parent c6106d91e2
commit ec7aa4b515
33 changed files with 702 additions and 533 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.83 2002/09/27 15:04:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.84 2003/07/21 20:29:37 tgl Exp $
*
* NOTES
* The old interface functions have been converted to macros
@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
case MinCommandIdAttributeNumber:
case MaxTransactionIdAttributeNumber:
case MaxCommandIdAttributeNumber:
/* these are never null */
break;
case 0:
elog(ERROR, "heap_attisnull: zero attnum disallowed");
default:
elog(ERROR, "heap_attisnull: undefined negative attnum");
elog(ERROR, "invalid attnum: %d", attnum);
}
return 0;
@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
result = ObjectIdGetDatum(tup->t_tableOid);
break;
default:
elog(ERROR, "heap_getsysattr: invalid attnum %d", attnum);
elog(ERROR, "invalid attnum: %d", attnum);
result = 0; /* keep compiler quiet */
break;
}
@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
int numberOfAttributes = tupleDescriptor->natts;
if (numberOfAttributes > MaxTupleAttributeNumber)
elog(ERROR, "heap_formtuple: numberOfAttributes %d exceeds limit %d",
numberOfAttributes, MaxTupleAttributeNumber);
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("number of attributes %d exceeds limit, %d",
numberOfAttributes, MaxTupleAttributeNumber)));
for (i = 0; i < numberOfAttributes; i++)
{
@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
* allocate and fill *value and *nulls arrays from either the tuple or
* the repl information, as appropriate.
*/
value = (Datum *) palloc(numberOfAttributes * sizeof *value);
nulls = (char *) palloc(numberOfAttributes * sizeof *nulls);
value = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
nulls = (char *) palloc(numberOfAttributes * sizeof(char));
for (attoff = 0;
attoff < numberOfAttributes;
attoff += 1)
for (attoff = 0; attoff < numberOfAttributes; attoff++)
{
if (repl[attoff] == ' ')
{
value[attoff] = heap_getattr(tuple,
@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
nulls[attoff] = (isNull) ? 'n' : ' ';
}
else if (repl[attoff] != 'r')
elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]);
else
{ /* == 'r' */
else if (repl[attoff] == 'r')
{
value[attoff] = replValue[attoff];
nulls[attoff] = replNull[attoff];
}
else
elog(ERROR, "unrecognized replace flag: %d", (int) repl[attoff]);
}
/*
@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
value,
nulls);
pfree(value);
pfree(nulls);
/*
* copy the identification info of the old tuple: t_ctid, t_self, and
* OID (if any)

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.64 2003/02/23 06:17:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.65 2003/07/21 20:29:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -52,8 +52,10 @@ index_formtuple(TupleDesc tupleDescriptor,
#endif
if (numberOfAttributes > INDEX_MAX_KEYS)
elog(ERROR, "index_formtuple: numberOfAttributes %d > %d",
numberOfAttributes, INDEX_MAX_KEYS);
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("number of index attributes %d exceeds limit, %d",
numberOfAttributes, INDEX_MAX_KEYS)));
#ifdef TOAST_INDEX_HACK
for (i = 0; i < numberOfAttributes; i++)
@ -158,8 +160,11 @@ index_formtuple(TupleDesc tupleDescriptor,
* it in t_info.
*/
if ((size & INDEX_SIZE_MASK) != size)
elog(ERROR, "index_formtuple: data takes %lu bytes, max is %d",
(unsigned long) size, INDEX_SIZE_MASK);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("index tuple requires %lu bytes, maximum size is %lu",
(unsigned long) size,
(unsigned long) INDEX_SIZE_MASK)));
infomask |= size;

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.74 2003/05/26 17:51:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.75 2003/07/21 20:29:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -273,7 +273,9 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
fmgr_info(thisState->typsend, &thisState->finfo);
}
else
elog(ERROR, "Unsupported format code %d", format);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unsupported format code: %d", format)));
}
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.95 2003/06/15 17:59:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.96 2003/07/21 20:29:38 tgl Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@ -417,7 +417,7 @@ TupleDescInitEntry(TupleDesc desc,
ObjectIdGetDatum(oidtypeid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Unable to look up type id %u", oidtypeid);
elog(ERROR, "cache lookup failed for type %u", oidtypeid);
/*
* type info exists so we initialize our attribute information from
@ -643,7 +643,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
int natts;
if (!OidIsValid(relid))
elog(ERROR, "Invalid typrelid for complex type %u", typeoid);
elog(ERROR, "invalid typrelid for complex type %u", typeoid);
rel = relation_open(relid, AccessShareLock);
tupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
@ -657,7 +657,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* does the list length match the number of attributes? */
if (length(colaliases) != natts)
elog(ERROR, "TypeGetTupleDesc: number of aliases does not match number of attributes");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("number of aliases does not match number of attributes")));
/* OK, use the aliases instead */
for (varattno = 0; varattno < natts; varattno++)
@ -676,11 +678,15 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* the alias list is required for base types */
if (colaliases == NIL)
elog(ERROR, "TypeGetTupleDesc: no column alias was provided");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("no column alias was provided")));
/* the alias list length must be 1 */
if (length(colaliases) != 1)
elog(ERROR, "TypeGetTupleDesc: number of aliases does not match number of attributes");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("number of aliases does not match number of attributes")));
/* OK, get the column alias */
attname = strVal(lfirst(colaliases));
@ -695,7 +701,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
false);
}
else if (functyptype == 'p' && typeoid == RECORDOID)
elog(ERROR, "Unable to determine tuple description for function returning \"record\"");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unable to determine tuple description for function returning record")));
else
{
/* crummy error message, but parser should have caught this */

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.103 2003/05/27 17:49:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.104 2003/07/21 20:29:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -168,7 +168,7 @@ gistbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
*/
if (RelationGetNumberOfBlocks(index) != 0)
elog(ERROR, "%s already contains data",
elog(ERROR, "index \"%s\" already contains data",
RelationGetRelationName(index));
/* initialize the root page */
@ -396,7 +396,7 @@ gistPageAddItem(GISTSTATE *giststate,
retval = PageAddItem(page, (Item) *newtup, IndexTupleSize(*newtup),
offsetNumber, flags);
if (retval == InvalidOffsetNumber)
elog(ERROR, "gist: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
/* be tidy */
if (DatumGetPointer(tmpcentry.key) != NULL &&
@ -603,7 +603,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
l = PageAddItem(page, (Item) itup[i], IndexTupleSize(itup[i]),
off, LP_USED);
if (l == InvalidOffsetNumber)
elog(ERROR, "gist: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
#endif
}
@ -1663,7 +1663,7 @@ initGISTstate(GISTSTATE *giststate, Relation index)
int i;
if (index->rd_att->natts > INDEX_MAX_KEYS)
elog(ERROR, "initGISTstate: numberOfAttributes %d > %d",
elog(ERROR, "numberOfAttributes %d > %d",
index->rd_att->natts, INDEX_MAX_KEYS);
giststate->tupdesc = index->rd_att;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.63 2003/03/23 23:01:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.64 2003/07/21 20:29:38 tgl Exp $
*
* NOTES
* This file contains only the public interface routines.
@ -69,7 +69,7 @@ hashbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
*/
if (RelationGetNumberOfBlocks(index) != 0)
elog(ERROR, "%s already contains data",
elog(ERROR, "index \"%s\" already contains data",
RelationGetRelationName(index));
/* initialize the hash index metadata page */

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.25 2002/06/20 20:29:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.26 2003/07/21 20:29:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -48,7 +48,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
/* we need a scan key to do our search, so build one */
itup = &(hitem->hash_itup);
if ((natts = rel->rd_rel->relnatts) != 1)
elog(ERROR, "Hash indices valid for only one index key.");
elog(ERROR, "Hash indexes support only one index key");
itup_scankey = _hash_mkscankey(rel, itup);
/*
@ -228,7 +228,7 @@ _hash_pgaddtup(Relation rel,
itup_off = OffsetNumberNext(PageGetMaxOffsetNumber(page));
if (PageAddItem(page, (Item) hitem, itemsize, itup_off, LP_USED)
== InvalidOffsetNumber)
elog(ERROR, "_hash_pgaddtup: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(rel));
/* write the buffer, but hold our lock */

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.34 2003/03/10 22:28:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.35 2003/07/21 20:29:38 tgl Exp $
*
* NOTES
* Overflow pages look like ordinary relation pages.
@ -58,7 +58,7 @@ _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf)
/* allocate an empty overflow page */
oaddr = _hash_getovfladdr(rel, metabufp);
if (oaddr == InvalidOvflAddress)
elog(ERROR, "_hash_addovflpage: problem with _hash_getovfladdr.");
elog(ERROR, "_hash_getovfladdr failed");
ovflblkno = OADDR_TO_BLKNO(OADDR_OF(SPLITNUM(oaddr), OPAGENUM(oaddr)));
Assert(BlockNumberIsValid(ovflblkno));
ovflbuf = _hash_getbuf(rel, ovflblkno, HASH_WRITE);
@ -158,12 +158,13 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
offset = metap->hashm_spares[splitnum] -
(splitnum ? metap->hashm_spares[splitnum - 1] : 0);
#define OVMSG "HASH: Out of overflow pages. Out of luck.\n"
if (offset > SPLITMASK)
{
if (++splitnum >= NCACHED)
elog(ERROR, OVMSG);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of overflow pages in hash index \"%s\"",
RelationGetRelationName(rel))));
metap->hashm_ovflpoint = splitnum;
metap->hashm_spares[splitnum] = metap->hashm_spares[splitnum - 1];
metap->hashm_spares[splitnum - 1]--;
@ -179,7 +180,10 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
free_page++;
if (free_page >= NCACHED)
elog(ERROR, OVMSG);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of overflow pages in hash index \"%s\"",
RelationGetRelationName(rel))));
/*
* This is tricky. The 1 indicates that you want the new page
@ -193,13 +197,16 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
*/
if (_hash_initbitmap(rel, metap, OADDR_OF(splitnum, offset),
1, free_page))
elog(ERROR, "overflow_page: problem with _hash_initbitmap.");
elog(ERROR, "_hash_initbitmap failed");
metap->hashm_spares[splitnum]++;
offset++;
if (offset > SPLITMASK)
{
if (++splitnum >= NCACHED)
elog(ERROR, OVMSG);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of overflow pages in hash index \"%s\"",
RelationGetRelationName(rel))));
metap->hashm_ovflpoint = splitnum;
metap->hashm_spares[splitnum] = metap->hashm_spares[splitnum - 1];
metap->hashm_spares[splitnum - 1]--;
@ -242,7 +249,10 @@ found:
;
offset = (i ? bit - metap->hashm_spares[i - 1] : bit);
if (offset >= SPLITMASK)
elog(ERROR, OVMSG);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of overflow pages in hash index \"%s\"",
RelationGetRelationName(rel))));
/* initialize this page */
oaddr = OADDR_OF(i, offset);
@ -479,8 +489,6 @@ _hash_squeezebucket(Relation rel,
HashItem hitem;
Size itemsz;
/* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */
/*
* start squeezing into the base bucket page.
*/
@ -565,7 +573,7 @@ _hash_squeezebucket(Relation rel,
woffnum = OffsetNumberNext(PageGetMaxOffsetNumber(wpage));
if (PageAddItem(wpage, (Item) hitem, itemsz, woffnum, LP_USED)
== InvalidOffsetNumber)
elog(ERROR, "_hash_squeezebucket: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(rel));
/*

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.36 2002/06/20 20:29:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.37 2003/07/21 20:29:38 tgl Exp $
*
* NOTES
* Postgres hash pages look like ordinary relation pages. The opaque
@ -90,7 +90,7 @@ _hash_metapinit(Relation rel)
LockRelation(rel, AccessExclusiveLock);
if (RelationGetNumberOfBlocks(rel) != 0)
elog(ERROR, "Cannot initialize non-empty hash table %s",
elog(ERROR, "cannot initialize non-empty hash index \"%s\"",
RelationGetRelationName(rel));
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE);
@ -148,7 +148,7 @@ _hash_metapinit(Relation rel)
* created the first two buckets above.
*/
if (_hash_initbitmap(rel, metap, OADDR_OF(lg2nelem, 1), lg2nelem + 1, 0))
elog(ERROR, "Problem with _hash_initbitmap.");
elog(ERROR, "_hash_initbitmap failed");
/* all done */
_hash_wrtnorelbuf(metabuf);
@ -193,7 +193,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
Buffer buf;
if (blkno == P_NEW)
elog(ERROR, "_hash_getbuf: internal error: hash AM does not use P_NEW");
elog(ERROR, "hash AM does not use P_NEW");
switch (access)
{
case HASH_WRITE:
@ -201,8 +201,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
_hash_setpagelock(rel, blkno, access);
break;
default:
elog(ERROR, "_hash_getbuf: invalid access (%d) on new blk: %s",
access, RelationGetRelationName(rel));
elog(ERROR, "unrecognized hash access code: %d", access);
break;
}
buf = ReadBuffer(rel, blkno);
@ -228,8 +227,8 @@ _hash_relbuf(Relation rel, Buffer buf, int access)
_hash_unsetpagelock(rel, blkno, access);
break;
default:
elog(ERROR, "_hash_relbuf: invalid access (%d) on blk %x: %s",
access, blkno, RelationGetRelationName(rel));
elog(ERROR, "unrecognized hash access code: %d", access);
break;
}
ReleaseBuffer(buf);
@ -287,8 +286,7 @@ _hash_chgbufaccess(Relation rel,
_hash_relbuf(rel, *bufp, from_access);
break;
default:
elog(ERROR, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s",
from_access, blkno, RelationGetRelationName(rel));
elog(ERROR, "unrecognized hash access code: %d", from_access);
break;
}
*bufp = _hash_getbuf(rel, blkno, to_access);
@ -322,8 +320,7 @@ _hash_setpagelock(Relation rel,
LockPage(rel, blkno, ShareLock);
break;
default:
elog(ERROR, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
access, blkno, RelationGetRelationName(rel));
elog(ERROR, "unrecognized hash access code: %d", access);
break;
}
}
@ -346,8 +343,7 @@ _hash_unsetpagelock(Relation rel,
UnlockPage(rel, blkno, ShareLock);
break;
default:
elog(ERROR, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",
access, blkno, RelationGetRelationName(rel));
elog(ERROR, "unrecognized hash access code: %d", access);
break;
}
}
@ -409,8 +405,6 @@ _hash_expandtable(Relation rel, Buffer metabuf)
Bucket new_bucket;
uint32 spare_ndx;
/* elog(DEBUG, "_hash_expandtable: expanding..."); */
metap = (HashMetaPage) BufferGetPage(metabuf);
_hash_checkpage((Page) metap, LH_META_PAGE);
@ -483,9 +477,6 @@ _hash_splitpage(Relation rel,
Page npage;
TupleDesc itupdesc;
/* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d",
obucket, obucket, nbucket);
*/
metap = (HashMetaPage) BufferGetPage(metabuf);
_hash_checkpage((Page) metap, LH_META_PAGE);
@ -534,7 +525,7 @@ _hash_splitpage(Relation rel,
opage = BufferGetPage(obuf);
_hash_checkpage(opage, LH_OVERFLOW_PAGE);
if (PageIsEmpty(opage))
elog(ERROR, "_hash_splitpage: empty overflow page %d", oblkno);
elog(ERROR, "empty hash overflow page %u", oblkno);
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
}
@ -569,13 +560,9 @@ _hash_splitpage(Relation rel,
opage = BufferGetPage(obuf);
_hash_checkpage(opage, LH_OVERFLOW_PAGE);
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
/* we're guaranteed that an ovfl page has at least 1 tuple */
if (PageIsEmpty(opage))
{
elog(ERROR, "_hash_splitpage: empty ovfl page %d!",
oblkno);
}
elog(ERROR, "empty hash overflow page %u", oblkno);
ooffnum = FirstOffsetNumber;
omaxoffnum = PageGetMaxOffsetNumber(opage);
}
@ -626,7 +613,7 @@ _hash_splitpage(Relation rel,
noffnum = OffsetNumberNext(PageGetMaxOffsetNumber(npage));
if (PageAddItem(npage, (Item) hitem, itemsz, noffnum, LP_USED)
== InvalidOffsetNumber)
elog(ERROR, "_hash_splitpage: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(rel));
_hash_wrtnorelbuf(nbuf);
@ -670,10 +657,7 @@ _hash_splitpage(Relation rel,
oblkno = BufferGetBlockNumber(obuf);
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
if (PageIsEmpty(opage))
{
elog(ERROR, "_hash_splitpage: empty overflow page %d",
oblkno);
}
elog(ERROR, "empty hash overflow page %u", oblkno);
ooffnum = FirstOffsetNumber;
omaxoffnum = PageGetMaxOffsetNumber(opage);
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.31 2002/07/02 06:18:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.32 2003/07/21 20:29:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -78,7 +78,9 @@ _hash_formitem(IndexTuple itup)
/* disallow nulls in hash keys */
if (IndexTupleHasNulls(itup))
elog(ERROR, "hash indices cannot include null keys");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("hash indexes cannot include null keys")));
/* make a copy of the index tuple with room for the sequence number */
tuplen = IndexTupleSize(itup);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.151 2003/02/23 20:32:11 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.152 2003/07/21 20:29:38 tgl Exp $
*
*
* INTERFACE ROUTINES
@ -134,19 +134,16 @@ heapgettup(Relation relation,
*/
#ifdef HEAPDEBUGALL
if (ItemPointerIsValid(tid))
{
elog(LOG, "heapgettup(%s, tid=0x%x[%d,%d], dir=%d, ...)",
elog(DEBUG2, "heapgettup(%s, tid=0x%x[%d,%d], dir=%d, ...)",
RelationGetRelationName(relation), tid, tid->ip_blkid,
tid->ip_posid, dir);
}
else
{
elog(LOG, "heapgettup(%s, tid=0x%x, dir=%d, ...)",
elog(DEBUG2, "heapgettup(%s, tid=0x%x, dir=%d, ...)",
RelationGetRelationName(relation), tid, dir);
}
elog(LOG, "heapgettup(..., b=0x%x, nkeys=%d, key=0x%x", buffer, nkeys, key);
elog(LOG, "heapgettup: relation(%c)=`%s', %p",
elog(DEBUG2, "heapgettup(..., b=0x%x, nkeys=%d, key=0x%x", buffer, nkeys, key);
elog(DEBUG2, "heapgettup: relation(%c)=`%s', %p",
relation->rd_rel->relkind, RelationGetRelationName(relation),
snapshot);
#endif /* !defined(HEAPLOGALL) */
@ -194,7 +191,7 @@ heapgettup(Relation relation,
relation,
ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(*buffer))
elog(ERROR, "heapgettup: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -229,7 +226,7 @@ heapgettup(Relation relation,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "heapgettup: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -269,7 +266,7 @@ heapgettup(Relation relation,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "heapgettup: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -363,7 +360,7 @@ heapgettup(Relation relation,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "heapgettup: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
dp = (Page) BufferGetPage(*buffer);
@ -459,7 +456,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
r = RelationIdGetRelation(relationId);
if (!RelationIsValid(r))
elog(ERROR, "Relation %u does not exist", relationId);
elog(ERROR, "could not open relation with OID %u", relationId);
if (lockmode != NoLock)
LockRelation(r, lockmode);
@ -532,7 +529,7 @@ relation_openr(const char *sysRelationName, LOCKMODE lockmode)
r = RelationSysNameGetRelation(sysRelationName);
if (!RelationIsValid(r))
elog(ERROR, "Relation \"%s\" does not exist", sysRelationName);
elog(ERROR, "could not open relation \"%s\"", sysRelationName);
if (lockmode != NoLock)
LockRelation(r, lockmode);
@ -578,14 +575,20 @@ heap_open(Oid relationId, LOCKMODE lockmode)
r = relation_open(relationId, lockmode);
if (r->rd_rel->relkind == RELKIND_INDEX)
elog(ERROR, "%s is an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an index relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_SPECIAL)
elog(ERROR, "%s is a special relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a special relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
elog(ERROR, "%s is a composite type",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a composite type",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -607,14 +610,20 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
r = relation_openrv(relation, lockmode);
if (r->rd_rel->relkind == RELKIND_INDEX)
elog(ERROR, "%s is an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an index relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_SPECIAL)
elog(ERROR, "%s is a special relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a special relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
elog(ERROR, "%s is a composite type",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a composite type",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -636,14 +645,20 @@ heap_openr(const char *sysRelationName, LOCKMODE lockmode)
r = relation_openr(sysRelationName, lockmode);
if (r->rd_rel->relkind == RELKIND_INDEX)
elog(ERROR, "%s is an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an index relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_SPECIAL)
elog(ERROR, "%s is a special relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a special relation",
RelationGetRelationName(r))));
else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
elog(ERROR, "%s is a composite type",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a composite type",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -661,12 +676,6 @@ heap_beginscan(Relation relation, Snapshot snapshot,
{
HeapScanDesc scan;
/*
* sanity checks
*/
if (!RelationIsValid(relation))
elog(ERROR, "heap_beginscan: !RelationIsValid(relation)");
/*
* increment relation ref count while scanning relation
*
@ -767,14 +776,12 @@ heap_endscan(HeapScanDesc scan)
#ifdef HEAPDEBUGALL
#define HEAPDEBUG_1 \
elog(LOG, "heap_getnext([%s,nkeys=%d],dir=%d) called", \
elog(DEBUG2, "heap_getnext([%s,nkeys=%d],dir=%d) called", \
RelationGetRelationName(scan->rs_rd), scan->rs_nkeys, (int) direction)
#define HEAPDEBUG_2 \
elog(LOG, "heap_getnext returning EOS")
elog(DEBUG2, "heap_getnext returning EOS")
#define HEAPDEBUG_3 \
elog(LOG, "heap_getnext returning tuple")
elog(DEBUG2, "heap_getnext returning tuple")
#else
#define HEAPDEBUG_1
#define HEAPDEBUG_2
@ -787,12 +794,6 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
{
/* Note: no locking manipulations needed */
/*
* argument checks
*/
if (scan == NULL)
elog(ERROR, "heap_getnext: NULL relscan");
HEAPDEBUG_1; /* heap_getnext( info ) */
/*
@ -847,7 +848,7 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
* the tuple); when keep_buf = false, the pin is released and *userbuf is set
* to InvalidBuffer.
*
* It is somewhat inconsistent that we elog() on invalid block number but
* It is somewhat inconsistent that we ereport() on invalid block number but
* return false on invalid item number. This is historical. The only
* justification I can see is that the caller can relatively easily check the
* block number for validity, but cannot check the item number without reading
@ -875,7 +876,7 @@ heap_fetch(Relation relation,
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "heap_fetch: ReadBuffer(%s, %lu) failed",
elog(ERROR, "ReadBuffer(\"%s\", %lu) failed",
RelationGetRelationName(relation),
(unsigned long) ItemPointerGetBlockNumber(tid));
@ -985,8 +986,9 @@ heap_get_latest_tid(Relation relation,
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "heap_get_latest_tid: %s relation: ReadBuffer(%lx) failed",
RelationGetRelationName(relation), (long) tid);
elog(ERROR, "ReadBuffer(\"%s\", %lu) failed",
RelationGetRelationName(relation),
(unsigned long) ItemPointerGetBlockNumber(tid));
LockBuffer(buffer, BUFFER_LOCK_SHARE);
@ -1103,7 +1105,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
/* Find buffer to insert this tuple into */
buffer = RelationGetBufferForTuple(relation, tup->t_len, InvalidBuffer);
/* NO ELOG(ERROR) from here till changes are logged */
/* NO EREPORT(ERROR) from here till changes are logged */
START_CRIT_SECTION();
RelationPutHeapTuple(relation, buffer, tup);
@ -1219,7 +1221,7 @@ heap_delete(Relation relation, ItemPointer tid,
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "heap_delete: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
@ -1238,7 +1240,7 @@ l1:
{
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
elog(ERROR, "heap_delete: (am)invalid tid");
elog(ERROR, "attempted to delete invisible tuple");
}
else if (result == HeapTupleBeingUpdated)
{
@ -1358,7 +1360,7 @@ l1:
* This routine may be used to delete a tuple when concurrent updates of
* the target tuple are not expected (for example, because we have a lock
* on the relation associated with the tuple). Any failure is reported
* via elog().
* via ereport().
*/
void
simple_heap_delete(Relation relation, ItemPointer tid)
@ -1371,7 +1373,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
{
case HeapTupleSelfUpdated:
/* Tuple was already updated in current command? */
elog(ERROR, "simple_heap_delete: tuple already updated by self");
elog(ERROR, "tuple already updated by self");
break;
case HeapTupleMayBeUpdated:
@ -1379,11 +1381,11 @@ simple_heap_delete(Relation relation, ItemPointer tid)
break;
case HeapTupleUpdated:
elog(ERROR, "simple_heap_delete: tuple concurrently updated");
elog(ERROR, "tuple concurrently updated");
break;
default:
elog(ERROR, "Unknown status %u from heap_delete", result);
elog(ERROR, "unrecognized heap_delete status: %u", result);
break;
}
}
@ -1413,7 +1415,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(otid));
if (!BufferIsValid(buffer))
elog(ERROR, "heap_update: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
dp = (PageHeader) BufferGetPage(buffer);
@ -1438,7 +1440,7 @@ l2:
{
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
elog(ERROR, "heap_update: (am)invalid tid");
elog(ERROR, "attempted to update invisible tuple");
}
else if (result == HeapTupleBeingUpdated)
{
@ -1611,7 +1613,7 @@ l2:
* buffer, only one pin is held.
*/
/* NO ELOG(ERROR) from here till changes are logged */
/* NO EREPORT(ERROR) from here till changes are logged */
START_CRIT_SECTION();
RelationPutHeapTuple(relation, newbuf, newtup); /* insert new tuple */
@ -1688,7 +1690,7 @@ l2:
* This routine may be used to update a tuple when concurrent updates of
* the target tuple are not expected (for example, because we have a lock
* on the relation associated with the tuple). Any failure is reported
* via elog().
* via ereport().
*/
void
simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
@ -1701,7 +1703,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
{
case HeapTupleSelfUpdated:
/* Tuple was already updated in current command? */
elog(ERROR, "simple_heap_update: tuple already updated by self");
elog(ERROR, "tuple already updated by self");
break;
case HeapTupleMayBeUpdated:
@ -1709,11 +1711,11 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
break;
case HeapTupleUpdated:
elog(ERROR, "simple_heap_update: tuple concurrently updated");
elog(ERROR, "tuple concurrently updated");
break;
default:
elog(ERROR, "Unknown status %u from heap_update", result);
elog(ERROR, "unrecognized heap_update status: %u", result);
break;
}
}
@ -1733,7 +1735,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
*buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(*buffer))
elog(ERROR, "heap_mark4update: failed ReadBuffer");
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
@ -1750,7 +1752,7 @@ l3:
{
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(*buffer);
elog(ERROR, "heap_mark4update: (am)invalid tid");
elog(ERROR, "attempted to mark4update invisible tuple");
}
else if (result == HeapTupleBeingUpdated)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Id: hio.c,v 1.47 2003/02/13 05:35:11 momjian Exp $
* $Id: hio.c,v 1.48 2003/07/21 20:29:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -23,7 +23,7 @@
/*
* RelationPutHeapTuple - place tuple at specified page
*
* !!! ELOG(ERROR) IS DISALLOWED HERE !!!
* !!! EREPORT(ERROR) IS DISALLOWED HERE !!! Must PANIC on failure!!!
*
* Note - caller must hold BUFFER_LOCK_EXCLUSIVE on the buffer.
*/
@ -44,7 +44,7 @@ RelationPutHeapTuple(Relation relation,
tuple->t_len, InvalidOffsetNumber, LP_USED);
if (offnum == InvalidOffsetNumber)
elog(PANIC, "RelationPutHeapTuple: failed to add tuple");
elog(PANIC, "failed to add tuple to page");
/* Update tuple->t_self to the actual position where it was stored */
ItemPointerSet(&(tuple->t_self), BufferGetBlockNumber(buffer), offnum);
@ -84,7 +84,7 @@ RelationPutHeapTuple(Relation relation,
* for indices only. Alternatively, we could define pseudo-table as
* we do for transactions with XactLockTable.
*
* ELOG(ERROR) is allowed here, so this routine *must* be called
* ereport(ERROR) is allowed here, so this routine *must* be called
* before any (unlogged) changes are made in buffer pool.
*/
Buffer
@ -104,8 +104,11 @@ RelationGetBufferForTuple(Relation relation, Size len,
* If we're gonna fail for oversize tuple, do it right away
*/
if (len > MaxTupleSize)
elog(ERROR, "Tuple is too big: size %lu, max size %ld",
(unsigned long) len, MaxTupleSize);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("tuple is too big: size %lu, maximum size %lu",
(unsigned long) len,
(unsigned long) MaxTupleSize)));
if (otherBuffer != InvalidBuffer)
otherBlock = BufferGetBlockNumber(otherBuffer);
@ -268,7 +271,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
if (len > PageGetFreeSpace(pageHeader))
{
/* We should not get here given the test at the top */
elog(PANIC, "Tuple is too big: size %lu", (unsigned long) len);
elog(PANIC, "tuple is too big: size %lu", (unsigned long) len);
}
/*

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.36 2002/09/04 20:31:09 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.37 2003/07/21 20:29:39 tgl Exp $
*
*
* INTERFACE ROUTINES
@ -896,7 +896,7 @@ toast_save_datum(Relation rel, Datum value)
memcpy(VARATT_DATA(&chunk_data), data_p, chunk_size);
toasttup = heap_formtuple(toasttupDesc, t_values, t_nulls);
if (!HeapTupleIsValid(toasttup))
elog(ERROR, "Failed to build TOAST tuple");
elog(ERROR, "failed to build TOAST tuple");
simple_heap_insert(toastrel, toasttup);
@ -912,7 +912,7 @@ toast_save_datum(Relation rel, Datum value)
&(toasttup->t_self),
toastrel, toastidx->rd_index->indisunique);
if (idxres == NULL)
elog(ERROR, "Failed to insert index entry for TOAST tuple");
elog(ERROR, "failed to insert index entry for TOAST tuple");
/*
* Free memory

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.38 2003/03/24 21:42:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.39 2003/07/21 20:29:39 tgl Exp $
*
* NOTES
* many of the old access method routines have been turned into
@ -70,9 +70,6 @@ RelationGetIndexScan(Relation indexRelation,
{
IndexScanDesc scan;
if (!RelationIsValid(indexRelation))
elog(ERROR, "RelationGetIndexScan: relation invalid");
scan = (IndexScanDesc) palloc(sizeof(IndexScanDescData));
scan->heapRelation = NULL; /* may be set later */
@ -135,9 +132,6 @@ RelationGetIndexScan(Relation indexRelation,
void
IndexScanEnd(IndexScanDesc scan)
{
if (!IndexScanIsValid(scan))
elog(ERROR, "IndexScanEnd: invalid scan");
if (scan->keyData != NULL)
pfree(scan->keyData);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.66 2003/03/24 21:42:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.67 2003/07/21 20:29:39 tgl Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relation OID
@ -90,7 +90,7 @@
procedure = indexRelation->rd_am->y, \
(!RegProcedureIsValid(procedure)) ? \
elog(ERROR, "index_%s: invalid %s regproc", \
CppAsString(x), CppAsString(y)) \
CppAsString(x), CppAsString(y)) \
: (void)NULL \
)
@ -99,7 +99,7 @@
procedure = scan->indexRelation->rd_am->y, \
(!RegProcedureIsValid(procedure)) ? \
elog(ERROR, "index_%s: invalid %s regproc", \
CppAsString(x), CppAsString(y)) \
CppAsString(x), CppAsString(y)) \
: (void)NULL \
)
@ -129,8 +129,10 @@ index_open(Oid relationId)
r = relation_open(relationId, NoLock);
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index relation",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -152,8 +154,10 @@ index_openrv(const RangeVar *relation)
r = relation_openrv(relation, NoLock);
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index relation",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -175,8 +179,10 @@ index_openr(const char *sysRelationName)
r = relation_openr(sysRelationName, NoLock);
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation",
RelationGetRelationName(r));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index relation",
RelationGetRelationName(r))));
pgstat_initstats(&r->pgstat_info, r);
@ -753,7 +759,7 @@ index_getprocinfo(Relation irel,
* use index_getprocid.)
*/
if (!RegProcedureIsValid(procId))
elog(ERROR, "Missing support function %d for attribute %d of index %s",
elog(ERROR, "missing support function %d for attribute %d of index \"%s\"",
procnum, attnum, RelationGetRelationName(irel));
fmgr_info_cxt(procId, locinfo, irel->rd_indexcxt);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.58 2002/06/20 20:29:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.59 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -235,7 +235,7 @@ StrategyTermEvaluate(StrategyTerm term,
break;
default:
elog(ERROR, "StrategyTermEvaluate: impossible case %d",
elog(ERROR, "impossible strategy case: %d",
operator->flags ^ entry->sk_flags);
}
if (!result)
@ -310,13 +310,14 @@ RelationGetStrategy(Relation relation,
break;
default:
elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags);
elog(ERROR, "impossible strategy case: %d",
entry->sk_flags);
}
if (!StrategyNumberIsInBounds(strategy, evaluation->maxStrategy))
{
if (!StrategyNumberIsValid(strategy))
elog(ERROR, "RelationGetStrategy: corrupted evaluation");
elog(ERROR, "corrupted strategy evaluation");
}
return strategy;
@ -435,8 +436,7 @@ RelationInvokeStrategy(Relation relation,
}
}
elog(ERROR, "RelationInvokeStrategy: cannot evaluate strategy %d",
strategy);
elog(ERROR, "cannot evaluate strategy %d", strategy);
/* not reached, just to make compiler happy */
return FALSE;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.100 2003/05/27 17:49:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.101 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -153,7 +153,7 @@ top:
*
* Returns InvalidTransactionId if there is no conflict, else an xact ID
* we must wait for to see if it commits a conflicting tuple. If an actual
* conflict is detected, no return --- just elog().
* conflict is detected, no return --- just ereport().
*/
static TransactionId
_bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
@ -237,8 +237,10 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
/*
* Otherwise we have a definite conflict.
*/
elog(ERROR, "Cannot insert a duplicate key into unique index %s",
RelationGetRelationName(rel));
ereport(ERROR,
(errcode(ERRCODE_UNIQUE_VIOLATION),
errmsg("duplicate key violates UNIQUE constraint \"%s\"",
RelationGetRelationName(rel))));
}
else if (htup.t_data != NULL)
{
@ -291,7 +293,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
if (!P_IGNORE(opaque))
break;
if (P_RIGHTMOST(opaque))
elog(ERROR, "_bt_check_unique: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
}
maxoff = PageGetMaxOffsetNumber(page);
@ -387,8 +389,11 @@ _bt_insertonpg(Relation rel,
* itemsz doesn't include the ItemId.
*/
if (itemsz > BTMaxItemSize(page))
elog(ERROR, "btree: index item size %lu exceeds maximum %lu",
(unsigned long) itemsz, BTMaxItemSize(page));
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("index tuple size %lu exceeds btree maximum, %lu",
(unsigned long) itemsz,
(unsigned long) BTMaxItemSize(page))));
/*
* Determine exactly where new item will go.
@ -445,7 +450,7 @@ _bt_insertonpg(Relation rel,
if (!P_IGNORE(lpageop))
break;
if (P_RIGHTMOST(lpageop))
elog(ERROR, "_bt_insertonpg: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
}
_bt_relbuf(rel, buf);
@ -536,7 +541,7 @@ _bt_insertonpg(Relation rel,
}
}
/* Do the actual update. No elog(ERROR) until changes are logged */
/* Do the update. No ereport(ERROR) until changes are logged */
START_CRIT_SECTION();
_bt_pgaddtup(rel, page, itemsz, btitem, newitemoff, "page");
@ -705,7 +710,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
item = (BTItem) PageGetItem(origpage, itemid);
if (PageAddItem(rightpage, (Item) item, itemsz, rightoff,
LP_USED) == InvalidOffsetNumber)
elog(PANIC, "btree: failed to add hikey to the right sibling");
elog(PANIC, "failed to add hikey to the right sibling");
rightoff = OffsetNumberNext(rightoff);
}
@ -730,7 +735,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
}
if (PageAddItem(leftpage, (Item) item, itemsz, leftoff,
LP_USED) == InvalidOffsetNumber)
elog(PANIC, "btree: failed to add hikey to the left sibling");
elog(PANIC, "failed to add hikey to the left sibling");
leftoff = OffsetNumberNext(leftoff);
/*
@ -815,14 +820,14 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
spage = BufferGetPage(sbuf);
sopaque = (BTPageOpaque) PageGetSpecialPointer(spage);
if (sopaque->btpo_prev != ropaque->btpo_prev)
elog(PANIC, "btree: right sibling's left-link doesn't match");
elog(PANIC, "right sibling's left-link doesn't match");
}
/*
* Right sibling is locked, new siblings are prepared, but original
* page is not updated yet. Log changes before continuing.
*
* NO ELOG(ERROR) till right sibling is updated.
* NO EREPORT(ERROR) till right sibling is updated.
*/
START_CRIT_SECTION();
@ -1059,7 +1064,7 @@ _bt_findsplitloc(Relation rel,
* just in case ...
*/
if (!state.have_split)
elog(FATAL, "_bt_findsplitloc: can't find a feasible split point for %s",
elog(ERROR, "cannot find a feasible split point for \"%s\"",
RelationGetRelationName(rel));
*newitemonleft = state.newitemonleft;
@ -1193,7 +1198,7 @@ _bt_insert_parent(Relation rel,
BTPageOpaque lpageop;
if (!InRecovery)
elog(DEBUG2, "_bt_insert_parent: concurrent ROOT page split");
elog(DEBUG2, "concurrent ROOT page split");
lpageop = (BTPageOpaque) PageGetSpecialPointer(page);
/* Find the leftmost page at the next level up */
pbuf = _bt_get_endpoint(rel, lpageop->btpo.level + 1, false);
@ -1232,8 +1237,8 @@ _bt_insert_parent(Relation rel,
/* Check for error only after writing children */
if (pbuf == InvalidBuffer)
elog(ERROR, "_bt_getstackbuf: my bits moved right off the end of the world!"
"\n\tRecreate index %s.", RelationGetRelationName(rel));
elog(ERROR, "failed to re-find parent key in \"%s\"",
RelationGetRelationName(rel));
/* Recursively update the parent */
newres = _bt_insertonpg(rel, pbuf, stack->bts_parent,
@ -1399,7 +1404,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
metapg = BufferGetPage(metabuf);
metad = BTPageGetMeta(metapg);
/* NO ELOG(ERROR) from here till newroot op is logged */
/* NO EREPORT(ERROR) from here till newroot op is logged */
START_CRIT_SECTION();
/* set btree special data */
@ -1431,7 +1436,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
* the two items will go into positions P_HIKEY and P_FIRSTKEY.
*/
if (PageAddItem(rootpage, (Item) new_item, itemsz, P_HIKEY, LP_USED) == InvalidOffsetNumber)
elog(PANIC, "btree: failed to add leftkey to new root page");
elog(PANIC, "failed to add leftkey to new root page");
pfree(new_item);
/*
@ -1448,7 +1453,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
* insert the right page pointer into the new root page.
*/
if (PageAddItem(rootpage, (Item) new_item, itemsz, P_FIRSTKEY, LP_USED) == InvalidOffsetNumber)
elog(PANIC, "btree: failed to add rightkey to new root page");
elog(PANIC, "failed to add rightkey to new root page");
pfree(new_item);
/* XLOG stuff */
@ -1533,7 +1538,7 @@ _bt_pgaddtup(Relation rel,
if (PageAddItem(page, (Item) btitem, itemsize, itup_off,
LP_USED) == InvalidOffsetNumber)
elog(PANIC, "btree: failed to add item to the %s for %s",
elog(PANIC, "failed to add item to the %s for \"%s\"",
where, RelationGetRelationName(rel));
}

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.65 2003/05/27 17:49:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.66 2003/07/21 20:29:39 tgl Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
@ -44,7 +44,7 @@ _bt_metapinit(Relation rel)
BTPageOpaque op;
if (RelationGetNumberOfBlocks(rel) != 0)
elog(ERROR, "Cannot initialize non-empty btree %s",
elog(ERROR, "cannot initialize non-empty btree index \"%s\"",
RelationGetRelationName(rel));
buf = ReadBuffer(rel, P_NEW);
@ -145,13 +145,17 @@ _bt_getroot(Relation rel, int access)
/* sanity-check the metapage */
if (!(metaopaque->btpo_flags & BTP_META) ||
metad->btm_magic != BTREE_MAGIC)
elog(ERROR, "Index %s is not a btree",
RelationGetRelationName(rel));
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("index \"%s\" is not a btree",
RelationGetRelationName(rel))));
if (metad->btm_version != BTREE_VERSION)
elog(ERROR, "Version mismatch on %s: version %d file, version %d code",
RelationGetRelationName(rel),
metad->btm_version, BTREE_VERSION);
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("version mismatch in \"%s\": file version %d, code version %d",
RelationGetRelationName(rel),
metad->btm_version, BTREE_VERSION)));
/* if no root page initialized yet, do it */
if (metad->btm_root == P_NONE)
@ -265,7 +269,7 @@ _bt_getroot(Relation rel, int access)
/* it's dead, Jim. step right one page */
if (P_RIGHTMOST(rootopaque))
elog(ERROR, "No live root page found in %s",
elog(ERROR, "no live root page found in \"%s\"",
RelationGetRelationName(rel));
rootblkno = rootopaque->btpo_next;
@ -274,7 +278,7 @@ _bt_getroot(Relation rel, int access)
/* Note: can't check btpo.level on deleted pages */
if (rootopaque->btpo.level != rootlevel)
elog(ERROR, "Root page %u of %s has level %u, expected %u",
elog(ERROR, "root page %u of \"%s\" has level %u, expected %u",
rootblkno, RelationGetRelationName(rel),
rootopaque->btpo.level, rootlevel);
}
@ -320,13 +324,17 @@ _bt_gettrueroot(Relation rel)
if (!(metaopaque->btpo_flags & BTP_META) ||
metad->btm_magic != BTREE_MAGIC)
elog(ERROR, "Index %s is not a btree",
RelationGetRelationName(rel));
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("index \"%s\" is not a btree",
RelationGetRelationName(rel))));
if (metad->btm_version != BTREE_VERSION)
elog(ERROR, "Version mismatch on %s: version %d file, version %d code",
RelationGetRelationName(rel),
metad->btm_version, BTREE_VERSION);
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("version mismatch in \"%s\": file version %d, code version %d",
RelationGetRelationName(rel),
metad->btm_version, BTREE_VERSION)));
/* if no root page initialized yet, fail */
if (metad->btm_root == P_NONE)
@ -351,7 +359,7 @@ _bt_gettrueroot(Relation rel)
/* it's dead, Jim. step right one page */
if (P_RIGHTMOST(rootopaque))
elog(ERROR, "No live root page found in %s",
elog(ERROR, "no live root page found in \"%s\"",
RelationGetRelationName(rel));
rootblkno = rootopaque->btpo_next;
@ -360,7 +368,7 @@ _bt_gettrueroot(Relation rel)
/* Note: can't check btpo.level on deleted pages */
if (rootopaque->btpo.level != rootlevel)
elog(ERROR, "Root page %u of %s has level %u, expected %u",
elog(ERROR, "root page %u of \"%s\" has level %u, expected %u",
rootblkno, RelationGetRelationName(rel),
rootopaque->btpo.level, rootlevel);
@ -416,7 +424,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
_bt_pageinit(page, BufferGetPageSize(buf));
return buf;
}
elog(DEBUG2, "_bt_getbuf: FSM returned nonrecyclable page");
elog(DEBUG2, "FSM returned nonrecyclable page");
_bt_relbuf(rel, buf);
}
@ -630,7 +638,7 @@ _bt_delitems(Relation rel, Buffer buf,
Page page = BufferGetPage(buf);
int i;
/* No elog(ERROR) until changes are logged */
/* No ereport(ERROR) until changes are logged */
START_CRIT_SECTION();
/*
@ -775,7 +783,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
for (;;)
{
if (stack == NULL)
elog(ERROR, "_bt_pagedel: not enough stack items");
elog(ERROR, "not enough stack items");
if (ilevel == targetlevel)
break;
stack = stack->bts_parent;
@ -805,7 +813,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
_bt_relbuf(rel, lbuf);
if (leftsib == P_NONE)
{
elog(LOG, "_bt_pagedel: no left sibling (concurrent deletion?)");
elog(LOG, "no left sibling (concurrent deletion?)");
return 0;
}
lbuf = _bt_getbuf(rel, leftsib, BT_WRITE);
@ -837,7 +845,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
return 0;
}
if (opaque->btpo_prev != leftsib)
elog(ERROR, "_bt_pagedel: left link changed unexpectedly");
elog(ERROR, "left link changed unexpectedly");
/*
* And next write-lock the (current) right sibling.
*/
@ -851,8 +859,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
target, P_HIKEY);
pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
if (pbuf == InvalidBuffer)
elog(ERROR, "_bt_getstackbuf: my bits moved right off the end of the world!"
"\n\tRecreate index %s.", RelationGetRelationName(rel));
elog(ERROR, "failed to re-find parent key in \"%s\"",
RelationGetRelationName(rel));
parent = stack->bts_blkno;
poffset = stack->bts_offset;
/*
@ -924,7 +932,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
* Here we begin doing the deletion.
*/
/* No elog(ERROR) until changes are logged */
/* No ereport(ERROR) until changes are logged */
START_CRIT_SECTION();
/*
@ -954,7 +962,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
itemid = PageGetItemId(page, nextoffset);
btitem = (BTItem) PageGetItem(page, itemid);
if (ItemPointerGetBlockNumber(&(btitem->bti_itup.t_tid)) != rightsib)
elog(PANIC, "_bt_pagedel: right sibling is not next child");
elog(PANIC, "right sibling is not next child");
PageIndexTupleDelete(page, nextoffset);
}

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.102 2003/03/23 23:01:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.103 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -108,7 +108,7 @@ btbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
*/
if (RelationGetNumberOfBlocks(index) != 0)
elog(ERROR, "%s already contains data",
elog(ERROR, "index \"%s\" already contains data",
RelationGetRelationName(index));
/* initialize the btree index metadata page */
@ -816,8 +816,7 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
*/
i = FlushRelationBuffers(rel, new_pages);
if (i < 0)
elog(ERROR, "btvacuumcleanup: FlushRelationBuffers returned %d",
i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
/*
* Do the physical truncation.
@ -929,8 +928,8 @@ _bt_restscan(IndexScanDesc scan)
* we can find it again.
*/
if (P_RIGHTMOST(opaque))
elog(ERROR, "_bt_restscan: my bits moved right off the end of the world!"
"\n\tRecreate index %s.", RelationGetRelationName(rel));
elog(ERROR, "failed to re-find previous key in \"%s\"",
RelationGetRelationName(rel));
/* Advance to next non-dead page --- there must be one */
nextbuf = InvalidBuffer;
for (;;)
@ -944,7 +943,7 @@ _bt_restscan(IndexScanDesc scan)
if (!P_IGNORE(opaque))
break;
if (P_RIGHTMOST(opaque))
elog(ERROR, "_bt_restscan: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
}
_bt_relbuf(rel, buf);

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.74 2003/02/22 00:45:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.75 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -168,7 +168,7 @@ _bt_moveright(Relation rel,
}
if (P_IGNORE(opaque))
elog(ERROR, "_bt_moveright: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
return buf;
@ -552,7 +552,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
{
pfree(nKeyIs);
pfree(scankeys);
elog(ERROR, "_bt_first: btree doesn't support is(not)null, yet");
elog(ERROR, "btree doesn't support is(not)null, yet");
return false;
}
procinfo = index_getprocinfo(rel, i + 1, BTORDER_PROC);
@ -700,7 +700,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
result = _bt_compare(rel, keysCount, scankeys, page, offnum);
} while (result == 0);
if (!_bt_step(scan, &buf, BackwardScanDirection))
elog(ERROR, "_bt_first: equal items disappeared?");
elog(ERROR, "equal items disappeared?");
}
break;
@ -991,7 +991,7 @@ _bt_walk_left(Relation rel, Buffer buf)
for (;;)
{
if (P_RIGHTMOST(opaque))
elog(ERROR, "_bt_walk_left: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
blkno = opaque->btpo_next;
_bt_relbuf(rel, buf);
@ -1015,7 +1015,7 @@ _bt_walk_left(Relation rel, Buffer buf)
* if there's anything wrong.
*/
if (opaque->btpo_prev == lblkno)
elog(ERROR, "_bt_walk_left: can't find left sibling in %s",
elog(ERROR, "cannot find left sibling in \"%s\"",
RelationGetRelationName(rel));
/* Okay to try again with new lblkno value */
}
@ -1028,7 +1028,7 @@ _bt_walk_left(Relation rel, Buffer buf)
* _bt_get_endpoint() -- Find the first or last page on a given tree level
*
* If the index is empty, we will return InvalidBuffer; any other failure
* condition causes elog(). We will not return a dead page.
* condition causes ereport(). We will not return a dead page.
*
* The returned buffer is pinned and read-locked.
*/
@ -1075,7 +1075,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
{
blkno = opaque->btpo_next;
if (blkno == P_NONE)
elog(ERROR, "_bt_get_endpoint: fell off the end of %s",
elog(ERROR, "fell off the end of \"%s\"",
RelationGetRelationName(rel));
_bt_relbuf(rel, buf);
buf = _bt_getbuf(rel, blkno, BT_READ);
@ -1087,7 +1087,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
if (opaque->btpo.level == level)
break;
if (opaque->btpo.level < level)
elog(ERROR, "_bt_get_endpoint: btree level %u not found", level);
elog(ERROR, "btree level %u not found", level);
/* Descend to leftmost or rightmost child page */
if (rightmost)
@ -1176,7 +1176,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
}
else
{
elog(ERROR, "Illegal scan direction %d", dir);
elog(ERROR, "invalid scan direction: %d", (int) dir);
start = 0; /* keep compiler quiet */
}

View File

@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.72 2003/02/22 00:45:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.73 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -332,7 +332,7 @@ _bt_sortaddtup(Page page,
if (PageAddItem(page, (Item) btitem, itemsize, itup_off,
LP_USED) == InvalidOffsetNumber)
elog(ERROR, "btree: failed to add item to the page in _bt_sort");
elog(ERROR, "failed to add item to the index page");
}
/*----------
@ -397,8 +397,11 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti)
* during creation of an index, we don't go through there.
*/
if (btisz > BTMaxItemSize(npage))
elog(ERROR, "btree: index item size %lu exceeds maximum %ld",
(unsigned long) btisz, BTMaxItemSize(npage));
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("index tuple size %lu exceeds btree maximum, %lu",
(unsigned long) btisz,
(unsigned long) BTMaxItemSize(npage))));
if (pgspc < btisz || pgspc < state->btps_full)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.51 2002/09/04 20:31:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.52 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -227,7 +227,7 @@ _bt_orderkeys(IndexScanDesc scan)
cur = &key[0];
/* check input keys are correctly ordered */
if (cur->sk_attno != 1)
elog(ERROR, "_bt_orderkeys: key(s) for attribute 1 missed");
elog(ERROR, "key(s) for attribute 1 missed");
/* We can short-circuit most of the work if there's just one key */
if (numberOfKeys == 1)
@ -305,8 +305,7 @@ _bt_orderkeys(IndexScanDesc scan)
/* check input keys are correctly ordered */
if (i < numberOfKeys && cur->sk_attno != attno + 1)
elog(ERROR, "_bt_orderkeys: key(s) for attribute %d missed",
attno + 1);
elog(ERROR, "key(s) for attribute %d missed", attno + 1);
/*
* If = has been specified, no other key will be used. In case
@ -462,8 +461,7 @@ _bt_getstrategynumber(RegProcedure sk_procedure, StrategyMap map)
if (sk_procedure == map->entry[j].sk_procedure)
return j;
}
elog(ERROR, "_bt_getstrategynumber: unable to identify operator %u",
sk_procedure);
elog(ERROR, "unable to identify operator %u", sk_procedure);
return -1; /* keep compiler quiet */
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.77 2003/02/24 00:57:17 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.78 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -125,7 +125,7 @@ rtbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
*/
if (RelationGetNumberOfBlocks(index) != 0)
elog(ERROR, "%s already contains data",
elog(ERROR, "index \"%s\" already contains data",
RelationGetRelationName(index));
/* initialize the root page */
@ -328,7 +328,7 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate)
LP_USED);
}
if (l == InvalidOffsetNumber)
elog(ERROR, "rtdoinsert: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
WriteBuffer(buffer);
@ -520,7 +520,7 @@ rtdosplit(Relation r,
if (PageAddItem(left, (Item) item, IndexTupleSize(item),
leftoff, LP_USED) == InvalidOffsetNumber)
elog(ERROR, "rtdosplit: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
leftoff = OffsetNumberNext(leftoff);
@ -544,7 +544,7 @@ rtdosplit(Relation r,
if (PageAddItem(right, (Item) item, IndexTupleSize(item),
rightoff, LP_USED) == InvalidOffsetNumber)
elog(ERROR, "rtdosplit: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
rightoff = OffsetNumberNext(rightoff);
@ -640,7 +640,9 @@ rtintinsert(Relation r,
*/
if (IndexTupleSize(old) != IndexTupleSize(ltup))
elog(ERROR, "Variable-length rtree keys are not supported.");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("variable-length rtree keys are not supported")));
/* install pointer to left child */
memmove(old, ltup, IndexTupleSize(ltup));
@ -660,7 +662,7 @@ rtintinsert(Relation r,
if (PageAddItem(p, (Item) rtup, IndexTupleSize(rtup),
PageGetMaxOffsetNumber(p),
LP_USED) == InvalidOffsetNumber)
elog(ERROR, "rtintinsert: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
WriteBuffer(b);
ldatum = IndexTupleGetDatum(ltup);
@ -686,12 +688,12 @@ rtnewroot(Relation r, IndexTuple lt, IndexTuple rt)
if (PageAddItem(p, (Item) lt, IndexTupleSize(lt),
FirstOffsetNumber,
LP_USED) == InvalidOffsetNumber)
elog(ERROR, "rtnewroot: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
if (PageAddItem(p, (Item) rt, IndexTupleSize(rt),
OffsetNumberNext(FirstOffsetNumber),
LP_USED) == InvalidOffsetNumber)
elog(ERROR, "rtnewroot: failed to add index item to %s",
elog(ERROR, "failed to add index item to \"%s\"",
RelationGetRelationName(r));
WriteBuffer(b);
}
@ -778,8 +780,11 @@ rtpicksplit(Relation r,
*/
newitemsz = IndexTupleTotalSize(itup);
if (newitemsz > RTPageAvailSpace)
elog(ERROR, "rtree: index item size %lu exceeds maximum %lu",
(unsigned long) newitemsz, (unsigned long) RTPageAvailSpace);
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("index tuple size %lu exceeds rtree maximum, %lu",
(unsigned long) newitemsz,
(unsigned long) RTPageAvailSpace)));
maxoff = PageGetMaxOffsetNumber(page);
newitemoff = OffsetNumberNext(maxoff); /* phony index for new
@ -1065,7 +1070,7 @@ rtpicksplit(Relation r,
choose_left = false;
else
{
elog(ERROR, "rtpicksplit: failed to find a workable page split");
elog(ERROR, "failed to find a workable rtree page split");
choose_left = false; /* keep compiler quiet */
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.43 2003/03/23 23:01:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.44 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -384,7 +384,7 @@ adjustiptr(IndexScanDesc s,
break;
default:
elog(ERROR, "Bad operation in rtree scan adjust: %d", op);
elog(ERROR, "unrecognized operation in rtree scan adjust: %d", op);
}
}
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.148 2003/05/14 03:26:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.149 2003/07/21 20:29:39 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -400,7 +400,9 @@ CommandCounterIncrement(void)
s->commandId += 1;
if (s->commandId == FirstCommandId) /* check for overflow */
elog(ERROR, "You may only have 2^32-1 commands per transaction");
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot have more than 2^32-1 commands in a transaction")));
/* Propagate new command ID into query snapshots, if set */
if (QuerySnapshot)
@ -672,8 +674,7 @@ RecordTransactionAbort(void)
* RecordTransactionCommit ...
*/
if (TransactionIdDidCommit(xid))
elog(PANIC, "RecordTransactionAbort: xact %u already committed",
xid);
elog(PANIC, "cannot abort transaction %u, it was already committed", xid);
START_CRIT_SECTION();
@ -1367,23 +1368,24 @@ PreventTransactionChain(void *stmtNode, const char *stmtType)
* xact block already started?
*/
if (IsTransactionBlock())
{
/* translator: %s represents an SQL statement name */
elog(ERROR, "%s cannot run inside a transaction block", stmtType);
}
ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
/* translator: %s represents an SQL statement name */
errmsg("%s cannot run inside a transaction block",
stmtType)));
/*
* Are we inside a function call? If the statement's parameter block
* was allocated in QueryContext, assume it is an interactive command.
* Otherwise assume it is coming from a function.
*/
if (!MemoryContextContains(QueryContext, stmtNode))
{
/* translator: %s represents an SQL statement name */
elog(ERROR, "%s cannot be executed from a function", stmtType);
}
ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
/* translator: %s represents an SQL statement name */
errmsg("%s cannot be executed from a function", stmtType)));
/* If we got past IsTransactionBlock test, should be in default state */
if (CurrentTransactionState->blockState != TBLOCK_DEFAULT)
elog(ERROR, "PreventTransactionChain: can't prevent chain");
elog(ERROR, "cannot prevent transaction chain");
/* all okay */
}
@ -1419,9 +1421,11 @@ RequireTransactionChain(void *stmtNode, const char *stmtType)
*/
if (!MemoryContextContains(QueryContext, stmtNode))
return;
/* translator: %s represents an SQL statement name */
elog(ERROR, "%s may only be used in begin/end transaction blocks",
stmtType);
ereport(ERROR,
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
/* translator: %s represents an SQL statement name */
errmsg("%s may only be used in BEGIN/END transaction blocks",
stmtType)));
}
@ -1441,7 +1445,9 @@ BeginTransactionBlock(void)
* check the current transaction state
*/
if (s->blockState != TBLOCK_DEFAULT)
elog(WARNING, "BEGIN: already a transaction in progress");
ereport(WARNING,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("there is already a transaction in progress")));
/*
* set the current transaction block state information appropriately
@ -1501,7 +1507,9 @@ EndTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* state.
*/
elog(WARNING, "COMMIT: no transaction in progress");
ereport(WARNING,
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
errmsg("there is no transaction in progress")));
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}
@ -1537,7 +1545,9 @@ AbortTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* state.
*/
elog(WARNING, "ROLLBACK: no transaction in progress");
ereport(WARNING,
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
errmsg("there is no transaction in progress")));
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}
@ -1583,7 +1593,9 @@ UserAbortTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* state.
*/
elog(WARNING, "ROLLBACK: no transaction in progress");
ereport(WARNING,
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
errmsg("there is no transaction in progress")));
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}
@ -1663,7 +1675,8 @@ TransactionBlockStatusCode(void)
}
/* should never get here */
elog(ERROR, "bogus transaction block state");
elog(ERROR, "invalid transaction block state: %d",
(int) s->blockState);
return 0; /* keep compiler quiet */
}

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.52 2003/07/21 17:05:11 tgl Exp $
* $Id: elog.h,v 1.53 2003/07/21 20:29:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -177,6 +177,7 @@
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','5')
#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','6')
#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5', '0','0','7')
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5', 'P','0','1')
/* Class 26 - Invalid SQL Statement Name */
/* (we take this to mean prepared statements) */
@ -308,6 +309,7 @@
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('5','5', 'P','0','2')
/* Class 57 - Operator Intervention (class borrowed from DB2) */
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')

View File

@ -475,7 +475,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
insert into atacc1 (test) values (2);
-- should fail
insert into atacc1 (test) values (2);
ERROR: Cannot insert a duplicate key into unique index atacc_test1
ERROR: duplicate key violates UNIQUE constraint "atacc_test1"
-- should succeed
insert into atacc1 (test) values (4);
-- try adding a unique oid constraint
@ -509,7 +509,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
insert into atacc1 (test,test2) values (4,4);
-- should fail
insert into atacc1 (test,test2) values (4,4);
ERROR: Cannot insert a duplicate key into unique index atacc_test1
ERROR: duplicate key violates UNIQUE constraint "atacc_test1"
-- should all succeed
insert into atacc1 (test,test2) values (4,5);
insert into atacc1 (test,test2) values (5,4);
@ -523,7 +523,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc1_test2_key"
-- should fail for @@ second one @@
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (2, 3);
ERROR: Cannot insert a duplicate key into unique index atacc1_test_key
ERROR: duplicate key violates UNIQUE constraint "atacc1_test_key"
drop table atacc1;
-- test primary key constraint adding
create table atacc1 ( test int );
@ -534,7 +534,7 @@ NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1"
insert into atacc1 (test) values (2);
-- should fail
insert into atacc1 (test) values (2);
ERROR: Cannot insert a duplicate key into unique index atacc_test1
ERROR: duplicate key violates UNIQUE constraint "atacc_test1"
-- should succeed
insert into atacc1 (test) values (4);
-- inserting NULL should fail
@ -589,7 +589,7 @@ ERROR: multiple primary keys for table "atacc1" are not allowed
insert into atacc1 (test,test2) values (4,4);
-- should fail
insert into atacc1 (test,test2) values (4,4);
ERROR: Cannot insert a duplicate key into unique index atacc_test1
ERROR: duplicate key violates UNIQUE constraint "atacc_test1"
insert into atacc1 (test,test2) values (NULL,3);
ERROR: null value for attribute "test" violates NOT NULL constraint
insert into atacc1 (test,test2) values (3, NULL);
@ -607,7 +607,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "atacc1_pkey" for
-- only first should succeed
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (2, 3);
ERROR: Cannot insert a duplicate key into unique index atacc1_pkey
ERROR: duplicate key violates UNIQUE constraint "atacc1_pkey"
insert into atacc1 (test2, test) values (1, NULL);
ERROR: null value for attribute "test" violates NOT NULL constraint
drop table atacc1;

View File

@ -363,7 +363,7 @@ insert into arr_tbl values ('{1,2,3}');
insert into arr_tbl values ('{1,2}');
-- failure expected:
insert into arr_tbl values ('{1,2,3}');
ERROR: Cannot insert a duplicate key into unique index arr_tbl_f1_key
ERROR: duplicate key violates UNIQUE constraint "arr_tbl_f1_key"
insert into arr_tbl values ('{2,3,4}');
insert into arr_tbl values ('{1,5,3}');
insert into arr_tbl values ('{1,2,10}');

View File

@ -78,7 +78,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
INSERT INTO func_index_heap VALUES('QWE','RTY');
-- this should fail because of unique index:
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
ERROR: Cannot insert a duplicate key into unique index func_index_index
ERROR: duplicate key violates UNIQUE constraint "func_index_index"
-- but this shouldn't:
INSERT INTO func_index_heap VALUES('QWERTY');
--
@ -92,7 +92,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
INSERT INTO func_index_heap VALUES('QWE','RTY');
-- this should fail because of unique index:
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
ERROR: Cannot insert a duplicate key into unique index func_index_index
ERROR: duplicate key violates UNIQUE constraint "func_index_index"
-- but this shouldn't:
INSERT INTO func_index_heap VALUES('QWERTY');
--

View File

@ -99,10 +99,10 @@ ERROR: attribute "oid" of relation "stud_emp" already exists
-- not in a xact
abort;
WARNING: ROLLBACK: no transaction in progress
WARNING: there is no transaction in progress
-- not in a xact
end;
WARNING: COMMIT: no transaction in progress
WARNING: there is no transaction in progress
--
-- CREATE AGGREGATE
-- sfunc/finalfunc type disagreement

View File

@ -1515,7 +1515,7 @@ select * from PField_v1 where pfname = 'PF0_2' order by slotname;
-- Finally we want errors
--
insert into PField values ('PF1_1', 'should fail due to unique index');
ERROR: Cannot insert a duplicate key into unique index pfield_name
ERROR: duplicate key violates UNIQUE constraint "pfield_name"
update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
ERROR: WS.not.there does not exist
CONTEXT: PL/pgSQL function tg_backlink_a line 16 at assignment
@ -1529,7 +1529,7 @@ update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
ERROR: illegal slotlink beginning with XX
CONTEXT: PL/pgSQL function tg_slotlink_a line 16 at assignment
insert into HSlot values ('HS', 'base.hub1', 1, '');
ERROR: Cannot insert a duplicate key into unique index hslot_name
ERROR: duplicate key violates UNIQUE constraint "hslot_name"
insert into HSlot values ('HS', 'base.hub1', 20, '');
ERROR: no manual manipulation of HSlot
delete from HSlot;

View File

@ -290,7 +290,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey
INSERT INTO PRIMARY_TBL VALUES (1, 'one');
INSERT INTO PRIMARY_TBL VALUES (2, 'two');
INSERT INTO PRIMARY_TBL VALUES (1, 'three');
ERROR: Cannot insert a duplicate key into unique index primary_tbl_pkey
ERROR: duplicate key violates UNIQUE constraint "primary_tbl_pkey"
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
@ -334,7 +334,7 @@ NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
ERROR: Cannot insert a duplicate key into unique index unique_tbl_i_key
ERROR: duplicate key violates UNIQUE constraint "unique_tbl_i_key"
INSERT INTO UNIQUE_TBL VALUES (4, 'four');
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
@ -358,7 +358,7 @@ INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
ERROR: Cannot insert a duplicate key into unique index unique_tbl_i_key
ERROR: duplicate key violates UNIQUE constraint "unique_tbl_i_key"
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
SELECT '' AS five, * FROM UNIQUE_TBL;