/* otherwise xmin should not be dirty... */
if (TransactionIdIsValid(SnapshotDirty.xmin))
- elog(ERROR, "t_xmin is uncommitted in tuple to be updated");
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("t_xmin is uncommitted in tuple to be updated")));
/*
* If tuple is being updated by other transaction then we
* Some checks on the data we've found
*/
if (residx != nextidx)
- elog(ERROR, "unexpected chunk number %d (expected %d) for toast value %u in %s",
- residx, nextidx,
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("unexpected chunk number %d (expected %d) for toast value %u in %s",
+ residx, nextidx,
+ toast_pointer.va_valueid,
+ RelationGetRelationName(toastrel))));
if (residx < numchunks - 1)
{
if (chunksize != TOAST_MAX_CHUNK_SIZE)
- elog(ERROR, "unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
- chunksize, (int) TOAST_MAX_CHUNK_SIZE,
- residx, numchunks,
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
+ chunksize, (int) TOAST_MAX_CHUNK_SIZE,
+ residx, numchunks,
+ toast_pointer.va_valueid,
+ RelationGetRelationName(toastrel))));
}
else if (residx == numchunks - 1)
{
if ((residx * TOAST_MAX_CHUNK_SIZE + chunksize) != ressize)
- elog(ERROR, "unexpected chunk size %d (expected %d) in final chunk %d for toast value %u in %s",
- chunksize,
- (int) (ressize - residx * TOAST_MAX_CHUNK_SIZE),
- residx,
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("unexpected chunk size %d (expected %d) in final chunk %d for toast value %u in %s",
+ chunksize,
+ (int) (ressize - residx * TOAST_MAX_CHUNK_SIZE),
+ residx,
+ toast_pointer.va_valueid,
+ RelationGetRelationName(toastrel))));
}
else
- elog(ERROR, "unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
- residx,
- 0, numchunks - 1,
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
+ residx,
+ 0, numchunks - 1,
+ toast_pointer.va_valueid,
+ RelationGetRelationName(toastrel))));
/*
* Copy the data into proper place in our result
* Final checks that we successfully fetched the datum
*/
if (nextidx != numchunks)
- elog(ERROR, "missing chunk number %d for toast value %u in %s",
- nextidx,
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg_internal("missing chunk number %d for toast value %u in %s",
+ nextidx,
+ toast_pointer.va_valueid,
+ RelationGetRelationName(toastrel))));
/*
* End scan and close relations
if (sopaque->btpo_prev != origpagenumber)
{
memset(rightpage, 0, BufferGetPageSize(rbuf));
- elog(ERROR, "right sibling's left-link doesn't match: "
- "block %u links to %u instead of expected %u in index \"%s\"",
- oopaque->btpo_next, sopaque->btpo_prev, origpagenumber,
- RelationGetRelationName(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("right sibling's left-link doesn't match: "
+ "block %u links to %u instead of expected %u in index \"%s\"",
+ oopaque->btpo_next, sopaque->btpo_prev, origpagenumber,
+ RelationGetRelationName(rel))));
}
/*
_bt_relbuf(rel, rbuf);
if (pbuf == InvalidBuffer)
- elog(ERROR, "failed to re-find parent key in index \"%s\" for split pages %u/%u",
- RelationGetRelationName(rel), bknum, rbknum);
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("failed to re-find parent key in index \"%s\" for split pages %u/%u",
+ RelationGetRelationName(rel), bknum, rbknum)));
/* Recursively update the parent */
_bt_insertonpg(rel, NULL, pbuf, buf, stack->bts_parent,
stack->bts_btentry = child;
pbuf = _bt_getstackbuf(rel, stack);
if (pbuf == InvalidBuffer)
- elog(ERROR, "failed to re-find parent key in index \"%s\" for deletion target page %u",
- RelationGetRelationName(rel), child);
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("failed to re-find parent key in index \"%s\" for deletion target page %u",
+ RelationGetRelationName(rel), child)));
parent = stack->bts_blkno;
poffset = stack->bts_offset;
itemid = PageGetItemId(page, nextoffset);
itup = (IndexTuple) PageGetItem(page, itemid);
if (BTreeInnerTupleGetDownLink(itup) != rightsib)
- elog(ERROR, "right sibling %u of block %u is not next child %u of block %u in index \"%s\"",
- rightsib, target, BTreeInnerTupleGetDownLink(itup),
- BufferGetBlockNumber(topparent), RelationGetRelationName(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("right sibling %u of block %u is not next child %u of block %u in index \"%s\"",
+ rightsib, target, BTreeInnerTupleGetDownLink(itup),
+ BufferGetBlockNumber(topparent), RelationGetRelationName(rel))));
/*
* Any insert which would have gone on the leaf block will now go to its
target, RelationGetRelationName(rel));
}
if (opaque->btpo_prev != leftsib)
- elog(ERROR, "left link changed unexpectedly in block %u of index \"%s\"",
- target, RelationGetRelationName(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("left link changed unexpectedly in block %u of index \"%s\"",
+ target, RelationGetRelationName(rel))));
if (target == leafblkno)
{
page = BufferGetPage(rbuf);
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
if (opaque->btpo_prev != target)
- elog(ERROR, "right sibling's left-link doesn't match: "
- "block %u links to %u instead of expected %u in index \"%s\"",
- rightsib, opaque->btpo_prev, target,
- RelationGetRelationName(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("right sibling's left-link doesn't match: "
+ "block %u links to %u instead of expected %u in index \"%s\"",
+ rightsib, opaque->btpo_prev, target,
+ RelationGetRelationName(rel))));
rightsib_is_rightmost = P_RIGHTMOST(opaque);
*rightsib_empty = (P_FIRSTDATAKEY(opaque) > PageGetMaxOffsetNumber(page));
if (opaque->btpo.level == level)
break;
if (opaque->btpo.level < level)
- elog(ERROR, "btree level %u not found in index \"%s\"",
- level, RelationGetRelationName(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg_internal("btree level %u not found in index \"%s\"",
+ level, RelationGetRelationName(rel))));
/* Descend to leftmost or rightmost child page */
if (rightmost)