aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-04-09 22:04:08 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-04-09 22:04:08 +0000
commit56218fbc487991ed98358cd8016dc5c4615bed96 (patch)
tree0840591dffb49c556f0943e1c91b0628c18b4ced /src/backend/access/nbtree/nbtutils.c
parent485d9ca96ff0ef6ab1e424a4ded3eeb53a9cf3df (diff)
downloadpostgresql-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/access/nbtree/nbtutils.c')
-rw-r--r--src/backend/access/nbtree/nbtutils.c14
1 files changed, 8 insertions, 6 deletions
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++)