Skip to content

Commit 6889303

Browse files
committed
Redefine the lp_flags field of item pointers as having four states, rather
than two independent bits (one of which was never used in heap pages anyway, or at least hadn't been in a very long time). This gives us flexibility to add the HOT notions of redirected and dead item pointers without requiring anything so klugy as magic values of lp_off and lp_len. The state values are chosen so that for the states currently in use (pre-HOT) there is no change in the physical representation.
1 parent eb0a773 commit 6889303

31 files changed

+278
-185
lines changed

contrib/pageinspect/btreefuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat * stat)
140140

141141
item_size += IndexTupleSize(itup);
142142

143-
if (!ItemIdDeleted(id))
143+
if (!ItemIdIsDead(id))
144144
stat->live_items++;
145145
else
146146
stat->dead_items++;

contrib/pageinspect/heapfuncs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Copyright (c) 2007, PostgreSQL Global Development Group
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.1 2007/05/17 19:11:24 momjian Exp $
21+
* $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.2 2007/09/12 22:10:25 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -156,15 +156,15 @@ heap_page_items(PG_FUNCTION_ARGS)
156156
* could be corrupt in many other ways, but at least we won't
157157
* crash.
158158
*/
159-
if ((lp_len >= sizeof(HeapTupleHeader)) &&
160-
(lp_offset == MAXALIGN(lp_offset)) &&
161-
(lp_offset + lp_len <= raw_page_size) &&
162-
ItemIdIsUsed(id))
159+
if (ItemIdHasStorage(id) &&
160+
lp_len >= sizeof(HeapTupleHeader) &&
161+
lp_offset == MAXALIGN(lp_offset) &&
162+
lp_offset + lp_len <= raw_page_size)
163163
{
164164
HeapTupleHeader tuphdr;
165165
int bits_len;
166166

167-
/* Extract infromation from the tuple header */
167+
/* Extract information from the tuple header */
168168

169169
tuphdr = (HeapTupleHeader) PageGetItem(page, id);
170170

contrib/pgstattuple/pgstattuple.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.28 2007/08/26 23:59:50 tgl Exp $
2+
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.29 2007/09/12 22:10:25 tgl Exp $
33
*
44
* Copyright (c) 2001,2002 Tatsuo Ishii
55
*
@@ -477,7 +477,7 @@ pgstat_index_page(pgstattuple_type * stat, Page page,
477477
{
478478
ItemId itemid = PageGetItemId(page, i);
479479

480-
if (ItemIdDeleted(itemid))
480+
if (ItemIdIsDead(itemid))
481481
{
482482
stat->dead_tuple_count++;
483483
stat->dead_tuple_len += ItemIdGetLength(itemid);

src/backend/access/gin/ginentrypage.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.7 2007/06/04 15:56:28 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.8 2007/09/12 22:10:25 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -359,7 +359,7 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
359359
*prdata = rdata;
360360
data.updateBlkno = entryPreparePage(btree, page, off);
361361

362-
placed = PageAddItem(page, (Item) btree->entry, IndexTupleSize(btree->entry), off, LP_USED);
362+
placed = PageAddItem(page, (Item) btree->entry, IndexTupleSize(btree->entry), off, false);
363363
if (placed != off)
364364
elog(ERROR, "failed to add item to index page in \"%s\"",
365365
RelationGetRelationName(btree->index));
@@ -488,7 +488,7 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
488488
lsize += MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
489489
}
490490

491-
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
491+
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
492492
elog(ERROR, "failed to add item to index page in \"%s\"",
493493
RelationGetRelationName(btree->index));
494494
ptr += MAXALIGN(IndexTupleSize(itup));
@@ -563,11 +563,11 @@ entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
563563
page = BufferGetPage(root);
564564

565565
itup = ginPageGetLinkItup(lbuf);
566-
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
566+
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
567567
elog(ERROR, "failed to add item to index root page");
568568

569569
itup = ginPageGetLinkItup(rbuf);
570-
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
570+
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
571571
elog(ERROR, "failed to add item to index root page");
572572
}
573573

src/backend/access/gin/ginvacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.15 2007/06/05 12:47:49 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.16 2007/09/12 22:10:25 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -544,7 +544,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
544544
itup = GinFormTuple(&gvs->ginstate, value, GinGetPosting(itup), newN);
545545
PageIndexTupleDelete(tmppage, i);
546546

547-
if (PageAddItem(tmppage, (Item) itup, IndexTupleSize(itup), i, LP_USED) != i)
547+
if (PageAddItem(tmppage, (Item) itup, IndexTupleSize(itup), i, false) != i)
548548
elog(ERROR, "failed to add item to index page in \"%s\"",
549549
RelationGetRelationName(gvs->index));
550550

src/backend/access/gin/ginxlog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.7 2007/06/04 15:56:28 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.8 2007/09/12 22:10:25 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -199,7 +199,7 @@ ginRedoInsert(XLogRecPtr lsn, XLogRecord *record)
199199

200200
itup = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogInsert));
201201

202-
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), data->offset, LP_USED) == InvalidOffsetNumber)
202+
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), data->offset, false) == InvalidOffsetNumber)
203203
elog(ERROR, "failed to add item to index page in %u/%u/%u",
204204
data->node.spcNode, data->node.dbNode, data->node.relNode);
205205

@@ -281,15 +281,15 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
281281

282282
for (i = 0; i < data->separator; i++)
283283
{
284-
if (PageAddItem(lpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
284+
if (PageAddItem(lpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
285285
elog(ERROR, "failed to add item to index page in %u/%u/%u",
286286
data->node.spcNode, data->node.dbNode, data->node.relNode);
287287
itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));
288288
}
289289

290290
for (i = data->separator; i < data->nitem; i++)
291291
{
292-
if (PageAddItem(rpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
292+
if (PageAddItem(rpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
293293
elog(ERROR, "failed to add item to index page in %u/%u/%u",
294294
data->node.spcNode, data->node.dbNode, data->node.relNode);
295295
itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));
@@ -375,7 +375,7 @@ ginRedoVacuumPage(XLogRecPtr lsn, XLogRecord *record)
375375

376376
for (i = 0; i < data->nitem; i++)
377377
{
378-
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
378+
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false) == InvalidOffsetNumber)
379379
elog(ERROR, "failed to add item to index page in %u/%u/%u",
380380
data->node.spcNode, data->node.dbNode, data->node.relNode);
381381
itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));

src/backend/access/gist/gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.145 2007/01/05 22:19:21 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.146 2007/09/12 22:10:25 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -366,7 +366,7 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
366366
data = (char *) (ptr->list);
367367
for (i = 0; i < ptr->block.num; i++)
368368
{
369-
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, LP_USED) == InvalidOffsetNumber)
369+
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, false) == InvalidOffsetNumber)
370370
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(state->r));
371371
data += IndexTupleSize((IndexTuple) data);
372372
}

src/backend/access/gist/gistget.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.66 2007/05/27 03:50:38 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.67 2007/09/12 22:10:25 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -46,7 +46,7 @@ killtuple(Relation r, GISTScanOpaque so, ItemPointer iptr)
4646
{
4747
/* page unchanged, so all is simple */
4848
offset = ItemPointerGetOffsetNumber(iptr);
49-
PageGetItemId(p, offset)->lp_flags |= LP_DELETE;
49+
ItemIdMarkDead(PageGetItemId(p, offset));
5050
SetBufferCommitInfoNeedsSave(buffer);
5151
LockBuffer(buffer, GIST_UNLOCK);
5252
break;
@@ -61,7 +61,7 @@ killtuple(Relation r, GISTScanOpaque so, ItemPointer iptr)
6161
if (ItemPointerEquals(&(ituple->t_tid), iptr))
6262
{
6363
/* found */
64-
PageGetItemId(p, offset)->lp_flags |= LP_DELETE;
64+
ItemIdMarkDead(PageGetItemId(p, offset));
6565
SetBufferCommitInfoNeedsSave(buffer);
6666
LockBuffer(buffer, GIST_UNLOCK);
6767
if (buffer != so->curbuf)
@@ -289,7 +289,7 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids,
289289
ItemPointerSet(&(so->curpos),
290290
BufferGetBlockNumber(so->curbuf), n);
291291

292-
if (!(ignore_killed_tuples && ItemIdDeleted(PageGetItemId(p, n))))
292+
if (!(ignore_killed_tuples && ItemIdIsDead(PageGetItemId(p, n))))
293293
{
294294
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
295295
tids[ntids] = scan->xs_ctup.t_self = it->t_tid;

src/backend/access/gist/gistutil.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.22 2007/04/09 22:03:57 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.23 2007/09/12 22:10:25 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -42,7 +42,7 @@ gistfillbuffer(Relation r, Page page, IndexTuple *itup,
4242
for (i = 0; i < len; i++)
4343
{
4444
l = PageAddItem(page, (Item) itup[i], IndexTupleSize(itup[i]),
45-
off, LP_USED);
45+
off, false);
4646
if (l == InvalidOffsetNumber)
4747
elog(ERROR, "failed to add item to index page in \"%s\"",
4848
RelationGetRelationName(r));

src/backend/access/gist/gistvacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.30 2007/05/31 14:03:09 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.31 2007/09/12 22:10:25 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -201,7 +201,7 @@ vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon,
201201
data = (char *) (ptr->list);
202202
for (i = 0; i < ptr->block.num; i++)
203203
{
204-
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, LP_USED) == InvalidOffsetNumber)
204+
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, false) == InvalidOffsetNumber)
205205
elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(gv->index));
206206
data += IndexTupleSize((IndexTuple) data);
207207
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy