mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Remove Item type
This type is just char * underneath, it provides no real value, no type safety, and just makes the code one level more mysterious. It is more idiomatic to refer to blobs of memory by a combination of void * and size_t, so change it to that. Also, since this type hides the pointerness, we can't apply qualifiers to what is pointed to, which requires some unconstify nonsense. This change allows fixing that. Extension code that uses the Item type can change its code to use void * to be backward compatible. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://www.postgresql.org/message-id/flat/c75cccf5-5709-407b-a36a-2ae6570be766@eisentraut.org
This commit is contained in:
@@ -176,7 +176,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
|
|||||||
brin_can_do_samepage_update(oldbuf, origsz, newsz))
|
brin_can_do_samepage_update(oldbuf, origsz, newsz))
|
||||||
{
|
{
|
||||||
START_CRIT_SECTION();
|
START_CRIT_SECTION();
|
||||||
if (!PageIndexTupleOverwrite(oldpage, oldoff, (Item) unconstify(BrinTuple *, newtup), newsz))
|
if (!PageIndexTupleOverwrite(oldpage, oldoff, newtup, newsz))
|
||||||
elog(ERROR, "failed to replace BRIN tuple");
|
elog(ERROR, "failed to replace BRIN tuple");
|
||||||
MarkBufferDirty(oldbuf);
|
MarkBufferDirty(oldbuf);
|
||||||
|
|
||||||
@@ -250,8 +250,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
|
|||||||
brin_page_init(newpage, BRIN_PAGETYPE_REGULAR);
|
brin_page_init(newpage, BRIN_PAGETYPE_REGULAR);
|
||||||
|
|
||||||
PageIndexTupleDeleteNoCompact(oldpage, oldoff);
|
PageIndexTupleDeleteNoCompact(oldpage, oldoff);
|
||||||
newoff = PageAddItem(newpage, (Item) unconstify(BrinTuple *, newtup), newsz,
|
newoff = PageAddItem(newpage, newtup, newsz, InvalidOffsetNumber, false, false);
|
||||||
InvalidOffsetNumber, false, false);
|
|
||||||
if (newoff == InvalidOffsetNumber)
|
if (newoff == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add BRIN tuple to new page");
|
elog(ERROR, "failed to add BRIN tuple to new page");
|
||||||
MarkBufferDirty(oldbuf);
|
MarkBufferDirty(oldbuf);
|
||||||
@@ -408,8 +407,7 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange,
|
|||||||
START_CRIT_SECTION();
|
START_CRIT_SECTION();
|
||||||
if (extended)
|
if (extended)
|
||||||
brin_page_init(page, BRIN_PAGETYPE_REGULAR);
|
brin_page_init(page, BRIN_PAGETYPE_REGULAR);
|
||||||
off = PageAddItem(page, (Item) tup, itemsz, InvalidOffsetNumber,
|
off = PageAddItem(page, tup, itemsz, InvalidOffsetNumber, false, false);
|
||||||
false, false);
|
|
||||||
if (off == InvalidOffsetNumber)
|
if (off == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add BRIN tuple to new page");
|
elog(ERROR, "failed to add BRIN tuple to new page");
|
||||||
MarkBufferDirty(*buffer);
|
MarkBufferDirty(*buffer);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ brin_xlog_insert_update(XLogReaderState *record,
|
|||||||
if (PageGetMaxOffsetNumber(page) + 1 < offnum)
|
if (PageGetMaxOffsetNumber(page) + 1 < offnum)
|
||||||
elog(PANIC, "brin_xlog_insert_update: invalid max offset number");
|
elog(PANIC, "brin_xlog_insert_update: invalid max offset number");
|
||||||
|
|
||||||
offnum = PageAddItem(page, (Item) tuple, tuplen, offnum, true, false);
|
offnum = PageAddItem(page, tuple, tuplen, offnum, true, false);
|
||||||
if (offnum == InvalidOffsetNumber)
|
if (offnum == InvalidOffsetNumber)
|
||||||
elog(PANIC, "brin_xlog_insert_update: failed to add tuple");
|
elog(PANIC, "brin_xlog_insert_update: failed to add tuple");
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ brin_xlog_samepage_update(XLogReaderState *record)
|
|||||||
|
|
||||||
offnum = xlrec->offnum;
|
offnum = xlrec->offnum;
|
||||||
|
|
||||||
if (!PageIndexTupleOverwrite(page, offnum, (Item) brintuple, tuplen))
|
if (!PageIndexTupleOverwrite(page, offnum, brintuple, tuplen))
|
||||||
elog(PANIC, "brin_xlog_samepage_update: failed to replace tuple");
|
elog(PANIC, "brin_xlog_samepage_update: failed to replace tuple");
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ entryExecPlaceToPage(GinBtree btree, Buffer buf, GinBtreeStack *stack,
|
|||||||
entryPreparePage(btree, page, off, insertData, updateblkno);
|
entryPreparePage(btree, page, off, insertData, updateblkno);
|
||||||
|
|
||||||
placed = PageAddItem(page,
|
placed = PageAddItem(page,
|
||||||
(Item) insertData->entry,
|
insertData->entry,
|
||||||
IndexTupleSize(insertData->entry),
|
IndexTupleSize(insertData->entry),
|
||||||
off, false, false);
|
off, false, false);
|
||||||
if (placed != off)
|
if (placed != off)
|
||||||
@@ -684,7 +684,7 @@ entrySplitPage(GinBtree btree, Buffer origbuf,
|
|||||||
lsize += MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
|
lsize += MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(page, itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"",
|
elog(ERROR, "failed to add item to index page in \"%s\"",
|
||||||
RelationGetRelationName(btree->index));
|
RelationGetRelationName(btree->index));
|
||||||
ptr += MAXALIGN(IndexTupleSize(itup));
|
ptr += MAXALIGN(IndexTupleSize(itup));
|
||||||
@@ -727,12 +727,12 @@ ginEntryFillRoot(GinBtree btree, Page root,
|
|||||||
IndexTuple itup;
|
IndexTuple itup;
|
||||||
|
|
||||||
itup = GinFormInteriorTuple(getRightMostTuple(lpage), lpage, lblkno);
|
itup = GinFormInteriorTuple(getRightMostTuple(lpage), lpage, lblkno);
|
||||||
if (PageAddItem(root, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(root, itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index root page");
|
elog(ERROR, "failed to add item to index root page");
|
||||||
pfree(itup);
|
pfree(itup);
|
||||||
|
|
||||||
itup = GinFormInteriorTuple(getRightMostTuple(rpage), rpage, rblkno);
|
itup = GinFormInteriorTuple(getRightMostTuple(rpage), rpage, rblkno);
|
||||||
if (PageAddItem(root, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(root, itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index root page");
|
elog(ERROR, "failed to add item to index root page");
|
||||||
pfree(itup);
|
pfree(itup);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ writeListPage(Relation index, Buffer buffer,
|
|||||||
ptr += this_size;
|
ptr += this_size;
|
||||||
size += this_size;
|
size += this_size;
|
||||||
|
|
||||||
l = PageAddItem(page, (Item) tuples[i], this_size, off, false, false);
|
l = PageAddItem(page, tuples[i], this_size, off, false, false);
|
||||||
|
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"",
|
elog(ERROR, "failed to add item to index page in \"%s\"",
|
||||||
@@ -384,7 +384,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
|
|||||||
for (i = 0; i < collector->ntuples; i++)
|
for (i = 0; i < collector->ntuples; i++)
|
||||||
{
|
{
|
||||||
tupsize = IndexTupleSize(collector->tuples[i]);
|
tupsize = IndexTupleSize(collector->tuples[i]);
|
||||||
l = PageAddItem(page, (Item) collector->tuples[i], tupsize, off, false, false);
|
l = PageAddItem(page, collector->tuples[i], tupsize, off, false, false);
|
||||||
|
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"",
|
elog(ERROR, "failed to add item to index page in \"%s\"",
|
||||||
|
|||||||
@@ -547,7 +547,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
|
|||||||
pfree(plist);
|
pfree(plist);
|
||||||
PageIndexTupleDelete(tmppage, i);
|
PageIndexTupleDelete(tmppage, i);
|
||||||
|
|
||||||
if (PageAddItem(tmppage, (Item) itup, IndexTupleSize(itup), i, false, false) != i)
|
if (PageAddItem(tmppage, itup, IndexTupleSize(itup), i, false, false) != i)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"",
|
elog(ERROR, "failed to add item to index page in \"%s\"",
|
||||||
RelationGetRelationName(gvs->index));
|
RelationGetRelationName(gvs->index));
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ ginRedoInsertEntry(Buffer buffer, bool isLeaf, BlockNumber rightblkno, void *rda
|
|||||||
|
|
||||||
itup = &data->tuple;
|
itup = &data->tuple;
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), offset, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(page, itup, IndexTupleSize(itup), offset, false, false) == InvalidOffsetNumber)
|
||||||
{
|
{
|
||||||
RelFileLocator locator;
|
RelFileLocator locator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
@@ -573,8 +573,7 @@ ginRedoUpdateMetapage(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
tupsize = IndexTupleSize(tuples);
|
tupsize = IndexTupleSize(tuples);
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) tuples, tupsize, off,
|
if (PageAddItem(page, tuples, tupsize, off, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add item to index page");
|
elog(ERROR, "failed to add item to index page");
|
||||||
|
|
||||||
tuples = (IndexTuple) (((char *) tuples) + tupsize);
|
tuples = (IndexTuple) (((char *) tuples) + tupsize);
|
||||||
@@ -654,7 +653,7 @@ ginRedoInsertListPage(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
tupsize = IndexTupleSize(tuples);
|
tupsize = IndexTupleSize(tuples);
|
||||||
|
|
||||||
l = PageAddItem(page, (Item) tuples, tupsize, off, false, false);
|
l = PageAddItem(page, tuples, tupsize, off, false, false);
|
||||||
|
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page");
|
elog(ERROR, "failed to add item to index page");
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
|||||||
{
|
{
|
||||||
IndexTuple thistup = (IndexTuple) data;
|
IndexTuple thistup = (IndexTuple) data;
|
||||||
|
|
||||||
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize(thistup), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(ptr->page, data, IndexTupleSize(thistup), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(rel));
|
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(rel));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -551,8 +551,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
|||||||
if (ntup == 1)
|
if (ntup == 1)
|
||||||
{
|
{
|
||||||
/* One-for-one replacement, so use PageIndexTupleOverwrite */
|
/* One-for-one replacement, so use PageIndexTupleOverwrite */
|
||||||
if (!PageIndexTupleOverwrite(page, oldoffnum, (Item) *itup,
|
if (!PageIndexTupleOverwrite(page, oldoffnum, *itup, IndexTupleSize(*itup)))
|
||||||
IndexTupleSize(*itup)))
|
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"",
|
elog(ERROR, "failed to add item to index page in \"%s\"",
|
||||||
RelationGetRelationName(rel));
|
RelationGetRelationName(rel));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ gist_indexsortbuild_levelstate_flush(GISTBuildState *state,
|
|||||||
{
|
{
|
||||||
IndexTuple thistup = (IndexTuple) data;
|
IndexTuple thistup = (IndexTuple) data;
|
||||||
|
|
||||||
if (PageAddItem(target, (Item) data, IndexTupleSize(thistup), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(target, data, IndexTupleSize(thistup), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(state->indexrel));
|
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(state->indexrel));
|
||||||
|
|
||||||
data += IndexTupleSize(thistup);
|
data += IndexTupleSize(thistup);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
|
|||||||
Size sz = IndexTupleSize(itup[i]);
|
Size sz = IndexTupleSize(itup[i]);
|
||||||
OffsetNumber l;
|
OffsetNumber l;
|
||||||
|
|
||||||
l = PageAddItem(page, (Item) itup[i], sz, off, false, false);
|
l = PageAddItem(page, itup[i], sz, off, false, false);
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to GiST index page, item %d out of %d, size %d bytes",
|
elog(ERROR, "failed to add item to GiST index page, item %d out of %d, size %d bytes",
|
||||||
i, len, (int) sz);
|
i, len, (int) sz);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
|
|||||||
data += sizeof(OffsetNumber);
|
data += sizeof(OffsetNumber);
|
||||||
itup = (IndexTuple) data;
|
itup = (IndexTuple) data;
|
||||||
itupsize = IndexTupleSize(itup);
|
itupsize = IndexTupleSize(itup);
|
||||||
if (!PageIndexTupleOverwrite(page, offnum, (Item) itup, itupsize))
|
if (!PageIndexTupleOverwrite(page, offnum, itup, itupsize))
|
||||||
elog(ERROR, "failed to add item to GiST index page, size %d bytes",
|
elog(ERROR, "failed to add item to GiST index page, size %d bytes",
|
||||||
(int) itupsize);
|
(int) itupsize);
|
||||||
data += itupsize;
|
data += itupsize;
|
||||||
@@ -133,7 +133,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
|
|||||||
|
|
||||||
data += sz;
|
data += sz;
|
||||||
|
|
||||||
l = PageAddItem(page, (Item) itup, sz, off, false, false);
|
l = PageAddItem(page, itup, sz, off, false, false);
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add item to GiST index page, size %d bytes",
|
elog(ERROR, "failed to add item to GiST index page, size %d bytes",
|
||||||
(int) sz);
|
(int) sz);
|
||||||
|
|||||||
@@ -137,8 +137,7 @@ hash_xlog_insert(XLogReaderState *record)
|
|||||||
|
|
||||||
page = BufferGetPage(buffer);
|
page = BufferGetPage(buffer);
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) datapos, datalen, xlrec->offnum,
|
if (PageAddItem(page, datapos, datalen, xlrec->offnum, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "hash_xlog_insert: failed to add item");
|
elog(PANIC, "hash_xlog_insert: failed to add item");
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
@@ -557,7 +556,7 @@ hash_xlog_move_page_contents(XLogReaderState *record)
|
|||||||
|
|
||||||
data += itemsz;
|
data += itemsz;
|
||||||
|
|
||||||
l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
|
l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes",
|
elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes",
|
||||||
(int) itemsz);
|
(int) itemsz);
|
||||||
@@ -689,7 +688,7 @@ hash_xlog_squeeze_page(XLogReaderState *record)
|
|||||||
|
|
||||||
data += itemsz;
|
data += itemsz;
|
||||||
|
|
||||||
l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
|
l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
|
||||||
if (l == InvalidOffsetNumber)
|
if (l == InvalidOffsetNumber)
|
||||||
elog(ERROR, "hash_xlog_squeeze_page: failed to add item to hash index page, size %d bytes",
|
elog(ERROR, "hash_xlog_squeeze_page: failed to add item to hash index page, size %d bytes",
|
||||||
(int) itemsz);
|
(int) itemsz);
|
||||||
|
|||||||
@@ -310,10 +310,8 @@ _hash_pgaddtup(Relation rel, Buffer buf, Size itemsize, IndexTuple itup,
|
|||||||
itup_off = _hash_binsearch(page, hashkey);
|
itup_off = _hash_binsearch(page, hashkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, itemsize, itup_off, false, false)
|
if (PageAddItem(page, itup, itemsize, itup_off, false, false) == InvalidOffsetNumber)
|
||||||
== InvalidOffsetNumber)
|
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(rel));
|
||||||
elog(ERROR, "failed to add index item to \"%s\"",
|
|
||||||
RelationGetRelationName(rel));
|
|
||||||
|
|
||||||
return itup_off;
|
return itup_off;
|
||||||
}
|
}
|
||||||
@@ -352,10 +350,8 @@ _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups,
|
|||||||
|
|
||||||
itup_offsets[i] = itup_off;
|
itup_offsets[i] = itup_off;
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itups[i], itemsize, itup_off, false, false)
|
if (PageAddItem(page, itups[i], itemsize, itup_off, false, false) == InvalidOffsetNumber)
|
||||||
== InvalidOffsetNumber)
|
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(rel));
|
||||||
elog(ERROR, "failed to add index item to \"%s\"",
|
|
||||||
RelationGetRelationName(rel));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -572,8 +572,7 @@ heap_xlog_insert(XLogReaderState *record)
|
|||||||
HeapTupleHeaderSetCmin(htup, FirstCommandId);
|
HeapTupleHeaderSetCmin(htup, FirstCommandId);
|
||||||
htup->t_ctid = target_tid;
|
htup->t_ctid = target_tid;
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) htup, newlen, xlrec->offnum,
|
if (PageAddItem(page, htup, newlen, xlrec->offnum, true, true) == InvalidOffsetNumber)
|
||||||
true, true) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add tuple");
|
elog(PANIC, "failed to add tuple");
|
||||||
|
|
||||||
freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */
|
freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */
|
||||||
@@ -713,7 +712,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
|||||||
ItemPointerSetBlockNumber(&htup->t_ctid, blkno);
|
ItemPointerSetBlockNumber(&htup->t_ctid, blkno);
|
||||||
ItemPointerSetOffsetNumber(&htup->t_ctid, offnum);
|
ItemPointerSetOffsetNumber(&htup->t_ctid, offnum);
|
||||||
|
|
||||||
offnum = PageAddItem(page, (Item) htup, newlen, offnum, true, true);
|
offnum = PageAddItem(page, htup, newlen, offnum, true, true);
|
||||||
if (offnum == InvalidOffsetNumber)
|
if (offnum == InvalidOffsetNumber)
|
||||||
elog(PANIC, "failed to add tuple");
|
elog(PANIC, "failed to add tuple");
|
||||||
}
|
}
|
||||||
@@ -1034,7 +1033,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
/* Make sure there is no forward chain link in t_ctid */
|
/* Make sure there is no forward chain link in t_ctid */
|
||||||
htup->t_ctid = newtid;
|
htup->t_ctid = newtid;
|
||||||
|
|
||||||
offnum = PageAddItem(page, (Item) htup, newlen, offnum, true, true);
|
offnum = PageAddItem(page, htup, newlen, offnum, true, true);
|
||||||
if (offnum == InvalidOffsetNumber)
|
if (offnum == InvalidOffsetNumber)
|
||||||
elog(PANIC, "failed to add tuple");
|
elog(PANIC, "failed to add tuple");
|
||||||
|
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ RelationPutHeapTuple(Relation relation,
|
|||||||
/* Add the tuple to the page */
|
/* Add the tuple to the page */
|
||||||
pageHeader = BufferGetPage(buffer);
|
pageHeader = BufferGetPage(buffer);
|
||||||
|
|
||||||
offnum = PageAddItem(pageHeader, (Item) tuple->t_data,
|
offnum = PageAddItem(pageHeader, tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, true);
|
||||||
tuple->t_len, InvalidOffsetNumber, false, true);
|
|
||||||
|
|
||||||
if (offnum == InvalidOffsetNumber)
|
if (offnum == InvalidOffsetNumber)
|
||||||
elog(PANIC, "failed to add tuple to page");
|
elog(PANIC, "failed to add tuple to page");
|
||||||
|
|
||||||
|
|||||||
@@ -673,8 +673,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* And now we can insert the tuple into the page */
|
/* And now we can insert the tuple into the page */
|
||||||
newoff = PageAddItem(page, (Item) heaptup->t_data, heaptup->t_len,
|
newoff = PageAddItem(page, heaptup->t_data, heaptup->t_len, InvalidOffsetNumber, false, true);
|
||||||
InvalidOffsetNumber, false, true);
|
|
||||||
if (newoff == InvalidOffsetNumber)
|
if (newoff == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add tuple");
|
elog(ERROR, "failed to add tuple");
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ _bt_dedup_pass(Relation rel, Buffer buf, IndexTuple newitem, Size newitemsz,
|
|||||||
Size hitemsz = ItemIdGetLength(hitemid);
|
Size hitemsz = ItemIdGetLength(hitemid);
|
||||||
IndexTuple hitem = (IndexTuple) PageGetItem(page, hitemid);
|
IndexTuple hitem = (IndexTuple) PageGetItem(page, hitemid);
|
||||||
|
|
||||||
if (PageAddItem(newpage, (Item) hitem, hitemsz, P_HIKEY,
|
if (PageAddItem(newpage, hitem, hitemsz, P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "deduplication failed to add highkey");
|
elog(ERROR, "deduplication failed to add highkey");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,8 +569,7 @@ _bt_dedup_finish_pending(Page newpage, BTDedupState state)
|
|||||||
tuplesz = IndexTupleSize(state->base);
|
tuplesz = IndexTupleSize(state->base);
|
||||||
Assert(tuplesz == MAXALIGN(IndexTupleSize(state->base)));
|
Assert(tuplesz == MAXALIGN(IndexTupleSize(state->base)));
|
||||||
Assert(tuplesz <= BTMaxItemSize);
|
Assert(tuplesz <= BTMaxItemSize);
|
||||||
if (PageAddItem(newpage, (Item) state->base, tuplesz, tupoff,
|
if (PageAddItem(newpage, state->base, tuplesz, tupoff, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "deduplication failed to add tuple to page");
|
elog(ERROR, "deduplication failed to add tuple to page");
|
||||||
|
|
||||||
spacesaving = 0;
|
spacesaving = 0;
|
||||||
@@ -590,8 +588,7 @@ _bt_dedup_finish_pending(Page newpage, BTDedupState state)
|
|||||||
|
|
||||||
Assert(tuplesz == MAXALIGN(IndexTupleSize(final)));
|
Assert(tuplesz == MAXALIGN(IndexTupleSize(final)));
|
||||||
Assert(tuplesz <= BTMaxItemSize);
|
Assert(tuplesz <= BTMaxItemSize);
|
||||||
if (PageAddItem(newpage, (Item) final, tuplesz, tupoff, false,
|
if (PageAddItem(newpage, final, tuplesz, tupoff, false, false) == InvalidOffsetNumber)
|
||||||
false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "deduplication failed to add tuple to page");
|
elog(ERROR, "deduplication failed to add tuple to page");
|
||||||
|
|
||||||
pfree(final);
|
pfree(final);
|
||||||
|
|||||||
@@ -1278,8 +1278,7 @@ _bt_insertonpg(Relation rel,
|
|||||||
if (postingoff != 0)
|
if (postingoff != 0)
|
||||||
memcpy(oposting, nposting, MAXALIGN(IndexTupleSize(nposting)));
|
memcpy(oposting, nposting, MAXALIGN(IndexTupleSize(nposting)));
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, itemsz, newitemoff, false,
|
if (PageAddItem(page, itup, itemsz, newitemoff, false, false) == InvalidOffsetNumber)
|
||||||
false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add new item to block %u in index \"%s\"",
|
elog(PANIC, "failed to add new item to block %u in index \"%s\"",
|
||||||
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
||||||
|
|
||||||
@@ -1700,8 +1699,7 @@ _bt_split(Relation rel, Relation heaprel, BTScanInsert itup_key, Buffer buf,
|
|||||||
Assert(BTreeTupleGetNAtts(lefthighkey, rel) <=
|
Assert(BTreeTupleGetNAtts(lefthighkey, rel) <=
|
||||||
IndexRelationGetNumberOfKeyAttributes(rel));
|
IndexRelationGetNumberOfKeyAttributes(rel));
|
||||||
Assert(itemsz == MAXALIGN(IndexTupleSize(lefthighkey)));
|
Assert(itemsz == MAXALIGN(IndexTupleSize(lefthighkey)));
|
||||||
if (PageAddItem(leftpage, (Item) lefthighkey, itemsz, afterleftoff, false,
|
if (PageAddItem(leftpage, lefthighkey, itemsz, afterleftoff, false, false) == InvalidOffsetNumber)
|
||||||
false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add high key to the left sibling"
|
elog(ERROR, "failed to add high key to the left sibling"
|
||||||
" while splitting block %u of index \"%s\"",
|
" while splitting block %u of index \"%s\"",
|
||||||
origpagenumber, RelationGetRelationName(rel));
|
origpagenumber, RelationGetRelationName(rel));
|
||||||
@@ -1771,8 +1769,7 @@ _bt_split(Relation rel, Relation heaprel, BTScanInsert itup_key, Buffer buf,
|
|||||||
Assert(BTreeTupleGetNAtts(righthighkey, rel) > 0);
|
Assert(BTreeTupleGetNAtts(righthighkey, rel) > 0);
|
||||||
Assert(BTreeTupleGetNAtts(righthighkey, rel) <=
|
Assert(BTreeTupleGetNAtts(righthighkey, rel) <=
|
||||||
IndexRelationGetNumberOfKeyAttributes(rel));
|
IndexRelationGetNumberOfKeyAttributes(rel));
|
||||||
if (PageAddItem(rightpage, (Item) righthighkey, itemsz, afterrightoff,
|
if (PageAddItem(rightpage, righthighkey, itemsz, afterrightoff, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
{
|
{
|
||||||
elog(ERROR, "failed to add high key to the right sibling"
|
elog(ERROR, "failed to add high key to the right sibling"
|
||||||
" while splitting block %u of index \"%s\"",
|
" while splitting block %u of index \"%s\"",
|
||||||
@@ -2537,8 +2534,7 @@ _bt_newlevel(Relation rel, Relation heaprel, Buffer lbuf, Buffer rbuf)
|
|||||||
* benefit of _bt_restore_page().
|
* benefit of _bt_restore_page().
|
||||||
*/
|
*/
|
||||||
Assert(BTreeTupleGetNAtts(left_item, rel) == 0);
|
Assert(BTreeTupleGetNAtts(left_item, rel) == 0);
|
||||||
if (PageAddItem(rootpage, (Item) left_item, left_item_sz, P_HIKEY,
|
if (PageAddItem(rootpage, left_item, left_item_sz, P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add leftkey to new root page"
|
elog(PANIC, "failed to add leftkey to new root page"
|
||||||
" while splitting block %u of index \"%s\"",
|
" while splitting block %u of index \"%s\"",
|
||||||
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
|
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
|
||||||
@@ -2549,8 +2545,7 @@ _bt_newlevel(Relation rel, Relation heaprel, Buffer lbuf, Buffer rbuf)
|
|||||||
Assert(BTreeTupleGetNAtts(right_item, rel) > 0);
|
Assert(BTreeTupleGetNAtts(right_item, rel) > 0);
|
||||||
Assert(BTreeTupleGetNAtts(right_item, rel) <=
|
Assert(BTreeTupleGetNAtts(right_item, rel) <=
|
||||||
IndexRelationGetNumberOfKeyAttributes(rel));
|
IndexRelationGetNumberOfKeyAttributes(rel));
|
||||||
if (PageAddItem(rootpage, (Item) right_item, right_item_sz, P_FIRSTKEY,
|
if (PageAddItem(rootpage, right_item, right_item_sz, P_FIRSTKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add rightkey to new root page"
|
elog(PANIC, "failed to add rightkey to new root page"
|
||||||
" while splitting block %u of index \"%s\"",
|
" while splitting block %u of index \"%s\"",
|
||||||
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
|
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
|
||||||
@@ -2654,8 +2649,7 @@ _bt_pgaddtup(Page page,
|
|||||||
itemsize = sizeof(IndexTupleData);
|
itemsize = sizeof(IndexTupleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(PageAddItem(page, (Item) itup, itemsize, itup_off, false,
|
if (unlikely(PageAddItem(page, itup, itemsize, itup_off, false, false) == InvalidOffsetNumber))
|
||||||
false) == InvalidOffsetNumber))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1194,8 +1194,7 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
|
|||||||
|
|
||||||
itup = updatable[i]->itup;
|
itup = updatable[i]->itup;
|
||||||
itemsz = MAXALIGN(IndexTupleSize(itup));
|
itemsz = MAXALIGN(IndexTupleSize(itup));
|
||||||
if (!PageIndexTupleOverwrite(page, updatedoffset, (Item) itup,
|
if (!PageIndexTupleOverwrite(page, updatedoffset, itup, itemsz))
|
||||||
itemsz))
|
|
||||||
elog(PANIC, "failed to update partially dead item in block %u of index \"%s\"",
|
elog(PANIC, "failed to update partially dead item in block %u of index \"%s\"",
|
||||||
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
||||||
}
|
}
|
||||||
@@ -1314,8 +1313,7 @@ _bt_delitems_delete(Relation rel, Buffer buf,
|
|||||||
|
|
||||||
itup = updatable[i]->itup;
|
itup = updatable[i]->itup;
|
||||||
itemsz = MAXALIGN(IndexTupleSize(itup));
|
itemsz = MAXALIGN(IndexTupleSize(itup));
|
||||||
if (!PageIndexTupleOverwrite(page, updatedoffset, (Item) itup,
|
if (!PageIndexTupleOverwrite(page, updatedoffset, itup, itemsz))
|
||||||
itemsz))
|
|
||||||
elog(PANIC, "failed to update partially dead item in block %u of index \"%s\"",
|
elog(PANIC, "failed to update partially dead item in block %u of index \"%s\"",
|
||||||
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
|
||||||
}
|
}
|
||||||
@@ -2239,8 +2237,7 @@ _bt_mark_page_halfdead(Relation rel, Relation heaprel, Buffer leafbuf,
|
|||||||
else
|
else
|
||||||
BTreeTupleSetTopParent(&trunctuple, InvalidBlockNumber);
|
BTreeTupleSetTopParent(&trunctuple, InvalidBlockNumber);
|
||||||
|
|
||||||
if (!PageIndexTupleOverwrite(page, P_HIKEY, (Item) &trunctuple,
|
if (!PageIndexTupleOverwrite(page, P_HIKEY, &trunctuple, IndexTupleSize(&trunctuple)))
|
||||||
IndexTupleSize(&trunctuple)))
|
|
||||||
elog(ERROR, "could not overwrite high key in half-dead page");
|
elog(ERROR, "could not overwrite high key in half-dead page");
|
||||||
|
|
||||||
/* Must mark buffers dirty before XLogInsert */
|
/* Must mark buffers dirty before XLogInsert */
|
||||||
|
|||||||
@@ -731,8 +731,7 @@ _bt_sortaddtup(Page page,
|
|||||||
itemsize = sizeof(IndexTupleData);
|
itemsize = sizeof(IndexTupleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, itemsize, itup_off,
|
if (PageAddItem(page, itup, itemsize, itup_off, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add item to the index page");
|
elog(ERROR, "failed to add item to the index page");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,8 +933,7 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup,
|
|||||||
Assert(IndexTupleSize(oitup) > last_truncextra);
|
Assert(IndexTupleSize(oitup) > last_truncextra);
|
||||||
truncated = _bt_truncate(wstate->index, lastleft, oitup,
|
truncated = _bt_truncate(wstate->index, lastleft, oitup,
|
||||||
wstate->inskey);
|
wstate->inskey);
|
||||||
if (!PageIndexTupleOverwrite(opage, P_HIKEY, (Item) truncated,
|
if (!PageIndexTupleOverwrite(opage, P_HIKEY, truncated, IndexTupleSize(truncated)))
|
||||||
IndexTupleSize(truncated)))
|
|
||||||
elog(ERROR, "failed to add high key to the index page");
|
elog(ERROR, "failed to add high key to the index page");
|
||||||
pfree(truncated);
|
pfree(truncated);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ _bt_restore_page(Page page, char *from, int len)
|
|||||||
IndexTupleData itupdata;
|
IndexTupleData itupdata;
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
char *end = from + len;
|
char *end = from + len;
|
||||||
Item items[MaxIndexTuplesPerPage];
|
void *items[MaxIndexTuplesPerPage];
|
||||||
uint16 itemsizes[MaxIndexTuplesPerPage];
|
uint16 itemsizes[MaxIndexTuplesPerPage];
|
||||||
int i;
|
int i;
|
||||||
int nitems;
|
int nitems;
|
||||||
@@ -53,16 +53,15 @@ _bt_restore_page(Page page, char *from, int len)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* As we step through the items, 'from' won't always be properly
|
* As we step through the items, 'from' won't always be properly
|
||||||
* aligned, so we need to use memcpy(). Further, we use Item (which
|
* aligned, so we need to use memcpy(). Further, we use void * here
|
||||||
* is just a char*) here for our items array for the same reason;
|
* for our items array for the same reason; wouldn't want the compiler
|
||||||
* wouldn't want the compiler or anyone thinking that an item is
|
* or anyone thinking that an item is aligned when it isn't.
|
||||||
* aligned when it isn't.
|
|
||||||
*/
|
*/
|
||||||
memcpy(&itupdata, from, sizeof(IndexTupleData));
|
memcpy(&itupdata, from, sizeof(IndexTupleData));
|
||||||
itemsz = IndexTupleSize(&itupdata);
|
itemsz = IndexTupleSize(&itupdata);
|
||||||
itemsz = MAXALIGN(itemsz);
|
itemsz = MAXALIGN(itemsz);
|
||||||
|
|
||||||
items[i] = (Item) from;
|
items[i] = from;
|
||||||
itemsizes[i] = itemsz;
|
itemsizes[i] = itemsz;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
@@ -72,8 +71,7 @@ _bt_restore_page(Page page, char *from, int len)
|
|||||||
|
|
||||||
for (i = nitems - 1; i >= 0; i--)
|
for (i = nitems - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (PageAddItem(page, items[i], itemsizes[i], nitems - i,
|
if (PageAddItem(page, items[i], itemsizes[i], nitems - i, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "_bt_restore_page: cannot add item to page");
|
elog(PANIC, "_bt_restore_page: cannot add item to page");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,8 +184,7 @@ btree_xlog_insert(bool isleaf, bool ismeta, bool posting,
|
|||||||
if (!posting)
|
if (!posting)
|
||||||
{
|
{
|
||||||
/* Simple retail insertion */
|
/* Simple retail insertion */
|
||||||
if (PageAddItem(page, (Item) datapos, datalen, xlrec->offnum,
|
if (PageAddItem(page, datapos, datalen, xlrec->offnum, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add new item");
|
elog(PANIC, "failed to add new item");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -225,8 +222,7 @@ btree_xlog_insert(bool isleaf, bool ismeta, bool posting,
|
|||||||
|
|
||||||
/* Insert "final" new item (not orignewitem from WAL stream) */
|
/* Insert "final" new item (not orignewitem from WAL stream) */
|
||||||
Assert(IndexTupleSize(newitem) == datalen);
|
Assert(IndexTupleSize(newitem) == datalen);
|
||||||
if (PageAddItem(page, (Item) newitem, datalen, xlrec->offnum,
|
if (PageAddItem(page, newitem, datalen, xlrec->offnum, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "failed to add posting split new item");
|
elog(PANIC, "failed to add posting split new item");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,8 +364,7 @@ btree_xlog_split(bool newitemonleft, XLogReaderState *record)
|
|||||||
|
|
||||||
/* Add high key tuple from WAL record to temp page */
|
/* Add high key tuple from WAL record to temp page */
|
||||||
leftoff = P_HIKEY;
|
leftoff = P_HIKEY;
|
||||||
if (PageAddItem(leftpage, (Item) left_hikey, left_hikeysz, P_HIKEY,
|
if (PageAddItem(leftpage, left_hikey, left_hikeysz, P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add high key to left page after split");
|
elog(ERROR, "failed to add high key to left page after split");
|
||||||
leftoff = OffsetNumberNext(leftoff);
|
leftoff = OffsetNumberNext(leftoff);
|
||||||
|
|
||||||
@@ -384,9 +379,7 @@ btree_xlog_split(bool newitemonleft, XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
Assert(newitemonleft ||
|
Assert(newitemonleft ||
|
||||||
xlrec->firstrightoff == xlrec->newitemoff);
|
xlrec->firstrightoff == xlrec->newitemoff);
|
||||||
if (PageAddItem(leftpage, (Item) nposting,
|
if (PageAddItem(leftpage, nposting, MAXALIGN(IndexTupleSize(nposting)), leftoff, false, false) == InvalidOffsetNumber)
|
||||||
MAXALIGN(IndexTupleSize(nposting)), leftoff,
|
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add new posting list item to left page after split");
|
elog(ERROR, "failed to add new posting list item to left page after split");
|
||||||
leftoff = OffsetNumberNext(leftoff);
|
leftoff = OffsetNumberNext(leftoff);
|
||||||
continue; /* don't insert oposting */
|
continue; /* don't insert oposting */
|
||||||
@@ -395,8 +388,7 @@ btree_xlog_split(bool newitemonleft, XLogReaderState *record)
|
|||||||
/* add the new item if it was inserted on left page */
|
/* add the new item if it was inserted on left page */
|
||||||
else if (newitemonleft && off == xlrec->newitemoff)
|
else if (newitemonleft && off == xlrec->newitemoff)
|
||||||
{
|
{
|
||||||
if (PageAddItem(leftpage, (Item) newitem, newitemsz, leftoff,
|
if (PageAddItem(leftpage, newitem, newitemsz, leftoff, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add new item to left page after split");
|
elog(ERROR, "failed to add new item to left page after split");
|
||||||
leftoff = OffsetNumberNext(leftoff);
|
leftoff = OffsetNumberNext(leftoff);
|
||||||
}
|
}
|
||||||
@@ -404,8 +396,7 @@ btree_xlog_split(bool newitemonleft, XLogReaderState *record)
|
|||||||
itemid = PageGetItemId(origpage, off);
|
itemid = PageGetItemId(origpage, off);
|
||||||
itemsz = ItemIdGetLength(itemid);
|
itemsz = ItemIdGetLength(itemid);
|
||||||
item = (IndexTuple) PageGetItem(origpage, itemid);
|
item = (IndexTuple) PageGetItem(origpage, itemid);
|
||||||
if (PageAddItem(leftpage, (Item) item, itemsz, leftoff,
|
if (PageAddItem(leftpage, item, itemsz, leftoff, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add old item to left page after split");
|
elog(ERROR, "failed to add old item to left page after split");
|
||||||
leftoff = OffsetNumberNext(leftoff);
|
leftoff = OffsetNumberNext(leftoff);
|
||||||
}
|
}
|
||||||
@@ -413,8 +404,7 @@ btree_xlog_split(bool newitemonleft, XLogReaderState *record)
|
|||||||
/* cope with possibility that newitem goes at the end */
|
/* cope with possibility that newitem goes at the end */
|
||||||
if (newitemonleft && off == xlrec->newitemoff)
|
if (newitemonleft && off == xlrec->newitemoff)
|
||||||
{
|
{
|
||||||
if (PageAddItem(leftpage, (Item) newitem, newitemsz, leftoff,
|
if (PageAddItem(leftpage, newitem, newitemsz, leftoff, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "failed to add new item to left page after split");
|
elog(ERROR, "failed to add new item to left page after split");
|
||||||
leftoff = OffsetNumberNext(leftoff);
|
leftoff = OffsetNumberNext(leftoff);
|
||||||
}
|
}
|
||||||
@@ -503,8 +493,7 @@ btree_xlog_dedup(XLogReaderState *record)
|
|||||||
Size itemsz = ItemIdGetLength(itemid);
|
Size itemsz = ItemIdGetLength(itemid);
|
||||||
IndexTuple item = (IndexTuple) PageGetItem(page, itemid);
|
IndexTuple item = (IndexTuple) PageGetItem(page, itemid);
|
||||||
|
|
||||||
if (PageAddItem(newpage, (Item) item, itemsz, P_HIKEY,
|
if (PageAddItem(newpage, item, itemsz, P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "deduplication failed to add highkey");
|
elog(ERROR, "deduplication failed to add highkey");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,8 +569,7 @@ btree_xlog_updates(Page page, OffsetNumber *updatedoffsets,
|
|||||||
|
|
||||||
/* Overwrite updated version of tuple */
|
/* Overwrite updated version of tuple */
|
||||||
itemsz = MAXALIGN(IndexTupleSize(vacposting->itup));
|
itemsz = MAXALIGN(IndexTupleSize(vacposting->itup));
|
||||||
if (!PageIndexTupleOverwrite(page, updatedoffsets[i],
|
if (!PageIndexTupleOverwrite(page, updatedoffsets[i], vacposting->itup, itemsz))
|
||||||
(Item) vacposting->itup, itemsz))
|
|
||||||
elog(PANIC, "failed to update partially dead item");
|
elog(PANIC, "failed to update partially dead item");
|
||||||
|
|
||||||
pfree(vacposting->itup);
|
pfree(vacposting->itup);
|
||||||
@@ -788,8 +776,7 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record)
|
|||||||
trunctuple.t_info = sizeof(IndexTupleData);
|
trunctuple.t_info = sizeof(IndexTupleData);
|
||||||
BTreeTupleSetTopParent(&trunctuple, xlrec->topparent);
|
BTreeTupleSetTopParent(&trunctuple, xlrec->topparent);
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) &trunctuple, sizeof(IndexTupleData), P_HIKEY,
|
if (PageAddItem(page, &trunctuple, sizeof(IndexTupleData), P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "could not add dummy high key to half-dead page");
|
elog(ERROR, "could not add dummy high key to half-dead page");
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
@@ -923,8 +910,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
|
|||||||
trunctuple.t_info = sizeof(IndexTupleData);
|
trunctuple.t_info = sizeof(IndexTupleData);
|
||||||
BTreeTupleSetTopParent(&trunctuple, xlrec->leaftopparent);
|
BTreeTupleSetTopParent(&trunctuple, xlrec->leaftopparent);
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) &trunctuple, sizeof(IndexTupleData), P_HIKEY,
|
if (PageAddItem(page, &trunctuple, sizeof(IndexTupleData), P_HIKEY, false, false) == InvalidOffsetNumber)
|
||||||
false, false) == InvalidOffsetNumber)
|
|
||||||
elog(ERROR, "could not add dummy high key to half-dead page");
|
elog(ERROR, "could not add dummy high key to half-dead page");
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
|
|||||||
@@ -165,8 +165,7 @@ spgPageIndexMultiDelete(SpGistState *state, Page page,
|
|||||||
if (tuple == NULL || tuple->tupstate != tupstate)
|
if (tuple == NULL || tuple->tupstate != tupstate)
|
||||||
tuple = spgFormDeadTuple(state, tupstate, blkno, offnum);
|
tuple = spgFormDeadTuple(state, tupstate, blkno, offnum);
|
||||||
|
|
||||||
if (PageAddItem(page, (Item) tuple, tuple->size,
|
if (PageAddItem(page, tuple, tuple->size, itemno, false, false) != itemno)
|
||||||
itemno, false, false) != itemno)
|
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
tuple->size);
|
tuple->size);
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ addLeafTuple(Relation index, SpGistState *state, SpGistLeafTuple leafTuple,
|
|||||||
/* Tuple is not part of a chain */
|
/* Tuple is not part of a chain */
|
||||||
SGLT_SET_NEXTOFFSET(leafTuple, InvalidOffsetNumber);
|
SGLT_SET_NEXTOFFSET(leafTuple, InvalidOffsetNumber);
|
||||||
current->offnum = SpGistPageAddNewItem(state, current->page,
|
current->offnum = SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) leafTuple, leafTuple->size,
|
leafTuple, leafTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
xlrec.offnumLeaf = current->offnum;
|
xlrec.offnumLeaf = current->offnum;
|
||||||
@@ -255,7 +254,7 @@ addLeafTuple(Relation index, SpGistState *state, SpGistLeafTuple leafTuple,
|
|||||||
{
|
{
|
||||||
SGLT_SET_NEXTOFFSET(leafTuple, SGLT_GET_NEXTOFFSET(head));
|
SGLT_SET_NEXTOFFSET(leafTuple, SGLT_GET_NEXTOFFSET(head));
|
||||||
offnum = SpGistPageAddNewItem(state, current->page,
|
offnum = SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) leafTuple, leafTuple->size,
|
leafTuple, leafTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -274,7 +273,7 @@ addLeafTuple(Relation index, SpGistState *state, SpGistLeafTuple leafTuple,
|
|||||||
SGLT_SET_NEXTOFFSET(leafTuple, InvalidOffsetNumber);
|
SGLT_SET_NEXTOFFSET(leafTuple, InvalidOffsetNumber);
|
||||||
PageIndexTupleDelete(current->page, current->offnum);
|
PageIndexTupleDelete(current->page, current->offnum);
|
||||||
if (PageAddItem(current->page,
|
if (PageAddItem(current->page,
|
||||||
(Item) leafTuple, leafTuple->size,
|
leafTuple, leafTuple->size,
|
||||||
current->offnum, false, false) != current->offnum)
|
current->offnum, false, false) != current->offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
leafTuple->size);
|
leafTuple->size);
|
||||||
@@ -478,8 +477,7 @@ moveLeafs(Relation index, SpGistState *state,
|
|||||||
*/
|
*/
|
||||||
SGLT_SET_NEXTOFFSET(it, r);
|
SGLT_SET_NEXTOFFSET(it, r);
|
||||||
|
|
||||||
r = SpGistPageAddNewItem(state, npage, (Item) it, it->size,
|
r = SpGistPageAddNewItem(state, npage, it, it->size, &startOffset, false);
|
||||||
&startOffset, false);
|
|
||||||
|
|
||||||
toInsert[nInsert] = r;
|
toInsert[nInsert] = r;
|
||||||
nInsert++;
|
nInsert++;
|
||||||
@@ -492,9 +490,7 @@ moveLeafs(Relation index, SpGistState *state,
|
|||||||
|
|
||||||
/* add the new tuple as well */
|
/* add the new tuple as well */
|
||||||
SGLT_SET_NEXTOFFSET(newLeafTuple, r);
|
SGLT_SET_NEXTOFFSET(newLeafTuple, r);
|
||||||
r = SpGistPageAddNewItem(state, npage,
|
r = SpGistPageAddNewItem(state, npage, newLeafTuple, newLeafTuple->size, &startOffset, false);
|
||||||
(Item) newLeafTuple, newLeafTuple->size,
|
|
||||||
&startOffset, false);
|
|
||||||
toInsert[nInsert] = r;
|
toInsert[nInsert] = r;
|
||||||
nInsert++;
|
nInsert++;
|
||||||
memcpy(leafptr, newLeafTuple, newLeafTuple->size);
|
memcpy(leafptr, newLeafTuple, newLeafTuple->size);
|
||||||
@@ -1226,7 +1222,7 @@ doPickSplit(Relation index, SpGistState *state,
|
|||||||
|
|
||||||
/* Insert it on page */
|
/* Insert it on page */
|
||||||
newoffset = SpGistPageAddNewItem(state, BufferGetPage(leafBuffer),
|
newoffset = SpGistPageAddNewItem(state, BufferGetPage(leafBuffer),
|
||||||
(Item) it, it->size,
|
it, it->size,
|
||||||
&startOffsets[leafPageSelect[i]],
|
&startOffsets[leafPageSelect[i]],
|
||||||
false);
|
false);
|
||||||
toInsert[i] = newoffset;
|
toInsert[i] = newoffset;
|
||||||
@@ -1268,7 +1264,7 @@ doPickSplit(Relation index, SpGistState *state,
|
|||||||
current->page = parent->page;
|
current->page = parent->page;
|
||||||
xlrec.offnumInner = current->offnum =
|
xlrec.offnumInner = current->offnum =
|
||||||
SpGistPageAddNewItem(state, current->page,
|
SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) innerTuple, innerTuple->size,
|
innerTuple, innerTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1302,7 +1298,7 @@ doPickSplit(Relation index, SpGistState *state,
|
|||||||
current->page = BufferGetPage(current->buffer);
|
current->page = BufferGetPage(current->buffer);
|
||||||
xlrec.offnumInner = current->offnum =
|
xlrec.offnumInner = current->offnum =
|
||||||
SpGistPageAddNewItem(state, current->page,
|
SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) innerTuple, innerTuple->size,
|
innerTuple, innerTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
/* Done modifying new current buffer, mark it dirty */
|
/* Done modifying new current buffer, mark it dirty */
|
||||||
@@ -1340,7 +1336,7 @@ doPickSplit(Relation index, SpGistState *state,
|
|||||||
xlrec.innerIsParent = false;
|
xlrec.innerIsParent = false;
|
||||||
|
|
||||||
xlrec.offnumInner = current->offnum =
|
xlrec.offnumInner = current->offnum =
|
||||||
PageAddItem(current->page, (Item) innerTuple, innerTuple->size,
|
PageAddItem(current->page, innerTuple, innerTuple->size,
|
||||||
InvalidOffsetNumber, false, false);
|
InvalidOffsetNumber, false, false);
|
||||||
if (current->offnum != FirstOffsetNumber)
|
if (current->offnum != FirstOffsetNumber)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
@@ -1547,7 +1543,7 @@ spgAddNodeAction(Relation index, SpGistState *state,
|
|||||||
|
|
||||||
PageIndexTupleDelete(current->page, current->offnum);
|
PageIndexTupleDelete(current->page, current->offnum);
|
||||||
if (PageAddItem(current->page,
|
if (PageAddItem(current->page,
|
||||||
(Item) newInnerTuple, newInnerTuple->size,
|
newInnerTuple, newInnerTuple->size,
|
||||||
current->offnum, false, false) != current->offnum)
|
current->offnum, false, false) != current->offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
newInnerTuple->size);
|
newInnerTuple->size);
|
||||||
@@ -1631,7 +1627,7 @@ spgAddNodeAction(Relation index, SpGistState *state,
|
|||||||
/* insert new ... */
|
/* insert new ... */
|
||||||
xlrec.offnumNew = current->offnum =
|
xlrec.offnumNew = current->offnum =
|
||||||
SpGistPageAddNewItem(state, current->page,
|
SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) newInnerTuple, newInnerTuple->size,
|
newInnerTuple, newInnerTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
|
|
||||||
MarkBufferDirty(current->buffer);
|
MarkBufferDirty(current->buffer);
|
||||||
@@ -1654,7 +1650,7 @@ spgAddNodeAction(Relation index, SpGistState *state,
|
|||||||
current->blkno, current->offnum);
|
current->blkno, current->offnum);
|
||||||
|
|
||||||
PageIndexTupleDelete(saveCurrent.page, saveCurrent.offnum);
|
PageIndexTupleDelete(saveCurrent.page, saveCurrent.offnum);
|
||||||
if (PageAddItem(saveCurrent.page, (Item) dt, dt->size,
|
if (PageAddItem(saveCurrent.page, dt, dt->size,
|
||||||
saveCurrent.offnum,
|
saveCurrent.offnum,
|
||||||
false, false) != saveCurrent.offnum)
|
false, false) != saveCurrent.offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
@@ -1818,7 +1814,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
|
|||||||
*/
|
*/
|
||||||
PageIndexTupleDelete(current->page, current->offnum);
|
PageIndexTupleDelete(current->page, current->offnum);
|
||||||
xlrec.offnumPrefix = PageAddItem(current->page,
|
xlrec.offnumPrefix = PageAddItem(current->page,
|
||||||
(Item) prefixTuple, prefixTuple->size,
|
prefixTuple, prefixTuple->size,
|
||||||
current->offnum, false, false);
|
current->offnum, false, false);
|
||||||
if (xlrec.offnumPrefix != current->offnum)
|
if (xlrec.offnumPrefix != current->offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
@@ -1832,7 +1828,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
|
|||||||
postfixBlkno = current->blkno;
|
postfixBlkno = current->blkno;
|
||||||
xlrec.offnumPostfix = postfixOffset =
|
xlrec.offnumPostfix = postfixOffset =
|
||||||
SpGistPageAddNewItem(state, current->page,
|
SpGistPageAddNewItem(state, current->page,
|
||||||
(Item) postfixTuple, postfixTuple->size,
|
postfixTuple, postfixTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
xlrec.postfixBlkSame = true;
|
xlrec.postfixBlkSame = true;
|
||||||
}
|
}
|
||||||
@@ -1841,7 +1837,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
|
|||||||
postfixBlkno = BufferGetBlockNumber(newBuffer);
|
postfixBlkno = BufferGetBlockNumber(newBuffer);
|
||||||
xlrec.offnumPostfix = postfixOffset =
|
xlrec.offnumPostfix = postfixOffset =
|
||||||
SpGistPageAddNewItem(state, BufferGetPage(newBuffer),
|
SpGistPageAddNewItem(state, BufferGetPage(newBuffer),
|
||||||
(Item) postfixTuple, postfixTuple->size,
|
postfixTuple, postfixTuple->size,
|
||||||
NULL, false);
|
NULL, false);
|
||||||
MarkBufferDirty(newBuffer);
|
MarkBufferDirty(newBuffer);
|
||||||
xlrec.postfixBlkSame = false;
|
xlrec.postfixBlkSame = false;
|
||||||
|
|||||||
@@ -1200,7 +1200,7 @@ spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
|
|||||||
* rather than returning InvalidOffsetNumber.
|
* rather than returning InvalidOffsetNumber.
|
||||||
*/
|
*/
|
||||||
OffsetNumber
|
OffsetNumber
|
||||||
SpGistPageAddNewItem(SpGistState *state, Page page, Item item, Size size,
|
SpGistPageAddNewItem(SpGistState *state, Page page, const void *item, Size size,
|
||||||
OffsetNumber *startOffset, bool errorOK)
|
OffsetNumber *startOffset, bool errorOK)
|
||||||
{
|
{
|
||||||
SpGistPageOpaque opaque = SpGistPageGetOpaque(page);
|
SpGistPageOpaque opaque = SpGistPageGetOpaque(page);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fillFakeState(SpGistState *state, spgxlogState stateSrc)
|
|||||||
* existing tuple, it had better be a placeholder tuple.
|
* existing tuple, it had better be a placeholder tuple.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
addOrReplaceTuple(Page page, Item tuple, int size, OffsetNumber offset)
|
addOrReplaceTuple(Page page, const void *tuple, int size, OffsetNumber offset)
|
||||||
{
|
{
|
||||||
if (offset <= PageGetMaxOffsetNumber(page))
|
if (offset <= PageGetMaxOffsetNumber(page))
|
||||||
{
|
{
|
||||||
@@ -110,8 +110,7 @@ spgRedoAddLeaf(XLogReaderState *record)
|
|||||||
if (xldata->offnumLeaf != xldata->offnumHeadLeaf)
|
if (xldata->offnumLeaf != xldata->offnumHeadLeaf)
|
||||||
{
|
{
|
||||||
/* normal cases, tuple was added by SpGistPageAddNewItem */
|
/* normal cases, tuple was added by SpGistPageAddNewItem */
|
||||||
addOrReplaceTuple(page, (Item) leafTuple, leafTupleHdr.size,
|
addOrReplaceTuple(page, leafTuple, leafTupleHdr.size, xldata->offnumLeaf);
|
||||||
xldata->offnumLeaf);
|
|
||||||
|
|
||||||
/* update head tuple's chain link if needed */
|
/* update head tuple's chain link if needed */
|
||||||
if (xldata->offnumHeadLeaf != InvalidOffsetNumber)
|
if (xldata->offnumHeadLeaf != InvalidOffsetNumber)
|
||||||
@@ -129,7 +128,7 @@ spgRedoAddLeaf(XLogReaderState *record)
|
|||||||
/* replacing a DEAD tuple */
|
/* replacing a DEAD tuple */
|
||||||
PageIndexTupleDelete(page, xldata->offnumLeaf);
|
PageIndexTupleDelete(page, xldata->offnumLeaf);
|
||||||
if (PageAddItem(page,
|
if (PageAddItem(page,
|
||||||
(Item) leafTuple, leafTupleHdr.size,
|
leafTuple, leafTupleHdr.size,
|
||||||
xldata->offnumLeaf, false, false) != xldata->offnumLeaf)
|
xldata->offnumLeaf, false, false) != xldata->offnumLeaf)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
leafTupleHdr.size);
|
leafTupleHdr.size);
|
||||||
@@ -232,8 +231,7 @@ spgRedoMoveLeafs(XLogReaderState *record)
|
|||||||
memcpy(&leafTupleHdr, leafTuple,
|
memcpy(&leafTupleHdr, leafTuple,
|
||||||
sizeof(SpGistLeafTupleData));
|
sizeof(SpGistLeafTupleData));
|
||||||
|
|
||||||
addOrReplaceTuple(page, (Item) leafTuple,
|
addOrReplaceTuple(page, leafTuple, leafTupleHdr.size, toInsert[i]);
|
||||||
leafTupleHdr.size, toInsert[i]);
|
|
||||||
ptr += leafTupleHdr.size;
|
ptr += leafTupleHdr.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +307,7 @@ spgRedoAddNode(XLogReaderState *record)
|
|||||||
page = BufferGetPage(buffer);
|
page = BufferGetPage(buffer);
|
||||||
|
|
||||||
PageIndexTupleDelete(page, xldata->offnum);
|
PageIndexTupleDelete(page, xldata->offnum);
|
||||||
if (PageAddItem(page, (Item) innerTuple, innerTupleHdr.size,
|
if (PageAddItem(page, innerTuple, innerTupleHdr.size,
|
||||||
xldata->offnum,
|
xldata->offnum,
|
||||||
false, false) != xldata->offnum)
|
false, false) != xldata->offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
@@ -351,8 +349,7 @@ spgRedoAddNode(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
page = BufferGetPage(buffer);
|
page = BufferGetPage(buffer);
|
||||||
|
|
||||||
addOrReplaceTuple(page, (Item) innerTuple,
|
addOrReplaceTuple(page, innerTuple, innerTupleHdr.size, xldata->offnumNew);
|
||||||
innerTupleHdr.size, xldata->offnumNew);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If parent is in this same page, update it now.
|
* If parent is in this same page, update it now.
|
||||||
@@ -390,7 +387,7 @@ spgRedoAddNode(XLogReaderState *record)
|
|||||||
xldata->offnumNew);
|
xldata->offnumNew);
|
||||||
|
|
||||||
PageIndexTupleDelete(page, xldata->offnum);
|
PageIndexTupleDelete(page, xldata->offnum);
|
||||||
if (PageAddItem(page, (Item) dt, dt->size,
|
if (PageAddItem(page, dt, dt->size,
|
||||||
xldata->offnum,
|
xldata->offnum,
|
||||||
false, false) != xldata->offnum)
|
false, false) != xldata->offnum)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
@@ -492,8 +489,7 @@ spgRedoSplitTuple(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
page = BufferGetPage(buffer);
|
page = BufferGetPage(buffer);
|
||||||
|
|
||||||
addOrReplaceTuple(page, (Item) postfixTuple,
|
addOrReplaceTuple(page, postfixTuple, postfixTupleHdr.size, xldata->offnumPostfix);
|
||||||
postfixTupleHdr.size, xldata->offnumPostfix);
|
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
MarkBufferDirty(buffer);
|
MarkBufferDirty(buffer);
|
||||||
@@ -508,15 +504,13 @@ spgRedoSplitTuple(XLogReaderState *record)
|
|||||||
page = BufferGetPage(buffer);
|
page = BufferGetPage(buffer);
|
||||||
|
|
||||||
PageIndexTupleDelete(page, xldata->offnumPrefix);
|
PageIndexTupleDelete(page, xldata->offnumPrefix);
|
||||||
if (PageAddItem(page, (Item) prefixTuple, prefixTupleHdr.size,
|
if (PageAddItem(page, prefixTuple, prefixTupleHdr.size,
|
||||||
xldata->offnumPrefix, false, false) != xldata->offnumPrefix)
|
xldata->offnumPrefix, false, false) != xldata->offnumPrefix)
|
||||||
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
elog(ERROR, "failed to add item of size %u to SPGiST index page",
|
||||||
prefixTupleHdr.size);
|
prefixTupleHdr.size);
|
||||||
|
|
||||||
if (xldata->postfixBlkSame)
|
if (xldata->postfixBlkSame)
|
||||||
addOrReplaceTuple(page, (Item) postfixTuple,
|
addOrReplaceTuple(page, postfixTuple, postfixTupleHdr.size, xldata->offnumPostfix);
|
||||||
postfixTupleHdr.size,
|
|
||||||
xldata->offnumPostfix);
|
|
||||||
|
|
||||||
PageSetLSN(page, lsn);
|
PageSetLSN(page, lsn);
|
||||||
MarkBufferDirty(buffer);
|
MarkBufferDirty(buffer);
|
||||||
@@ -662,8 +656,7 @@ spgRedoPickSplit(XLogReaderState *record)
|
|||||||
if (page == NULL)
|
if (page == NULL)
|
||||||
continue; /* no need to touch this page */
|
continue; /* no need to touch this page */
|
||||||
|
|
||||||
addOrReplaceTuple(page, (Item) leafTuple, leafTupleHdr.size,
|
addOrReplaceTuple(page, leafTuple, leafTupleHdr.size, toInsert[i]);
|
||||||
toInsert[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now update src and dest page LSNs if needed */
|
/* Now update src and dest page LSNs if needed */
|
||||||
@@ -692,8 +685,7 @@ spgRedoPickSplit(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
page = BufferGetPage(innerBuffer);
|
page = BufferGetPage(innerBuffer);
|
||||||
|
|
||||||
addOrReplaceTuple(page, (Item) innerTuple, innerTupleHdr.size,
|
addOrReplaceTuple(page, innerTuple, innerTupleHdr.size, xldata->offnumInner);
|
||||||
xldata->offnumInner);
|
|
||||||
|
|
||||||
/* if inner is also parent, update link while we're here */
|
/* if inner is also parent, update link while we're here */
|
||||||
if (xldata->innerIsParent)
|
if (xldata->innerIsParent)
|
||||||
|
|||||||
@@ -404,8 +404,7 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum)
|
|||||||
|
|
||||||
MarkBufferDirty(buf);
|
MarkBufferDirty(buf);
|
||||||
|
|
||||||
offnum = PageAddItem(page, (Item) tuple->t_data, tuple->t_len,
|
offnum = PageAddItem(page, tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, false);
|
||||||
InvalidOffsetNumber, false, false);
|
|
||||||
if (offnum != FirstOffsetNumber)
|
if (offnum != FirstOffsetNumber)
|
||||||
elog(ERROR, "failed to add sequence tuple to page");
|
elog(ERROR, "failed to add sequence tuple to page");
|
||||||
|
|
||||||
@@ -1946,8 +1945,7 @@ seq_redo(XLogReaderState *record)
|
|||||||
item = (char *) xlrec + sizeof(xl_seq_rec);
|
item = (char *) xlrec + sizeof(xl_seq_rec);
|
||||||
itemsz = XLogRecGetDataLen(record) - sizeof(xl_seq_rec);
|
itemsz = XLogRecGetDataLen(record) - sizeof(xl_seq_rec);
|
||||||
|
|
||||||
if (PageAddItem(localpage, (Item) item, itemsz,
|
if (PageAddItem(localpage, item, itemsz, FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
||||||
FirstOffsetNumber, false, false) == InvalidOffsetNumber)
|
|
||||||
elog(PANIC, "seq_redo: failed to add item to page");
|
elog(PANIC, "seq_redo: failed to add item to page");
|
||||||
|
|
||||||
PageSetLSN(localpage, lsn);
|
PageSetLSN(localpage, lsn);
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ PageIsVerified(PageData *page, BlockNumber blkno, int flags, bool *checksum_fail
|
|||||||
*/
|
*/
|
||||||
OffsetNumber
|
OffsetNumber
|
||||||
PageAddItemExtended(Page page,
|
PageAddItemExtended(Page page,
|
||||||
Item item,
|
const void *item,
|
||||||
Size size,
|
Size size,
|
||||||
OffsetNumber offsetNumber,
|
OffsetNumber offsetNumber,
|
||||||
int flags)
|
int flags)
|
||||||
@@ -1402,7 +1402,7 @@ PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum)
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
|
PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
|
||||||
Item newtup, Size newsize)
|
const void *newtup, Size newsize)
|
||||||
{
|
{
|
||||||
PageHeader phdr = (PageHeader) page;
|
PageHeader phdr = (PageHeader) page;
|
||||||
ItemId tupid;
|
ItemId tupid;
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ extern void spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor,
|
|||||||
extern Datum *spgExtractNodeLabels(SpGistState *state,
|
extern Datum *spgExtractNodeLabels(SpGistState *state,
|
||||||
SpGistInnerTuple innerTuple);
|
SpGistInnerTuple innerTuple);
|
||||||
extern OffsetNumber SpGistPageAddNewItem(SpGistState *state, Page page,
|
extern OffsetNumber SpGistPageAddNewItem(SpGistState *state, Page page,
|
||||||
Item item, Size size,
|
const void *item, Size size,
|
||||||
OffsetNumber *startOffset,
|
OffsetNumber *startOffset,
|
||||||
bool errorOK);
|
bool errorOK);
|
||||||
extern bool spgproperty(Oid index_oid, int attno,
|
extern bool spgproperty(Oid index_oid, int attno,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/xlogdefs.h"
|
#include "access/xlogdefs.h"
|
||||||
#include "storage/block.h"
|
#include "storage/block.h"
|
||||||
#include "storage/item.h"
|
|
||||||
#include "storage/off.h"
|
#include "storage/off.h"
|
||||||
|
|
||||||
/* GUC variable */
|
/* GUC variable */
|
||||||
@@ -351,13 +350,13 @@ PageValidateSpecialPointer(const PageData *page)
|
|||||||
* This does not change the status of any of the resources passed.
|
* This does not change the status of any of the resources passed.
|
||||||
* The semantics may change in the future.
|
* The semantics may change in the future.
|
||||||
*/
|
*/
|
||||||
static inline Item
|
static inline void *
|
||||||
PageGetItem(const PageData *page, const ItemIdData *itemId)
|
PageGetItem(const PageData *page, const ItemIdData *itemId)
|
||||||
{
|
{
|
||||||
Assert(page);
|
Assert(page);
|
||||||
Assert(ItemIdHasStorage(itemId));
|
Assert(ItemIdHasStorage(itemId));
|
||||||
|
|
||||||
return (Item) (((const char *) page) + ItemIdGetOffset(itemId));
|
return (void *) (((const char *) page) + ItemIdGetOffset(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -488,7 +487,7 @@ StaticAssertDecl(BLCKSZ == ((BLCKSZ / sizeof(size_t)) * sizeof(size_t)),
|
|||||||
extern void PageInit(Page page, Size pageSize, Size specialSize);
|
extern void PageInit(Page page, Size pageSize, Size specialSize);
|
||||||
extern bool PageIsVerified(PageData *page, BlockNumber blkno, int flags,
|
extern bool PageIsVerified(PageData *page, BlockNumber blkno, int flags,
|
||||||
bool *checksum_failure_p);
|
bool *checksum_failure_p);
|
||||||
extern OffsetNumber PageAddItemExtended(Page page, Item item, Size size,
|
extern OffsetNumber PageAddItemExtended(Page page, const void *item, Size size,
|
||||||
OffsetNumber offsetNumber, int flags);
|
OffsetNumber offsetNumber, int flags);
|
||||||
extern Page PageGetTempPage(const PageData *page);
|
extern Page PageGetTempPage(const PageData *page);
|
||||||
extern Page PageGetTempPageCopy(const PageData *page);
|
extern Page PageGetTempPageCopy(const PageData *page);
|
||||||
@@ -504,7 +503,7 @@ extern void PageIndexTupleDelete(Page page, OffsetNumber offnum);
|
|||||||
extern void PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems);
|
extern void PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems);
|
||||||
extern void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum);
|
extern void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum);
|
||||||
extern bool PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
|
extern bool PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
|
||||||
Item newtup, Size newsize);
|
const void *newtup, Size newsize);
|
||||||
extern char *PageSetChecksumCopy(Page page, BlockNumber blkno);
|
extern char *PageSetChecksumCopy(Page page, BlockNumber blkno);
|
||||||
extern void PageSetChecksumInplace(Page page, BlockNumber blkno);
|
extern void PageSetChecksumInplace(Page page, BlockNumber blkno);
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* item.h
|
|
||||||
* POSTGRES disk item definitions.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
* src/include/storage/item.h
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#ifndef ITEM_H
|
|
||||||
#define ITEM_H
|
|
||||||
|
|
||||||
typedef Pointer Item;
|
|
||||||
|
|
||||||
#endif /* ITEM_H */
|
|
||||||
@@ -1321,7 +1321,6 @@ IsForeignRelUpdatable_function
|
|||||||
IsForeignScanParallelSafe_function
|
IsForeignScanParallelSafe_function
|
||||||
IsoConnInfo
|
IsoConnInfo
|
||||||
IspellDict
|
IspellDict
|
||||||
Item
|
|
||||||
ItemArray
|
ItemArray
|
||||||
ItemId
|
ItemId
|
||||||
ItemIdData
|
ItemIdData
|
||||||
|
|||||||
Reference in New Issue
Block a user