summaryrefslogtreecommitdiff
path: root/db/qam
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-07-30 11:58:31 +0300
committerPanu Matilainen <pmatilai@redhat.com>2007-07-30 11:58:31 +0300
commitcab228435bde1b5496522c03a4ce9840f2ef3701 (patch)
tree2c37b65d176e2de097603333f4de071c31eeff3d /db/qam
parent2d07882d45e9e575c00f8f402d4c7271bb65cfe9 (diff)
downloadrpm-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.gz
rpm-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.bz2
rpm-cab228435bde1b5496522c03a4ce9840f2ef3701.zip
Update internal BDB to version 4.6.18.
Diffstat (limited to 'db/qam')
-rw-r--r--db/qam/qam.c224
-rw-r--r--db/qam/qam.src5
-rw-r--r--db/qam/qam_auto.c40
-rw-r--r--db/qam/qam_conv.c5
-rw-r--r--db/qam/qam_files.c61
-rw-r--r--db/qam/qam_method.c29
-rw-r--r--db/qam/qam_open.c92
-rw-r--r--db/qam/qam_rec.c111
-rw-r--r--db/qam/qam_stat.c11
-rw-r--r--db/qam/qam_stub.c9
-rw-r--r--db/qam/qam_upgrade.c5
-rw-r--r--db/qam/qam_verify.c11
12 files changed, 293 insertions, 310 deletions
diff --git a/db/qam/qam.c b/db/qam/qam.c
index 08c5e3417..8ef93e0b5 100644
--- a/db/qam/qam.c
+++ b/db/qam/qam.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam.c,v 12.38 2006/09/09 14:28:24 bostic Exp $
+ * $Id: qam.c,v 12.51 2007/05/17 17:18:03 bostic Exp $
*/
#include "db_config.h"
@@ -18,11 +17,11 @@
#include "dbinc/qam.h"
static int __qam_bulk __P((DBC *, DBT *, u_int32_t));
-static int __qam_c_close __P((DBC *, db_pgno_t, int *));
-static int __qam_c_del __P((DBC *));
-static int __qam_c_destroy __P((DBC *));
-static int __qam_c_get __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
-static int __qam_c_put __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
+static int __qamc_close __P((DBC *, db_pgno_t, int *));
+static int __qamc_del __P((DBC *));
+static int __qamc_destroy __P((DBC *));
+static int __qamc_get __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
+static int __qamc_put __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
static int __qam_consume __P((DBC *, QMETA *, db_recno_t));
static int __qam_getno __P((DB *, const DBT *, db_recno_t *));
@@ -199,7 +198,8 @@ no_partial:
indx, recno, datap, qp->flags,
olddata.size == 0 ? NULL : &olddata)) != 0)
goto err;
- }
+ } else if (!F_ISSET((dbc), DBC_RECOVER))
+ LSN_NOT_LOGGED(LSN(pagep));
F_SET(qp, QAM_VALID | QAM_SET);
memcpy(p, datap->data, datap->size);
@@ -213,12 +213,12 @@ err: if (allocated)
return (ret);
}
/*
- * __qam_c_put
+ * __qamc_put
* Cursor put for queued access method.
* BEFORE and AFTER cannot be specified.
*/
static int
-__qam_c_put(dbc, key, data, flags, pgnop)
+__qamc_put(dbc, key, data, flags, pgnop)
DBC *dbc;
DBT *key, *data;
u_int32_t flags;
@@ -281,7 +281,8 @@ __qam_c_put(dbc, key, data, flags, pgnop)
/* Doing record locking, release the page lock */
if ((t_ret = __LPUT(dbc, cp->lock)) != 0 && ret == 0)
ret = t_ret;
- if ((t_ret = __qam_fput(dbp, cp->pgno, cp->page, 0)) != 0 && ret == 0)
+ if ((t_ret = __qam_fput(dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
cp->page = NULL;
cp->lock = lock;
@@ -301,7 +302,7 @@ __qam_c_put(dbc, key, data, flags, pgnop)
return (ret);
if ((ret = __db_lget(dbc, LCK_COUPLE,
pg, DB_LOCK_READ, 0, &cp->lock)) != 0) {
- (void)__memp_fput(mpf, meta, 0);
+ (void)__memp_fput(mpf, meta, dbc->priority);
return (ret);
}
@@ -344,13 +345,14 @@ recheck:
/* Drop the read lock and get the a write lock on the meta page. */
if (writelock == 0 && (ret = __db_lget(dbc, LCK_COUPLE_ALWAYS,
pg, DB_LOCK_WRITE, 0, &cp->lock)) != 0) {
- (void)__memp_fput(mpf, meta, 0);
+ (void)__memp_fput(mpf, meta, dbc->priority);
return (ret);
}
if (writelock++ == 0)
goto recheck;
- if (((ret = __memp_dirty(mpf, &meta, dbc->txn, DB_MPOOL_DIRTY)) != 0 ||
+ if (((ret = __memp_dirty(mpf,
+ &meta, dbc->txn, dbc->priority, DB_MPOOL_DIRTY)) != 0 ||
(DBC_LOGGING(dbc) &&
(ret = __qam_mvptr_log(dbp, dbc->txn,
&meta->dbmeta.lsn, 0, opcode, meta->first_recno,
@@ -363,7 +365,8 @@ recheck:
if (opcode & QAM_SETFIRST)
meta->first_recno = new_first;
-done: if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+done: if ((t_ret = __memp_fput(mpf,
+ meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
/* Don't hold the meta page long term. */
@@ -407,7 +410,7 @@ __qam_append(dbc, key, data)
return (ret);
/* Write lock the meta page. */
if ((ret = __db_lget(dbc, 0, pg, DB_LOCK_WRITE, 0, &lock)) != 0) {
- (void)__memp_fput(mpf, meta, 0);
+ (void)__memp_fput(mpf, meta, dbc->priority);
return (ret);
}
@@ -483,11 +486,11 @@ __qam_append(dbc, key, data)
ret = t_ret;
if ((t_ret =
- __qam_fput(dbp, pg, page, 0)) != 0 && ret == 0)
+ __qam_fput(dbp, pg, page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
/* Return the record number to the user. */
- if (ret == 0)
+ if (ret == 0 && key != NULL)
ret = __db_retcopy(dbp->dbenv, key,
&recno, sizeof(recno), &dbc->rkey->data, &dbc->rkey->ulen);
@@ -510,18 +513,18 @@ __qam_append(dbc, key, data)
}
err: /* Release the meta page. */
- if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+ if ((t_ret = __memp_fput(mpf, meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
return (ret);
}
/*
- * __qam_c_del --
+ * __qamc_del --
* Qam cursor->am_del function
*/
static int
-__qam_c_del(dbc)
+__qamc_del(dbc)
DBC *dbc;
{
DB *dbp;
@@ -549,7 +552,7 @@ __qam_c_del(dbc)
return (ret);
/* Write lock the meta page. */
if ((ret = __db_lget(dbc, 0, pg, DB_LOCK_READ, 0, &metalock)) != 0) {
- (void)__memp_fput(mpf, meta, 0);
+ (void)__memp_fput(mpf, meta, dbc->priority);
return (ret);
}
@@ -597,7 +600,8 @@ __qam_c_del(dbc)
pagep->pgno, cp->indx, cp->recno, &data)) != 0)
goto err;
}
- }
+ } else
+ LSN_NOT_LOGGED(LSN(pagep));
F_CLR(qp, QAM_VALID);
@@ -607,7 +611,6 @@ __qam_c_del(dbc)
* our position while we have the record locked.
* If it's pointing at the deleted record then lock
* the metapage and check again as lower numbered
-recheck:
* record may have been inserted.
*/
if (cp->recno == meta->first_recno) {
@@ -621,10 +624,11 @@ recheck:
ret = t_ret;
}
-err: if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+err: if ((t_ret = __memp_fput(mpf, meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
if (cp->page != NULL &&
- (t_ret = __qam_fput(dbp, cp->pgno, cp->page, 0)) != 0 && ret == 0)
+ (t_ret = __qam_fput(dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
cp->page = NULL;
@@ -641,11 +645,11 @@ err: if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
#endif
/*
- * __qam_c_get --
- * Queue cursor->c_get function.
+ * __qamc_get --
+ * Queue DBC->get function.
*/
static int
-__qam_c_get(dbc, key, data, flags, pgnop)
+__qamc_get(dbc, key, data, flags, pgnop)
DBC *dbc;
DBT *key, *data;
u_int32_t flags;
@@ -675,18 +679,12 @@ __qam_c_get(dbc, key, data, flags, pgnop)
LOCK_INIT(lock);
LOCK_INIT(pglock);
- PANIC_CHECK(dbenv);
-
- wait = 0;
- with_delete = 0;
- retrying = 0;
lock_mode = F_ISSET(dbc, DBC_RMW) ? DB_LOCK_WRITE : DB_LOCK_READ;
meta_mode = DB_LOCK_READ;
meta = NULL;
- inorder = F_ISSET(dbp, DB_AM_INORDER);
- t_ret = 0;
*pgnop = 0;
pg = NULL;
+ retrying = t_ret = wait = with_delete = 0;
if (flags == DB_CONSUME_WAIT) {
wait = 1;
@@ -697,8 +695,9 @@ __qam_c_get(dbc, key, data, flags, pgnop)
flags = DB_FIRST;
meta_mode = lock_mode = DB_LOCK_WRITE;
}
+ inorder = F_ISSET(dbp, DB_AM_INORDER) && with_delete;
- DEBUG_LREAD(dbc, dbc->txn, "qam_c_get",
+ DEBUG_LREAD(dbc, dbc->txn, "qamc_get",
flags == DB_SET || flags == DB_SET_RANGE ? key : NULL, NULL, flags);
/* Make lint and friends happy. */
@@ -745,6 +744,7 @@ retry: /* Update the record number. */
case DB_CURRENT:
break;
case DB_NEXT_DUP:
+ case DB_PREV_DUP:
ret = DB_NOTFOUND;
goto err;
/* NOTREACHED */
@@ -778,7 +778,8 @@ retry: /* Update the record number. */
if (CDB_LOCKING(dbenv)) {
/* Drop the metapage before we wait. */
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf,
+ meta, dbc->priority);
meta = NULL;
if (ret != 0)
goto err;
@@ -814,7 +815,7 @@ retry: /* Update the record number. */
goto retry;
}
/* Drop the metapage before we wait. */
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
meta = NULL;
if (ret != 0)
goto err;
@@ -881,7 +882,7 @@ retry: /* Update the record number. */
goto err;
break;
default:
- ret = __db_unknown_flag(dbenv, "__qam_c_get", flags);
+ ret = __db_unknown_flag(dbenv, "__qamc_get", flags);
goto err;
}
@@ -894,7 +895,7 @@ retry: /* Update the record number. */
/* Lock the record. */
if (((ret = __db_lget(dbc, LCK_COUPLE, cp->recno, lock_mode,
- (with_delete && !retrying) ?
+ (with_delete && !inorder && !retrying) ?
DB_LOCK_NOWAIT | DB_LOCK_RECORD : DB_LOCK_RECORD,
&lock)) == DB_LOCK_DEADLOCK || ret == DB_LOCK_NOTGRANTED) &&
with_delete) {
@@ -902,7 +903,8 @@ retry: /* Update the record number. */
if (DBC_LOGGING(dbc))
(void)__log_printf(dbenv,
dbc->txn, "Queue S: %x %d %d %d",
- dbc->locker, cp->recno, first, meta->first_recno);
+ dbc->locker ? dbc->locker->id : 0,
+ cp->recno, first, meta->first_recno);
#endif
first = 0;
if ((ret =
@@ -917,12 +919,18 @@ retry: /* Update the record number. */
/*
* In the DB_FIRST or DB_LAST cases we must wait and then start over
- * since the first/last may have moved while we slept.
- * We release our locks and try again.
+ * since the first/last may have moved while we slept. If we are
+ * reading in order and the first record was not there, we can skip it
+ * as it must have been aborted was was skipped by a non-queue insert
+ * or we could not have gotten its lock. If we have the wrong
+ * record we release our locks and try again.
*/
switch (flags) {
default:
- if ((!inorder && with_delete) || !is_first)
+ if (inorder) {
+ if (first != cp->recno)
+ break;
+ } else if (with_delete || !is_first)
break;
/* FALLTHROUGH */
case DB_SET:
@@ -983,7 +991,7 @@ retry: /* Update the record number. */
if (!exact) {
release_retry: /* Release locks and retry, if possible. */
if (pg != NULL)
- (void)__qam_fput(dbp, cp->pgno, pg, 0);
+ (void)__qam_fput(dbp, cp->pgno, pg, dbc->priority);
cp->page = pg = NULL;
if ((ret = __LPUT(dbc, pglock)) != 0)
goto err1;
@@ -1082,13 +1090,13 @@ release_retry: /* Release locks and retry, if possible. */
DB_ASSERT(dbenv, !F_ISSET(dbp, DB_AM_SECONDARY));
if ((ret = __qam_dirty(dbp, cp->pgno, &cp->page,
- dbc->txn, 0)) != 0)
+ dbc->txn, dbc->priority)) != 0)
goto err1;
pg = cp->page;
/*
* Check and see if we *have* any secondary indices.
- * If we do, we're a primary, so call __db_c_del_primary
+ * If we do, we're a primary, so call __dbc_del_primary
* to delete the references to the item we're about to
* delete.
*
@@ -1097,20 +1105,20 @@ release_retry: /* Release locks and retry, if possible. */
* to perform any additional ops on this cursor.
*/
if (LIST_FIRST(&dbp->s_secondaries) != NULL) {
- if ((ret = __db_c_idup(dbc,
+ if ((ret = __dbc_idup(dbc,
&dbcdup, DB_POSITION)) != 0)
goto err1;
- if ((ret = __db_c_del_primary(dbcdup)) != 0) {
+ if ((ret = __dbc_del_primary(dbcdup)) != 0) {
/*
- * The __db_c_del_primary return is more
+ * The __dbc_del_primary return is more
* interesting.
*/
- (void)__db_c_close(dbcdup);
+ (void)__dbc_close(dbcdup);
goto err1;
}
- if ((ret = __db_c_close(dbcdup)) != 0)
+ if ((ret = __dbc_close(dbcdup)) != 0)
goto err1;
}
@@ -1128,7 +1136,8 @@ release_retry: /* Release locks and retry, if possible. */
pg->pgno, cp->indx, cp->recno, &tmp)) != 0)
goto err1;
}
- }
+ } else
+ LSN_NOT_LOGGED(LSN(pg));
F_CLR(qp, QAM_VALID);
@@ -1156,7 +1165,8 @@ release_retry: /* Release locks and retry, if possible. */
if (DBC_LOGGING(dbc))
(void)__log_printf(dbenv,
dbc->txn, "Queue D: %x %d %d %d",
- dbc->locker, cp->recno, first, meta->first_recno);
+ dbc->locker ? dbc->locker->id : 0,
+ cp->recno, first, meta->first_recno);
#endif
/*
* See if we deleted the "first" record. If
@@ -1175,8 +1185,8 @@ release_retry: /* Release locks and retry, if possible. */
done:
err1: if (cp->page != NULL) {
- if ((t_ret = __qam_fput(dbp, cp->pgno, cp->page, 0)) != 0 &&
- ret == 0)
+ if ((t_ret = __qam_fput(dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
/* Doing record locking, release the page lock */
@@ -1190,7 +1200,8 @@ lerr: (void)__LPUT(dbc, lock);
err: if (meta) {
/* Release the meta page. */
- if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+ if ((t_ret = __memp_fput(mpf,
+ meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
/* Don't hold the meta page long term. */
@@ -1222,13 +1233,12 @@ __qam_consume(dbc, meta, first)
db_indx_t save_indx;
db_pgno_t save_page;
db_recno_t current, save_recno;
- u_int32_t put_mode, rec_extent;
+ u_int32_t rec_extent;
int exact, ret, t_ret, wrapped;
dbp = dbc->dbp;
mpf = dbp->mpf;
cp = (QUEUE_CURSOR *)dbc->internal;
- put_mode = 0;
ret = 0;
save_page = cp->pgno;
@@ -1251,7 +1261,7 @@ __qam_consume(dbc, meta, first)
if (ret != 0)
goto done;
if ((ret =
- __qam_fput(dbp, cp->pgno, cp->page, 0)) != 0)
+ __qam_fput(dbp, cp->pgno, cp->page, dbc->priority)) != 0)
goto done;
cp->page = NULL;
if ((ret = __qam_position(dbc,
@@ -1291,12 +1301,12 @@ __qam_consume(dbc, meta, first)
#ifdef QDEBUG
if (DBC_LOGGING(dbc))
(void)__log_printf(dbp->dbenv, dbc->txn,
- "Queue R: %x %d %d %d", dbc->locker,
+ "Queue R: %x %d %d %d",
+ dbc->locker ? dbc->locker->id : 0,
cp->pgno, first, meta->first_recno);
#endif
- put_mode |= DB_MPOOL_DISCARD;
- if ((ret =
- __qam_fput(dbp, cp->pgno, cp->page, put_mode)) != 0)
+ if ((ret = __qam_fput(dbp,
+ cp->pgno, cp->page, DB_PRIORITY_VERY_LOW)) != 0)
break;
cp->page = NULL;
@@ -1308,8 +1318,8 @@ __qam_consume(dbc, meta, first)
}
if (ret != 0)
break;
- } else if (cp->page != NULL && (ret =
- __qam_fput(dbp, cp->pgno, cp->page, put_mode)) != 0)
+ } else if (cp->page != NULL && (ret = __qam_fput(dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0)
break;
cp->page = NULL;
first++;
@@ -1339,11 +1349,10 @@ __qam_consume(dbc, meta, first)
(void)__LPUT(dbc, lock);
break;
}
- put_mode = 0;
if ((ret =__LPUT(dbc, lock)) != 0 ||
(ret = __LPUT(dbc, cp->lock)) != 0 || exact) {
if ((t_ret = __qam_fput(dbp, cp->pgno,
- cp->page, put_mode)) != 0 && ret == 0)
+ cp->page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
cp->page = NULL;
break;
@@ -1360,19 +1369,23 @@ __qam_consume(dbc, meta, first)
* Advance first_recno to this point.
*/
if (ret == 0 && meta->first_recno != first) {
- if ((ret = __memp_dirty(mpf, &meta, dbc->txn, 0)) != 0)
+ if ((ret = __memp_dirty(mpf,
+ &meta, dbc->txn, dbc->priority, 0)) != 0)
goto done;
#ifdef QDEBUG
if (DBC_LOGGING(dbc))
(void)__log_printf(dbp->dbenv, dbc->txn,
- "Queue M: %x %d %d %d", dbc->locker, cp->recno,
- first, meta->first_recno);
+ "Queue M: %x %d %d %d",
+ dbc->locker ? dbc->locker->id : 0,
+ cp->recno, first, meta->first_recno);
#endif
- if (DBC_LOGGING(dbc))
+ if (DBC_LOGGING(dbc)) {
if ((ret = __qam_incfirst_log(dbp,
dbc->txn, &meta->dbmeta.lsn, 0,
cp->recno, PGNO_BASE_MD)) != 0)
goto done;
+ } else
+ LSN_NOT_LOGGED(meta->dbmeta.lsn);
meta->first_recno = first;
}
@@ -1517,8 +1530,8 @@ get_space:
ret = t_ret;
if (cp->page != NULL) {
- if ((t_ret =
- __qam_fput(dbp, cp->pgno, cp->page, 0)) != 0 && ret == 0)
+ if ((t_ret = __qam_fput(dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
cp->page = NULL;
}
@@ -1542,7 +1555,7 @@ get_space:
*offp = (u_int32_t)-1;
done: /* Release the meta page. */
- if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+ if ((t_ret = __memp_fput(mpf, meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
if ((t_ret = __LPUT(dbc, metalock)) != 0 && ret == 0)
ret = t_ret;
@@ -1553,11 +1566,11 @@ done: /* Release the meta page. */
}
/*
- * __qam_c_close --
+ * __qamc_close --
* Close down the cursor from a single use.
*/
static int
-__qam_c_close(dbc, root_pgno, rmroot)
+__qamc_close(dbc, root_pgno, rmroot)
DBC *dbc;
db_pgno_t root_pgno;
int *rmroot;
@@ -1585,14 +1598,14 @@ __qam_c_close(dbc, root_pgno, rmroot)
}
/*
- * __qam_c_dup --
+ * __qamc_dup --
* Duplicate a queue cursor, such that the new one holds appropriate
* locks for the position of the original.
*
- * PUBLIC: int __qam_c_dup __P((DBC *, DBC *));
+ * PUBLIC: int __qamc_dup __P((DBC *, DBC *));
*/
int
-__qam_c_dup(orig_dbc, new_dbc)
+__qamc_dup(orig_dbc, new_dbc)
DBC *orig_dbc, *new_dbc;
{
QUEUE_CURSOR *orig, *new;
@@ -1606,12 +1619,12 @@ __qam_c_dup(orig_dbc, new_dbc)
}
/*
- * __qam_c_init
+ * __qamc_init
*
- * PUBLIC: int __qam_c_init __P((DBC *));
+ * PUBLIC: int __qamc_init __P((DBC *));
*/
int
-__qam_c_init(dbc)
+__qamc_init(dbc)
DBC *dbc;
{
QUEUE_CURSOR *cp;
@@ -1630,30 +1643,30 @@ __qam_c_init(dbc)
}
/* Initialize methods. */
- dbc->c_close = __db_c_close_pp;
- dbc->c_count = __db_c_count_pp;
- dbc->c_del = __db_c_del_pp;
- dbc->c_dup = __db_c_dup_pp;
- dbc->c_get = __db_c_get_pp;
- dbc->c_pget = __db_c_pget_pp;
- dbc->c_put = __db_c_put_pp;
- dbc->c_am_bulk = __qam_bulk;
- dbc->c_am_close = __qam_c_close;
- dbc->c_am_del = __qam_c_del;
- dbc->c_am_destroy = __qam_c_destroy;
- dbc->c_am_get = __qam_c_get;
- dbc->c_am_put = __qam_c_put;
- dbc->c_am_writelock = NULL;
+ dbc->close = dbc->c_close = __dbc_close_pp;
+ dbc->count = dbc->c_count = __dbc_count_pp;
+ dbc->del = dbc->c_del = __dbc_del_pp;
+ dbc->dup = dbc->c_dup = __dbc_dup_pp;
+ dbc->get = dbc->c_get = __dbc_get_pp;
+ dbc->pget = dbc->c_pget = __dbc_pget_pp;
+ dbc->put = dbc->c_put = __dbc_put_pp;
+ dbc->am_bulk = __qam_bulk;
+ dbc->am_close = __qamc_close;
+ dbc->am_del = __qamc_del;
+ dbc->am_destroy = __qamc_destroy;
+ dbc->am_get = __qamc_get;
+ dbc->am_put = __qamc_put;
+ dbc->am_writelock = NULL;
return (0);
}
/*
- * __qam_c_destroy --
+ * __qamc_destroy --
* Close a single cursor -- internal version.
*/
static int
-__qam_c_destroy(dbc)
+__qamc_destroy(dbc)
DBC *dbc;
{
/* Discard the structures. */
@@ -1702,7 +1715,7 @@ __qam_truncate(dbc, countp)
/* Walk the queue, counting rows. */
for (count = 0;
- (ret = __qam_c_get(dbc, NULL, NULL, DB_CONSUME, &metapno)) == 0;)
+ (ret = __qamc_get(dbc, NULL, NULL, DB_CONSUME, &metapno)) == 0;)
count++;
if (ret != DB_NOTFOUND)
return (ret);
@@ -1731,11 +1744,12 @@ __qam_truncate(dbc, countp)
ret = __qam_mvptr_log(dbp, dbc->txn, &meta->dbmeta.lsn, 0,
QAM_SETCUR | QAM_SETFIRST | QAM_TRUNCATE, meta->first_recno,
1, meta->cur_recno, 1, &meta->dbmeta.lsn, PGNO_BASE_MD);
- }
+ } else
+ LSN_NOT_LOGGED(meta->dbmeta.lsn);
if (ret == 0)
meta->first_recno = meta->cur_recno = 1;
- if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+ if ((t_ret = __memp_fput(mpf, meta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
if ((t_ret = __LPUT(dbc, metalock)) != 0 && ret == 0)
ret = t_ret;
@@ -1764,7 +1778,7 @@ __qam_delete(dbc, key)
if ((ret = __qam_getno(dbc->dbp, key, &cp->recno)) != 0)
goto err;
- ret = __qam_c_del(dbc);
+ ret = __qamc_del(dbc);
err: return (ret);
}
diff --git a/db/qam/qam.src b/db/qam/qam.src
index 4e795e553..f89e552c9 100644
--- a/db/qam/qam.src
+++ b/db/qam/qam.src
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam.src,v 12.5 2006/08/24 14:46:23 bostic Exp $
+ * $Id: qam.src,v 12.7 2007/05/17 15:15:50 bostic Exp $
*/
PREFIX __qam
diff --git a/db/qam/qam_auto.c b/db/qam/qam_auto.c
index acca78332..79c2d3de6 100644
--- a/db/qam/qam_auto.c
+++ b/db/qam/qam_auto.c
@@ -138,6 +138,7 @@ __qam_incfirst_log(dbp, txnp, ret_lsnp, flags, recno, meta_pgno)
*ret_lsnp = *rlsnp;
}
} else {
+ ret = 0;
#ifdef DIAGNOSTIC
/*
* Set the debug bit if we are going to log non-durable
@@ -147,10 +148,9 @@ __qam_incfirst_log(dbp, txnp, ret_lsnp, flags, recno, meta_pgno)
rectype |= DB_debug_FLAG;
memcpy(logrec.data, &rectype, sizeof(rectype));
- ret = __log_put(dbenv,
- rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
-#else
- ret = 0;
+ if (!IS_REP_CLIENT(dbenv))
+ ret = __log_put(dbenv,
+ rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
#endif
STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
@@ -387,6 +387,7 @@ __qam_mvptr_log(dbp, txnp, ret_lsnp, flags,
*ret_lsnp = *rlsnp;
}
} else {
+ ret = 0;
#ifdef DIAGNOSTIC
/*
* Set the debug bit if we are going to log non-durable
@@ -396,10 +397,9 @@ __qam_mvptr_log(dbp, txnp, ret_lsnp, flags,
rectype |= DB_debug_FLAG;
memcpy(logrec.data, &rectype, sizeof(rectype));
- ret = __log_put(dbenv,
- rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
-#else
- ret = 0;
+ if (!IS_REP_CLIENT(dbenv))
+ ret = __log_put(dbenv,
+ rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
#endif
STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
@@ -633,6 +633,7 @@ __qam_del_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno)
*ret_lsnp = *rlsnp;
}
} else {
+ ret = 0;
#ifdef DIAGNOSTIC
/*
* Set the debug bit if we are going to log non-durable
@@ -642,10 +643,9 @@ __qam_del_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno)
rectype |= DB_debug_FLAG;
memcpy(logrec.data, &rectype, sizeof(rectype));
- ret = __log_put(dbenv,
- rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
-#else
- ret = 0;
+ if (!IS_REP_CLIENT(dbenv))
+ ret = __log_put(dbenv,
+ rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
#endif
STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
@@ -901,6 +901,7 @@ __qam_add_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno, data,
*ret_lsnp = *rlsnp;
}
} else {
+ ret = 0;
#ifdef DIAGNOSTIC
/*
* Set the debug bit if we are going to log non-durable
@@ -910,10 +911,9 @@ __qam_add_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno, data,
rectype |= DB_debug_FLAG;
memcpy(logrec.data, &rectype, sizeof(rectype));
- ret = __log_put(dbenv,
- rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
-#else
- ret = 0;
+ if (!IS_REP_CLIENT(dbenv))
+ ret = __log_put(dbenv,
+ rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
#endif
STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
@@ -1165,6 +1165,7 @@ __qam_delext_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno, data)
*ret_lsnp = *rlsnp;
}
} else {
+ ret = 0;
#ifdef DIAGNOSTIC
/*
* Set the debug bit if we are going to log non-durable
@@ -1174,10 +1175,9 @@ __qam_delext_log(dbp, txnp, ret_lsnp, flags, lsn, pgno, indx, recno, data)
rectype |= DB_debug_FLAG;
memcpy(logrec.data, &rectype, sizeof(rectype));
- ret = __log_put(dbenv,
- rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
-#else
- ret = 0;
+ if (!IS_REP_CLIENT(dbenv))
+ ret = __log_put(dbenv,
+ rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
#endif
STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
diff --git a/db/qam/qam_conv.c b/db/qam/qam_conv.c
index 85fb47871..0f3584390 100644
--- a/db/qam/qam_conv.c
+++ b/db/qam/qam_conv.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_conv.c,v 12.4 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_conv.c,v 12.6 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
diff --git a/db/qam/qam_files.c b/db/qam/qam_files.c
index 62ad8ed8a..eebe16e64 100644
--- a/db/qam/qam_files.c
+++ b/db/qam/qam_files.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_files.c,v 12.17 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_files.c,v 12.31 2007/06/08 17:34:56 bostic Exp $
*/
#include "db_config.h"
@@ -27,15 +26,16 @@
* Calculate which extent the page is in, open and create if necessary.
*
* PUBLIC: int __qam_fprobe __P((DB *, db_pgno_t,
- * PUBLIC: DB_TXN *, void *, qam_probe_mode, u_int32_t));
+ * PUBLIC: DB_TXN *, void *, qam_probe_mode, DB_CACHE_PRIORITY, u_int32_t));
*/
int
-__qam_fprobe(dbp, pgno, txn, addrp, mode, flags)
+__qam_fprobe(dbp, pgno, txn, addrp, mode, priority, flags)
DB *dbp;
db_pgno_t pgno;
DB_TXN *txn;
void *addrp;
qam_probe_mode mode;
+ DB_CACHE_PRIORITY priority;
u_int32_t flags;
{
DB_ENV *dbenv;
@@ -57,9 +57,9 @@ __qam_fprobe(dbp, pgno, txn, addrp, mode, flags)
case QAM_PROBE_GET:
return (__memp_fget(mpf, &pgno, txn, flags, addrp));
case QAM_PROBE_PUT:
- return (__memp_fput(mpf, addrp, flags));
+ return (__memp_fput(mpf, addrp, priority));
case QAM_PROBE_DIRTY:
- return (__memp_dirty(mpf, addrp, txn, flags));
+ return (__memp_dirty(mpf, addrp, txn, priority, flags));
case QAM_PROBE_MPF:
*(DB_MPOOLFILE **)addrp = mpf;
return (0);
@@ -296,10 +296,11 @@ err:
return (0);
break;
case QAM_PROBE_PUT:
- ret = __memp_fput(mpf, addrp, flags);
+ ret = __memp_fput(mpf, addrp, dbp->priority);
break;
case QAM_PROBE_DIRTY:
- return (__memp_dirty(mpf, addrp, txn, flags));
+ return (__memp_dirty(mpf,
+ addrp, txn, dbp->priority, flags));
case QAM_PROBE_MPF:
*(DB_MPOOLFILE **)addrp = mpf;
return (0);
@@ -461,25 +462,17 @@ int
__qam_sync(dbp)
DB *dbp;
{
- DB_ENV *dbenv;
- DB_MPOOLFILE *mpf;
-
- dbenv = dbp->dbenv;
- mpf = dbp->mpf;
-
+ int ret;
/*
- * We need to flush all extent files. There is no easy way to find
- * all the extents for this queue which are currently open. For now
- * just flush the whole cache. An alternative would be to have a
- * call into the cache layer that would flush all of the queue extent
- * files it has open (there's a flag when we open a queue extent file,
- * so the cache layer can identify them).
+ * We can't easily identify the extent files associated with a specific
+ * Queue file, so flush all Queue extent files.
*/
-
- if (((QUEUE *)dbp->q_internal)->page_ext == 0)
- return (__memp_fsync(mpf));
- else
- return (__memp_sync(dbenv, NULL));
+ if ((ret = __memp_fsync(dbp->mpf)) != 0)
+ return (ret);
+ if (((QUEUE *)dbp->q_internal)->page_ext != 0)
+ return (__memp_sync_int(
+ dbp->dbenv, NULL, 0, DB_SYNC_QUEUE_EXTENT, NULL, NULL));
+ return (0);
}
/*
@@ -487,7 +480,7 @@ __qam_sync(dbp)
* Another thread may close the handle so this should only
* be used single threaded or with care.
*
- * PUBLIC: int __qam_gen_filelist __P(( DB *, QUEUE_FILELIST **));
+ * PUBLIC: int __qam_gen_filelist __P((DB *, QUEUE_FILELIST **));
*/
int
__qam_gen_filelist(dbp, filelistp)
@@ -523,7 +516,7 @@ __qam_gen_filelist(dbp, filelistp)
current = meta->cur_recno;
first = meta->first_recno;
- if ((ret = __memp_fput(mpf, meta, 0)) != 0)
+ if ((ret = __memp_fput(mpf, meta, dbp->priority)) != 0)
return (ret);
/*
@@ -541,6 +534,9 @@ __qam_gen_filelist(dbp, filelistp)
else
extent_cnt =
(current + (UINT32_MAX - first)) / rec_extent + 4;
+
+ if (extent_cnt == 0)
+ return (0);
if ((ret = __os_calloc(dbenv,
extent_cnt, sizeof(QUEUE_FILELIST), filelistp)) != 0)
return (ret);
@@ -563,7 +559,7 @@ again:
for (i = first; i >= first && i <= stop; i += rec_extent) {
if ((ret = __qam_fprobe(dbp, QAM_RECNO_PAGE(dbp, i), NULL,
- &fp->mpf, QAM_PROBE_MPF, 0)) != 0) {
+ &fp->mpf, QAM_PROBE_MPF, dbp->priority, 0)) != 0) {
if (ret == ENOENT)
continue;
return (ret);
@@ -601,7 +597,7 @@ __qam_extent_names(dbenv, name, namelistp)
*namelistp = NULL;
filelist = NULL;
- if ((ret = db_create(&dbp, dbenv, 0)) != 0)
+ if ((ret = __db_create_internal(&dbp, dbenv, 0)) != 0)
return (ret);
if ((ret = __db_open(dbp,
NULL, name, NULL, DB_QUEUE, DB_RDONLY, 0, PGNO_BASE_MD)) != 0)
@@ -691,7 +687,8 @@ __qam_exid(dbp, fidp, exnum)
*
* PUBLIC: int __qam_nameop __P((DB *, DB_TXN *, const char *, qam_name_op));
*/
-int __qam_nameop(dbp, txn, newname, op)
+int
+__qam_nameop(dbp, txn, newname, op)
DB *dbp;
DB_TXN *txn;
const char *newname;
@@ -822,7 +819,7 @@ int __qam_nameop(dbp, txn, newname, op)
ndir, PATH_SEPARATOR[0], new, exid);
QAM_EXNAME(qp, exid, buf, sizeof(buf));
if ((ret = __fop_rename(dbenv,
- txn, buf, nbuf, fid, DB_APP_DATA,
+ txn, buf, nbuf, fid, DB_APP_DATA, 1,
F_ISSET(dbp, DB_AM_NOT_DURABLE) ?
DB_LOG_NOT_DURABLE : 0)) != 0)
goto err;
diff --git a/db/qam/qam_method.c b/db/qam/qam_method.c
index ff5129517..ebb94c7b5 100644
--- a/db/qam/qam_method.c
+++ b/db/qam/qam_method.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_method.c,v 12.8 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_method.c,v 12.15 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
@@ -180,7 +179,7 @@ __queue_pageinfo(dbp, firstp, lastp, emptyp, prpage, flags)
COMPQUIET(flags, 0);
#endif
- if ((t_ret = __memp_fput(mpf, meta, 0)) != 0 && ret == 0)
+ if ((t_ret = __memp_fput(mpf, meta, dbp->priority)) != 0 && ret == 0)
ret = t_ret;
return (ret);
@@ -231,7 +230,7 @@ begin:
return (ret);
}
(void)__db_prpage(dbp, h, flags);
- if ((ret = __qam_fput(dbp, i, h, 0)) != 0)
+ if ((ret = __qam_fput(dbp, i, h, dbp->priority)) != 0)
return (ret);
}
@@ -295,8 +294,6 @@ __qam_rr(dbp, txn, name, subdb, newname, op)
dbenv = dbp->dbenv;
ret = 0;
- PANIC_CHECK(dbenv);
-
if (subdb != NULL && name != NULL) {
__db_errx(dbenv,
"Queue does not support multiple databases per file");
@@ -310,14 +307,14 @@ __qam_rr(dbp, txn, name, subdb, newname, op)
if (F_ISSET(dbp, DB_AM_OPEN_CALLED))
tmpdbp = dbp;
else {
- if ((ret = db_create(&tmpdbp, dbenv, 0)) != 0)
+ if ((ret = __db_create_internal(&tmpdbp, dbenv, 0)) != 0)
return (ret);
/*
* We need to make sure we don't self-deadlock, so give
* this dbp the same locker as the incoming one.
*/
- tmpdbp->lid = dbp->lid;
+ tmpdbp->locker = dbp->locker;
if ((ret = __db_open(tmpdbp, txn,
name, NULL, DB_QUEUE, DB_RDONLY, 0, PGNO_BASE_MD)) != 0)
goto err;
@@ -332,16 +329,22 @@ err: /*
* Since we copied the locker ID from the dbp, we'd better not
* free it here.
*/
- tmpdbp->lid = DB_LOCK_INVALIDID;
+ tmpdbp->locker = NULL;
/* We need to remove the lock event we associated with this. */
if (txn != NULL)
__txn_remlock(dbenv,
txn, &tmpdbp->handle_lock, DB_LOCK_INVALIDID);
- if ((t_ret =
- __db_close(tmpdbp, txn, DB_NOSYNC)) != 0 && ret == 0)
- ret = t_ret;
+ if (txn == NULL ) {
+ if ((t_ret = __db_close(tmpdbp,
+ txn, DB_NOSYNC)) != 0 && ret == 0)
+ ret = t_ret;
+ } else {
+ if ((t_ret = __txn_closeevent(dbenv,
+ txn, tmpdbp)) != 0 && ret == 0)
+ ret = t_ret;
+ }
}
return (ret);
}
diff --git a/db/qam/qam_open.c b/db/qam/qam_open.c
index 75df8e41c..a00a0f319 100644
--- a/db/qam/qam_open.c
+++ b/db/qam/qam_open.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_open.c,v 12.11 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_open.c,v 12.17 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
@@ -104,22 +103,22 @@ __qam_open(dbp, txn, name, base_pgno, mode, flags)
if (mode == 0)
mode = __db_omode("rw-rw----");
t->mode = mode;
- t->re_pad = qmeta->re_pad;
+ t->re_pad = (int)qmeta->re_pad;
t->re_len = qmeta->re_len;
t->rec_page = qmeta->rec_page;
t->q_meta = base_pgno;
t->q_root = base_pgno + 1;
-err: if (qmeta != NULL &&
- (t_ret = __memp_fput(mpf, qmeta, 0)) != 0 && ret == 0)
+err: if (qmeta != NULL && (t_ret =
+ __memp_fput(mpf, qmeta, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
/* Don't hold the meta page long term. */
if ((t_ret = __LPUT(dbc, metalock)) != 0 && ret == 0)
ret = t_ret;
- if ((t_ret = __db_c_close(dbc)) != 0 && ret == 0)
+ if ((t_ret = __dbc_close(dbc)) != 0 && ret == 0)
ret = t_ret;
return (ret);
@@ -254,7 +253,7 @@ __qam_init_meta(dbp, meta)
meta->crypto_magic = meta->dbmeta.magic;
}
meta->dbmeta.type = P_QAMMETA;
- meta->re_pad = t->re_pad;
+ meta->re_pad = (u_int32_t)t->re_pad;
meta->re_len = t->re_len;
meta->rec_page = CALC_QAM_RECNO_PER_PAGE(dbp);
meta->cur_recno = 1;
@@ -278,12 +277,6 @@ __qam_init_meta(dbp, meta)
* __qam_new_file --
* Create the necessary pages to begin a new queue database file.
*
- * This code appears more complex than it is because of the two cases (named
- * and unnamed). The way to read the code is that for each page being created,
- * there are three parts: 1) a "get page" chunk (which either uses malloc'd
- * memory or calls __memp_fget), 2) the initialization, and 3) the "put page"
- * chunk which either does a fop write or an __memp_fput.
- *
* PUBLIC: int __qam_new_file __P((DB *, DB_TXN *, DB_FH *, const char *));
*/
int
@@ -293,61 +286,62 @@ __qam_new_file(dbp, txn, fhp, name)
DB_FH *fhp;
const char *name;
{
- QMETA *meta;
+ DBT pdbt;
DB_ENV *dbenv;
DB_MPOOLFILE *mpf;
DB_PGINFO pginfo;
- DBT pdbt;
+ QMETA *meta;
db_pgno_t pgno;
- int ret;
- void *buf;
-
- dbenv = dbp->dbenv;
- mpf = dbp->mpf;
- buf = NULL;
- meta = NULL;
-
- /* Build meta-data page. */
+ int ret, t_ret;
+ /*
+ * Build meta-data page.
+ *
+ * This code appears more complex than it is because of the two cases
+ * (named and unnamed).
+ *
+ * For each page being created, there are three parts: 1) a "get page"
+ * chunk (which either uses malloc'd memory or calls __memp_fget), 2)
+ * the initialization, and 3) the "put page" chunk which either does a
+ * fop write or an __memp_fput.
+ */
if (F_ISSET(dbp, DB_AM_INMEM)) {
+ mpf = dbp->mpf;
pgno = PGNO_BASE_MD;
- ret = __memp_fget(mpf, &pgno, txn,
- DB_MPOOL_CREATE | DB_MPOOL_DIRTY, &meta);
- } else {
- ret = __os_calloc(dbenv, 1, dbp->pgsize, &buf);
- meta = (QMETA *)buf;
- }
- if (ret != 0)
- return (ret);
+ if ((ret = __memp_fget(mpf, &pgno, txn,
+ DB_MPOOL_CREATE | DB_MPOOL_DIRTY, &meta)) != 0)
+ return (ret);
- if ((ret = __qam_init_meta(dbp, meta)) != 0)
- goto err;
+ if ((ret = __qam_init_meta(dbp, meta)) != 0)
+ goto err1;
- if (F_ISSET(dbp, DB_AM_INMEM)) {
if ((ret = __db_log_page(dbp,
txn, &meta->dbmeta.lsn, pgno, (PAGE *)meta)) != 0)
- goto err;
- ret = __memp_fput(mpf, meta, 0);
+ goto err1;
+err1: if ((t_ret =
+ __memp_fput(mpf, meta, dbp->priority)) != 0 && ret == 0)
+ ret = t_ret;
} else {
+ dbenv = dbp->dbenv;
+ if ((ret = __os_calloc(dbenv, 1, dbp->pgsize, &meta)) != 0)
+ return (ret);
+
+ if ((ret = __qam_init_meta(dbp, meta)) != 0)
+ goto err2;
+
pginfo.db_pagesize = dbp->pgsize;
pginfo.flags =
F_ISSET(dbp, (DB_AM_CHKSUM | DB_AM_ENCRYPT | DB_AM_SWAP));
pginfo.type = DB_QUEUE;
- pdbt.data = &pginfo;
- pdbt.size = sizeof(pginfo);
+ DB_SET_DBT(pdbt, &pginfo, sizeof(pginfo));
if ((ret = __db_pgout(dbenv, PGNO_BASE_MD, meta, &pdbt)) != 0)
- goto err;
+ goto err2;
ret = __fop_write(dbenv, txn, name,
- DB_APP_DATA, fhp, dbp->pgsize, 0, 0, buf, dbp->pgsize, 1,
+ DB_APP_DATA, fhp, dbp->pgsize, 0, 0, meta, dbp->pgsize, 1,
F_ISSET(dbp, DB_AM_NOT_DURABLE) ? DB_LOG_NOT_DURABLE : 0);
+
+err2: __os_free(dbenv, meta);
}
- if (ret != 0)
- goto err;
- meta = NULL;
-err: if (name != NULL)
- __os_free(dbenv, buf);
- else if (meta != NULL)
- (void)__memp_fput(mpf, meta, 0);
return (ret);
}
diff --git a/db/qam/qam_rec.c b/db/qam/qam_rec.c
index 88a7bf261..d1798b891 100644
--- a/db/qam/qam_rec.c
+++ b/db/qam/qam_rec.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_rec.c,v 12.20 2006/09/09 14:28:24 bostic Exp $
+ * $Id: qam_rec.c,v 12.26 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
@@ -26,14 +25,10 @@
* transaction may be completed during a later hot backup cycle.
*/
-/* Determine if we are restoring prepared transactions from __txn_recover. */
-#define IS_IN_RESTORE(dbenv) \
- (((DB_TXNREGION *) \
- (dbenv)->tx_handle->reginfo.primary)->stat.st_nrestores != 0)
-
/* Queue version of REC_DIRTY -- needs to probe the correct file. */
#define QAM_DIRTY(dbp, pgno, pagep) \
- if ((ret = __qam_dirty((dbp), pgno, pagep, NULL, 0)) != 0) { \
+ if ((ret = __qam_dirty((dbp), \
+ pgno, pagep, NULL, (dbp)->priority)) != 0) { \
ret = __db_pgerr((dbp), (pgno), ret); \
goto out; \
}
@@ -99,7 +94,7 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info)
*/
if (DB_UNDO(op)) {
if (QAM_BEFORE_FIRST(meta, argp->recno)) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->first_recno = argp->recno;
}
@@ -107,12 +102,12 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info)
/* if we are truncating, update the LSN */
if (!IS_ZERO_LSN(trunc_lsn) &&
LOG_COMPARE(&LSN(meta), &trunc_lsn) > 0) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
LSN(meta) = trunc_lsn;
}
} else {
if (LOG_COMPARE(&LSN(meta), lsnp) < 0) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
LSN(meta) = *lsnp;
}
if (meta->page_ext == 0)
@@ -127,8 +122,8 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info)
if ((ret = __qam_position(dbc,
&meta->first_recno, DB_LOCK_READ, 0, &exact)) != 0)
goto err;
- if (cp->page != NULL && (ret =
- __qam_fput(file_dbp, cp->pgno, cp->page, 0)) != 0)
+ if (cp->page != NULL && (ret = __qam_fput(file_dbp,
+ cp->pgno, cp->page, dbc->priority)) != 0)
goto err;
if (exact == 1)
@@ -138,14 +133,14 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info)
if ((ret =
__qam_fremove(file_dbp, cp->pgno)) != 0)
goto err;
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->first_recno++;
if (meta->first_recno == RECNO_OOB)
meta->first_recno++;
}
}
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
@@ -155,7 +150,7 @@ done: *lsnp = argp->prev_lsn;
ret = 0;
if (0) {
-err: (void)__memp_fput(mpf, meta, 0);
+err: (void)__memp_fput(mpf, meta, dbc->priority);
(void)__LPUT(dbc, lock);
}
@@ -196,8 +191,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
if ((ret = __db_lget(dbc,
LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0)
goto done;
- if ((ret = __memp_fget(mpf, &metapg, NULL,
- 0, &meta)) != 0) {
+ if ((ret = __memp_fget(mpf, &metapg, NULL, 0, &meta)) != 0) {
if (DB_REDO(op)) {
if ((ret = __memp_fget(mpf, &metapg, NULL,
DB_MPOOL_CREATE, &meta)) != 0) {
@@ -228,7 +222,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
*/
if (DB_UNDO(op)) {
if ((argp->opcode & QAM_TRUNCATE) && cmp_n <= 0) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->first_recno = argp->old_first;
meta->cur_recno = argp->old_cur;
LSN(meta) = argp->metalsn;
@@ -237,11 +231,11 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
trunc_lsn = ((DB_TXNHEAD *)info)->trunc_lsn;
if (!IS_ZERO_LSN(trunc_lsn) &&
LOG_COMPARE(&trunc_lsn, &LSN(meta)) < 0) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
LSN(meta) = argp->metalsn;
}
} else if (op == DB_TXN_APPLY || cmp_p == 0) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
cp = (QUEUE_CURSOR *)dbc->internal;
if ((argp->opcode & QAM_SETFIRST) &&
meta->first_recno == argp->old_first) {
@@ -256,7 +250,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
meta->first_recno = argp->new_first;
if (cp->page != NULL &&
(ret = __qam_fput(file_dbp,
- cp->pgno, cp->page, 0)) != 0)
+ cp->pgno, cp->page, dbc->priority)) != 0)
goto err;
}
}
@@ -273,7 +267,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
meta->cur_recno = argp->new_cur;
if (cp->page != NULL &&
(ret = __qam_fput(file_dbp,
- cp->pgno, cp->page, 0)) != 0)
+ cp->pgno, cp->page, dbc->priority)) != 0)
goto err;
}
}
@@ -281,7 +275,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info)
meta->dbmeta.lsn = *lsnp;
}
- if ((ret = __memp_fput(mpf, meta, 0)) != 0)
+ if ((ret = __memp_fput(mpf, meta, dbc->priority)) != 0)
goto out;
if ((ret = __LPUT(dbc, lock)) != 0)
@@ -291,7 +285,7 @@ done: *lsnp = argp->prev_lsn;
ret = 0;
if (0) {
-err: (void)__memp_fput(mpf, meta, 0);
+err: (void)__memp_fput(mpf, meta, dbc->priority);
(void)__LPUT(dbc, lock);
}
@@ -325,7 +319,6 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info)
db_pgno_t metapg;
int cmp_n, ret, t_ret;
- COMPQUIET(info, NULL);
COMPQUIET(pagep, NULL);
REC_PRINT(__qam_del_print);
REC_INTRO(__qam_del_read, 1, 1);
@@ -358,11 +351,11 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info)
(meta->first_recno <= meta->cur_recno ||
meta->first_recno -
argp->recno < argp->recno - meta->cur_recno))) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->first_recno = argp->recno;
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
} else
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
@@ -375,17 +368,12 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info)
/*
* Move the LSN back to this point; do not move it forward.
- * Only move it back if we're in recovery. If we're in
- * an abort, because we don't hold a page lock, we could
- * foul up a concurrent put. Having too late an LSN
- * is harmless in queue except when we're determining
+ * If we're in an abort, because we don't hold a page lock,
+ * we could foul up a concurrent put. Having too late an
+ * LSN * is harmless in queue except when we're determining
* what we need to roll forward during recovery. [#2588]
- * If we are aborting a restored transaction then it
- * might get rolled forward later so the LSN needs to
- * be correct in that case too. [#12181]
*/
- if (cmp_n <= 0 &&
- (op == DB_TXN_BACKWARD_ROLL || IS_IN_RESTORE(dbenv)))
+ if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
LSN(pagep) = argp->lsn;
} else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) {
/* Need to redo delete - clear the valid bit */
@@ -401,14 +389,14 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info)
if (op == DB_TXN_APPLY)
LSN(pagep) = *lsnp;
}
- if ((ret = __qam_fput(file_dbp, argp->pgno, pagep, 0)) != 0)
+ if ((ret = __qam_fput(file_dbp, argp->pgno, pagep, dbc->priority)) != 0)
goto out;
done: *lsnp = argp->prev_lsn;
ret = 0;
if (0) {
-err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0);
+err: (void)__qam_fput(file_dbp, argp->pgno, pagep, dbc->priority);
}
out: REC_CLOSE;
}
@@ -439,7 +427,6 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info)
db_pgno_t metapg;
int cmp_n, ret, t_ret;
- COMPQUIET(info, NULL);
COMPQUIET(pagep, NULL);
REC_PRINT(__qam_delext_print);
REC_INTRO(__qam_delext_read, 1, 1);
@@ -480,9 +467,9 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info)
meta->first_recno -
argp->recno < argp->recno - meta->cur_recno))) {
meta->first_recno = argp->recno;
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
} else
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
@@ -495,14 +482,12 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info)
/*
* Move the LSN back to this point; do not move it forward.
- * Only move it back if we're in recovery. If we're in
- * an abort, because we don't hold a page lock, we could
- * foul up a concurrent put. Having too late an LSN
- * is harmless in queue except when we're determining
+ * If we're in an abort, because we don't hold a page lock,
+ * we could foul up a concurrent put. Having too late an
+ * LSN is harmless in queue except when we're determining
* what we need to roll forward during recovery. [#2588]
*/
- if (cmp_n <= 0 &&
- (op == DB_TXN_BACKWARD_ROLL || IS_IN_RESTORE(dbenv)))
+ if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
LSN(pagep) = argp->lsn;
} else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) {
QAM_DIRTY(file_dbp, pagep->pgno, &pagep);
@@ -518,14 +503,14 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info)
if (op == DB_TXN_APPLY)
LSN(pagep) = *lsnp;
}
- if ((ret = __qam_fput(file_dbp, argp->pgno, pagep, 0)) != 0)
+ if ((ret = __qam_fput(file_dbp, argp->pgno, pagep, dbc->priority)) != 0)
goto out;
done: *lsnp = argp->prev_lsn;
ret = 0;
if (0) {
-err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0);
+err: (void)__qam_fput(file_dbp, argp->pgno, pagep, dbc->priority);
}
out: REC_CLOSE;
}
@@ -555,7 +540,6 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info)
db_pgno_t metapg;
int cmp_n, ret;
- COMPQUIET(info, NULL);
COMPQUIET(pagep, NULL);
REC_PRINT(__qam_add_print);
REC_INTRO(__qam_add_read, 1, 1);
@@ -586,15 +570,15 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info)
0, &meta)) != 0)
goto err;
if (QAM_BEFORE_FIRST(meta, argp->recno)) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->first_recno = argp->recno;
}
if (argp->recno == meta->cur_recno ||
QAM_AFTER_CURRENT(meta, argp->recno)) {
- REC_DIRTY(mpf, &meta);
+ REC_DIRTY(mpf, dbc->priority, &meta);
meta->cur_recno = argp->recno + 1;
}
- if ((ret = __memp_fput(mpf, meta, 0)) != 0)
+ if ((ret = __memp_fput(mpf, meta, dbc->priority)) != 0)
goto err;
/* Now update the actual page if necessary. */
@@ -638,26 +622,23 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info)
/*
* Move the LSN back to this point; do not move it forward.
- * Only move it back if we're in recovery. If we're in
- * an abort, because we don't hold a page lock, we could
- * foul up a concurrent put. Having too late an LSN
- * is harmless in queue except when we're determining
+ * If we're in an abort, because we don't hold a page lock,
+ * we could foul up a concurrent put. Having too late an
+ * LSN is harmless in queue except when we're determining
* what we need to roll forward during recovery. [#2588]
*/
- if (cmp_n <= 0 &&
- (op == DB_TXN_BACKWARD_ROLL || IS_IN_RESTORE(dbenv)))
+ if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
LSN(pagep) = argp->lsn;
}
- if ((ret = __qam_fput(file_dbp,
- argp->pgno, pagep, 0)) != 0)
+ if ((ret = __qam_fput(file_dbp, argp->pgno, pagep, dbc->priority)) != 0)
goto out;
done: *lsnp = argp->prev_lsn;
ret = 0;
if (0) {
-err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0);
+err: (void)__qam_fput(file_dbp, argp->pgno, pagep, dbc->priority);
}
out: REC_CLOSE;
diff --git a/db/qam/qam_stat.c b/db/qam/qam_stat.c
index 067555a57..b2b24c33b 100644
--- a/db/qam/qam_stat.c
+++ b/db/qam/qam_stat.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_stat.c,v 12.8 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_stat.c,v 12.11 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
@@ -74,7 +73,7 @@ __qam_stat(dbc, spp, flags)
first = QAM_RECNO_PAGE(dbp, meta->first_recno);
last = QAM_RECNO_PAGE(dbp, meta->cur_recno);
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
@@ -124,7 +123,7 @@ begin:
sp->qs_pgfree += re_len;
}
- ret = __qam_fput(dbp, pgno, h, 0);
+ ret = __qam_fput(dbp, pgno, h, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
@@ -167,7 +166,7 @@ meta_only:
sp->qs_cur_recno = meta->cur_recno;
/* Discard the meta-data page. */
- ret = __memp_fput(mpf, meta, 0);
+ ret = __memp_fput(mpf, meta, dbc->priority);
if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
ret = t_ret;
if (ret != 0)
diff --git a/db/qam/qam_stub.c b/db/qam/qam_stub.c
index 7b02c8ef1..f001e6b16 100644
--- a/db/qam/qam_stub.c
+++ b/db/qam/qam_stub.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1996,2007 Oracle. All rights reserved.
*
- * $Id: qam_stub.c,v 12.5 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_stub.c,v 12.8 2007/05/17 15:15:50 bostic Exp $
*/
#ifndef HAVE_QUEUE
@@ -77,7 +76,7 @@ __qam_append(dbc, key, data)
}
int
-__qam_c_dup(orig_dbc, new_dbc)
+__qamc_dup(orig_dbc, new_dbc)
DBC *orig_dbc, *new_dbc;
{
COMPQUIET(new_dbc, NULL);
@@ -85,7 +84,7 @@ __qam_c_dup(orig_dbc, new_dbc)
}
int
-__qam_c_init(dbc)
+__qamc_init(dbc)
DBC *dbc;
{
return (__db_no_queue_am(dbc->dbp->dbenv));
diff --git a/db/qam/qam_upgrade.c b/db/qam/qam_upgrade.c
index 0c5777e25..58f5df302 100644
--- a/db/qam/qam_upgrade.c
+++ b/db/qam/qam_upgrade.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1996,2007 Oracle. All rights reserved.
*
- * $Id: qam_upgrade.c,v 12.4 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_upgrade.c,v 12.6 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
diff --git a/db/qam/qam_verify.c b/db/qam/qam_verify.c
index b6457ce70..64cfd4eb8 100644
--- a/db/qam/qam_verify.c
+++ b/db/qam/qam_verify.c
@@ -1,10 +1,9 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1999-2006
- * Oracle Corporation. All rights reserved.
+ * Copyright (c) 1999,2007 Oracle. All rights reserved.
*
- * $Id: qam_verify.c,v 12.9 2006/08/24 14:46:24 bostic Exp $
+ * $Id: qam_verify.c,v 12.13 2007/05/17 15:15:50 bostic Exp $
*/
#include "db_config.h"
@@ -44,12 +43,12 @@ __qam_vrfy_meta(dbp, vdp, meta, pgno, flags)
qp = (QUEUE *)dbp->q_internal;
extents = NULL;
first = last = 0;
+ isbad = 0;
buf = NULL;
names = NULL;
if ((ret = __db_vrfy_getpageinfo(vdp, pgno, &pip)) != 0)
return (ret);
- isbad = 0;
/*
* Queue can't be used in subdatabases, so if this isn't set
@@ -409,7 +408,7 @@ put: if ((ret = __db_vrfy_putpageinfo(dbenv, vdp, pip)) != 0)
}
/* Again, keep going iff we're salvaging. */
- if ((t_ret = __qam_fput(dbp, i, h, 0)) != 0) {
+ if ((t_ret = __qam_fput(dbp, i, h, dbp->priority)) != 0) {
if (LF_ISSET(DB_SALVAGE)) {
if (ret == 0)
ret = t_ret;
@@ -439,7 +438,7 @@ put: if ((ret = __db_vrfy_putpageinfo(dbenv, vdp, pip)) != 0)
}
if (0) {
-err: if ((t_ret = __qam_fput(dbp, i, h, 0)) != 0)
+err: if ((t_ret = __qam_fput(dbp, i, h, dbp->priority)) != 0)
return (ret == 0 ? t_ret : ret);
if (pip != NULL &&
(t_ret = __db_vrfy_putpageinfo(dbenv, vdp, pip)) != 0)