summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas2008-11-19 10:34:52 +0000
committerHeikki Linnakangas2008-11-19 10:34:52 +0000
commit3396000684b41e7e9467d1abc67152b39e697035 (patch)
treec8edf238f89cd7b0b1562b919f2addebc67eb54e /src/include
parent26e6c896c946bc1a9e9f608b2c7463be1e8c6291 (diff)
Rethink the way FSM truncation works. Instead of WAL-logging FSM
truncations in FSM code, call FreeSpaceMapTruncateRel from smgr_redo. To make that cleaner from modularity point of view, move the WAL-logging one level up to RelationTruncate, and move RelationTruncate and all the related WAL-logging to new src/backend/catalog/storage.c file. Introduce new RelationCreateStorage and RelationDropStorage functions that are used instead of calling smgrcreate/smgrscheduleunlink directly. Move the pending rel deletion stuff from smgrcreate/smgrscheduleunlink to the new functions. This leaves smgr.c as a thin wrapper around md.c; all the transactional stuff is now in storage.c. This will make it easier to add new forks with similar truncation logic, like the visibility map.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/rmgr.h3
-rw-r--r--src/include/access/xact.h14
-rw-r--r--src/include/catalog/storage.h39
-rw-r--r--src/include/storage/bufmgr.h3
-rw-r--r--src/include/storage/freespace.h6
-rw-r--r--src/include/storage/indexfsm.h4
-rw-r--r--src/include/storage/relfilenode.h11
-rw-r--r--src/include/storage/smgr.h18
8 files changed, 53 insertions, 45 deletions
diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h
index 6f018f0bee2..44b8a07a3fc 100644
--- a/src/include/access/rmgr.h
+++ b/src/include/access/rmgr.h
@@ -3,7 +3,7 @@
*
* Resource managers definition
*
- * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.18 2008/09/30 10:52:13 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.19 2008/11/19 10:34:52 heikki Exp $
*/
#ifndef RMGR_H
#define RMGR_H
@@ -23,7 +23,6 @@ typedef uint8 RmgrId;
#define RM_DBASE_ID 4
#define RM_TBLSPC_ID 5
#define RM_MULTIXACT_ID 6
-#define RM_FREESPACE_ID 7
#define RM_HEAP2_ID 9
#define RM_HEAP_ID 10
#define RM_BTREE_ID 11
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index c887716e591..b6439bd2945 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.95 2008/08/11 11:05:11 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.96 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -88,10 +88,10 @@ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid,
typedef struct xl_xact_commit
{
TimestampTz xact_time; /* time of commit */
- int nrels; /* number of RelFileForks */
+ int nrels; /* number of RelFileNodes */
int nsubxacts; /* number of subtransaction XIDs */
- /* Array of RelFileFork(s) to drop at commit */
- RelFileFork xnodes[1]; /* VARIABLE LENGTH ARRAY */
+ /* Array of RelFileNode(s) to drop at commit */
+ RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
} xl_xact_commit;
@@ -100,10 +100,10 @@ typedef struct xl_xact_commit
typedef struct xl_xact_abort
{
TimestampTz xact_time; /* time of abort */
- int nrels; /* number of RelFileForks */
+ int nrels; /* number of RelFileNodes */
int nsubxacts; /* number of subtransaction XIDs */
- /* Array of RelFileFork(s) to drop at abort */
- RelFileFork xnodes[1]; /* VARIABLE LENGTH ARRAY */
+ /* Array of RelFileNode(s) to drop at abort */
+ RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
/* ARRAY OF ABORTED SUBTRANSACTION XIDs FOLLOWS */
} xl_xact_abort;
diff --git a/src/include/catalog/storage.h b/src/include/catalog/storage.h
new file mode 100644
index 00000000000..c5caa1283f2
--- /dev/null
+++ b/src/include/catalog/storage.h
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+ *
+ * storage.h
+ * prototypes for functions in backend/catalog/storage.c
+ *
+ *
+ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $PostgreSQL: pgsql/src/include/catalog/storage.h,v 1.1 2008/11/19 10:34:52 heikki Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef STORAGE_H
+#define STORAGE_H
+
+#include "storage/block.h"
+#include "storage/relfilenode.h"
+#include "utils/rel.h"
+
+extern void RelationCreateStorage(RelFileNode rnode, bool istemp);
+extern void RelationDropStorage(Relation rel);
+extern void RelationTruncate(Relation rel, BlockNumber nblocks);
+
+/*
+ * These functions used to be in storage/smgr/smgr.c, which explains the
+ * naming
+ */
+extern void smgrDoPendingDeletes(bool isCommit);
+extern int smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr,
+ bool *haveNonTemp);
+extern void AtSubCommit_smgr(void);
+extern void AtSubAbort_smgr(void);
+extern void PostPrepare_smgr(void);
+
+extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record);
+extern void smgr_desc(StringInfo buf, uint8 xl_info, char *rec);
+
+#endif /* STORAGE_H */
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index f2252c8f460..4e8ae41ab70 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.117 2008/11/06 20:51:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.118 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -176,7 +176,6 @@ extern void PrintBufferLeakWarning(Buffer buffer);
extern void CheckPointBuffers(int flags);
extern BlockNumber BufferGetBlockNumber(Buffer buffer);
extern BlockNumber RelationGetNumberOfBlocks(Relation relation);
-extern void RelationTruncate(Relation rel, BlockNumber nblocks);
extern void FlushRelationBuffers(Relation rel);
extern void FlushDatabaseBuffers(Oid dbid);
extern void DropRelFileNodeBuffers(RelFileNode rnode, ForkNumber forkNum,
diff --git a/src/include/storage/freespace.h b/src/include/storage/freespace.h
index 858be595284..e9490933dbe 100644
--- a/src/include/storage/freespace.h
+++ b/src/include/storage/freespace.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.30 2008/10/31 19:40:27 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.31 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,8 +33,4 @@ extern void XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
extern void FreeSpaceMapTruncateRel(Relation rel, BlockNumber nblocks);
extern void FreeSpaceMapVacuum(Relation rel);
-/* WAL prototypes */
-extern void fsm_desc(StringInfo buf, uint8 xl_info, char *rec);
-extern void fsm_redo(XLogRecPtr lsn, XLogRecord *record);
-
#endif /* FREESPACE_H */
diff --git a/src/include/storage/indexfsm.h b/src/include/storage/indexfsm.h
index 36872076f87..d09732f5abe 100644
--- a/src/include/storage/indexfsm.h
+++ b/src/include/storage/indexfsm.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.2 2008/10/06 08:04:11 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.3 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,8 +20,6 @@ extern BlockNumber GetFreeIndexPage(Relation rel);
extern void RecordFreeIndexPage(Relation rel, BlockNumber page);
extern void RecordUsedIndexPage(Relation rel, BlockNumber page);
-extern void InitIndexFreeSpaceMap(Relation rel);
-extern void IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks);
extern void IndexFreeSpaceMapVacuum(Relation rel);
#endif /* INDEXFSM_H */
diff --git a/src/include/storage/relfilenode.h b/src/include/storage/relfilenode.h
index 383cc18a578..adedad61b33 100644
--- a/src/include/storage/relfilenode.h
+++ b/src/include/storage/relfilenode.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/relfilenode.h,v 1.19 2008/10/06 14:13:17 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/storage/relfilenode.h,v 1.20 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,13 +78,4 @@ typedef struct RelFileNode
(node1).dbNode == (node2).dbNode && \
(node1).spcNode == (node2).spcNode)
-/*
- * RelFileFork identifies a particular fork of a relation.
- */
-typedef struct RelFileFork
-{
- RelFileNode rnode;
- ForkNumber forknum;
-} RelFileFork;
-
#endif /* RELFILENODE_H */
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
index d4999c1049a..edc230f0b68 100644
--- a/src/include/storage/smgr.h
+++ b/src/include/storage/smgr.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.63 2008/08/11 11:05:11 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.64 2008/11/19 10:34:52 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -65,10 +65,7 @@ extern void smgrsetowner(SMgrRelation *owner, SMgrRelation reln);
extern void smgrclose(SMgrRelation reln);
extern void smgrcloseall(void);
extern void smgrclosenode(RelFileNode rnode);
-extern void smgrcreate(SMgrRelation reln, ForkNumber forknum,
- bool isTemp, bool isRedo);
-extern void smgrscheduleunlink(SMgrRelation reln, ForkNumber forknum,
- bool isTemp);
+extern void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
extern void smgrdounlink(SMgrRelation reln, ForkNumber forknum,
bool isTemp, bool isRedo);
extern void smgrextend(SMgrRelation reln, ForkNumber forknum,
@@ -81,21 +78,10 @@ extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
extern void smgrtruncate(SMgrRelation reln, ForkNumber forknum,
BlockNumber nblocks, bool isTemp);
extern void smgrimmedsync(SMgrRelation reln, ForkNumber forknum);
-extern void smgrDoPendingDeletes(bool isCommit);
-extern int smgrGetPendingDeletes(bool forCommit, RelFileFork **ptr,
- bool *haveNonTemp);
-extern void AtSubCommit_smgr(void);
-extern void AtSubAbort_smgr(void);
-extern void PostPrepare_smgr(void);
-extern void smgrcommit(void);
-extern void smgrabort(void);
extern void smgrpreckpt(void);
extern void smgrsync(void);
extern void smgrpostckpt(void);
-extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void smgr_desc(StringInfo buf, uint8 xl_info, char *rec);
-
/* internals: move me elsewhere -- ay 7/94 */