diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2010-03-28 09:27:02 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2010-03-28 09:27:02 +0000 |
commit | a760893dbda9934e287789d54bbd3c4ca3914ce0 (patch) | |
tree | dc27a0fd902264a9d9a6f882edca421df9ef255f /src/include | |
parent | 59292f28cace8c0d4b038cadbb127b440e3a7815 (diff) | |
download | postgresql-a760893dbda9934e287789d54bbd3c4ca3914ce0.tar.gz postgresql-a760893dbda9934e287789d54bbd3c4ca3914ce0.zip |
Derive latestRemovedXid for btree deletes by reading heap pages. The
WAL record for btree delete contains a list of tids, even when backup
blocks are present. We follow the tids to their heap tuples, taking
care to follow LP_REDIRECT tuples. We ignore LP_DEAD tuples on the
understanding that they will always have xmin/xmax earlier than any
LP_NORMAL tuples referred to by killed index tuples. Iff all tuples
are LP_DEAD we return InvalidTransactionId. The heap relfilenode is
added to the WAL record, requiring API changes to pass down the heap
Relation. XLOG_PAGE_MAGIC updated.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/nbtree.h | 25 | ||||
-rw-r--r-- | src/include/access/xlog_internal.h | 4 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index e00594b487d..775c47da55c 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.133 2010/03/20 07:49:48 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.134 2010/03/28 09:27:02 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -314,14 +314,15 @@ typedef struct xl_btree_split */ typedef struct xl_btree_delete { - RelFileNode node; + RelFileNode node; /* RelFileNode of the index */ BlockNumber block; - TransactionId latestRemovedXid; + RelFileNode hnode; /* RelFileNode of the heap the index currently points at */ + int nitems; /* TARGET OFFSET NUMBERS FOLLOW AT THE END */ } xl_btree_delete; -#define SizeOfBtreeDelete (offsetof(xl_btree_delete, latestRemovedXid) + sizeof(TransactionId)) +#define SizeOfBtreeDelete (offsetof(xl_btree_delete, nitems) + sizeof(int)) /* * This is what we need to know about page reuse within btree. @@ -349,13 +350,12 @@ typedef struct xl_btree_reuse_page * heap tuples. * * Any changes to any one block are registered on just one WAL record. All - * blocks that we need to run EnsureBlockUnpinned() before we touch the changed - * block are also given on this record as a variable length array. The array - * is compressed by way of storing an array of block ranges, rather than an - * actual array of blockids. + * blocks that we need to run EnsureBlockUnpinned() are listed as a block range + * starting from the last block vacuumed through until this one. Individual + * block numbers aren't given. * * Note that the *last* WAL record in any vacuum of an index is allowed to - * have numItems == 0. All other WAL records must have numItems > 0. + * have a zero length array of offsets. Earlier records must have at least one. */ typedef struct xl_btree_vacuum { @@ -588,9 +588,10 @@ extern Buffer _bt_relandgetbuf(Relation rel, Buffer obuf, extern void _bt_relbuf(Relation rel, Buffer buf); extern void _bt_pageinit(Page page, Size size); extern bool _bt_page_recyclable(Page page); -extern void _bt_delitems(Relation rel, Buffer buf, - OffsetNumber *itemnos, int nitems, bool isVacuum, - BlockNumber lastBlockVacuumed); +extern void _bt_delitems_delete(Relation rel, Buffer buf, + OffsetNumber *itemnos, int nitems, Relation heapRel); +extern void _bt_delitems_vacuum(Relation rel, Buffer buf, + OffsetNumber *itemnos, int nitems, BlockNumber lastBlockVacuumed); extern int _bt_pagedel(Relation rel, Buffer buf, BTStack stack); /* diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 0787eb582c0..c93e3848e87 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.30 2010/03/19 17:42:10 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.31 2010/03/28 09:27:02 sriggs Exp $ */ #ifndef XLOG_INTERNAL_H #define XLOG_INTERNAL_H @@ -71,7 +71,7 @@ typedef struct XLogContRecord /* * Each page of XLOG file has a header like this: */ -#define XLOG_PAGE_MAGIC 0x9002 /* can be used as WAL version indicator */ +#define XLOG_PAGE_MAGIC 0x9003 /* can be used as WAL version indicator */ typedef struct XLogPageHeaderData { |