aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-02-10 01:55:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-02-10 01:55:27 +0000
commit87bd95638552b8fc1f5f787ce5b862bb6fc2eb80 (patch)
treeb2b98d5a934750a9ee791992120343b109dac31d /src/backend/access/transam
parentf06e79525a57ccbf54ae5d0b673cd904ca978d67 (diff)
downloadpostgresql-87bd95638552b8fc1f5f787ce5b862bb6fc2eb80.tar.gz
postgresql-87bd95638552b8fc1f5f787ce5b862bb6fc2eb80.zip
Restructure smgr API as per recent proposal. smgr no longer depends on
the relcache, and so the notion of 'blind write' is gone. This should improve efficiency in bgwriter and background checkpoint processes. Internal restructuring in md.c to remove the not-very-useful array of MdfdVec objects --- might as well just use pointers. Also remove the long-dead 'persistent main memory' storage manager (mm.c), since it seems quite unlikely to ever get resurrected.
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r--src/backend/access/transam/slru.c3
-rw-r--r--src/backend/access/transam/xact.c3
-rw-r--r--src/backend/access/transam/xlog.c4
-rw-r--r--src/backend/access/transam/xlogutils.c41
4 files changed, 30 insertions, 21 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index ba3054f14bb..c92f90f6ca8 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.10 2004/01/28 21:02:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.11 2004/02/10 01:55:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,6 +19,7 @@
#include <unistd.h>
#include "access/slru.h"
+#include "storage/fd.h"
#include "storage/lwlock.h"
#include "miscadmin.h"
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index d5f357bc5ff..06e152d1bba 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.161 2004/01/26 22:51:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.162 2004/02/10 01:55:24 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -159,6 +159,7 @@
#include "executor/spi.h"
#include "libpq/be-fsstubs.h"
#include "miscadmin.h"
+#include "storage/fd.h"
#include "storage/proc.h"
#include "storage/sinval.h"
#include "storage/smgr.h"
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index fe1ecd453c5..9056f0b4549 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.133 2004/01/26 22:35:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.134 2004/02/10 01:55:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,6 +30,7 @@
#include "catalog/catversion.h"
#include "catalog/pg_control.h"
#include "storage/bufpage.h"
+#include "storage/fd.h"
#include "storage/lwlock.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
@@ -3126,7 +3127,6 @@ ShutdownXLOG(int code, Datum arg)
MyXactMadeTempRelUpdate = false;
CritSectionCount++;
- CreateDummyCaches();
CreateCheckPoint(true, true);
ShutdownCLOG();
CritSectionCount--;
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index d200b7e17ad..0271742ce0a 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.28 2003/12/14 00:34:47 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.29 2004/02/10 01:55:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -261,14 +261,12 @@ _xl_remove_hash_entry(XLogRelDesc *rdesc)
if (hentry == NULL)
elog(PANIC, "_xl_remove_hash_entry: file was not found in cache");
- if (rdesc->reldata.rd_fd >= 0)
- smgrclose(DEFAULT_SMGR, &(rdesc->reldata));
+ if (rdesc->reldata.rd_smgr != NULL)
+ smgrclose(rdesc->reldata.rd_smgr);
memset(rdesc, 0, sizeof(XLogRelDesc));
memset(tpgc, 0, sizeof(FormData_pg_class));
rdesc->reldata.rd_rel = tpgc;
-
- return;
}
static XLogRelDesc *
@@ -296,7 +294,6 @@ _xl_new_reldesc(void)
void
XLogInitRelationCache(void)
{
- CreateDummyCaches();
_xl_init_rel_cache();
}
@@ -306,8 +303,6 @@ XLogCloseRelationCache(void)
HASH_SEQ_STATUS status;
XLogRelCacheEntry *hentry;
- DestroyDummyCaches();
-
if (!_xlrelarr)
return;
@@ -347,11 +342,18 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
sprintf(RelationGetRelationName(&(res->reldata)), "%u", rnode.relNode);
- /* unexisting DB id */
- res->reldata.rd_lockInfo.lockRelId.dbId = RecoveryDb;
- res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode;
res->reldata.rd_node = rnode;
+ /*
+ * We set up the lockRelId in case anything tries to lock the dummy
+ * relation. Note that this is fairly bogus since relNode may be
+ * different from the relation's OID. It shouldn't really matter
+ * though, since we are presumably running by ourselves and can't
+ * have any lock conflicts ...
+ */
+ res->reldata.rd_lockInfo.lockRelId.dbId = rnode.tblNode;
+ res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode;
+
hentry = (XLogRelCacheEntry *)
hash_search(_xlrelcache, (void *) &rnode, HASH_ENTER, &found);
@@ -364,9 +366,17 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
hentry->rdesc = res;
res->reldata.rd_targblock = InvalidBlockNumber;
- res->reldata.rd_fd = -1;
- res->reldata.rd_fd = smgropen(DEFAULT_SMGR, &(res->reldata),
- true /* allow failure */ );
+ res->reldata.rd_smgr = smgropen(res->reldata.rd_node);
+ /*
+ * Create the target file if it doesn't already exist. This lets
+ * us cope if the replay sequence contains writes to a relation
+ * that is later deleted. (The original coding of this routine
+ * would instead return NULL, causing the writes to be suppressed.
+ * But that seems like it risks losing valuable data if the filesystem
+ * loses an inode during a crash. Better to write the data until we
+ * are actually told to delete the file.)
+ */
+ smgrcreate(res->reldata.rd_smgr, res->reldata.rd_istemp, true);
}
res->moreRecently = &(_xlrelarr[0]);
@@ -374,8 +384,5 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
_xlrelarr[0].lessRecently = res;
res->lessRecently->moreRecently = res;
- if (res->reldata.rd_fd < 0) /* file doesn't exist */
- return (NULL);
-
return (&(res->reldata));
}