Commit ba9e3542 authored by unknown's avatar unknown
Browse files

Merge mysql.com:/home/jimw/my/mysql-5.1-clean

into  mysql.com:/home/jimw/my/mysql-5.1-bdb


sql/ha_berkeley.cc:
  Auto merged
parents f653a686 3c7def8e
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ u_int32_t berkeley_lock_types[]=
TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names)-1,"",
				berkeley_lock_names, NULL};

static void berkeley_print_error(const char *db_errpfx, char *buffer);
static void berkeley_print_error(const DB_ENV *db_env, const char *db_errpfx,
                                 const char *buffer);
static byte* bdb_get_key(BDB_SHARE *share,uint *length,
			 my_bool not_used __attribute__((unused)));
static BDB_SHARE *get_share(const char *table_name, TABLE *table);
@@ -176,7 +177,7 @@ handlerton *berkeley_init(void)

  if (opt_endinfo)
    db_env->set_verbose(db_env,
			DB_VERB_CHKPOINT | DB_VERB_DEADLOCK | DB_VERB_RECOVERY,
			DB_VERB_DEADLOCK | DB_VERB_RECOVERY,
			1);

  db_env->set_cachesize(db_env, 0, berkeley_cache_size, 0);
@@ -248,7 +249,7 @@ static int berkeley_commit(THD *thd, bool all)
  DBUG_PRINT("trans",("ending transaction %s", all ? "all" : "stmt"));
  berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
  DB_TXN **txn= all ? &trx->all : &trx->stmt;
  int error=txn_commit(*txn,0);
  int error= (*txn)->commit(*txn,0);
  *txn=0;
#ifndef DBUG_OFF
  if (error)
@@ -263,7 +264,7 @@ static int berkeley_rollback(THD *thd, bool all)
  DBUG_PRINT("trans",("aborting transaction %s", all ? "all" : "stmt"));
  berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
  DB_TXN **txn= all ? &trx->all : &trx->stmt;
  int error=txn_abort(*txn);
  int error= (*txn)->abort(*txn);
  *txn=0;
  DBUG_RETURN(error);
}
@@ -321,7 +322,8 @@ int berkeley_show_logs(Protocol *protocol)
}


static void berkeley_print_error(const char *db_errpfx, char *buffer)
static void berkeley_print_error(const DB_ENV *db_env, const char *db_errpfx,
                                 const char *buffer)
{
  sql_print_error("%s:  %s",db_errpfx,buffer); /* purecov: tested */
}
@@ -612,7 +614,7 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked)
			  berkeley_cmp_packed_key));
    if (!hidden_primary_key)
      file->app_private= (void*) (table->key_info + table_share->primary_key);
    if ((error= txn_begin(db_env, 0, (DB_TXN**) &transaction, 0)) ||
    if ((error= db_env->txn_begin(db_env, NULL, (DB_TXN**) &transaction, 0)) ||
	(error= (file->open(file, transaction,
			    fn_format(name_buff, name, "", ha_berkeley_ext,
				      2 | 4),
@@ -651,7 +653,8 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked)
	  DBUG_PRINT("bdb",("Setting DB_DUP for key %u", i));
	  (*ptr)->set_flags(*ptr, DB_DUP);
	}
	if ((error= txn_begin(db_env, 0, (DB_TXN**) &transaction, 0)) ||
	if ((error= db_env->txn_begin(db_env, NULL, (DB_TXN**) &transaction,
                                      0)) ||
	    (error=((*ptr)->open(*ptr, transaction, name_buff, part, DB_BTREE,
				 open_mode, 0))) ||
	    (error= transaction->commit(transaction, 0)))
@@ -1852,7 +1855,7 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
	/* We have to start a master transaction */
	DBUG_PRINT("trans",("starting transaction all:  options: 0x%lx",
                            (ulong) thd->options));
        if ((error=txn_begin(db_env, 0, &trx->all, 0)))
        if ((error= db_env->txn_begin(db_env, NULL, &trx->all, 0)))
	{
          trx->bdb_lock_count--;        // We didn't get the lock
          DBUG_RETURN(error);
@@ -1862,7 +1865,7 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
	  DBUG_RETURN(0);			// Don't create stmt trans
      }
      DBUG_PRINT("trans",("starting transaction stmt"));
      if ((error=txn_begin(db_env, trx->all, &trx->stmt, 0)))
      if ((error= db_env->txn_begin(db_env, trx->all, &trx->stmt, 0)))
      {
	/* We leave the possible master transaction open */
        trx->bdb_lock_count--;                  // We didn't get the lock
@@ -1887,7 +1890,7 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
	   We must in this case commit the work to keep the row locks
	*/
	DBUG_PRINT("trans",("commiting non-updating transaction"));
        error= txn_commit(trx->stmt,0);
        error= trx->stmt->commit(trx->stmt,0);
        trx->stmt= transaction= 0;
      }
    }
@@ -1916,7 +1919,7 @@ int ha_berkeley::start_stmt(THD *thd)
  if (!trx->stmt)
  {
    DBUG_PRINT("trans",("starting transaction stmt"));
    error=txn_begin(db_env, trx->all, &trx->stmt, 0);
    error= db_env->txn_begin(db_env, trx->all, &trx->stmt, 0);
    trans_register_ha(thd, FALSE, &berkeley_hton);
  }
  transaction= trx->stmt;
@@ -2297,7 +2300,7 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt)
      free(stat);
      stat=0;
    }
    if ((key_file[i]->stat)(key_file[i], (void*) &stat, 0))
    if ((key_file[i]->stat)(key_file[i], NULL, (void*) &stat, 0))
      goto err; /* purecov: inspected */
    share->rec_per_key[i]= (stat->bt_ndata /
			    (stat->bt_nkeys ? stat->bt_nkeys : 1));
@@ -2310,7 +2313,7 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt)
      free(stat);
      stat=0;
    }
    if ((file->stat)(file, (void*) &stat, 0))
    if ((file->stat)(file, NULL, (void*) &stat, 0))
      goto err; /* purecov: inspected */
  }
  pthread_mutex_lock(&share->mutex);
+4 −4
Original line number Diff line number Diff line
/*-
 * $Id: LICENSE,v 11.9 2002/01/11 15:51:10 bostic Exp $
 * $Id: LICENSE,v 11.12 2004/03/30 20:49:44 bostic Exp $
 */

The following is the license that applies to this copy of the Berkeley DB
software.  For a license to use the Berkeley DB software under conditions
other than those described here, or to purchase support for this software,
please contact Sleepycat Software by email at db@sleepycat.com, or on the
Web at http://www.sleepycat.com.
please contact Sleepycat Software by email at info@sleepycat.com, or on
the Web at http://www.sleepycat.com.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*
 * Copyright (c) 1990-2002
 * Copyright (c) 1990-2004
 *	Sleepycat Software.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
+10 −8
Original line number Diff line number Diff line
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1996-2002
 * Copyright (c) 1996-2004
 *	Sleepycat Software.  All rights reserved.
 */
/*
@@ -38,14 +38,12 @@
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Id: bt_compare.c,v 11.20 2004/02/21 15:54:44 bostic Exp $
 */

#include "db_config.h"

#ifndef lint
static const char revid[] = "$Id: bt_compare.c,v 11.17 2002/03/27 04:30:42 bostic Exp $";
#endif /* not lint */

#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#endif
@@ -204,8 +202,12 @@ __bam_defpfx(dbp, a, b)
			return (cnt);

	/*
	 * We know that a->size must be <= b->size, or they wouldn't be
	 * in this order.
	 * They match up to the smaller of the two sizes.
	 * Collate the longer after the shorter.
	 */
	return (a->size < b->size ? a->size + 1 : a->size);
	if (a->size < b->size)
		return (a->size + 1);
	if (b->size < a->size)
		return (b->size + 1);
	return (b->size);
}
+3 −5
Original line number Diff line number Diff line
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1996-2002
 * Copyright (c) 1996-2004
 *	Sleepycat Software.  All rights reserved.
 *
 * $Id: bt_conv.c,v 11.15 2004/01/28 03:35:48 bostic Exp $
 */

#include "db_config.h"

#ifndef lint
static const char revid[] = "$Id: bt_conv.c,v 11.13 2002/08/06 06:11:12 bostic Exp $";
#endif /* not lint */

#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#endif
+35 −33
Original line number Diff line number Diff line
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1996-2002
 * Copyright (c) 1996-2004
 *	Sleepycat Software.  All rights reserved.
 *
 * $Id: bt_curadj.c,v 11.37 2004/03/13 14:11:33 bostic Exp $
 */

#include "db_config.h"

#ifndef lint
static const char revid[] = "$Id: bt_curadj.c,v 11.30 2002/07/03 19:03:48 bostic Exp $";
#endif /* not lint */

#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#endif
@@ -21,30 +19,6 @@ static const char revid[] = "$Id: bt_curadj.c,v 11.30 2002/07/03 19:03:48 bostic

static int __bam_opd_cursor __P((DB *, DBC *, db_pgno_t, u_int32_t, u_int32_t));

#ifdef DEBUG
/*
 * __bam_cprint --
 *	Display the current internal cursor.
 *
 * PUBLIC: void __bam_cprint __P((DBC *));
 */
void
__bam_cprint(dbc)
	DBC *dbc;
{
	BTREE_CURSOR *cp;

	cp = (BTREE_CURSOR *)dbc->internal;

	fprintf(stderr, "\tinternal: ovflsize: %lu", (u_long)cp->ovflsize);
	if (dbc->dbtype == DB_RECNO)
		fprintf(stderr, " recno: %lu", (u_long)cp->recno);
	if (F_ISSET(cp, C_DELETED))
		fprintf(stderr, " (deleted)");
	fprintf(stderr, "\n");
}
#endif

/*
 * Cursor adjustments are logged if they are for subtransactions.  This is
 * because it's possible for a subtransaction to adjust cursors which will
@@ -98,6 +72,19 @@ __bam_ca_delete(dbp, pgno, indx, delete)
		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {
			cp = (BTREE_CURSOR *)dbc->internal;
			if (cp->pgno == pgno && cp->indx == indx) {
				/*
				 * [#8032] This assert is checking
				 * for possible race conditions where we
				 * hold a cursor position without a lock.
				 * Unfortunately, there are paths in the
				 * Btree code that do not satisfy these
				 * conditions. None of them are known to
				 * be a problem, but this assert should
				 * be re-activated when the Btree stack
				 * code is re-written.
				DB_ASSERT(!STD_LOCKING(dbc) ||
				    cp->lock_mode != DB_LOCK_NG);
				 */
				if (delete)
					F_SET(cp, C_DELETED);
				else
@@ -192,7 +179,10 @@ __bam_ca_di(my_dbc, pgno, indx, adjust)
			if (cp->pgno == pgno && cp->indx >= indx) {
				/* Cursor indices should never be negative. */
				DB_ASSERT(cp->indx != 0 || adjust > 0);

				/* [#8032]
				DB_ASSERT(!STD_LOCKING(dbc) ||
				    cp->lock_mode != DB_LOCK_NG);
				*/
				cp->indx += adjust;
				if (my_txn != NULL && dbc->txn != my_txn)
					found = 1;
@@ -203,8 +193,8 @@ __bam_ca_di(my_dbc, pgno, indx, adjust)
	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);

	if (found != 0 && DBC_LOGGING(my_dbc)) {
		if ((ret = __bam_curadj_log(dbp, my_dbc->txn,
		    &lsn, 0, DB_CA_DI, pgno, 0, 0, adjust, indx, 0)) != 0)
		if ((ret = __bam_curadj_log(dbp, my_dbc->txn, &lsn, 0,
		    DB_CA_DI, pgno, 0, 0, (u_int32_t)adjust, indx, 0)) != 0)
			return (ret);
	}

@@ -319,6 +309,10 @@ loop: MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);
				continue;

			MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);
			/* [#8032]
			DB_ASSERT(!STD_LOCKING(dbc) ||
			    orig_cp->lock_mode != DB_LOCK_NG);
			*/
			if ((ret = __bam_opd_cursor(dbp,
			    dbc, first, tpgno, ti)) !=0)
				return (ret);
@@ -388,7 +382,7 @@ loop: MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);
			    != ti)
				continue;
			MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);
			if ((ret = orig_cp->opd->c_close(orig_cp->opd)) != 0)
			if ((ret = __db_c_close(orig_cp->opd)) != 0)
				return (ret);
			orig_cp->opd = NULL;
			orig_cp->indx = fi;
@@ -442,6 +436,10 @@ __bam_ca_rsplit(my_dbc, fpgno, tpgno)
				continue;
			if (dbc->internal->pgno == fpgno) {
				dbc->internal->pgno = tpgno;
				/* [#8032]
				DB_ASSERT(!STD_LOCKING(dbc) ||
				    dbc->internal->lock_mode != DB_LOCK_NG);
				*/
				if (my_txn != NULL && dbc->txn != my_txn)
					found = 1;
			}
@@ -506,6 +504,10 @@ __bam_ca_split(my_dbc, ppgno, lpgno, rpgno, split_indx, cleft)
				continue;
			cp = dbc->internal;
			if (cp->pgno == ppgno) {
				/* [#8032]
				DB_ASSERT(!STD_LOCKING(dbc) ||
				    cp->lock_mode != DB_LOCK_NG);
				*/
				if (my_txn != NULL && dbc->txn != my_txn)
					found = 1;
				if (cp->indx < split_indx) {
Loading