Commit 87bd9563 authored by Tom Lane's avatar Tom Lane

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.
parent f06e7952
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.111 2004/02/06 19:36:17 wieck Exp $ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.112 2004/02/10 01:55:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -821,7 +821,9 @@ btvacuumcleanup(PG_FUNCTION_ARGS) ...@@ -821,7 +821,9 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
/* /*
* Do the physical truncation. * Do the physical truncation.
*/ */
new_pages = smgrtruncate(DEFAULT_SMGR, rel, new_pages); if (rel->rd_smgr == NULL)
rel->rd_smgr = smgropen(rel->rd_node);
new_pages = smgrtruncate(rel->rd_smgr, new_pages);
rel->rd_nblocks = new_pages; /* update relcache rel->rd_nblocks = new_pages; /* update relcache
* immediately */ * immediately */
rel->rd_targblock = InvalidBlockNumber; rel->rd_targblock = InvalidBlockNumber;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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 @@ ...@@ -19,6 +19,7 @@
#include <unistd.h> #include <unistd.h>
#include "access/slru.h" #include "access/slru.h"
#include "storage/fd.h"
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "miscadmin.h" #include "miscadmin.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* Transaction aborts can now occur two ways: * Transaction aborts can now occur two ways:
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
#include "executor/spi.h" #include "executor/spi.h"
#include "libpq/be-fsstubs.h" #include "libpq/be-fsstubs.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "storage/proc.h" #include "storage/proc.h"
#include "storage/sinval.h" #include "storage/sinval.h"
#include "storage/smgr.h" #include "storage/smgr.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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 @@ ...@@ -30,6 +30,7 @@
#include "catalog/catversion.h" #include "catalog/catversion.h"
#include "catalog/pg_control.h" #include "catalog/pg_control.h"
#include "storage/bufpage.h" #include "storage/bufpage.h"
#include "storage/fd.h"
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "storage/pmsignal.h" #include "storage/pmsignal.h"
#include "storage/proc.h" #include "storage/proc.h"
...@@ -3126,7 +3127,6 @@ ShutdownXLOG(int code, Datum arg) ...@@ -3126,7 +3127,6 @@ ShutdownXLOG(int code, Datum arg)
MyXactMadeTempRelUpdate = false; MyXactMadeTempRelUpdate = false;
CritSectionCount++; CritSectionCount++;
CreateDummyCaches();
CreateCheckPoint(true, true); CreateCheckPoint(true, true);
ShutdownCLOG(); ShutdownCLOG();
CritSectionCount--; CritSectionCount--;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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) ...@@ -261,14 +261,12 @@ _xl_remove_hash_entry(XLogRelDesc *rdesc)
if (hentry == NULL) if (hentry == NULL)
elog(PANIC, "_xl_remove_hash_entry: file was not found in cache"); elog(PANIC, "_xl_remove_hash_entry: file was not found in cache");
if (rdesc->reldata.rd_fd >= 0) if (rdesc->reldata.rd_smgr != NULL)
smgrclose(DEFAULT_SMGR, &(rdesc->reldata)); smgrclose(rdesc->reldata.rd_smgr);
memset(rdesc, 0, sizeof(XLogRelDesc)); memset(rdesc, 0, sizeof(XLogRelDesc));
memset(tpgc, 0, sizeof(FormData_pg_class)); memset(tpgc, 0, sizeof(FormData_pg_class));
rdesc->reldata.rd_rel = tpgc; rdesc->reldata.rd_rel = tpgc;
return;
} }
static XLogRelDesc * static XLogRelDesc *
...@@ -296,7 +294,6 @@ _xl_new_reldesc(void) ...@@ -296,7 +294,6 @@ _xl_new_reldesc(void)
void void
XLogInitRelationCache(void) XLogInitRelationCache(void)
{ {
CreateDummyCaches();
_xl_init_rel_cache(); _xl_init_rel_cache();
} }
...@@ -306,8 +303,6 @@ XLogCloseRelationCache(void) ...@@ -306,8 +303,6 @@ XLogCloseRelationCache(void)
HASH_SEQ_STATUS status; HASH_SEQ_STATUS status;
XLogRelCacheEntry *hentry; XLogRelCacheEntry *hentry;
DestroyDummyCaches();
if (!_xlrelarr) if (!_xlrelarr)
return; return;
...@@ -347,11 +342,18 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode) ...@@ -347,11 +342,18 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
sprintf(RelationGetRelationName(&(res->reldata)), "%u", rnode.relNode); 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; 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 *) hentry = (XLogRelCacheEntry *)
hash_search(_xlrelcache, (void *) &rnode, HASH_ENTER, &found); hash_search(_xlrelcache, (void *) &rnode, HASH_ENTER, &found);
...@@ -364,9 +366,17 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode) ...@@ -364,9 +366,17 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
hentry->rdesc = res; hentry->rdesc = res;
res->reldata.rd_targblock = InvalidBlockNumber; res->reldata.rd_targblock = InvalidBlockNumber;
res->reldata.rd_fd = -1; res->reldata.rd_smgr = smgropen(res->reldata.rd_node);
res->reldata.rd_fd = smgropen(DEFAULT_SMGR, &(res->reldata), /*
true /* allow failure */ ); * 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]); res->moreRecently = &(_xlrelarr[0]);
...@@ -374,8 +384,5 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode) ...@@ -374,8 +384,5 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
_xlrelarr[0].lessRecently = res; _xlrelarr[0].lessRecently = res;
res->lessRecently->moreRecently = res; res->lessRecently->moreRecently = res;
if (res->reldata.rd_fd < 0) /* file doesn't exist */
return (NULL);
return (&(res->reldata)); return (&(res->reldata));
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.175 2004/01/07 18:56:25 neilc Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.176 2004/02/10 01:55:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -465,14 +465,12 @@ BootstrapMain(int argc, char *argv[]) ...@@ -465,14 +465,12 @@ BootstrapMain(int argc, char *argv[])
break; break;
case BS_XLOG_CHECKPOINT: case BS_XLOG_CHECKPOINT:
CreateDummyCaches();
CreateCheckPoint(false, false); CreateCheckPoint(false, false);
SetSavedRedoRecPtr(); /* pass redo ptr back to SetSavedRedoRecPtr(); /* pass redo ptr back to
* postmaster */ * postmaster */
proc_exit(0); /* done */ proc_exit(0); /* done */
case BS_XLOG_BGWRITER: case BS_XLOG_BGWRITER:
CreateDummyCaches();
BufferBackgroundWriter(); BufferBackgroundWriter();
proc_exit(0); /* done */ proc_exit(0); /* done */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.257 2003/12/28 21:57:36 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.258 2004/02/10 01:55:24 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -298,9 +298,9 @@ heap_create(const char *relname, ...@@ -298,9 +298,9 @@ heap_create(const char *relname,
void void
heap_storage_create(Relation rel) heap_storage_create(Relation rel)
{ {
Assert(rel->rd_fd < 0); Assert(rel->rd_smgr == NULL);
rel->rd_fd = smgrcreate(DEFAULT_SMGR, rel); rel->rd_smgr = smgropen(rel->rd_node);
Assert(rel->rd_fd >= 0); smgrcreate(rel->rd_smgr, rel->rd_istemp, false);
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -1210,7 +1210,12 @@ heap_drop_with_catalog(Oid rid) ...@@ -1210,7 +1210,12 @@ heap_drop_with_catalog(Oid rid)
*/ */
if (rel->rd_rel->relkind != RELKIND_VIEW && if (rel->rd_rel->relkind != RELKIND_VIEW &&
rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE) rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE)
smgrunlink(DEFAULT_SMGR, rel); {
if (rel->rd_smgr == NULL)
rel->rd_smgr = smgropen(rel->rd_node);
smgrscheduleunlink(rel->rd_smgr, rel->rd_istemp);
rel->rd_smgr = NULL;
}
/* /*
* Close relcache entry, but *keep* AccessExclusiveLock on the * Close relcache entry, but *keep* AccessExclusiveLock on the
...@@ -1706,7 +1711,7 @@ SetRelationNumChecks(Relation rel, int numchecks) ...@@ -1706,7 +1711,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
else else
{ {
/* Skip the disk update, but force relcache inval anyway */ /* Skip the disk update, but force relcache inval anyway */
CacheInvalidateRelcache(RelationGetRelid(rel)); CacheInvalidateRelcache(rel);
} }
heap_freetuple(reltup); heap_freetuple(reltup);
...@@ -1943,7 +1948,9 @@ RelationTruncateIndexes(Oid heapId) ...@@ -1943,7 +1948,9 @@ RelationTruncateIndexes(Oid heapId)
DropRelationBuffers(currentIndex); DropRelationBuffers(currentIndex);
/* Now truncate the actual data and set blocks to zero */ /* Now truncate the actual data and set blocks to zero */
smgrtruncate(DEFAULT_SMGR, currentIndex, 0); if (currentIndex->rd_smgr == NULL)
currentIndex->rd_smgr = smgropen(currentIndex->rd_node);
smgrtruncate(currentIndex->rd_smgr, 0);
currentIndex->rd_nblocks = 0; currentIndex->rd_nblocks = 0;
currentIndex->rd_targblock = InvalidBlockNumber; currentIndex->rd_targblock = InvalidBlockNumber;
...@@ -1990,7 +1997,9 @@ heap_truncate(Oid rid) ...@@ -1990,7 +1997,9 @@ heap_truncate(Oid rid)
DropRelationBuffers(rel); DropRelationBuffers(rel);
/* Now truncate the actual data and set blocks to zero */ /* Now truncate the actual data and set blocks to zero */
smgrtruncate(DEFAULT_SMGR, rel, 0); if (rel->rd_smgr == NULL)
rel->rd_smgr = smgropen(rel->rd_node);
smgrtruncate(rel->rd_smgr, 0);
rel->rd_nblocks = 0; rel->rd_nblocks = 0;
rel->rd_targblock = InvalidBlockNumber; rel->rd_targblock = InvalidBlockNumber;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.226 2004/01/28 21:02:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.227 2004/02/10 01:55:24 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -808,7 +808,11 @@ index_drop(Oid indexId) ...@@ -808,7 +808,11 @@ index_drop(Oid indexId)
if (i < 0) if (i < 0)
elog(ERROR, "FlushRelationBuffers returned %d", i); elog(ERROR, "FlushRelationBuffers returned %d", i);
smgrunlink(DEFAULT_SMGR, userIndexRelation); if (userIndexRelation->rd_smgr == NULL)
userIndexRelation->rd_smgr = smgropen(userIndexRelation->rd_node);
smgrscheduleunlink(userIndexRelation->rd_smgr,
userIndexRelation->rd_istemp);
userIndexRelation->rd_smgr = NULL;
/* /*
* We are presently too lazy to attempt to compute the new correct * We are presently too lazy to attempt to compute the new correct
...@@ -818,7 +822,7 @@ index_drop(Oid indexId) ...@@ -818,7 +822,7 @@ index_drop(Oid indexId)
* owning relation to ensure other backends update their relcache * owning relation to ensure other backends update their relcache
* lists of indexes. * lists of indexes.
*/ */
CacheInvalidateRelcache(heapId); CacheInvalidateRelcache(userHeapRelation);
/* /*
* Close rels, but keep locks * Close rels, but keep locks
...@@ -1057,7 +1061,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid) ...@@ -1057,7 +1061,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
else else
{ {
/* no need to change tuple, but force relcache rebuild anyway */ /* no need to change tuple, but force relcache rebuild anyway */
CacheInvalidateRelcache(relid); CacheInvalidateRelcacheByTuple(tuple);
} }
if (!pg_class_scan) if (!pg_class_scan)
...@@ -1077,10 +1081,11 @@ void ...@@ -1077,10 +1081,11 @@ void
setNewRelfilenode(Relation relation) setNewRelfilenode(Relation relation)
{ {
Oid newrelfilenode; Oid newrelfilenode;
RelFileNode newrnode;
SMgrRelation srel;
Relation pg_class; Relation pg_class;
HeapTuple tuple; HeapTuple tuple;
Form_pg_class rd_rel; Form_pg_class rd_rel;
RelationData workrel;
/* Can't change relfilenode for nailed tables (indexes ok though) */ /* Can't change relfilenode for nailed tables (indexes ok though) */
Assert(!relation->rd_isnailed || Assert(!relation->rd_isnailed ||
...@@ -1107,14 +1112,18 @@ setNewRelfilenode(Relation relation) ...@@ -1107,14 +1112,18 @@ setNewRelfilenode(Relation relation)
/* create another storage file. Is it a little ugly ? */ /* create another storage file. Is it a little ugly ? */
/* NOTE: any conflict in relfilenode value will be caught here */ /* NOTE: any conflict in relfilenode value will be caught here */
memcpy((char *) &workrel, relation, sizeof(RelationData)); newrnode = relation->rd_node;
workrel.rd_fd = -1; newrnode.relNode = newrelfilenode;
workrel.rd_node.relNode = newrelfilenode;
heap_storage_create(&workrel); srel = smgropen(newrnode);
smgrclose(DEFAULT_SMGR, &workrel); smgrcreate(srel, relation->rd_istemp, false);
smgrclose(srel);
/* schedule unlinking old relfilenode */ /* schedule unlinking old relfilenode */
smgrunlink(DEFAULT_SMGR, relation); if (relation->rd_smgr == NULL)
relation->rd_smgr = smgropen(relation->rd_node);
smgrscheduleunlink(relation->rd_smgr, relation->rd_istemp);
relation->rd_smgr = NULL;
/* update the pg_class row */ /* update the pg_class row */
rd_rel->relfilenode = newrelfilenode; rd_rel->relfilenode = newrelfilenode;
...@@ -1672,7 +1681,9 @@ reindex_index(Oid indexId) ...@@ -1672,7 +1681,9 @@ reindex_index(Oid indexId)
DropRelationBuffers(iRel); DropRelationBuffers(iRel);
/* Now truncate the actual data and set blocks to zero */ /* Now truncate the actual data and set blocks to zero */
smgrtruncate(DEFAULT_SMGR, iRel, 0); if (iRel->rd_smgr == NULL)
iRel->rd_smgr = smgropen(iRel->rd_node);
smgrtruncate(iRel->rd_smgr, 0);
iRel->rd_nblocks = 0; iRel->rd_nblocks = 0;
iRel->rd_targblock = InvalidBlockNumber; iRel->rd_targblock = InvalidBlockNumber;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.217 2004/01/28 21:02:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.218 2004/02/10 01:55:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "parser/parse_coerce.h" #include "parser/parse_coerce.h"
#include "parser/parse_relation.h" #include "parser/parse_relation.h"
#include "rewrite/rewriteHandler.h" #include "rewrite/rewriteHandler.h"
#include "storage/fd.h"
#include "tcop/pquery.h" #include "tcop/pquery.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/acl.h" #include "utils/acl.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.130 2004/01/07 18:56:25 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "storage/freespace.h" #include "storage/freespace.h"
#include "storage/sinval.h" #include "storage/sinval.h"
#include "utils/acl.h" #include "utils/acl.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.97 2004/01/28 21:02:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.98 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1010,7 +1010,7 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass) ...@@ -1010,7 +1010,7 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
else else
{ {
/* no need to change tuple, but force relcache rebuild anyway */ /* no need to change tuple, but force relcache rebuild anyway */
CacheInvalidateRelcache(relationId); CacheInvalidateRelcacheByTuple(tuple);
} }
heap_freetuple(tuple); heap_freetuple(tuple);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.163 2003/11/29 19:51:47 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.164 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -691,7 +691,7 @@ renametrig(Oid relid, ...@@ -691,7 +691,7 @@ renametrig(Oid relid,
* relcache entries. (Ideally this should happen * relcache entries. (Ideally this should happen
* automatically...) * automatically...)
*/ */
CacheInvalidateRelcache(relid); CacheInvalidateRelcache(targetrel);
} }
else else
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.136 2004/02/02 17:21:07 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.137 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "commands/user.h" #include "commands/user.h"
#include "libpq/crypt.h" #include "libpq/crypt.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "storage/pmsignal.h" #include "storage/pmsignal.h"
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/array.h" #include "utils/array.h"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.271 2004/01/07 18:56:25 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.272 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2513,7 +2513,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, ...@@ -2513,7 +2513,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
/* truncate relation, if needed */ /* truncate relation, if needed */
if (blkno < nblocks) if (blkno < nblocks)
{ {
blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno); if (onerel->rd_smgr == NULL)
onerel->rd_smgr = smgropen(onerel->rd_node);
blkno = smgrtruncate(onerel->rd_smgr, blkno);
onerel->rd_nblocks = blkno; /* update relcache immediately */ onerel->rd_nblocks = blkno; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber; onerel->rd_targblock = InvalidBlockNumber;
vacrelstats->rel_pages = blkno; /* set new number of blocks */ vacrelstats->rel_pages = blkno; /* set new number of blocks */
...@@ -2582,7 +2584,9 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages) ...@@ -2582,7 +2584,9 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages)
(errmsg("\"%s\": truncated %u to %u pages", (errmsg("\"%s\": truncated %u to %u pages",
RelationGetRelationName(onerel), RelationGetRelationName(onerel),
vacrelstats->rel_pages, relblocks))); vacrelstats->rel_pages, relblocks)));
relblocks = smgrtruncate(DEFAULT_SMGR, onerel, relblocks); if (onerel->rd_smgr == NULL)
onerel->rd_smgr = smgropen(onerel->rd_node);
relblocks = smgrtruncate(onerel->rd_smgr, relblocks);
onerel->rd_nblocks = relblocks; /* update relcache immediately */ onerel->rd_nblocks = relblocks; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber; onerel->rd_targblock = InvalidBlockNumber;
vacrelstats->rel_pages = relblocks; /* set new number of vacrelstats->rel_pages = relblocks; /* set new number of
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.35 2004/02/06 19:36:17 wieck Exp $ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.36 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -148,9 +148,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) ...@@ -148,9 +148,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
vac_open_indexes(onerel, &nindexes, &Irel); vac_open_indexes(onerel, &nindexes, &Irel);
hasindex = (nindexes > 0); hasindex = (nindexes > 0);
/* Turn on vacuum cost accounting */ /* Turn vacuum cost accounting on or off */
if (VacuumCostNaptime > 0) VacuumCostActive = (VacuumCostNaptime > 0);
VacuumCostActive = true;
VacuumCostBalance = 0; VacuumCostBalance = 0;
/* Do the vacuuming */ /* Do the vacuuming */
...@@ -784,7 +783,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -784,7 +783,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
/* /*
* Do the physical truncation. * Do the physical truncation.
*/ */
new_rel_pages = smgrtruncate(DEFAULT_SMGR, onerel, new_rel_pages); if (onerel->rd_smgr == NULL)
onerel->rd_smgr = smgropen(onerel->rd_node);
new_rel_pages = smgrtruncate(onerel->rd_smgr, new_rel_pages);
onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */ onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */
onerel->rd_targblock = InvalidBlockNumber; onerel->rd_targblock = InvalidBlockNumber;
vacrelstats->rel_pages = new_rel_pages; /* save new number of vacrelstats->rel_pages = new_rel_pages; /* save new number of
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.69 2003/11/29 19:51:49 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.70 2004/02/10 01:55:25 tgl Exp $
* *
* NOTES * NOTES
* This should be moved to a more appropriate place. It is here * This should be moved to a more appropriate place. It is here
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "libpq/be-fsstubs.h" #include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h" #include "libpq/libpq-fs.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "storage/large_object.h" #include "storage/large_object.h"
#include "utils/memutils.h" #include "utils/memutils.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.92 2004/01/14 23:01:55 tgl Exp $ * $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.93 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -480,7 +480,12 @@ DefineQueryRewrite(RuleStmt *stmt) ...@@ -480,7 +480,12 @@ DefineQueryRewrite(RuleStmt *stmt)
* XXX what about getting rid of its TOAST table? For now, we don't. * XXX what about getting rid of its TOAST table? For now, we don't.
*/ */
if (RelisBecomingView) if (RelisBecomingView)
smgrunlink(DEFAULT_SMGR, event_relation); {
if (event_relation->rd_smgr == NULL)
event_relation->rd_smgr = smgropen(event_relation->rd_node);
smgrscheduleunlink(event_relation->rd_smgr, event_relation->rd_istemp);
event_relation->rd_smgr = NULL;
}
/* Close rel, but keep lock till commit... */ /* Close rel, but keep lock till commit... */
heap_close(event_relation, NoLock); heap_close(event_relation, NoLock);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.57 2003/11/29 19:51:55 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.58 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -84,7 +84,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules, ...@@ -84,7 +84,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules,
else else
{ {
/* no need to change tuple, but force relcache rebuild anyway */ /* no need to change tuple, but force relcache rebuild anyway */
CacheInvalidateRelcache(relationId); CacheInvalidateRelcacheByTuple(tuple);
} }
heap_freetuple(tuple); heap_freetuple(tuple);
......
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.51 2004/01/07 18:56:27 neilc Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.52 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -90,24 +90,15 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) ...@@ -90,24 +90,15 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
*/ */
if (bufHdr->flags & BM_DIRTY || bufHdr->cntxDirty) if (bufHdr->flags & BM_DIRTY || bufHdr->cntxDirty)
{ {
Relation bufrel = RelationNodeCacheGetRelation(bufHdr->tag.rnode); SMgrRelation reln;
/* flush this page */ /* Find smgr relation for buffer */
if (bufrel == NULL) reln = smgropen(bufHdr->tag.rnode);
{
smgrblindwrt(DEFAULT_SMGR, /* And write... */
bufHdr->tag.rnode, smgrwrite(reln,
bufHdr->tag.blockNum, bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data)); (char *) MAKE_PTR(bufHdr->data));
}
else
{
smgrwrite(DEFAULT_SMGR, bufrel,
bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data));
/* drop refcount incremented by RelationNodeCacheGetRelation */
RelationDecrementReferenceCount(bufrel);
}
LocalBufferFlushCount++; LocalBufferFlushCount++;
} }
...@@ -143,9 +134,6 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) ...@@ -143,9 +134,6 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
/* /*
* it's all ours now. * it's all ours now.
*
* We need not in tblNode currently but will in future I think, when
* we'll give up rel->rd_fd to fmgr cache.
*/ */
bufHdr->tag.rnode = reln->rd_node; bufHdr->tag.rnode = reln->rd_node;
bufHdr->tag.blockNum = blockNum; bufHdr->tag.blockNum = blockNum;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.63 2004/01/26 22:59:53 momjian Exp $ * $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.64 2004/02/10 01:55:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -65,9 +65,6 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, ...@@ -65,9 +65,6 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
size += FreeSpaceShmemSize(); size += FreeSpaceShmemSize();
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
size += ShmemBackendArraySize(); size += ShmemBackendArraySize();
#endif
#ifdef STABLE_MEMORY_STORAGE
size += MMShmemSize();
#endif #endif
size += 100000; size += 100000;
/* might as well round it off to a multiple of a typical page size */ /* might as well round it off to a multiple of a typical page size */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for storage/smgr # Makefile for storage/smgr
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/storage/smgr/Makefile,v 1.14 2003/11/29 19:51:57 pgsql Exp $ # $PostgreSQL: pgsql/src/backend/storage/smgr/Makefile,v 1.15 2004/02/10 01:55:26 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -12,7 +12,7 @@ subdir = src/backend/storage/smgr ...@@ -12,7 +12,7 @@ subdir = src/backend/storage/smgr
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
OBJS = md.o mm.o smgr.o smgrtype.o OBJS = md.o smgr.o smgrtype.o
all: SUBSYS.o all: SUBSYS.o
......
# $PostgreSQL: pgsql/src/backend/storage/smgr/README,v 1.2 2003/11/29 19:51:57 pgsql Exp $ # $PostgreSQL: pgsql/src/backend/storage/smgr/README,v 1.3 2004/02/10 01:55:26 tgl Exp $
This directory contains the code that supports the Postgres storage manager In the original Berkeley Postgres system, there were several storage managers,
switch and all of the installed storage managers. In released systems, of which only the "magnetic disk" manager remains. (At Berkeley there were
the only supported storage manager is the magnetic disk manager. At UC also managers for the Sony WORM optical disk jukebox and persistent main
Berkeley, the Sony WORM optical disk jukebox and persistent main memory are memory, but these were never supported in any externally released Postgres,
also supported. nor in any version of PostgreSQL.) However, we retain the notion of a storage
manager switch in case anyone wants to reintroduce other kinds of storage
managers.
As of Postgres Release 3.0, every relation in the system is tagged with the In Berkeley Postgres each relation was tagged with the ID of the storage
storage manager on which it resides. The storage manager switch code turns manager to use for it. This is gone. It would be more reasonable to
what used to by filesystem operations into operations on the correct store, associate storage managers with tablespaces (a feature not present as this
for any given relation. text is being written, but one likely to emerge soon).
The files in this directory, and their contents, are The files in this directory, and their contents, are
smgrtype.c Storage manager type -- maps string names to storage manager smgrtype.c Storage manager type -- maps string names to storage manager
IDs and provides simple comparison operators. This is the IDs and provides simple comparison operators. This is the
regproc support for type 'smgr' in the system catalogs. regproc support for type 'smgr' in the system catalogs.
(This is vestigial since no columns of type smgr exist
in the catalogs anymore.)
smgr.c The storage manager switch dispatch code. The routines in smgr.c The storage manager switch dispatch code. The routines in
this file call the appropriate storage manager to do hardware this file call the appropriate storage manager to do hardware
accesses requested by the backend. accesses requested by the backend. smgr.c also manages the
file handle cache (SMgrRelation table).
md.c The magnetic disk storage manager. md.c The magnetic disk storage manager.
mm.c The persistent main memory storage manager (#undef'ed in Note that md.c in turn relies on src/backend/storage/file/fd.c.
tmp/c.h for all distributed systems).
sj.c The sony jukebox storage manager and cache management code
(#undef'ed in tmp/c.h for all distributed systems). The
routines in this file allocate extents, maintain block
maps, and guarantee the persistence and coherency of a cache
of jukebox blocks on magnetic disk.
pgjb.c The postgres jukebox interface routines. The routines here
handle exclusion on the physical device and translate requests
from the storage manager code (sj.c) into jbaccess calls.
jbaccess.c Access code for the physical Sony jukebox device. This code
was swiped from Andy McFadden's jblib.a code at UC Berkeley.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgrtype.c,v 1.22 2003/11/29 19:51:57 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/storage/smgr/smgrtype.c,v 1.23 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -16,26 +16,21 @@ ...@@ -16,26 +16,21 @@
#include "storage/smgr.h" #include "storage/smgr.h"
typedef struct smgrid typedef struct smgrid
{ {
char *smgr_name; const char *smgr_name;
} smgrid; } smgrid;
/* /*
* StorageManager[] -- List of defined storage managers. * StorageManager[] -- List of defined storage managers.
*
* The weird comma placement is to keep compilers happy no matter
* which of these is (or is not) defined.
*/ */
static const smgrid StorageManager[] = {
static smgrid StorageManager[] = { {"magnetic disk"}
{"magnetic disk"},
#ifdef STABLE_MEMORY_STORAGE
{"main memory"}
#endif
}; };
static int NStorageManagers = lengthof(StorageManager); static const int NStorageManagers = lengthof(StorageManager);
Datum Datum
smgrin(PG_FUNCTION_ARGS) smgrin(PG_FUNCTION_ARGS)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.209 2003/11/29 19:51:57 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.210 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "rewrite/rewriteDefine.h" #include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteRemove.h" #include "rewrite/rewriteRemove.h"
#include "storage/fd.h"
#include "tcop/pquery.h" #include "tcop/pquery.h"
#include "tcop/utility.h" #include "tcop/utility.h"
#include "utils/acl.h" #include "utils/acl.h"
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.59 2003/11/29 19:52:00 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.60 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/sinval.h" #include "storage/sinval.h"
#include "storage/smgr.h"
#include "utils/catcache.h" #include "utils/catcache.h"
#include "utils/inval.h" #include "utils/inval.h"
#include "utils/memutils.h" #include "utils/memutils.h"
...@@ -298,19 +299,22 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr, ...@@ -298,19 +299,22 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr,
*/ */
static void static void
AddRelcacheInvalidationMessage(InvalidationListHeader *hdr, AddRelcacheInvalidationMessage(InvalidationListHeader *hdr,
Oid dbId, Oid relId) Oid dbId, Oid relId, RelFileNode physId)
{ {
SharedInvalidationMessage msg; SharedInvalidationMessage msg;
/* Don't add a duplicate item */ /* Don't add a duplicate item */
/* We assume comparing relId is sufficient, needn't check dbId */ /* We assume dbId need not be checked because it will never change */
/* relfilenode fields must be checked to support reassignment */
ProcessMessageList(hdr->rclist, ProcessMessageList(hdr->rclist,
if (msg->rc.relId == relId) return); if (msg->rc.relId == relId &&
RelFileNodeEquals(msg->rc.physId, physId)) return);
/* OK, add the item */ /* OK, add the item */
msg.rc.id = SHAREDINVALRELCACHE_ID; msg.rc.id = SHAREDINVALRELCACHE_ID;
msg.rc.dbId = dbId; msg.rc.dbId = dbId;
msg.rc.relId = relId; msg.rc.relId = relId;
msg.rc.physId = physId;
AddInvalidationMessage(&hdr->rclist, &msg); AddInvalidationMessage(&hdr->rclist, &msg);
} }
...@@ -391,10 +395,10 @@ RegisterCatcacheInvalidation(int cacheId, ...@@ -391,10 +395,10 @@ RegisterCatcacheInvalidation(int cacheId,
* As above, but register a relcache invalidation event. * As above, but register a relcache invalidation event.
*/ */
static void static void
RegisterRelcacheInvalidation(Oid dbId, Oid relId) RegisterRelcacheInvalidation(Oid dbId, Oid relId, RelFileNode physId)
{ {
AddRelcacheInvalidationMessage(&CurrentCmdInvalidMsgs, AddRelcacheInvalidationMessage(&CurrentCmdInvalidMsgs,
dbId, relId); dbId, relId, physId);
/* /*
* If the relation being invalidated is one of those cached in the * If the relation being invalidated is one of those cached in the
...@@ -435,9 +439,17 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) ...@@ -435,9 +439,17 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
} }
else if (msg->id == SHAREDINVALRELCACHE_ID) else if (msg->id == SHAREDINVALRELCACHE_ID)
{ {
if (msg->rc.dbId == MyDatabaseId || msg->rc.dbId == 0) /*
* If the message includes a valid relfilenode, we must ensure that
* smgr cache entry gets zapped. The relcache will handle this if
* called, otherwise we must do it directly.
*/
if (msg->rc.dbId == MyDatabaseId || msg->rc.dbId == InvalidOid)
{ {
RelationIdInvalidateRelationCacheByRelationId(msg->rc.relId); if (OidIsValid(msg->rc.physId.relNode))
RelationCacheInvalidateEntry(msg->rc.relId, &msg->rc.physId);
else
RelationCacheInvalidateEntry(msg->rc.relId, NULL);
for (i = 0; i < cache_callback_count; i++) for (i = 0; i < cache_callback_count; i++)
{ {
...@@ -447,6 +459,12 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) ...@@ -447,6 +459,12 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
(*ccitem->function) (ccitem->arg, msg->rc.relId); (*ccitem->function) (ccitem->arg, msg->rc.relId);
} }
} }
else
{
/* might have smgr entry even if not in our database */
if (OidIsValid(msg->rc.physId.relNode))
smgrclosenode(msg->rc.physId);
}
} }
else else
elog(FATAL, "unrecognized SI message id: %d", msg->id); elog(FATAL, "unrecognized SI message id: %d", msg->id);
...@@ -456,7 +474,7 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) ...@@ -456,7 +474,7 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
* InvalidateSystemCaches * InvalidateSystemCaches
* *
* This blows away all tuples in the system catalog caches and * This blows away all tuples in the system catalog caches and
* all the cached relation descriptors (and closes their files too). * all the cached relation descriptors and smgr cache entries.
* Relation descriptors that have positive refcounts are then rebuilt. * Relation descriptors that have positive refcounts are then rebuilt.
* *
* We call this when we see a shared-inval-queue overflow signal, * We call this when we see a shared-inval-queue overflow signal,
...@@ -469,7 +487,7 @@ InvalidateSystemCaches(void) ...@@ -469,7 +487,7 @@ InvalidateSystemCaches(void)
int i; int i;
ResetCatalogCaches(); ResetCatalogCaches();
RelationCacheInvalidate(); RelationCacheInvalidate(); /* gets smgr cache too */
for (i = 0; i < cache_callback_count; i++) for (i = 0; i < cache_callback_count; i++)
{ {
...@@ -488,11 +506,15 @@ static void ...@@ -488,11 +506,15 @@ static void
PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
void (*CacheIdRegisterFunc) (int, uint32, void (*CacheIdRegisterFunc) (int, uint32,
ItemPointer, Oid), ItemPointer, Oid),
void (*RelationIdRegisterFunc) (Oid, Oid)) void (*RelationIdRegisterFunc) (Oid, Oid,
RelFileNode))
{ {
Oid tupleRelId; Oid tupleRelId;
Oid databaseId;
Oid relationId; Oid relationId;
RelFileNode rnode;
/* Do nothing during bootstrap */
if (IsBootstrapProcessingMode()) if (IsBootstrapProcessingMode())
return; return;
...@@ -524,24 +546,49 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, ...@@ -524,24 +546,49 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
tupleRelId = RelationGetRelid(relation); tupleRelId = RelationGetRelid(relation);
if (tupleRelId == RelOid_pg_class) if (tupleRelId == RelOid_pg_class)
{
Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
relationId = HeapTupleGetOid(tuple); relationId = HeapTupleGetOid(tuple);
if (classtup->relisshared)
databaseId = InvalidOid;
else
databaseId = MyDatabaseId;
rnode.tblNode = databaseId; /* XXX change for tablespaces */
rnode.relNode = classtup->relfilenode;
/*
* Note: during a pg_class row update that assigns a new relfilenode
* value, we will be called on both the old and new tuples, and thus
* will broadcast invalidation messages showing both the old and new
* relfilenode values. This ensures that other backends will close
* smgr references to the old relfilenode file.
*/
}
else if (tupleRelId == RelOid_pg_attribute) else if (tupleRelId == RelOid_pg_attribute)
relationId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid; {
Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
relationId = atttup->attrelid;
/*
* KLUGE ALERT: we always send the relcache event with MyDatabaseId,
* even if the rel in question is shared (which we can't easily tell).
* This essentially means that only backends in this same database
* will react to the relcache flush request. This is in fact
* appropriate, since only those backends could see our pg_attribute
* change anyway. It looks a bit ugly though.
*/
databaseId = MyDatabaseId;
/* We assume no smgr cache flush is needed, either */
rnode.tblNode = InvalidOid;
rnode.relNode = InvalidOid;
}
else else
return; return;
/* /*
* Yes. We need to register a relcache invalidation event for the * Yes. We need to register a relcache invalidation event.
* relation identified by relationId.
*
* KLUGE ALERT: we always send the relcache event with MyDatabaseId, even
* if the rel in question is shared. This essentially means that only
* backends in this same database will react to the relcache flush
* request. This is in fact appropriate, since only those backends
* could see our pg_class or pg_attribute change anyway. It looks a
* bit ugly though.
*/ */
(*RelationIdRegisterFunc) (MyDatabaseId, relationId); (*RelationIdRegisterFunc) (databaseId, relationId, rnode);
} }
...@@ -660,7 +707,7 @@ CommandEndInvalidationMessages(bool isCommit) ...@@ -660,7 +707,7 @@ CommandEndInvalidationMessages(bool isCommit)
/* /*
* CacheInvalidateHeapTuple * CacheInvalidateHeapTuple
* Register the given tuple for invalidation at end of command * Register the given tuple for invalidation at end of command
* (ie, current command is outdating this tuple). * (ie, current command is creating or outdating this tuple).
*/ */
void void
CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple) CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple)
...@@ -678,12 +725,44 @@ CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple) ...@@ -678,12 +725,44 @@ CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple)
* This is used in places that need to force relcache rebuild but aren't * This is used in places that need to force relcache rebuild but aren't
* changing any of the tuples recognized as contributors to the relcache * changing any of the tuples recognized as contributors to the relcache
* entry by PrepareForTupleInvalidation. (An example is dropping an index.) * entry by PrepareForTupleInvalidation. (An example is dropping an index.)
* We assume in particular that relfilenode isn't changing.
*/ */
void void
CacheInvalidateRelcache(Oid relationId) CacheInvalidateRelcache(Relation relation)
{ {
/* See KLUGE ALERT in PrepareForTupleInvalidation */ Oid databaseId;
RegisterRelcacheInvalidation(MyDatabaseId, relationId); Oid relationId;
relationId = RelationGetRelid(relation);
if (relation->rd_rel->relisshared)
databaseId = InvalidOid;
else
databaseId = MyDatabaseId;
RegisterRelcacheInvalidation(databaseId, relationId, relation->rd_node);
}
/*
* CacheInvalidateRelcacheByTuple
* As above, but relation is identified by passing its pg_class tuple.
*/
void
CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
{
Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
Oid databaseId;
Oid relationId;
RelFileNode rnode;
relationId = HeapTupleGetOid(classTuple);
if (classtup->relisshared)
databaseId = InvalidOid;
else
databaseId = MyDatabaseId;
rnode.tblNode = databaseId; /* XXX change for tablespaces */
rnode.relNode = classtup->relfilenode;
RegisterRelcacheInvalidation(databaseId, relationId, rnode);
} }
/* /*
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.122 2004/02/08 22:28:57 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.123 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "catalog/pg_shadow.h" #include "catalog/pg_shadow.h"
#include "libpq/libpq-be.h" #include "libpq/libpq-be.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "storage/ipc.h" #include "storage/ipc.h"
#include "storage/pg_shmem.h" #include "storage/pg_shmem.h"
#include "utils/builtins.h" #include "utils/builtins.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.30 2003/11/29 22:40:58 pgsql Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.31 2004/02/10 01:55:26 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -72,15 +72,6 @@ typedef FormData_pg_database *Form_pg_database; ...@@ -72,15 +72,6 @@ typedef FormData_pg_database *Form_pg_database;
DATA(insert OID = 1 ( template1 PGUID ENCODING t t 0 0 0 "" _null_ _null_ )); DATA(insert OID = 1 ( template1 PGUID ENCODING t t 0 0 0 "" _null_ _null_ ));
DESCR("Default template database"); DESCR("Default template database");
#define TemplateDbOid 1 #define TemplateDbOid 1
/* Just to mark OID as used for unused_oid script -:) */
#define DATAMARKOID(x)
DATAMARKOID(= 2)
#define RecoveryDb 2
#undef DATAMARKOID
#endif /* PG_DATABASE_H */ #endif /* PG_DATABASE_H */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.32 2003/11/29 22:41:13 pgsql Exp $ * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.33 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "storage/backendid.h" #include "storage/backendid.h"
#include "storage/itemptr.h" #include "storage/itemptr.h"
#include "storage/relfilenode.h"
/* /*
...@@ -27,6 +28,13 @@ ...@@ -27,6 +28,13 @@
* ID field). -1 means a relcache inval message. Other negative values * ID field). -1 means a relcache inval message. Other negative values
* are available to identify other inval message types. * are available to identify other inval message types.
* *
* Relcache invalidation messages usually also cause invalidation of entries
* in the smgr's relation cache. This means they must carry both logical
* and physical relation ID info (ie, both dbOID/relOID and RelFileNode).
* In some cases RelFileNode information is not available so the sender fills
* those fields with zeroes --- this is okay so long as no smgr cache flush
* is required.
*
* Shared-inval events are initially driven by detecting tuple inserts, * Shared-inval events are initially driven by detecting tuple inserts,
* updates and deletions in system catalogs (see CacheInvalidateHeapTuple). * updates and deletions in system catalogs (see CacheInvalidateHeapTuple).
* An update generates two inval events, one for the old tuple and one for * An update generates two inval events, one for the old tuple and one for
...@@ -63,6 +71,12 @@ typedef struct ...@@ -63,6 +71,12 @@ typedef struct
int16 id; /* type field --- must be first */ int16 id; /* type field --- must be first */
Oid dbId; /* database ID, or 0 if a shared relation */ Oid dbId; /* database ID, or 0 if a shared relation */
Oid relId; /* relation ID */ Oid relId; /* relation ID */
RelFileNode physId; /* physical file ID */
/*
* Note: it is likely that RelFileNode will someday be changed to
* include database ID. In that case the dbId field will be redundant
* and should be removed to save space.
*/
} SharedInvalRelcacheMsg; } SharedInvalRelcacheMsg;
typedef union typedef union
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.39 2003/11/29 22:41:13 pgsql Exp $ * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.40 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -16,36 +16,54 @@ ...@@ -16,36 +16,54 @@
#include "access/xlog.h" #include "access/xlog.h"
#include "fmgr.h" #include "fmgr.h"
#include "storage/relfilenode.h"
#include "storage/block.h" #include "storage/block.h"
#include "utils/rel.h" #include "storage/relfilenode.h"
/*
* smgr.c maintains a table of SMgrRelation objects, which are essentially
* cached file handles. An SMgrRelation is created (if not already present)
* by smgropen(), and destroyed by smgrclose(). Note that neither of these
* operations imply I/O, they just create or destroy a hashtable entry.
* (But smgrclose() may release associated resources, such as OS-level file
* descriptors.)
*/
typedef struct SMgrRelationData
{
/* rnode is the hashtable lookup key, so it must be first! */
RelFileNode smgr_rnode; /* relation physical identifier */
/* additional public fields may someday exist here */
#define SM_FAIL 0 /*
#define SM_SUCCESS 1 * Fields below here are intended to be private to smgr.c and its
* submodules. Do not touch them from elsewhere.
*/
int smgr_which; /* storage manager selector */
#define DEFAULT_SMGR 0 struct _MdfdVec *md_fd; /* for md.c; NULL if not open */
} SMgrRelationData;
extern int smgrinit(void); typedef SMgrRelationData *SMgrRelation;
extern int smgrcreate(int16 which, Relation reln);
extern int smgrunlink(int16 which, Relation reln);
extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum, extern void smgrinit(void);
char *buffer); extern SMgrRelation smgropen(RelFileNode rnode);
extern int smgropen(int16 which, Relation reln, bool failOK); extern void smgrclose(SMgrRelation reln);
extern int smgrclose(int16 which, Relation reln); extern void smgrcloseall(void);
extern int smgrread(int16 which, Relation reln, BlockNumber blocknum, extern void smgrclosenode(RelFileNode rnode);
char *buffer); extern void smgrcreate(SMgrRelation reln, bool isTemp, bool isRedo);
extern int smgrwrite(int16 which, Relation reln, BlockNumber blocknum, extern void smgrscheduleunlink(SMgrRelation reln, bool isTemp);
char *buffer); extern void smgrdounlink(SMgrRelation reln, bool isTemp, bool isRedo);
extern int smgrblindwrt(int16 which, RelFileNode rnode, extern void smgrextend(SMgrRelation reln, BlockNumber blocknum, char *buffer);
BlockNumber blkno, char *buffer); extern void smgrread(SMgrRelation reln, BlockNumber blocknum, char *buffer);
extern BlockNumber smgrnblocks(int16 which, Relation reln); extern void smgrwrite(SMgrRelation reln, BlockNumber blocknum, char *buffer);
extern BlockNumber smgrtruncate(int16 which, Relation reln, extern BlockNumber smgrnblocks(SMgrRelation reln);
BlockNumber nblocks); extern BlockNumber smgrtruncate(SMgrRelation reln, BlockNumber nblocks);
extern int smgrDoPendingDeletes(bool isCommit); extern void smgrDoPendingDeletes(bool isCommit);
extern int smgrcommit(void); extern void smgrcommit(void);
extern int smgrabort(void); extern void smgrabort(void);
extern int smgrsync(void); extern void smgrsync(void);
extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record); extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record);
extern void smgr_undo(XLogRecPtr lsn, XLogRecord *record); extern void smgr_undo(XLogRecPtr lsn, XLogRecord *record);
...@@ -55,38 +73,18 @@ extern void smgr_desc(char *buf, uint8 xl_info, char *rec); ...@@ -55,38 +73,18 @@ extern void smgr_desc(char *buf, uint8 xl_info, char *rec);
/* internals: move me elsewhere -- ay 7/94 */ /* internals: move me elsewhere -- ay 7/94 */
/* in md.c */ /* in md.c */
extern int mdinit(void); extern bool mdinit(void);
extern int mdcreate(Relation reln); extern bool mdclose(SMgrRelation reln);
extern int mdunlink(RelFileNode rnode); extern bool mdcreate(SMgrRelation reln, bool isRedo);
extern int mdextend(Relation reln, BlockNumber blocknum, char *buffer); extern bool mdunlink(RelFileNode rnode, bool isRedo);
extern int mdopen(Relation reln); extern bool mdextend(SMgrRelation reln, BlockNumber blocknum, char *buffer);
extern int mdclose(Relation reln); extern bool mdread(SMgrRelation reln, BlockNumber blocknum, char *buffer);
extern int mdread(Relation reln, BlockNumber blocknum, char *buffer); extern bool mdwrite(SMgrRelation reln, BlockNumber blocknum, char *buffer);
extern int mdwrite(Relation reln, BlockNumber blocknum, char *buffer); extern BlockNumber mdnblocks(SMgrRelation reln);
extern int mdblindwrt(RelFileNode rnode, BlockNumber blkno, char *buffer); extern BlockNumber mdtruncate(SMgrRelation reln, BlockNumber nblocks);
extern BlockNumber mdnblocks(Relation reln); extern bool mdcommit(void);
extern BlockNumber mdtruncate(Relation reln, BlockNumber nblocks); extern bool mdabort(void);
extern int mdcommit(void); extern bool mdsync(void);
extern int mdabort(void);
extern int mdsync(void);
/* mm.c */
extern int mminit(void);
extern int mmcreate(Relation reln);
extern int mmunlink(RelFileNode rnode);
extern int mmextend(Relation reln, BlockNumber blocknum, char *buffer);
extern int mmopen(Relation reln);
extern int mmclose(Relation reln);
extern int mmread(Relation reln, BlockNumber blocknum, char *buffer);
extern int mmwrite(Relation reln, BlockNumber blocknum, char *buffer);
extern int mmblindwrt(RelFileNode rnode, BlockNumber blkno, char *buffer);
extern BlockNumber mmnblocks(Relation reln);
extern BlockNumber mmtruncate(Relation reln, BlockNumber nblocks);
extern int mmcommit(void);
extern int mmabort(void);
extern int mmshutdown(void);
extern int MMShmemSize(void);
/* smgrtype.c */ /* smgrtype.c */
extern Datum smgrout(PG_FUNCTION_ARGS); extern Datum smgrout(PG_FUNCTION_ARGS);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.29 2003/11/29 22:41:15 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.30 2004/02/10 01:55:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,7 +28,9 @@ extern void CommandEndInvalidationMessages(bool isCommit); ...@@ -28,7 +28,9 @@ extern void CommandEndInvalidationMessages(bool isCommit);
extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple); extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple);
extern void CacheInvalidateRelcache(Oid relationId); extern void CacheInvalidateRelcache(Relation relation);
extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple);
extern void CacheRegisterSyscacheCallback(int cacheid, extern void CacheRegisterSyscacheCallback(int cacheid,
CacheCallbackFunction func, CacheCallbackFunction func,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.72 2004/01/06 18:07:32 neilc Exp $ * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.73 2004/02/10 01:55:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "catalog/pg_index.h" #include "catalog/pg_index.h"
#include "rewrite/prs2lock.h" #include "rewrite/prs2lock.h"
#include "storage/block.h" #include "storage/block.h"
#include "storage/fd.h"
#include "storage/relfilenode.h" #include "storage/relfilenode.h"
...@@ -98,16 +97,16 @@ typedef struct PgStat_Info ...@@ -98,16 +97,16 @@ typedef struct PgStat_Info
bool index_scan_counted; bool index_scan_counted;
} PgStat_Info; } PgStat_Info;
/* /*
* Here are the contents of a relation cache entry. * Here are the contents of a relation cache entry.
*/ */
typedef struct RelationData typedef struct RelationData
{ {
File rd_fd; /* open file descriptor, or -1 if RelFileNode rd_node; /* relation physical identifier */
* none; this is NOT an operating /* use "struct" here to avoid needing to include smgr.h: */
* system file descriptor */ struct SMgrRelationData *rd_smgr; /* cached file handle, or NULL */
RelFileNode rd_node; /* file node (physical identifier) */
BlockNumber rd_nblocks; /* number of blocks in rel */ BlockNumber rd_nblocks; /* number of blocks in rel */
BlockNumber rd_targblock; /* current insertion target block, or BlockNumber rd_targblock; /* current insertion target block, or
* InvalidBlockNumber */ * InvalidBlockNumber */
...@@ -226,14 +225,6 @@ typedef Relation *RelationPtr; ...@@ -226,14 +225,6 @@ typedef Relation *RelationPtr;
*/ */
#define RelationGetRelid(relation) ((relation)->rd_id) #define RelationGetRelid(relation) ((relation)->rd_id)
/*
* RelationGetFile
* Returns the open file descriptor for the rel, or -1 if
* none. This is NOT an operating system file descriptor; see md.c
* for more information
*/
#define RelationGetFile(relation) ((relation)->rd_fd)
/* /*
* RelationGetNumberOfAttributes * RelationGetNumberOfAttributes
* Returns the number of attributes in a relation. * Returns the number of attributes in a relation.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.38 2003/11/29 22:41:16 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.39 2004/02/10 01:55:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,7 +24,6 @@ extern Relation RelationSysNameGetRelation(const char *relationName); ...@@ -24,7 +24,6 @@ extern Relation RelationSysNameGetRelation(const char *relationName);
/* finds an existing cache entry, but won't make a new one */ /* finds an existing cache entry, but won't make a new one */
extern Relation RelationIdCacheGetRelation(Oid relationId); extern Relation RelationIdCacheGetRelation(Oid relationId);
extern Relation RelationNodeCacheGetRelation(RelFileNode rnode);
extern void RelationClose(Relation relation); extern void RelationClose(Relation relation);
...@@ -61,7 +60,7 @@ extern Relation RelationBuildLocalRelation(const char *relname, ...@@ -61,7 +60,7 @@ extern Relation RelationBuildLocalRelation(const char *relname,
*/ */
extern void RelationForgetRelation(Oid rid); extern void RelationForgetRelation(Oid rid);
extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId); extern void RelationCacheInvalidateEntry(Oid relationId, RelFileNode *rnode);
extern void RelationCacheInvalidate(void); extern void RelationCacheInvalidate(void);
...@@ -73,11 +72,6 @@ extern void AtEOXact_RelationCache(bool commit); ...@@ -73,11 +72,6 @@ extern void AtEOXact_RelationCache(bool commit);
extern bool RelationIdIsInInitFile(Oid relationId); extern bool RelationIdIsInInitFile(Oid relationId);
extern void RelationCacheInitFileInvalidate(bool beforeSend); extern void RelationCacheInitFileInvalidate(bool beforeSend);
/* XLOG support */
extern void CreateDummyCaches(void);
extern void DestroyDummyCaches(void);
/* should be used only by relcache.c and catcache.c */ /* should be used only by relcache.c and catcache.c */
extern bool criticalRelcachesBuilt; extern bool criticalRelcachesBuilt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment