Commit 4b832c98 authored by jimw@mysql.com's avatar jimw@mysql.com

Update ha_berkeley.cc to handle BDB 4.3.28, and re-add two features to

BDB that we require.
parent d8c07492
......@@ -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);
......@@ -173,7 +174,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);
......@@ -245,7 +246,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)
......@@ -260,7 +261,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);
}
......@@ -318,7 +319,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 */
}
......@@ -609,7 +611,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),
......@@ -648,7 +650,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)))
......@@ -1849,7 +1852,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);
......@@ -1859,7 +1862,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
......@@ -1884,7 +1887,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;
}
}
......@@ -1913,7 +1916,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;
......@@ -2294,7 +2297,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));
......@@ -2307,7 +2310,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);
......
......@@ -172,6 +172,8 @@ struct __db_dbt {
u_int32_t dlen; /* RO: get/put record length. */
u_int32_t doff; /* RO: get/put record offset. */
void *app_private; /* Application-private handle. */
#define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */
#define DB_DBT_ISSET 0x002 /* Lower level calls set value. */
#define DB_DBT_MALLOC 0x004 /* Return in malloc'd memory. */
......@@ -1734,6 +1736,10 @@ struct __db_qam_stat {
*******************************************************/
#define DB_REGION_MAGIC 0x120897 /* Environment magic number. */
typedef enum {
DB_NOTICE_LOGFILE_CHANGED
} db_notices;
/* Database Environment handle. */
struct __db_env {
/*******************************************************
......@@ -1751,6 +1757,7 @@ struct __db_env {
/* Other Callbacks. */
void (*db_feedback) __P((DB_ENV *, int, int));
void (*db_paniccall) __P((DB_ENV *, int));
void (*db_noticecall) __P((DB_ENV *, db_notices));
/* App-specified alloc functions. */
void *(*db_malloc) __P((size_t));
......@@ -1925,6 +1932,7 @@ struct __db_env {
int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
int (*get_flags) __P((DB_ENV *, u_int32_t *));
int (*set_flags) __P((DB_ENV *, u_int32_t, int));
void (*set_noticecall) __P((DB_ENV *, void (*)(DB_ENV *, db_notices)));
int (*get_home) __P((DB_ENV *, const char **));
int (*set_intermediate_dir) __P((DB_ENV *, int, u_int32_t));
int (*get_open_flags) __P((DB_ENV *, u_int32_t *));
......
......@@ -156,6 +156,7 @@ __dbenv_init(dbenv)
dbenv->set_feedback = __dbcl_env_set_feedback;
dbenv->get_flags = __dbcl_env_get_flags;
dbenv->set_flags = __dbcl_env_flags;
dbenv->set_noticecall = __dbcl_env_noticecall;
dbenv->set_paniccall = __dbcl_env_paniccall;
dbenv->set_rpc_server = __dbcl_envrpcserver;
dbenv->get_shm_key = __dbcl_get_shm_key;
......@@ -194,6 +195,7 @@ __dbenv_init(dbenv)
dbenv->get_flags = __dbenv_get_flags;
dbenv->set_flags = __dbenv_set_flags;
dbenv->set_intermediate_dir = __dbenv_set_intermediate_dir;
dbenv->set_noticecall = __dbenv_set_noticecall;
dbenv->set_paniccall = __dbenv_set_paniccall;
dbenv->set_rpc_server = __dbenv_set_rpc_server_noclnt;
dbenv->get_shm_key = __dbenv_get_shm_key;
......@@ -808,6 +810,21 @@ __dbenv_set_msgfile(dbenv, msgfile)
dbenv->db_msgfile = msgfile;
}
/*
* __dbenv_set_noticecall --
* {DB_ENV,DB}->set_noticecall.
*
* PUBLIC: int __dbenv_set_noticecall __P((DB_ENV *, void (*)(DB_ENV *, int)));
*/
int
__dbenv_set_noticecall(dbenv, noticecall)
DB_ENV *dbenv;
void (*noticecall) __P((DB_ENV *, int));
{
dbenv->db_noticecall = noticecall;
return (0);
}
/*
* __dbenv_set_paniccall --
* {DB_ENV,DB}->set_paniccall.
......
......@@ -376,6 +376,9 @@ __log_put_next(dbenv, lsn, dbt, hdr, old_lsnp)
* anyway.
*/
newfile = 1;
if (dbenv->db_noticecall != NULL)
dbenv->db_noticecall(dbenv, DB_NOTICE_LOGFILE_CHANGED);
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment