diff options
author | Marc G. Fournier <scrappy@hub.org> | 1996-08-24 20:49:41 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1996-08-24 20:49:41 +0000 |
commit | 208a30f23db0926604a338eda4ed69b5c278d2e2 (patch) | |
tree | a6b31fe54d006b5402d5dc6a3ee21dd573442116 /src/backend/access/transam/varsup.c | |
parent | 2adb6d703bd255f531fc8e33c9d6abd8d6236a0b (diff) | |
download | postgresql-208a30f23db0926604a338eda4ed69b5c278d2e2.tar.gz |
The patch does several things:
It adds a WITH OIDS option to the copy command, which allows
dumping and loading of oids.
If a copy command tried to load in an oid that is greater than
its current system max oid, the system max oid is incremented. No
checking is done to see if other backends are running and have cached
oids.
pg_dump as its first step when using the -o (oid) option, will
copy in a dummy row to set the system max oid value so as rows are
loaded in, they are certain to be lower than the system oid.
pg_dump now creates indexes at the end to speed loading
Submitted by: Bruce Momjian <maillist@candle.pha.pa.us>
Diffstat (limited to 'src/backend/access/transam/varsup.c')
-rw-r--r-- | src/backend/access/transam/varsup.c | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index a53cc7d35b..5fc47b7228 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 */ + +} + |