summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/gist/gist.c6
-rw-r--r--src/backend/access/hash/hash.c6
-rw-r--r--src/backend/access/heap/heapam.c22
-rw-r--r--src/backend/access/nbtree/nbtinsert.c29
-rw-r--r--src/backend/access/nbtree/nbtpage.c6
-rw-r--r--src/backend/access/nbtree/nbtree.c9
-rw-r--r--src/backend/access/rtree/rtree.c6
-rw-r--r--src/backend/access/transam/rmgr.c1
-rw-r--r--src/backend/access/transam/transam.c13
-rw-r--r--src/backend/access/transam/transsup.c6
-rw-r--r--src/backend/access/transam/varsup.c505
-rw-r--r--src/backend/access/transam/xact.c65
-rw-r--r--src/backend/access/transam/xlog.c34
-rw-r--r--src/backend/access/transam/xlog_varsup.c142
-rw-r--r--src/backend/access/transam/xlogutils.c5
15 files changed, 79 insertions, 776 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index ce1b067d52..7b30aa72a9 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.66 2000/11/21 21:15:53 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.67 2000/11/30 08:46:20 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,9 +23,7 @@
#include "miscadmin.h"
#include "utils/syscache.h"
-#ifdef XLOG
#include "access/xlogutils.h"
-#endif
/* non-export function prototypes */
static InsertIndexResult gistdoinsert(Relation r, IndexTuple itup,
@@ -1348,7 +1346,6 @@ int_range_out(INTRANGE *r)
#endif /* defined GISTDEBUG */
-#ifdef XLOG
void
gist_redo(XLogRecPtr lsn, XLogRecord *record)
{
@@ -1365,4 +1362,3 @@ void
gist_desc(char *buf, uint8 xl_info, char* rec)
{
}
-#endif
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 599696ba83..428eb32f0a 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.45 2000/11/21 21:15:54 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.46 2000/11/30 08:46:20 vadim Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -27,9 +27,7 @@
bool BuildingHash = false;
-#ifdef XLOG
#include "access/xlogutils.h"
-#endif
/*
@@ -482,7 +480,6 @@ hashdelete(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
-#ifdef XLOG
void
hash_redo(XLogRecPtr lsn, XLogRecord *record)
{
@@ -499,4 +496,3 @@ void
hash_desc(char *buf, uint8 xl_info, char* rec)
{
}
-#endif
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index f636c7fdaf..7b60a897aa 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.96 2000/11/21 21:15:54 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.97 2000/11/30 08:46:20 vadim Exp $
*
*
* INTERFACE ROUTINES
@@ -86,7 +86,6 @@
#include "utils/inval.h"
#include "utils/relcache.h"
-#ifdef XLOG
#include "access/xlogutils.h"
XLogRecPtr log_heap_move(Relation reln, ItemPointerData from, HeapTuple newtup);
@@ -99,8 +98,6 @@ static XLogRecPtr log_heap_update(Relation reln, ItemPointerData from,
static void HeapPageCleanup(Buffer buffer);
-#endif
-
/* ----------------------------------------------------------------
* heap support routines
@@ -1370,7 +1367,6 @@ heap_insert(Relation relation, HeapTuple tup)
/* NO ELOG(ERROR) from here till changes are logged */
RelationPutHeapTuple(relation, buffer, tup);
-#ifdef XLOG
/* XLOG stuff */
{
xl_heap_insert xlrec;
@@ -1392,7 +1388,6 @@ heap_insert(Relation relation, HeapTuple tup)
PageSetLSN(BufferGetPage(buffer), recptr);
PageSetSUI(BufferGetPage(buffer), ThisStartUpID);
}
-#endif
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
@@ -1485,7 +1480,6 @@ l1:
return result;
}
-#ifdef XLOG
/* XLOG stuff */
{
xl_heap_delete xlrec;
@@ -1500,7 +1494,6 @@ l1:
PageSetLSN(dp, recptr);
PageSetSUI(dp, ThisStartUpID);
}
-#endif
/* store transaction information of xact deleting the tuple */
TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax));
@@ -1638,7 +1631,6 @@ l2:
newbuf = buffer;
else
{
-#ifdef XLOG
/*
* We have to unlock old tuple buffer before extending table
* file but have to keep lock on the old tuple. To avoid second
@@ -1650,7 +1642,7 @@ l2:
_locked_tuple_.node = relation->rd_node;
_locked_tuple_.tid = *otid;
XactPushRollback(_heap_unlock_tuple, (void*) &_locked_tuple_);
-#endif
+
TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax));
oldtup.t_data->t_cmax = GetCurrentCommandId();
oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
@@ -1677,15 +1669,12 @@ l2:
else
{
oldtup.t_data->t_infomask &= ~HEAP_XMAX_UNLOGGED;
-#ifdef XLOG
XactPopRollback();
-#endif
}
/* record address of new tuple in t_ctid of old one */
oldtup.t_data->t_ctid = newtup->t_self;
-#ifdef XLOG
/* XLOG stuff */
{
XLogRecPtr recptr = log_heap_update(relation,
@@ -1699,7 +1688,6 @@ l2:
PageSetLSN(BufferGetPage(buffer), recptr);
PageSetSUI(BufferGetPage(buffer), ThisStartUpID);
}
-#endif
if (newbuf != buffer)
{
@@ -1791,13 +1779,11 @@ l3:
return result;
}
-#ifdef XLOG
/*
* XLOG stuff: no logging is required as long as we have no
* savepoints. For savepoints private log could be used...
*/
((PageHeader) BufferGetPage(*buffer))->pd_sui = ThisStartUpID;
-#endif
/* store transaction information of xact marking the tuple */
TransactionIdStore(GetCurrentTransactionId(), &(tuple->t_data->t_xmax));
@@ -1984,8 +1970,6 @@ heap_restrpos(HeapScanDesc scan)
}
}
-#ifdef XLOG
-
static XLogRecPtr
log_heap_update(Relation reln, ItemPointerData from,
HeapTuple newtup, bool move)
@@ -2634,5 +2618,3 @@ heap_desc(char *buf, uint8 xl_info, char* rec)
else
strcat(buf, "UNKNOWN");
}
-
-#endif /* XLOG */
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index 6d287fb79b..f00b1e7918 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.68 2000/11/16 05:50:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.69 2000/11/30 08:46:21 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,9 +61,7 @@ static void _bt_pgaddtup(Relation rel, Page page,
static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
int keysz, ScanKey scankey);
-#ifdef XLOG
static Relation _xlheapRel; /* temporary hack */
-#endif
/*
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
@@ -123,9 +121,7 @@ top:
}
}
-#ifdef XLOG
_xlheapRel = heapRel; /* temporary hack */
-#endif
/* do the insertion */
res = _bt_insertonpg(rel, buf, stack, natts, itup_scankey, btitem, 0);
@@ -522,7 +518,6 @@ _bt_insertonpg(Relation rel,
}
else
{
-#ifdef XLOG
/* XLOG stuff */
{
char xlbuf[sizeof(xl_btree_insert) +
@@ -562,7 +557,7 @@ _bt_insertonpg(Relation rel,
PageSetLSN(page, recptr);
PageSetSUI(page, ThisStartUpID);
}
-#endif
+
_bt_pgaddtup(rel, page, itemsz, btitem, newitemoff, "page");
itup_off = newitemoff;
itup_blkno = BufferGetBlockNumber(buf);
@@ -612,10 +607,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
rightoff;
OffsetNumber maxoff;
OffsetNumber i;
-
-#ifdef XLOG
BTItem lhikey;
-#endif
rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
origpage = BufferGetPage(buf);
@@ -685,9 +677,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
itemsz = ItemIdGetLength(itemid);
item = (BTItem) PageGetItem(origpage, itemid);
}
-#ifdef XLOG
lhikey = item;
-#endif
if (PageAddItem(leftpage, (Item) item, itemsz, leftoff,
LP_USED) == InvalidOffsetNumber)
elog(STOP, "btree: failed to add hikey to the left sibling");
@@ -775,7 +765,6 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
spage = BufferGetPage(sbuf);
}
-#ifdef XLOG
/*
* Right sibling is locked, new siblings are prepared, but original
* page is not updated yet. Log changes before continuing.
@@ -860,7 +849,6 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
PageSetSUI(spage, ThisStartUpID);
}
}
-#endif
/*
* By here, the original data page has been split into two new halves,
@@ -1165,19 +1153,13 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
BTItem item;
Size itemsz;
BTItem new_item;
-
-#ifdef XLOG
Buffer metabuf;
-#endif
/* get a new root page */
rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
rootpage = BufferGetPage(rootbuf);
rootblknum = BufferGetBlockNumber(rootbuf);
-
-#ifdef XLOG
metabuf = _bt_getbuf(rel, BTREE_METAPAGE,BT_WRITE);
-#endif
/* NO ELOG(ERROR) from here till newroot op is logged */
@@ -1237,7 +1219,6 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
elog(STOP, "btree: failed to add rightkey to new root page");
pfree(new_item);
-#ifdef XLOG
/* XLOG stuff */
{
xl_btree_newroot xlrec;
@@ -1267,16 +1248,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
_bt_wrtbuf(rel, metabuf);
}
-#endif
/* write and let go of the new root buffer */
_bt_wrtbuf(rel, rootbuf);
-#ifndef XLOG
- /* update metadata page with new root block number */
- _bt_metaproot(rel, rootblknum, 0);
-#endif
-
/* update and release new sibling, and finally the old root */
_bt_wrtbuf(rel, rbuf);
_bt_wrtbuf(rel, lbuf);
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index dd7882a9da..fe9036d111 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.41 2000/11/30 01:39:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.42 2000/11/30 08:46:21 vadim Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
@@ -170,7 +170,6 @@ _bt_getroot(Relation rel, int access)
rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage);
rootopaque->btpo_flags |= (BTP_LEAF | BTP_ROOT);
-#ifdef XLOG
/* XLOG stuff */
{
xl_btree_newroot xlrec;
@@ -187,7 +186,6 @@ _bt_getroot(Relation rel, int access)
PageSetLSN(metapg, recptr);
PageSetSUI(metapg, ThisStartUpID);
}
-#endif
metad->btm_root = rootblkno;
metad->btm_level = 1;
@@ -403,7 +401,6 @@ _bt_pagedel(Relation rel, ItemPointer tid)
buf = _bt_getbuf(rel, blkno, BT_WRITE);
page = BufferGetPage(buf);
-#ifdef XLOG
/* XLOG stuff */
{
xl_btree_delete xlrec;
@@ -417,7 +414,6 @@ _bt_pagedel(Relation rel, ItemPointer tid)
PageSetLSN(page, recptr);
PageSetSUI(page, ThisStartUpID);
}
-#endif
PageIndexTupleDelete(page, offno);
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 37d898d97e..80d8d996d1 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.71 2000/11/21 21:15:55 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.72 2000/11/30 08:46:21 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,11 +32,8 @@ bool BuildingBtree = false; /* see comment in btbuild() */
bool FastBuild = true; /* use sort/build instead of insertion
* build */
-#ifdef XLOG
#include "access/xlogutils.h"
-#endif
-
static void _bt_restscan(IndexScanDesc scan);
/*
@@ -733,8 +730,6 @@ _bt_restscan(IndexScanDesc scan)
}
}
-#ifdef XLOG
-
static bool
_bt_cleanup_page(Page page, RelFileNode hnode)
{
@@ -1529,5 +1524,3 @@ btree_desc(char *buf, uint8 xl_info, char* rec)
else
strcat(buf, "UNKNOWN");
}
-
-#endif
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 7104a53b70..e8abb0765c 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.56 2000/11/21 21:15:55 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.57 2000/11/30 08:46:21 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,9 +22,7 @@
#include "executor/executor.h"
#include "miscadmin.h"
-#ifdef XLOG
#include "access/xlogutils.h"
-#endif
typedef struct SPLITVEC
{
@@ -1069,7 +1067,6 @@ _rtdump(Relation r)
#endif /* defined RTDEBUG */
-#ifdef XLOG
void
rtree_redo(XLogRecPtr lsn, XLogRecord *record)
{
@@ -1086,4 +1083,3 @@ void
rtree_desc(char *buf, uint8 xl_info, char* rec)
{
}
-#endif
diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c
index ca8b77de57..b25db74da8 100644
--- a/src/backend/access/transam/rmgr.c
+++ b/src/backend/access/transam/rmgr.c
@@ -27,4 +27,3 @@ RmgrData RmgrTable[] = {
{"Gist", gist_redo, gist_undo, gist_desc},
{"Sequence", seq_redo, seq_undo, seq_desc}
};
-
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 72d5c23628..644d089b92 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.37 2000/11/21 21:15:57 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.38 2000/11/30 08:46:22 vadim Exp $
*
* NOTES
* This file contains the high level access-method interface to the
@@ -424,23 +424,12 @@ InitializeTransactionLog(void)
SpinAcquire(OidGenLockId);
if (!TransactionIdDidCommit(AmiTransactionId))
{
-
- /* ----------------
- * SOMEDAY initialize the information stored in
- * the headers of the log/variable relations.
- * ----------------
- */
TransactionLogUpdate(AmiTransactionId, XID_COMMIT);
TransactionIdStore(AmiTransactionId, &cachedTestXid);
cachedTestXidStatus = XID_COMMIT;
-#ifdef XLOG
Assert(!IsUnderPostmaster &&
ShmemVariableCache->nextXid <= FirstTransactionId);
ShmemVariableCache->nextXid = FirstTransactionId;
-#else
- VariableRelationPutNextXid(FirstTransactionId);
-#endif
-
}
else if (RecoveryCheckingEnabled())
{
diff --git a/src/backend/access/transam/transsup.c b/src/backend/access/transam/transsup.c
index 74e8c39eae..3b2a345ff3 100644
--- a/src/backend/access/transam/transsup.c
+++ b/src/backend/access/transam/transsup.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.26 2000/10/28 16:20:53 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.27 2000/11/30 08:46:22 vadim Exp $
*
* NOTES
* This file contains support functions for the high
@@ -186,9 +186,7 @@ TransBlockGetXidStatus(Block tblock,
bits8 bit2;
BitIndex offset;
-#ifdef XLOG
tblock = (Block) ((char*) tblock + sizeof(XLogRecPtr));
-#endif
/* ----------------
* calculate the index into the transaction data where
@@ -231,9 +229,7 @@ TransBlockSetXidStatus(Block tblock,
Index index;
BitIndex offset;
-#ifdef XLOG
tblock = (Block) ((char*) tblock + sizeof(XLogRecPtr));
-#endif
/* ----------------
* calculate the index into the transaction data where
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 75a568f8fd..3c81cb207a 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -1,290 +1,51 @@
/*-------------------------------------------------------------------------
*
* varsup.c
- * postgres variable relation support routines
- *
- * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
- * Portions Copyright (c) 1994, Regents of the University of California
+ * postgres OID & XID variables support routines
*
+ * Copyright (c) 2000, PostgreSQL, Inc
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.33 2000/11/20 16:47:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.34 2000/11/30 08:46:22 vadim Exp $
*
*-------------------------------------------------------------------------
*/
-#include "postgres.h"
-#ifdef XLOG
-#include "xlog_varsup.c"
-#else
+#include "postgres.h"
-#include "access/heapam.h"
-#include "catalog/catname.h"
+#include "access/transam.h"
#include "storage/proc.h"
-static void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size);
-static void VariableRelationGetNextOid(Oid *oid_return);
-static void VariableRelationGetNextXid(TransactionId *xidP);
-static void VariableRelationPutNextOid(Oid oid);
+SPINLOCK OidGenLockId;
-/* ---------------------
- * spin lock for oid generation
- * ---------------------
- */
-int OidGenLockId;
+extern SPINLOCK XidGenLockId;
+extern void XLogPutNextOid(Oid nextOid);
-/* ---------------------
- * pointer to "variable cache" in shared memory (set up by shmem.c)
- * ---------------------
- */
+/* pointer to "variable cache" in shared memory (set up by shmem.c) */
VariableCache ShmemVariableCache = NULL;
-
-/* ----------------------------------------------------------------
- * variable relation query/update routines
- * ----------------------------------------------------------------
- */
-
-/* --------------------------------
- * VariableRelationGetNextXid
- * --------------------------------
- */
-static void
-VariableRelationGetNextXid(TransactionId *xidP)
-{
- Buffer buf;
- VariableRelationContents var;
-
- /* ----------------
- * We assume that a spinlock has been acquired to guarantee
- * exclusive access to the variable relation.
- * ----------------
- */
-
- /* ----------------
- * do nothing before things are initialized
- * ----------------
- */
- if (!RelationIsValid(VariableRelation))
- return;
-
- /* ----------------
- * read the variable page, get the the nextXid field and
- * release the buffer
- * ----------------
- */
- buf = ReadBuffer(VariableRelation, 0);
-
- if (!BufferIsValid(buf))
- {
- SpinRelease(OidGenLockId);
- elog(ERROR, "VariableRelationGetNextXid: ReadBuffer failed");
- }
-
- var = (VariableRelationContents) BufferGetBlock(buf);
-
- TransactionIdStore(var->nextXidData, xidP);
-
- ReleaseBuffer(buf);
-}
-
-/* --------------------------------
- * VariableRelationPutNextXid
- * --------------------------------
- */
-void
-VariableRelationPutNextXid(TransactionId xid)
-{
- Buffer buf;
- VariableRelationContents var;
-
- /* ----------------
- * We assume that a spinlock has been acquired to guarantee
- * exclusive access to the variable relation.
- * ----------------
- */
-
- /* ----------------
- * do nothing before things are initialized
- * ----------------
- */
- if (!RelationIsValid(VariableRelation))
- return;
-
- /* ----------------
- * read the variable page, update the nextXid field and
- * write the page back out to disk (with immediate write).
- * ----------------
- */
- buf = ReadBuffer(VariableRelation, 0);
-
- if (!BufferIsValid(buf))
- {
- SpinRelease(OidGenLockId);
- elog(ERROR, "VariableRelationPutNextXid: ReadBuffer failed");
- }
-
- var = (VariableRelationContents) BufferGetBlock(buf);
-
- TransactionIdStore(xid, &(var->nextXidData));
-
- FlushBuffer(buf, true, true);
-}
-
-/* --------------------------------
- * VariableRelationGetNextOid
- * --------------------------------
- */
-static void
-VariableRelationGetNextOid(Oid *oid_return)
-{
- Buffer buf;
- VariableRelationContents var;
-
- /* ----------------
- * We assume that a spinlock has been acquired to guarantee
- * exclusive access to the variable relation.
- * ----------------
- */
-
- /* ----------------
- * if the variable relation is not initialized, then we
- * assume we are running at bootstrap time and so we return
- * an invalid object id (this path should never be taken, probably).
- * ----------------
- */
- if (!RelationIsValid(VariableRelation))
- {
- (*oid_return) = InvalidOid;
- return;
- }
-
- /* ----------------
- * read the variable page, get the the nextOid field and
- * release the buffer
- * ----------------
- */
- buf = ReadBuffer(VariableRelation, 0);
-
- if (!BufferIsValid(buf))
- {
- SpinRelease(OidGenLockId);
- elog(ERROR, "VariableRelationGetNextOid: ReadBuffer failed");
- }
-
- var = (VariableRelationContents) BufferGetBlock(buf);
-
- (*oid_return) = var->nextOid;
-
- ReleaseBuffer(buf);
-}
-
-/* --------------------------------
- * VariableRelationPutNextOid
- * --------------------------------
- */
-static void
-VariableRelationPutNextOid(Oid oid)
-{
- Buffer buf;
- VariableRelationContents var;
-
- /* ----------------
- * We assume that a spinlock has been acquired to guarantee
- * exclusive access to the variable relation.
- * ----------------
- */
-
- /* ----------------
- * do nothing before things are initialized
- * ----------------
- */
- if (!RelationIsValid(VariableRelation))
- return;
-
- /* ----------------
- * read the variable page, update the nextXid field and
- * write the page back out to disk.
- * ----------------
- */
- buf = ReadBuffer(VariableRelation, 0);
-
- if (!BufferIsValid(buf))
- {
- SpinRelease(OidGenLockId);
- elog(ERROR, "VariableRelationPutNextOid: ReadBuffer failed");
- }
-
- var = (VariableRelationContents) BufferGetBlock(buf);
-
- var->nextOid = oid;
-
- WriteBuffer(buf);
-}
-
-/* ----------------------------------------------------------------
- * transaction id generation support
- * ----------------------------------------------------------------
- */
-
-/* ----------------
- * GetNewTransactionId
- *
- * Transaction IDs are allocated via a cache in shared memory.
- * Each time we need more IDs, we advance the "next XID" value
- * in pg_variable by VAR_XID_PREFETCH and set the cache to
- * show that many XIDs as available. Then, allocating those XIDs
- * requires just a spinlock and not a buffer read/write cycle.
- *
- * Since the cache is shared across all backends, cached but unused
- * XIDs are not lost when a backend exits, only when the postmaster
- * quits or forces shared memory reinit. So we can afford to have
- * a pretty big value of VAR_XID_PREFETCH.
- *
- * This code does not worry about initializing the transaction counter
- * (see transam.c's InitializeTransactionLog() for that). We also
- * ignore the possibility that the counter could someday wrap around.
- * ----------------
- */
-
-#define VAR_XID_PREFETCH 1024
-
void
GetNewTransactionId(TransactionId *xid)
{
-
- /* ----------------
- * during bootstrap initialization, we return the special
- * bootstrap transaction id.
- * ----------------
+ /*
+ * During bootstrap initialization, we return the special
+ * bootstrap transaction id.
*/
if (AMI_OVERRIDE)
{
- TransactionIdStore(AmiTransactionId, xid);
+ *xid = AmiTransactionId;
return;
}
- SpinAcquire(OidGenLockId); /* not good for concurrency... */
-
- if (ShmemVariableCache->xid_count == 0)
- {
- TransactionId nextid;
-
- VariableRelationGetNextXid(&nextid);
- TransactionIdStore(nextid, &(ShmemVariableCache->nextXid));
- ShmemVariableCache->xid_count = VAR_XID_PREFETCH;
- TransactionIdAdd(&nextid, VAR_XID_PREFETCH);
- VariableRelationPutNextXid(nextid);
- }
-
- TransactionIdStore(ShmemVariableCache->nextXid, xid);
- TransactionIdAdd(&(ShmemVariableCache->nextXid), 1);
- (ShmemVariableCache->xid_count)--;
+ SpinAcquire(XidGenLockId);
+ *xid = ShmemVariableCache->nextXid;
+ (ShmemVariableCache->nextXid)++;
if (MyProc != (PROC *) NULL)
MyProc->xid = *xid;
- SpinRelease(OidGenLockId);
+ SpinRelease(XidGenLockId);
+
}
/*
@@ -294,30 +55,20 @@ void
ReadNewTransactionId(TransactionId *xid)
{
- /* ----------------
- * during bootstrap initialization, we return the special
- * bootstrap transaction id.
- * ----------------
+ /*
+ * During bootstrap initialization, we return the special
+ * bootstrap transaction id.
*/
if (AMI_OVERRIDE)
{
- TransactionIdStore(AmiTransactionId, xid);
+ *xid = AmiTransactionId;
return;
}
- SpinAcquire(OidGenLockId); /* not good for concurrency... */
+ SpinAcquire(XidGenLockId);
+ *xid = ShmemVariableCache->nextXid;
+ SpinRelease(XidGenLockId);
- /*
- * Note that we don't check is ShmemVariableCache->xid_count equal to
- * 0 or not. This will work as long as we don't call
- * ReadNewTransactionId() before GetNewTransactionId().
- */
- if (ShmemVariableCache->nextXid == 0)
- elog(ERROR, "ReadNewTransactionId: ShmemVariableCache->nextXid is not initialized");
-
- TransactionIdStore(ShmemVariableCache->nextXid, xid);
-
- SpinRelease(OidGenLockId);
}
/* ----------------------------------------------------------------
@@ -325,199 +76,67 @@ ReadNewTransactionId(TransactionId *xid)
* ----------------------------------------------------------------
*/
-/* ----------------
- * GetNewObjectIdBlock
- *
- * This support function is used to allocate a block of object ids
- * of the given size.
- * ----------------
- */
-static void
-GetNewObjectIdBlock(Oid *oid_return, /* place to return the first new
- * object id */
- int oid_block_size) /* number of oids desired */
-{
- Oid firstfreeoid;
- Oid nextoid;
-
- /* ----------------
- * Obtain exclusive access to the variable relation page
- * ----------------
- */
- SpinAcquire(OidGenLockId);
-
- /* ----------------
- * get the "next" oid from the variable relation
- * ----------------
- */
- VariableRelationGetNextOid(&firstfreeoid);
-
- /* ----------------
- * Allocate the range of OIDs to be returned to the caller.
- *
- * There are two things going on here.
- *
- * One: in a virgin database pg_variable will initially contain zeroes,
- * so we will read out firstfreeoid = InvalidOid. We want to start
- * allocating OIDs at BootstrapObjectIdData instead (OIDs below that
- * are reserved for static assignment in the initial catalog data).
- *
- * Two: if a database is run long enough, the OID counter will wrap
- * around. We must not generate an invalid OID when that happens,
- * and it seems wise not to generate anything in the reserved range.
- * Therefore we advance to BootstrapObjectIdData in this case too.
- *
- * The comparison here assumes that Oid is an unsigned type.
- */
- nextoid = firstfreeoid + oid_block_size;
-
- if (! OidIsValid(firstfreeoid) || nextoid < firstfreeoid)
- {
- /* Initialization or wraparound time, force it up to safe range */
- firstfreeoid = BootstrapObjectIdData;
- nextoid = firstfreeoid + oid_block_size;
- }
-
- (*oid_return) = firstfreeoid;
-
- /* ----------------
- * Update the variable relation to show the block range as used.
- * ----------------
- */
- VariableRelationPutNextOid(nextoid);
-
- /* ----------------
- * Relinquish our lock on the variable relation page
- * ----------------
- */
- SpinRelease(OidGenLockId);
-}
-
-/* ----------------
- * GetNewObjectId
- *
- * This function allocates and parses out object ids. Like
- * GetNewTransactionId(), it "prefetches" 32 object ids by
- * incrementing the nextOid stored in the var relation by 32 and then
- * returning these id's one at a time until they are exhausted.
- * This means we reduce the number of accesses to the variable
- * relation by 32 for each backend.
- *
- * Note: 32 has no special significance. We don't want the
- * number to be too large because when the backend
- * terminates, we lose the oids we cached.
- *
- * Question: couldn't we use a shared-memory cache just like XIDs?
- * That would allow a larger interval between pg_variable updates
- * without cache losses. Note, however, that we can assign an OID
- * without even a spinlock from the backend-local OID cache.
- * Maybe two levels of caching would be good.
- * ----------------
- */
-
-#define VAR_OID_PREFETCH 32
-
-static int prefetched_oid_count = 0;
-static Oid next_prefetched_oid;
+#define VAR_OID_PREFETCH 8192
+static Oid lastSeenOid = InvalidOid;
void
-GetNewObjectId(Oid *oid_return) /* place to return the new object id */
+GetNewObjectId(Oid *oid_return)
{
- /* ----------------
- * if we run out of prefetched oids, then we get some
- * more before handing them out to the caller.
- * ----------------
- */
+ SpinAcquire(OidGenLockId);
- if (prefetched_oid_count == 0)
+ /* If we run out of logged for use oids then we log more */
+ if (ShmemVariableCache->oidCount == 0)
{
- int oid_block_size = VAR_OID_PREFETCH;
-
- /* ----------------
- * Make sure pg_variable is open.
- * ----------------
- */
- if (!RelationIsValid(VariableRelation))
- VariableRelation = heap_openr(VariableRelationName, NoLock);
-
- /* ----------------
- * get a new block of prefetched object ids.
- * ----------------
- */
- GetNewObjectIdBlock(&next_prefetched_oid, oid_block_size);
-
- /* ----------------
- * now reset the prefetched_oid_count.
- * ----------------
- */
- prefetched_oid_count = oid_block_size;
+ XLogPutNextOid(ShmemVariableCache->nextOid + VAR_OID_PREFETCH);
+ ShmemVariableCache->oidCount = VAR_OID_PREFETCH;
}
- /* ----------------
- * return the next prefetched oid in the pointer passed by
- * the user and decrement the prefetch count.
- * ----------------
- */
if (PointerIsValid(oid_return))
- (*oid_return) = next_prefetched_oid;
+ lastSeenOid = (*oid_return) = ShmemVariableCache->nextOid;
- next_prefetched_oid++;
- prefetched_oid_count--;
+ (ShmemVariableCache->nextOid)++;
+ (ShmemVariableCache->oidCount)--;
+
+ SpinRelease(OidGenLockId);
}
void
CheckMaxObjectId(Oid assigned_oid)
{
- Oid temp_oid;
- if (prefetched_oid_count == 0) /* make sure next/max is set, or
- * reload */
- GetNewObjectId(&temp_oid);
-
- /* ----------------
- * If we are below prefetched limits, do nothing
- * ----------------
- */
-
- if (assigned_oid < next_prefetched_oid)
+ if (lastSeenOid != InvalidOid && assigned_oid < lastSeenOid)
return;
- /* ----------------
- * If we are here, we are coming from a 'copy from' with oid's
- *
- * If we are in the prefetched oid range, just bump it up
- * ----------------
- */
+ SpinAcquire(OidGenLockId);
+ if (assigned_oid < ShmemVariableCache->nextOid)
+ {
+ lastSeenOid = ShmemVariableCache->nextOid - 1;
+ SpinRelease(OidGenLockId);
+ return;
+ }
- if (assigned_oid <= next_prefetched_oid + prefetched_oid_count - 1)
+ /* If we are in the logged oid range, just bump nextOid up */
+ if (assigned_oid <= ShmemVariableCache->nextOid +
+ ShmemVariableCache->oidCount - 1)
{
- prefetched_oid_count -= assigned_oid - next_prefetched_oid + 1;
- next_prefetched_oid = assigned_oid + 1;
+ ShmemVariableCache->oidCount -=
+ assigned_oid - ShmemVariableCache->nextOid + 1;
+ ShmemVariableCache->nextOid = assigned_oid + 1;
+ SpinRelease(OidGenLockId);
return;
}
- /* ----------------
- * We have exceeded the prefetch oid range
- *
- * We should lock the database and kill all other backends
- * but we are loading oid's that we can not guarantee are unique
- * anyway, so we must rely on the user
- *
- * We now:
- * set the variable relation with the new max oid
- * force the backend to reload its oid cache
- *
- * By reloading the oid cache, we don't have to update the variable
- * relation every time when sequential OIDs are being loaded by COPY.
- * ----------------
+ /*
+ * We have exceeded the logged oid range.
+ * We should lock the database and kill all other backends
+ * but we are loading oid's that we can not guarantee are unique
+ * anyway, so we must rely on the user.
*/
- SpinAcquire(OidGenLockId);
- VariableRelationPutNextOid(assigned_oid);
+ XLogPutNextOid(assigned_oid + VAR_OID_PREFETCH);
+ ShmemVariableCache->oidCount = VAR_OID_PREFETCH - 1;
+ ShmemVariableCache->nextOid = assigned_oid + 1;
+
SpinRelease(OidGenLockId);
- prefetched_oid_count = 0; /* force reload */
- GetNewObjectId(&temp_oid); /* cause target OID to be allocated */
}
-
-#endif /* !XLOG */
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index df679d277d..b9ba82b63b 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.85 2000/11/30 01:47:31 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.86 2000/11/30 08:46:22 vadim Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -219,7 +219,6 @@ TransactionState CurrentTransactionState = &CurrentTransactionStateData;
int DefaultXactIsoLevel = XACT_READ_COMMITTED;
int XactIsoLevel;
-#ifdef XLOG
#include "access/xlogutils.h"
int CommitDelay = 5; /* 1/200000 sec */
@@ -227,8 +226,6 @@ int CommitDelay = 5; /* 1/200000 sec */
static void (*_RollbackFunc)(void*) = NULL;
static void *_RollbackData = NULL;
-#endif
-
/* ----------------
* info returned when the system is disabled
*
@@ -662,19 +659,10 @@ RecordTransactionCommit()
TransactionId xid;
int leak;
- /* ----------------
- * get the current transaction id
- * ----------------
- */
xid = GetCurrentTransactionId();
- /*
- * flush the buffer manager pages. Note: if we have stable main
- * memory, dirty shared buffers are not flushed plai 8/7/90
- */
leak = BufferPoolCheckLeak();
-#ifdef XLOG
if (MyLastRecPtr.xrecoff != 0)
{
xl_xact_commit xlrec;
@@ -685,7 +673,7 @@ RecordTransactionCommit()
xlrec.xtime = time(NULL);
/*
- * MUST SAVE ARRAY OF RELFILENODE-s TO DROP
+ * SHOULD SAVE ARRAY OF RELFILENODE-s TO DROP
*/
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_COMMIT,
(char*) &xlrec, SizeOfXactCommit, NULL, 0);
@@ -704,30 +692,6 @@ RecordTransactionCommit()
MyProc->logRec.xrecoff = 0;
}
-#else
- /*
- * If no one shared buffer was changed by this transaction then we
- * don't flush shared buffers and don't record commit status.
- */
- if (SharedBufferChanged)
- {
- FlushBufferPool();
- if (leak)
- ResetBufferPool(true);
-
- /*
- * have the transaction access methods record the status of this
- * transaction id in the pg_log relation.
- */
- TransactionIdCommit(xid);
-
- /*
- * Now write the log info to the disk too.
- */
- leak = BufferPoolCheckLeak();
- FlushBufferPool();
- }
-#endif
if (leak)
ResetBufferPool(true);
@@ -815,23 +779,8 @@ AtCommit_Memory(void)
static void
RecordTransactionAbort(void)
{
- TransactionId xid;
+ TransactionId xid = GetCurrentTransactionId();
- /* ----------------
- * get the current transaction id
- * ----------------
- */
- xid = GetCurrentTransactionId();
-
- /*
- * Have the transaction access methods record the status of this
- * transaction id in the pg_log relation. We skip it if no one shared
- * buffer was changed by this transaction.
- */
- if (SharedBufferChanged && !TransactionIdDidCommit(xid))
- TransactionIdAbort(xid);
-
-#ifdef XLOG
if (MyLastRecPtr.xrecoff != 0)
{
xl_xact_abort xlrec;
@@ -841,9 +790,9 @@ RecordTransactionAbort(void)
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_ABORT,
(char*) &xlrec, SizeOfXactAbort, NULL, 0);
+ TransactionIdAbort(xid);
MyProc->logRec.xrecoff = 0;
}
-#endif
/*
* Tell bufmgr and smgr to release resources.
@@ -1748,8 +1697,6 @@ IsTransactionBlock(void)
return false;
}
-#ifdef XLOG
-
void
xact_redo(XLogRecPtr lsn, XLogRecord *record)
{
@@ -1760,7 +1707,7 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
xl_xact_commit *xlrec = (xl_xact_commit*) XLogRecGetData(record);
TransactionIdCommit(record->xl_xid);
- /* MUST REMOVE FILES OF ALL DROPPED RELATIONS */
+ /* SHOULD REMOVE FILES OF ALL DROPPED RELATIONS */
}
else if (info == XLOG_XACT_ABORT)
{
@@ -1825,5 +1772,3 @@ XactPopRollback(void)
{
_RollbackFunc = NULL;
}
-
-#endif
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index b96159b414..70be51695d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.37 2000/11/30 01:47:31 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.38 2000/11/30 08:46:22 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1443,12 +1443,10 @@ void
BootStrapXLOG()
{
CheckPoint checkPoint;
-#ifdef XLOG
char buffer[BLCKSZ];
bool usexistent = false;
XLogPageHeader page = (XLogPageHeader) buffer;
XLogRecord *record;
-#endif
checkPoint.redo.xlogid = 0;
checkPoint.redo.xrecoff = SizeOfXLogPHD;
@@ -1462,8 +1460,6 @@ BootStrapXLOG()
ShmemVariableCache->nextOid = checkPoint.nextOid;
ShmemVariableCache->oidCount = 0;
-#ifdef XLOG
-
memset(buffer, 0, BLCKSZ);
page->xlp_magic = XLOG_PAGE_MAGIC;
page->xlp_info = 0;
@@ -1488,8 +1484,6 @@ BootStrapXLOG()
close(logFile);
logFile = -1;
-#endif
-
memset(ControlFile, 0, sizeof(ControlFileData));
ControlFile->logId = 0;
ControlFile->logSeg = 1;
@@ -1513,14 +1507,12 @@ str_time(time_t tnow)
return buf;
}
-
/*
* This func must be called ONCE on system startup
*/
void
StartupXLOG()
{
-#ifdef XLOG
XLogCtlInsert *Insert;
CheckPoint checkPoint;
XLogRecPtr RecPtr,
@@ -1529,8 +1521,6 @@ StartupXLOG()
char buffer[MAXLOGRECSZ + SizeOfXLogRecord];
bool sie_saved = false;
-#endif
-
elog(LOG, "starting up");
XLogCtl->xlblocks = (XLogRecPtr *) (((char *) XLogCtl) + sizeof(XLogCtlData));
@@ -1580,8 +1570,6 @@ StartupXLOG()
elog(LOG, "database system was interrupted at %s",
str_time(ControlFile->time));
-#ifdef XLOG
-
LastRec = RecPtr = ControlFile->checkPoint;
if (!XRecOffIsValid(RecPtr.xrecoff))
elog(STOP, "Invalid checkPoint in control file");
@@ -1602,12 +1590,7 @@ StartupXLOG()
checkPoint.nextXid, checkPoint.nextOid);
if (checkPoint.nextXid < FirstTransactionId ||
checkPoint.nextOid < BootstrapObjectIdData)
-
-#ifdef XLOG_2
elog(STOP, "Invalid NextTransactionId/NextOid");
-#else
- elog(LOG, "Invalid NextTransactionId/NextOid");
-#endif
ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->nextOid = checkPoint.nextOid;
@@ -1751,8 +1734,6 @@ StartupXLOG()
}
InRecovery = false;
-#endif /* XLOG */
-
ControlFile->state = DB_IN_PRODUCTION;
ControlFile->time = time(NULL);
UpdateControlFile();
@@ -1783,9 +1764,7 @@ ShutdownXLOG()
{
elog(LOG, "shutting down");
-#ifdef XLOG
CreateDummyCaches();
-#endif
CreateCheckPoint(true);
elog(LOG, "database system is shut down");
@@ -1796,7 +1775,6 @@ extern XLogRecPtr GetUndoRecPtr(void);
void
CreateCheckPoint(bool shutdown)
{
-#ifdef XLOG
CheckPoint checkPoint;
XLogRecPtr recptr;
XLogCtlInsert *Insert = &XLogCtl->Insert;
@@ -1880,12 +1858,9 @@ CreateCheckPoint(bool shutdown)
XLogFlush(recptr);
-#endif /* XLOG */
-
SpinAcquire(ControlFileLockId);
if (shutdown)
ControlFile->state = DB_SHUTDOWNED;
-#ifdef XLOG
else /* create new log file */
{
if (recptr.xrecoff % XLogSegSize >=
@@ -1914,16 +1889,10 @@ CreateCheckPoint(bool shutdown)
_logSeg = ControlFile->logSeg - 1;
strcpy(archdir, ControlFile->archdir);
-#else
- ControlFile->checkPoint.xlogid = 0;
- ControlFile->checkPoint.xrecoff = SizeOfXLogPHD;
-#endif
-
ControlFile->time = time(NULL);
UpdateControlFile();
SpinRelease(ControlFileLockId);
-#ifdef XLOG
/*
* Delete offline log files. Get oldest online
* log file from undo rec if it's valid.
@@ -1948,7 +1917,6 @@ CreateCheckPoint(bool shutdown)
S_UNLOCK(&(XLogCtl->chkp_lck));
MyLastRecPtr.xrecoff = 0; /* to avoid commit record */
-#endif
return;
}
diff --git a/src/backend/access/transam/xlog_varsup.c b/src/backend/access/transam/xlog_varsup.c
deleted file mode 100644
index fd64085e78..0000000000
--- a/src/backend/access/transam/xlog_varsup.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * varsup.c
- * postgres OID & XID variables support routines
- *
- * Copyright (c) 2000, PostgreSQL, Inc
- *
- * IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xlog_varsup.c,v 1.1 2000/11/03 11:39:35 vadim Exp $
- *
- *-------------------------------------------------------------------------
- */
-
-#include "postgres.h"
-
-#include "access/transam.h"
-#include "storage/proc.h"
-
-SPINLOCK OidGenLockId;
-
-extern SPINLOCK XidGenLockId;
-extern void XLogPutNextOid(Oid nextOid);
-
-/* pointer to "variable cache" in shared memory (set up by shmem.c) */
-VariableCache ShmemVariableCache = NULL;
-
-void
-GetNewTransactionId(TransactionId *xid)
-{
- /*
- * During bootstrap initialization, we return the special
- * bootstrap transaction id.
- */
- if (AMI_OVERRIDE)
- {
- *xid = AmiTransactionId;
- return;
- }
-
- SpinAcquire(XidGenLockId);
- *xid = ShmemVariableCache->nextXid;
- (ShmemVariableCache->nextXid)++;
-
- if (MyProc != (PROC *) NULL)
- MyProc->xid = *xid;
-
- SpinRelease(XidGenLockId);
-
-}
-
-/*
- * Like GetNewTransactionId reads nextXid but don't fetch it.
- */
-void
-ReadNewTransactionId(TransactionId *xid)
-{
-
- /*
- * During bootstrap initialization, we return the special
- * bootstrap transaction id.
- */
- if (AMI_OVERRIDE)
- {
- *xid = AmiTransactionId;
- return;
- }
-
- SpinAcquire(XidGenLockId);
- *xid = ShmemVariableCache->nextXid;
- SpinRelease(XidGenLockId);
-
-}
-
-/* ----------------------------------------------------------------
- * object id generation support
- * ----------------------------------------------------------------
- */
-
-#define VAR_OID_PREFETCH 8192
-static Oid lastSeenOid = InvalidOid;
-
-void
-GetNewObjectId(Oid *oid_return)
-{
- SpinAcquire(OidGenLockId);
-
- /* If we run out of logged for use oids then we log more */
- if (ShmemVariableCache->oidCount == 0)
- {
- XLogPutNextOid(ShmemVariableCache->nextOid + VAR_OID_PREFETCH);
- ShmemVariableCache->oidCount = VAR_OID_PREFETCH;
- }
-
- if (PointerIsValid(oid_return))
- lastSeenOid = (*oid_return) = ShmemVariableCache->nextOid;
-
- (ShmemVariableCache->nextOid)++;
- (ShmemVariableCache->oidCount)--;
-
- SpinRelease(OidGenLockId);
-}
-
-void
-CheckMaxObjectId(Oid assigned_oid)
-{
-
- if (lastSeenOid != InvalidOid && assigned_oid < lastSeenOid)
- return;
-
- SpinAcquire(OidGenLockId);
- if (assigned_oid < ShmemVariableCache->nextOid)
- {
- lastSeenOid = ShmemVariableCache->nextOid - 1;
- SpinRelease(OidGenLockId);
- return;
- }
-
- /* If we are in the logged oid range, just bump nextOid up */
- if (assigned_oid <= ShmemVariableCache->nextOid +
- ShmemVariableCache->oidCount - 1)
- {
- ShmemVariableCache->oidCount -=
- assigned_oid - ShmemVariableCache->nextOid + 1;
- ShmemVariableCache->nextOid = assigned_oid + 1;
- SpinRelease(OidGenLockId);
- return;
- }
-
- /*
- * We have exceeded the logged oid range.
- * We should lock the database and kill all other backends
- * but we are loading oid's that we can not guarantee are unique
- * anyway, so we must rely on the user.
- */
-
- XLogPutNextOid(assigned_oid + VAR_OID_PREFETCH);
- ShmemVariableCache->oidCount = VAR_OID_PREFETCH - 1;
- ShmemVariableCache->nextOid = assigned_oid + 1;
-
- SpinRelease(OidGenLockId);
-
-}
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index ab085875b5..acd19da263 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -10,9 +10,6 @@
*/
#include "postgres.h"
-
-#ifdef XLOG
-
#include "access/xlog.h"
#include "access/transam.h"
#include "access/xact.h"
@@ -397,5 +394,3 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
return(&(res->reldata));
}
-
-#endif