1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

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

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