diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-09 22:04:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-09 22:04:08 +0000 |
commit | 56218fbc487991ed98358cd8016dc5c4615bed96 (patch) | |
tree | 0840591dffb49c556f0943e1c91b0628c18b4ced /src/backend | |
parent | 485d9ca96ff0ef6ab1e424a4ded3eeb53a9cf3df (diff) | |
download | postgresql-56218fbc487991ed98358cd8016dc5c4615bed96.tar.gz postgresql-56218fbc487991ed98358cd8016dc5c4615bed96.zip |
Minor tweaking of index special-space definitions so that the various
index types can be reliably distinguished by examining the special space
on an index page. Per my earlier proposal, plus the realization that
there's no need for btree's vacuum cycle ID to cycle through every possible
16-bit value. Restricting its range a little costs nearly nothing and
eliminates the possibility of collisions.
Memo to self: remember to make bitmap indexes play along with this scheme,
assuming that patch ever gets accepted.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/gist/gistutil.c | 7 | ||||
-rw-r--r-- | src/backend/access/hash/hashovfl.c | 6 | ||||
-rw-r--r-- | src/backend/access/hash/hashpage.c | 8 | ||||
-rw-r--r-- | src/backend/access/nbtree/nbtutils.c | 14 |
4 files changed, 19 insertions, 16 deletions
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index 0c10fc49cc7..c09e9249ea3 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.21 2007/01/05 22:19:22 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.22 2007/04/09 22:03:57 tgl Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -559,10 +559,11 @@ GISTInitBuffer(Buffer b, uint32 f) PageInit(page, pageSize, sizeof(GISTPageOpaqueData)); opaque = GistPageGetOpaque(page); - opaque->flags = f; - opaque->rightlink = InvalidBlockNumber; /* page was already zeroed by PageInit, so this is not needed: */ /* memset(&(opaque->nsn), 0, sizeof(GistNSN)); */ + opaque->rightlink = InvalidBlockNumber; + opaque->flags = f; + opaque->gist_page_id = GIST_PAGE_ID; } /* diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index abd9972ced6..2a844f40d42 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.54 2007/01/05 22:19:22 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.55 2007/04/09 22:03:57 tgl Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -141,7 +141,7 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf) ovflopaque->hasho_nextblkno = InvalidBlockNumber; ovflopaque->hasho_bucket = pageopaque->hasho_bucket; ovflopaque->hasho_flag = LH_OVERFLOW_PAGE; - ovflopaque->hasho_filler = HASHO_FILL; + ovflopaque->hasho_page_id = HASHO_PAGE_ID; MarkBufferDirty(ovflbuf); @@ -529,7 +529,7 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno) op->hasho_nextblkno = InvalidBlockNumber; op->hasho_bucket = -1; op->hasho_flag = LH_BITMAP_PAGE; - op->hasho_filler = HASHO_FILL; + op->hasho_page_id = HASHO_PAGE_ID; /* set all of the bits to 1 */ freep = HashPageGetBitmap(pg); diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 97eb3c379ee..c368bcd05d2 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.64 2007/01/29 23:22:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.65 2007/04/09 22:03:57 tgl Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -252,7 +252,7 @@ _hash_metapinit(Relation rel) pageopaque->hasho_nextblkno = InvalidBlockNumber; pageopaque->hasho_bucket = -1; pageopaque->hasho_flag = LH_META_PAGE; - pageopaque->hasho_filler = HASHO_FILL; + pageopaque->hasho_page_id = HASHO_PAGE_ID; metap = (HashMetaPage) pg; @@ -310,7 +310,7 @@ _hash_metapinit(Relation rel) pageopaque->hasho_nextblkno = InvalidBlockNumber; pageopaque->hasho_bucket = i; pageopaque->hasho_flag = LH_BUCKET_PAGE; - pageopaque->hasho_filler = HASHO_FILL; + pageopaque->hasho_page_id = HASHO_PAGE_ID; _hash_wrtbuf(rel, buf); } @@ -654,7 +654,7 @@ _hash_splitbucket(Relation rel, nopaque->hasho_nextblkno = InvalidBlockNumber; nopaque->hasho_bucket = nbucket; nopaque->hasho_flag = LH_BUCKET_PAGE; - nopaque->hasho_filler = HASHO_FILL; + nopaque->hasho_page_id = HASHO_PAGE_ID; /* * Partition the tuples in the old bucket between the old bucket and the diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index b5e7686303e..33c0ee00823 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.84 2007/04/06 22:33:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.85 2007/04/09 22:04:01 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1263,11 +1263,13 @@ _bt_start_vacuum(Relation rel) LWLockAcquire(BtreeVacuumLock, LW_EXCLUSIVE); - /* Assign the next cycle ID, being careful to avoid zero */ - do - { - result = ++(btvacinfo->cycle_ctr); - } while (result == 0); + /* + * Assign the next cycle ID, being careful to avoid zero as well as + * the reserved high values. + */ + result = ++(btvacinfo->cycle_ctr); + if (result == 0 || result > MAX_BT_CYCLE_ID) + result = btvacinfo->cycle_ctr = 1; /* Let's just make sure there's no entry already for this index */ for (i = 0; i < btvacinfo->num_vacuums; i++) |