diff options
| author | Tom Lane | 2005-04-13 18:54:57 +0000 |
|---|---|---|
| committer | Tom Lane | 2005-04-13 18:54:57 +0000 |
| commit | 2193a856a229026673cbc56310cd0bddf7b5ea25 (patch) | |
| tree | 85a5c8c9c8dc0b7135f02e823dc3749d61eb8325 /src/backend | |
| parent | 2fdf9e0be6b474e38e516007b5ac5274ecef514d (diff) | |
Simplify initdb-time assignment of OIDs as I proposed yesterday, and
avoid encroaching on the 'user' range of OIDs by allowing automatic
OID assignment to use values below 16k until we reach normal operation.
initdb not forced since this doesn't make any incompatible change;
however a lot of stuff will have different OIDs after your next initdb.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/access/transam/varsup.c | 32 | ||||
| -rw-r--r-- | src/backend/access/transam/xlog.c | 4 | ||||
| -rw-r--r-- | src/backend/catalog/genbki.sh | 26 | ||||
| -rw-r--r-- | src/backend/storage/lmgr/lock.c | 4 | ||||
| -rw-r--r-- | src/backend/utils/misc/guc.c | 4 |
5 files changed, 37 insertions, 33 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 8caa7638335..cb532d8df34 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.62 2005/02/20 21:46:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.63 2005/04/13 18:54:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -265,14 +265,36 @@ GetNewObjectId(void) /* * Check for wraparound of the OID counter. We *must* not return 0 * (InvalidOid); and as long as we have to check that, it seems a good - * idea to skip over everything below BootstrapObjectIdData too. (This + * idea to skip over everything below FirstNormalObjectId too. (This * basically just reduces the odds of OID collision right after a wrap * occurs.) Note we are relying on unsigned comparison here. + * + * During initdb, we start the OID generator at FirstBootstrapObjectId, + * so we only enforce wrapping to that point when in bootstrap or + * standalone mode. The first time through this routine after normal + * postmaster start, the counter will be forced up to FirstNormalObjectId. + * This mechanism leaves the OIDs between FirstBootstrapObjectId and + * FirstNormalObjectId available for automatic assignment during initdb, + * while ensuring they will never conflict with user-assigned OIDs. */ - if (ShmemVariableCache->nextOid < ((Oid) BootstrapObjectIdData)) + if (ShmemVariableCache->nextOid < ((Oid) FirstNormalObjectId)) { - ShmemVariableCache->nextOid = BootstrapObjectIdData; - ShmemVariableCache->oidCount = 0; + if (IsPostmasterEnvironment) + { + /* wraparound in normal environment */ + ShmemVariableCache->nextOid = FirstNormalObjectId; + ShmemVariableCache->oidCount = 0; + } + else + { + /* we may be bootstrapping, so don't enforce the full range */ + if (ShmemVariableCache->nextOid < ((Oid) FirstBootstrapObjectId)) + { + /* wraparound in standalone environment? */ + ShmemVariableCache->nextOid = FirstBootstrapObjectId; + ShmemVariableCache->oidCount = 0; + } + } } /* If we run out of logged for use oids then we must log more */ diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 2d05f6b2777..078e1956964 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.183 2005/03/29 03:01:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.184 2005/04/13 18:54:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3505,7 +3505,7 @@ BootStrapXLOG(void) checkPoint.undo = checkPoint.redo; checkPoint.ThisTimeLineID = ThisTimeLineID; checkPoint.nextXid = FirstNormalTransactionId; - checkPoint.nextOid = BootstrapObjectIdData; + checkPoint.nextOid = FirstBootstrapObjectId; checkPoint.time = time(NULL); ShmemVariableCache->nextXid = checkPoint.nextXid; diff --git a/src/backend/catalog/genbki.sh b/src/backend/catalog/genbki.sh index fdb4b6b0128..dd4c8d05a51 100644 --- a/src/backend/catalog/genbki.sh +++ b/src/backend/catalog/genbki.sh @@ -10,7 +10,7 @@ # # # IDENTIFICATION -# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.33 2005/03/29 00:16:55 tgl Exp $ +# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.34 2005/04/13 18:54:56 tgl Exp $ # # NOTES # non-essential whitespace is removed from the generated file. @@ -121,15 +121,6 @@ for dir in $INCLUDE_DIRS; do fi done -# Get FirstGenBKIObjectId from access/transam.h -for dir in $INCLUDE_DIRS; do - if [ -f "$dir/access/transam.h" ]; then - BKIOBJECTID=`grep '^#define[ ]*FirstGenBKIObjectId' $dir/access/transam.h | $AWK '{ print $3 }'` - break - fi -done -export BKIOBJECTID - touch ${OUTPUT_PREFIX}.description.$$ # ---------------- @@ -173,8 +164,7 @@ sed -e "s/;[ ]*$//g" \ # contents of a catalog definition. # reln_open is a flag indicating when we are processing DATA lines. # (i.e. have a relation open and need to close it) -# nextbkioid is the next OID available for automatic assignment. -# oid is the most recently seen or assigned oid. +# oid is the most recently seen oid, or 0 if none in the last DATA line. # ---------------- BEGIN { inside = 0; @@ -184,7 +174,6 @@ BEGIN { nc = 0; reln_open = 0; comment_level = 0; - nextbkioid = ENVIRON["BKIOBJECTID"]; oid = 0; } @@ -202,9 +191,8 @@ comment_level > 0 { next; } # ---------------- # DATA() statements are basically passed right through after -# stripping off the DATA( and the ) on the end. However, -# if we see "OID = 0" then we should assign an oid from nextbkioid. -# Remember any explicit or assigned OID for use by DESCR(). +# stripping off the DATA( and the ) on the end. +# Remember any explicit OID for use by DESCR(). # ---------------- /^DATA\(/ { data = substr($0, 6, length($0) - 6); @@ -213,12 +201,6 @@ comment_level > 0 { next; } if (nf >= 4 && datafields[1] == "insert" && datafields[2] == "OID" && datafields[3] == "=") { oid = datafields[4]; - if (oid == 0) - { - oid = nextbkioid; - nextbkioid++; - sub("OID *= *0", "OID = " oid, data); - } } print data; next; diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 0073666216f..7c7b2b1abdd 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.148 2005/03/11 03:52:06 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.149 2005/04/13 18:54:56 tgl Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -97,7 +97,7 @@ static const char *const lock_mode_names[] = * -------- */ -int Trace_lock_oidmin = BootstrapObjectIdData; +int Trace_lock_oidmin = FirstNormalObjectId; bool Trace_locks = false; bool Trace_userlocks = false; int Trace_lock_table = 0; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 4658991e734..711ecd077e2 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.258 2005/04/08 00:59:59 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.259 2005/04/13 18:54:56 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -1090,7 +1090,7 @@ static struct config_int ConfigureNamesInt[] = GUC_NOT_IN_SAMPLE }, &Trace_lock_oidmin, - BootstrapObjectIdData, 0, INT_MAX, NULL, NULL + FirstNormalObjectId, 0, INT_MAX, NULL, NULL }, { {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS, |
