Commit f31f24c2 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make set_errfile work. Fixes #72.

git-svn-id: file:///svn/tokudb@1260 c7de825b-a66e-492c-adef-691d508d4ae1
parent 382be293
......@@ -191,7 +191,7 @@ struct __toku_db {
void* __toku_dummy10[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=456 size=4, 64=bit offset=816 size=8 */
void* __toku_dummy11[2];
void (*set_errfile) (DB_ENV *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy12[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy13[6];
......
......@@ -190,16 +190,18 @@ struct __toku_db {
int (*set_bt_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=440 size=4, 64=bit offset=784 size=8 */
void* __toku_dummy10[3];
int (*set_dup_compare) (DB *, int (*)(DB *, const DBT *, const DBT *)); /* 32-bit offset=456 size=4, 64=bit offset=816 size=8 */
void* __toku_dummy11[5];
void* __toku_dummy11[2];
void (*set_errfile) (DB *, FILE*); /* 32-bit offset=468 size=4, 64=bit offset=840 size=8 */
void* __toku_dummy12[2];
int (*set_flags) (DB *, u_int32_t); /* 32-bit offset=480 size=4, 64=bit offset=864 size=8 */
void* __toku_dummy12[6];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=508 size=4, 64=bit offset=920 size=8 */
void* __toku_dummy13[6];
int (*set_pagesize) (DB *, u_int32_t); /* 32-bit offset=508 size=4, 64=bit offset=920 size=8 */
void* __toku_dummy14[6];
int (*stat) (DB *, void *, u_int32_t); /* 32-bit offset=536 size=4, 64=bit offset=976 size=8 */
void* __toku_dummy14[4];
void* __toku_dummy15[4];
int (*verify) (DB *, const char *, const char *, FILE *, u_int32_t); /* 32-bit offset=556 size=4, 64=bit offset=1016 size=8 */
void* __toku_dummy15[5]; /* Padding at the end */
char __toku_dummy16[16]; /* Padding at the end */
void* __toku_dummy16[5]; /* Padding at the end */
char __toku_dummy17[16]; /* Padding at the end */
};
struct __toku_db_txn_active {
u_int32_t txnid; /* 32-bit offset=0 size=4, 64=bit offset=0 size=4 */
......
......@@ -43,6 +43,7 @@ void test_dup_key(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup
/* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0);
db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode);
#if USE_TDB
if (r != 0 && dup_mode == DB_DUP) {
......@@ -93,6 +94,7 @@ void test_dup_dup(int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdup
/* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0);
db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode);
#if USE_TDB
if (r != 0 && dup_mode == DB_DUP) {
......@@ -143,6 +145,7 @@ void test_put_00_01_01(int dup_mode, u_int32_t put_flags) {
/* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0);
db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode);
#if USE_TDB
if (r != 0 && dup_mode == DB_DUP) {
......
......@@ -263,7 +263,7 @@ int main(int argc, const char *argv[]) {
/* dup tests */
#if USE_TDB
printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__);
// printf("%s:%d:WARNING:tokudb does not support DB_DUP\n", __FILE__, __LINE__);
#else
for (i = 1; i <= (1<<16); i *= 2) {
test_insert(i, DB_DUP);
......
......@@ -41,6 +41,7 @@ struct __toku_db_env_internal {
u_int32_t open_flags;
int open_mode;
void (*errcall) (const char *, char *);
void *errfile;
char *errpfx;
char *dir; /* A malloc'd copy of the directory. */
char *tmp_dir;
......@@ -365,6 +366,10 @@ static void toku_db_env_set_errcall(DB_ENV * env, void (*errcall) (const char *,
env->i->errcall = errcall;
}
static void toku_db_env_set_errfile(DB_ENV*env, FILE*errfile) {
env->i->errfile = errfile;
}
static void toku_db_env_set_errpfx(DB_ENV * env, const char *errpfx) {
if (env->i->errpfx)
toku_free(env->i->errpfx);
......@@ -457,6 +462,7 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) {
result->txn_checkpoint = toku_db_env_txn_checkpoint;
result->log_flush = toku_db_env_log_flush;
result->set_errcall = toku_db_env_set_errcall;
result->set_errfile = toku_db_env_set_errfile;
result->set_errpfx = toku_db_env_set_errpfx;
//result->set_noticecall = toku_db_env_set_noticecall;
result->set_flags = toku_db_env_set_flags;
......@@ -484,6 +490,7 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) {
result->i->ref_count = 1;
result->i->errcall = toku_default_errcall;
result->i->errpfx = toku_strdup("");
result->i->errfile = 0;
ydb_add_ref();
*envp = result;
......@@ -1259,6 +1266,11 @@ static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *db
return r;
}
static void do_error (DB_ENV *dbenv, const char *string) {
if (dbenv->i->errfile)
fprintf(dbenv->i->errfile, "%s\n", string);
}
static int toku_db_put_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r;
......@@ -1298,6 +1310,7 @@ static int toku_db_put_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data,
if (r == 0)
return DB_KEYEXIST;
#else
do_error(db->dbenv, "Tokudb requires that db->put specify DB_YESOVERWRITE or DB_NOOVERWRITE on DB_DUPSORT databases");
return EINVAL;
#endif
}
......@@ -1396,6 +1409,10 @@ static int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *,
return r;
}
static void toku_db_set_errfile (DB*db, FILE *errfile) {
db->dbenv->set_errfile(db->dbenv, errfile);
}
static int toku_db_set_flags(DB * db, u_int32_t flags) {
/* the following matches BDB */
......@@ -1488,6 +1505,7 @@ int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
result->rename = toku_db_rename;
result->set_bt_compare = toku_db_set_bt_compare;
result->set_dup_compare = toku_db_set_dup_compare;
result->set_errfile = toku_db_set_errfile;
result->set_pagesize = toku_db_set_pagesize;
result->set_flags = toku_db_set_flags;
result->get_flags = toku_db_get_flags;
......
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