aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/heapam.c4
-rw-r--r--src/backend/access/transam.h11
-rw-r--r--src/backend/access/transam/varsup.c69
3 files changed, 73 insertions, 11 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4bf31efd832..add8112710f 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.1.1.1 1996/07/09 06:21:11 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.2 1996/08/24 20:47:54 scrappy Exp $
*
*
* INTERFACE ROUTINES
@@ -1093,6 +1093,8 @@ heap_insert(Relation relation, HeapTuple tup)
tup->t_oid = newoid();
LastOidProcessed = tup->t_oid;
}
+ else
+ CheckMaxObjectId(tup->t_oid);
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
tup->t_cmin = GetCurrentCommandId();
diff --git a/src/backend/access/transam.h b/src/backend/access/transam.h
index 0f5a9724dc0..ca9a47e802b 100644
--- a/src/backend/access/transam.h
+++ b/src/backend/access/transam.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: transam.h,v 1.1.1.1 1996/07/09 06:21:09 scrappy Exp $
+ * $Id: transam.h,v 1.2 1996/08/24 20:47:42 scrappy Exp $
*
* NOTES
* Transaction System Version 101 now support proper oid
@@ -46,6 +46,14 @@
typedef unsigned char XidStatus; /* (2 bits) */
+/* ----------
+ * note: we reserve the first 16384 object ids for internal use.
+ * oid's less than this appear in the .bki files. the choice of
+ * 16384 is completely arbitrary.
+ * ----------
+ */
+#define BootstrapObjectIdData 16384
+
/* ----------------
* BitIndexOf computes the index of the Nth xid on a given block
* ----------------
@@ -182,6 +190,7 @@ extern void GetNewTransactionId(TransactionId *xid);
extern void UpdateLastCommittedXid(TransactionId xid);
extern void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size);
extern void GetNewObjectId(Oid *oid_return);
+extern void CheckMaxObjectId(Oid assigned_oid);
/* ----------------
* global variable extern declarations
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index a53cc7d35b1..5fc47b7228b 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.1.1.1 1996/07/09 06:21:13 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.2 1996/08/24 20:48:04 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,14 +28,6 @@
#include "catalog/catname.h"
-/* ----------
- * note: we reserve the first 16384 object ids for internal use.
- * oid's less than this appear in the .bki files. the choice of
- * 16384 is completely arbitrary.
- * ----------
- */
-#define BootstrapObjectIdData 16384
-
/* ---------------------
* spin lock for oid generation
* ---------------------
@@ -604,3 +596,62 @@ GetNewObjectId(Oid *oid_return) /* place to return the new object id */
next_prefetched_oid++;
prefetched_oid_count--;
}
+
+void
+CheckMaxObjectId(Oid assigned_oid)
+{
+Oid pass_oid;
+
+
+ if (prefetched_oid_count == 0) /* make sure next/max is set, or reload */
+ GetNewObjectId(&pass_oid);
+
+ /* ----------------
+ * If we are below prefetched limits, do nothing
+ * ----------------
+ */
+
+ if (assigned_oid < next_prefetched_oid)
+ 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
+ *
+ * ----------------
+ */
+
+ if (assigned_oid <= next_prefetched_oid + prefetched_oid_count - 1)
+ {
+ prefetched_oid_count -= assigned_oid - next_prefetched_oid + 1;
+ next_prefetched_oid = assigned_oid + 1;
+ 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
+ *
+ * We use the oid cache so we don't have to update the variable
+ * relation every time
+ *
+ * ----------------
+ */
+
+ pass_oid = assigned_oid;
+ VariableRelationPutNextOid(&pass_oid); /* not modified */
+ prefetched_oid_count = 0; /* force reload */
+ pass_oid = assigned_oid;
+ GetNewObjectId(&pass_oid); /* throw away returned oid */
+
+}
+