Commit a73af185 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

[t:4956] moving src-bdbwrap to bradley's directory


git-svn-id: file:///svn/toku/tokudb@44069 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5b829841
CFLAGS = -g -W -Wall -Wno-unused
CPPFLAGS = -I../include
C_OBJS= mut_pthread.lo \
bt_compare.lo bt_conv.lo bt_curadj.lo bt_cursor.lo bt_delete.lo \
bt_method.lo bt_open.lo bt_put.lo bt_rec.lo bt_reclaim.lo \
bt_recno.lo bt_rsearch.lo bt_search.lo bt_split.lo bt_stat.lo \
bt_upgrade.lo bt_verify.lo btree_auto.lo crdel_auto.lo \
crdel_rec.lo db.lo db_am.lo db_auto.lo db_byteorder.lo db_cam.lo \
db_conv.lo db_dispatch.lo db_dup.lo db_err.lo db_getlong.lo \
db_idspace.lo db_iface.lo db_join.lo db_log2.lo db_meta.lo \
db_method.lo db_open.lo db_overflow.lo db_pr.lo db_rec.lo \
db_reclaim.lo db_rename.lo db_remove.lo db_ret.lo db_salloc.lo \
db_shash.lo db_truncate.lo db_upg.lo db_upg_opd.lo db_vrfy.lo \
db_vrfyutil.lo dbm.lo dbreg.lo dbreg_auto.lo dbreg_rec.lo \
dbreg_util.lo env_file.lo env_method.lo env_open.lo env_recover.lo \
env_region.lo fileops_auto.lo fop_basic.lo fop_rec.lo \
fop_util.lo hash.lo hash_auto.lo hash_conv.lo hash_dup.lo \
hash_func.lo hash_meta.lo hash_method.lo hash_open.lo \
hash_page.lo hash_rec.lo hash_reclaim.lo hash_stat.lo \
hash_upgrade.lo hash_verify.lo hmac.lo hsearch.lo lock.lo \
lock_deadlock.lo lock_method.lo lock_region.lo lock_stat.lo \
lock_util.lo log.lo log_archive.lo log_compare.lo log_get.lo \
log_method.lo log_put.lo mp_alloc.lo mp_bh.lo mp_fget.lo \
mp_fopen.lo mp_fput.lo mp_fset.lo mp_method.lo mp_region.lo \
mp_register.lo mp_stat.lo mp_sync.lo mp_trickle.lo mutex.lo \
os_abs.lo os_alloc.lo os_clock.lo os_config.lo os_dir.lo \
os_errno.lo os_fid.lo os_fsync.lo os_handle.lo os_id.lo \
os_map.lo os_method.lo os_oflags.lo os_open.lo os_region.lo \
os_rename.lo os_root.lo os_rpath.lo os_rw.lo os_seek.lo \
os_sleep.lo os_spin.lo os_stat.lo os_tmpdir.lo os_unlink.lo \
qam.lo qam_auto.lo qam_conv.lo qam_files.lo qam_method.lo \
qam_open.lo qam_rec.lo qam_stat.lo qam_upgrade.lo qam_verify.lo \
rep_method.lo rep_record.lo rep_region.lo rep_util.lo sha1.lo \
txn.lo txn_auto.lo txn_method.lo txn_rec.lo txn_recover.lo \
txn_region.lo txn_stat.lo txn_util.lo xa.lo xa_db.lo xa_map.lo
MAYBENOTICECALL = noticecall.lo
install: libdb.so
cp libdb.so ../lib/
libdb.so: ydb.lo bdbw.lo $(MAYBENOTICECALL)
echo cc ydb.lo bdbw.lo BDB-OBJS -shared -fPIC -o libdb.so $(CFLAGS)
@cc ydb.lo bdbw.lo $(MAYBENOTICECALL) $(patsubst %,/home/bradley/mysql/build-bdb-with-uniquename/bdb/build_unix/%,$(C_OBJS)) -shared -fPIC -o libdb.so $(CFLAGS)
ydb.lo: bdbw.h
bdbw.lo: CPPFLAGS=-I/home/bradley/mysql/build-bdb-with-uniquename/bdb/build_unix
%.lo: %.c
cc $(CPPFLAGS) $< -c -fPIC -o $@ $(CFLAGS)
bdbw.lo: bdbw.h ydb-uniq.h
cd ~/yobiduck/ydb/src
make
cd ~/mysql/bdbi/mysql-5.0.27/
export LD_RUN_PATH=/home/bradley/yobiduck/ydb/src
./configure --with-berkeley-db-includes=/home/bradley/yobiduck/ydb/include --with-berkeley-db --with-berkeley-db-libs=/home/bradley/yobiduck/ydb/src --prefix=/home/bradley/usr
make
make install
#This one may not be needed
~/mysql/bdbi/usr/bin/mysql_install_db
#
pushd /home/bradley/mysql/bdbi/usr/ ; /home/bradley/mysql/bdbi/usr//bin/mysqld_safe &
popd
~/mysql/bdbi/usr/bin/mysql -u root
mysql> show databases;
mysql> create database yobitest;
mysql> use yobitest;
mysql> create table t1 (i int) engine=bdb;
Look for the error in /home/bradley/mysql/bdbi/usr/var/yobert.err
----
This links right:
LD_LIBRARY_PATH=/home/bradley/mysql/bdbi/usr/lib/mysql/ ldd sql/mysqld
----
This works,
LD_LIBRARY_PATH=/home/bradley/mysql/bdbi/usr/lib/mysql/ /home/bradley/mysql/bdbi/usr//bin/mysqld
producing the following in the log
061208 16:11:35 InnoDB: Started; log sequence number 0 43655
ydb.c:78 db_env_create flags=0
----
the LD_RUN_PATH thing above works.
--- on laptop I did this instead:
cd ~/mysql/mysql-5.0.27/
export LD_RUN_PATH=/home/bradley/yobiduck/ydb/src
./configure --with-berkeley-db-includes=/home/bradley/yobiduck/ydb/include --with-berkeley-db --with-berkeley-db-libs=/home/bradley/yobiduck/src --prefix=/home/bradley/usr
make
make install
/home/bradley/usr/bin/mysql_install_db
/home/bradley/usr/bin/mysqld_safe &
/home/bradley/usr/bin/mysql -u root
~/mysql/bdbi/usr/bin/mysql -u root
mysql> show databases;
mysql> create database yobitest;
mysql> use yobitest;
mysql> create table t1 (i int) engine=bdb;
Look for the error in ~/usr/var/localhost.localdomain.err
---
To clean up after a total screwup:
rm -rf ~/usr/var/
Didn't manage to clean it up very well.
---
Goal: compile mysql with debugging
export LD_RUN_PATH=/home/bradley/yobiduck/ydb/src
./configure CFLAGS="-g -O2" --with-berkeley-db-includes=/home/bradley/yobiduck/ydb/include --with-berkeley-db --with-berkeley-db-libs=/home/bradley/yobiduck/src --prefix=/home/bradley/usr
If you want to debug, you might need to start mysqld without using mysqld_safe.
Here is one way to do it:
gdb ~/usr/libexec/mysqld
(gdb) run --basedir=/home/bradley/usr --datadir=/home/bradley/usr/var --pid-file=/home/bradley/usr/var/localhost.localdomain.pid --skip-external-locking
That was screwed up (the configure args were wrong.) Try again:
---
export LD_RUN_PATH=/home/bradley/yobiduck/ydb/src
./configure CXXFLAGS="-g -O2" CFLAGS="-g -O2" --with-berkeley-db-includes=/home/bradley/yobiduck/ydb/include --with-berkeley-db --with-berkeley-db-libs=/home/bradley/yobiduck/ydb/src --prefix=/home/bradley/usr
gdb ~/usr/libexec/mysqld
(gdb) run --basedir=/home/bradley/usr --datadir=/home/bradley/usr/var --pid-file=/home/bradley/usr/var/localhost.localdomain.pid --skip-external-locking
and
~/usr/bin/mysql -u root
Note: Had to change mysql to declare berkeley_cmp_hidden_key and berkeley_cmp_packed_key to be extern, not static.
----
To start the mysql clean:
rm -r /home/bradley/usr/var/
/home/bradley/usr/bin/mysql_install_db
then run mysqld and mysql do
$ ~/usr/bin/mysql -u root
mysql> create database yobitest;
mysql> use yobitest;
mysql> create table t1 (i int) engine=bdb;
mysql> insert t1 values (3);
mysql> quit
~/usr/bin/mysqladmin -u root shutdown
Then create the trace1 from ydbtrace.c
(copy the output onto traces/trace1.c
cd traces
make
rm ~/usr/var/log.0000000001
rm ~/usr/var/yobitest/t1.db
./runtrace1
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#ifndef _BDBW_H
#define _BDBW_H
#if defined(__cplusplus)
extern "C" {
#if 0
}
#endif
#endif
int db_env_create_bdbw (struct __toku_db_env **, u_int32_t);
int txn_abort_bdbw (struct __toku_db_txn *);
int txn_begin_bdbw (struct __toku_db_env *env, struct __toku_db_txn *stxn, struct __toku_db_txn **txn, u_int32_t flags);
int txn_commit_bdbw (struct __toku_db_txn *, u_int32_t);
int db_create_bdbw (struct __toku_db **, struct __toku_db_env *, u_int32_t);
#if 0
typedef enum {
DB_BTREE=1,
// DB_HASH=2,
// DB_RECNO=3,
// DB_QUEUE=4,
// DB_UNKNOWN=5 /* Figure it out on open. */
} DBTYPE;
typedef enum {
DB_NOTICE_LOGFILE_CHANGED
} db_notices;
enum {
DB_VERB_CHKPOINT = 0x0001,
DB_VERB_DEADLOCK = 0x0002,
DB_VERB_RECOVERY = 0x0004
};
typedef struct __toku_db DB;
typedef struct yobi_db_btree_stat DB_BTREE_STAT;
typedef struct __toku_db_env DB_ENV;
typedef struct yobi_db_key_range DB_KEY_RANGE;
typedef struct yobi_db_lsn DB_LSN;
typedef struct __toku_db_txn DB_TXN;
typedef struct __toku_db_txn_active DB_TXN_ACTIVE;
typedef struct __toku_db_txn_stat DB_TXN_STAT;
typedef struct yobi_dbc DBC;
typedef struct yobi_dbt DBT;
struct __toku_db {
void *app_private;
int (*close) (DB *, u_int32_t);
int (*cursor) (DB *, DB_TXN *, DBC **, u_int32_t);
int (*del) (DB *, DB_TXN *, DBT *, u_int32_t);
int (*get) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*key_range) (DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t);
int (*open) (DB *, DB_TXN *,
const char *, const char *, DBTYPE, u_int32_t, int);
int (*put) (DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
int (*remove) (DB *, const char *, const char *, u_int32_t);
int (*rename) (DB *, const char *, const char *, const char *, u_int32_t);
int (*set_bt_compare) (DB *,
int (*)(DB *, const DBT *, const DBT *));
int (*set_flags) (DB *, u_int32_t);
int (*stat) (DB *, void *, u_int32_t);
struct __toku_db_internal *i;
};
enum {
DB_DBT_MALLOC = 0x002,
DB_DBT_REALLOC = 0x010,
DB_DBT_USERMEM = 0x020,
DB_DBT_DUPOK = 0x040
};
struct yobi_dbt {
void *app_private;
void *data;
u_int32_t flags;
u_int32_t size;
u_int32_t ulen;
};
struct __toku_db_txn {
int (*commit) (DB_TXN*, u_int32_t);
u_int32_t (*id) (DB_TXN *);
};
struct yobi_dbc {
int (*c_get) (DBC *, DBT *, DBT *, u_int32_t);
int (*c_close) (DBC *);
int (*c_del) (DBC *, u_int32_t);
};
struct __toku_db_env {
// Methods used by MYSQL
void (*err) (const DB_ENV *, int, const char *, ...);
int (*open) (DB_ENV *, const char *, u_int32_t, int);
int (*close) (DB_ENV *, u_int32_t);
int (*txn_checkpoint) (DB_ENV *, u_int32_t, u_int32_t, u_int32_t);
int (*log_flush) (DB_ENV *, const DB_LSN *);
void (*set_errcall) (DB_ENV *, void (*)(const char *, char *));
void (*set_errpfx) (DB_ENV *, const char *);
void (*set_noticecall) (DB_ENV *, void (*)(DB_ENV *, db_notices));
int (*set_flags) (DB_ENV *, u_int32_t, int);
int (*set_data_dir) (DB_ENV *, const char *);
int (*set_tmp_dir) (DB_ENV *, const char *);
int (*set_verbose) (DB_ENV *, u_int32_t, int);
int (*set_lg_bsize) (DB_ENV *, u_int32_t);
int (*set_lg_dir) (DB_ENV *, const char *);
int (*set_lg_max) (DB_ENV *, u_int32_t);
int (*set_cachesize) (DB_ENV *, u_int32_t, u_int32_t, int);
int (*set_lk_detect) (DB_ENV *, u_int32_t);
int (*set_lk_max) (DB_ENV *, u_int32_t);
int (*log_archive) (DB_ENV *, char **[], u_int32_t);
int (*txn_stat) (DB_ENV *, DB_TXN_STAT **, u_int32_t);
// Internal state
void (*errcall)(const char *, char *);
const char *errpfx;
char *dir; /* A malloc'd copy of the directory. */
u_int32_t open_flags;
int open_mode;
};
struct yobi_db_key_range {
double less,equal,grater;
};
struct yobi_db_btree_stat {
u_int32_t bt_ndata;
u_int32_t bt_nkeys;
};
struct __toku_db_txn_stat {
u_int32_t st_nactive;
DB_TXN_ACTIVE *st_txnarray;
};
struct yobi_db_lsn {
int hello;
};
struct __toku_db_txn_active {
DB_LSN lsn;
u_int32_t txnid;
};
#ifndef _YDB_WRAP_H
#define DB_VERSION_STRING "Yobiduck: Fractal DB (November 19, 2006)"
#else
#define DB_VERSION_STRING_ydb "Yobiduck: Fractal DB (November 19, 2006) (wrapped bdb)"
#endif
enum {
DB_ARCH_ABS = 0x001,
DB_ARCH_LOG = 0x004
};
enum {
//DB_AFTER = 1,
DB_FIRST = 10,
DB_GET_BOTH = 11,
DB_LAST = 18,
DB_NEXT = 19,
DB_NEXT_DUP = 20,
DB_PREV = 27,
DB_SET = 30,
DB_SET_RANGE = 32,
DB_RMW = 0x40000000
};
enum {
DB_KEYEMPTY = -30998,
DB_KEYEXIST = -30997,
DB_LOCK_DEADLOCK = -30996,
DB_NOTFOUND = -30991
};
enum {
DB_CREATE = 0x0000001,
DB_RDONLY = 0x0000010,
DB_RECOVER = 0x0000020,
DB_THREAD = 0x0000040,
DB_TXN_NOSYNC = 0x0000100,
DB_PRIVATE = 0x0100000
};
enum {
DB_LOCK_DEFAULT = 1,
DB_LOCK_OLDEST = 7,
DB_LOCK_RANDOM = 8
};
enum {
DB_DUP = 0x000002
};
enum {
DB_NOOVERWRITE = 23
};
enum {
DB_INIT_LOCK = 0x001000,
DB_INIT_LOG = 0x002000,
DB_INIT_MPOOL = 0x004000,
DB_INIT_TXN = 0x008000
};
int db_env_create (DB_ENV **, u_int32_t);
int txn_begin (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t);
int txn_abort (DB_TXN *);
int log_compare (const DB_LSN *, const DB_LSN *);
#endif
#if defined(__cplusplus)
}
#endif
#endif
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#include <db.h>
#include <pthread.h>
#include <stdlib.h>
#define MANAGER_BERKELEY_LOG_CLEANUP (1L << 0)
ulong volatile manager_status;
pthread_mutex_t LOCK_manager;
pthread_cond_t COND_manager;
void berkeley_noticecall(DB_ENV *db_env, db_notices notice)
{
switch (notice)
{
case DB_NOTICE_LOGFILE_CHANGED: /* purecov: tested */
pthread_mutex_lock(&LOCK_manager);
manager_status |= MANAGER_BERKELEY_LOG_CLEANUP;
pthread_mutex_unlock(&LOCK_manager);
pthread_cond_signal(&COND_manager);
break;
}
}
#define uint5korr(A) ((unsigned long long)(((unsigned long long) ((unsigned char) (A)[0])) +\
(((unsigned long long) ((unsigned char) (A)[1])) << 8) +\
(((unsigned long long) ((unsigned char) (A)[2])) << 16) +\
(((unsigned long long) ((unsigned char) (A)[3])) << 24)) +\
(((unsigned long long) ((unsigned char) (A)[4])) << 32))
int
berkeley_cmp_hidden_key(DB* file, const DBT *new_key, const DBT *saved_key)
{
unsigned long long a=uint5korr((char*) new_key->data);
unsigned long long b=uint5korr((char*) saved_key->data);
return a < b ? -1 : (a > b ? 1 : 0);
}
int
berkeley_cmp_packed_key(DB* file, const DBT *new_key, const DBT *saved_key)
{
printf("Whoops\n");
abort();
}
This directory provides a wrapper using the ydb db.h header file but
it calls the bdb internals. To get this to work requires a little
magic, since both BDB and YDB use the same type names.
BDB helps with a ./configure option (--with-uniquename) that makes it
so that all the link-time symbols have different names. But the type
names and enums collide. Hence we cannot include both the
../include/db.h and the BDB db.h.
To fix that we have a header ydb-uniq.h, which uses completely
different names for everything in the ydb interface. But those names
are compatible with the standard names: That is all the structs have
the same layout.
Thus we have the following three headers
bdb_db.h which defines things like db_env_create_4001(DBENV **, ...)
ydb_db.h which defines things like db_env_create(DBENV **, ...) (but the DBENV is a different type from BDB's)
bdbw.h which defines things like db_env_create_ydb(DBENV_ydb **, ...)
bdbw.h can be included with bdb_db.h or ydb_db.h
bdb_db.h and ydb_db.h cannot both be included in the same file.
An application, such as mysql, includes db.h from ../include
That is the ydb header file.
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#ifndef _TOKUDB_WRAP_H
#define _TOKUDB_WRAP_H
#define DB_BTREE DB_BTREE_ydb
#define DB_NOTICE_LOGFILE_CHANGED DB_NOTICE_LOGFILE_CHANGED_ydb
#define DBTYPE DBTYPE_ydb
#define db_notices db_notices_ydb
#define txn_abort txn_abort_ydb
#define txn_begin txn_begin_ydb
#define txn_commit txn_commit_ydb
#define DB_VERB_CHKPOINT DB_VERB_CHKPOINT_ydb
//#define DB_VERB_DEADLOCK DB_VERB_DEADLOCK_ydb
//#define DB_VERB_RECOVERY DB_VERB_RECOVERY_ydb
#define DB DB_ydb
#define DB_BTREE_STAT DB_BTREE_STAT_ydb
#define DB_ENV DB_ENV_ydb
#define DB_KEY_RANGE DB_KEY_RANGE_ydb
#define DB_LSN DB_LSN_ydb
#define DB_TXN DB_TXN_ydb
#define DB_TXN_ACTIVE DB_TXN_ACTIVE_ydb
#define DB_TXN_STAT DB_TXN_STAT_ydb
#define DBC DBC_ydb
#define DBT DBT_ydb
#define DB_DBT_MALLOC B_DBT_MALLOC_ydb
#define DB_DBT_REALLOC DB_DBT_REALLOC_ydb
#define DB_DBT_USERMEM DB_DBT_USERMEM_ydb
#define DB_DBT_DUPOK DB_DBT_DUPOK_ydb
#define DB_ARCH_ABS DB_ARCH_ABS_ydb
#define DB_ARCH_LOG DB_ARCH_LOG_ydb
#define DB_FIRST DB_FIRST_ydb
#define DB_GET_BOTH DB_GET_BOTH_ydb
#define DB_LAST DB_LAST_ydb
#define DB_NEXT DB_NEXT_ydb
#define DB_NEXT_DUP DB_NEXT_DUP_ydb
#define DB_PREV DB_PREV_ydb
#define DB_SET DB_SET_ydb
#define DB_SET_RANGE DB_SET_RANGE_ydb
#define DB_RMW DB_RMW_ydb
#define DB_KEYEMPTY DB_KEYEMPTY_ydb
#define DB_KEYEXIST DB_KEYEXIST_ydb
#define DB_LOCK_DEADLOCK DB_LOCK_DEADLOCK_ydb
#define DB_NOTFOUND DB_NOTFOUND_ydb
#define DB_CREATE DB_CREATE_ydb
#define DB_RDONLY DB_RDONLY_ydb
#define DB_RECOVER DB_RECOVER_ydb
#define DB_THREAD DB_THREAD_ydb
#define DB_TXN_NOSYNC DB_TXN_NOSYNC_ydb
#define DB_PRIVATE DB_PRIVATE_ydb
#define DB_LOCK_DEFAULT DB_LOCK_DEFAULT_ydb
#define DB_LOCK_OLDEST DB_LOCK_OLDEST_ydb
#define DB_LOCK_RANDOM DB_LOCK_RANDOM_ydb
#define DB_DUP DB_DUP_ydb
#define DB_NOOVERWRITE DB_NOOVERWRITE_ydb
#define DB_INIT_LOCK DB_INIT_LOCK_ydb
#define DB_INIT_LOG DB_INIT_LOG_ydb
#define DB_INIT_MPOOL DB_INIT_MPOOL_ydb
#define DB_INIT_TXN DB_INIT_TXN_ydb
#define db_create db_create_ydb
#define db_env_create db_env_create_ydb
#define txn_begin txn_begin_ydb
#define txn_commit txn_commit_ydb
#define txn_abort txn_abort_ydb
#define log_compare log_compare_ydb
#include "../include/db.h"
#undef DB_BTREE
#undef DB_NOTICE_LOGFILE_CHANGED
#undef DBTYPE
#undef db_notices
#undef txn_abort
#undef txn_begin
#undef txn_commit
#undef DB_VERB_CHKPOINT
#undef DB_VERB_DEADLOCK
#undef DB_VERB_RECOVERY
#undef DB
#undef DB_BTREE_STAT
#undef DB_ENV
#undef DB_KEY_RANGE
#undef DB_LSN
#undef DB_TXN
#undef DB_TXN_ACTIVE
#undef DB_TXN_STAT
#undef DBC
#undef DBT
#undef DB_DBT_MALLOC
#undef DB_DBT_REALLOC
#undef DB_DBT_USERMEM
#undef DB_DBT_DUPOK
#undef DB_ARCH_ABS
#undef DB_ARCH_LOG
#undef DB_FIRST
#undef DB_GET_BOTH
#undef DB_LAST
#undef DB_NEXT
#undef DB_NEXT_DUP
#undef DB_PREV
#undef DB_SET
#undef DB_SET_RANGE
#undef DB_RMW
#undef DB_KEYEMPTY
#undef DB_KEYEXIST
#undef DB_LOCK_DEADLOCK
#undef DB_NOTFOUND
#undef DB_CREATE
#undef DB_RDONLY
#undef DB_RECOVER
#undef DB_THREAD
#undef DB_TXN_NOSYNC
#undef DB_PRIVATE
#undef DB_LOCK_DEFAULT
#undef DB_LOCK_OLDEST
#undef DB_LOCK_RANDOM
#undef DB_DUP
#undef DB_NOOVERWRITE
#undef DB_INIT_LOCK
#undef DB_INIT_LOG
#undef DB_INIT_MPOOL
#undef DB_INIT_TXN
#undef db_create
#undef db_env_create
#undef txn_begin
#undef txn_commit
#undef txn_abort
#undef log_compare
#endif
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/* This version is what Mysql calls.
* It invokes the version in bdbw.
* The version in bdbw then converts to Berkeley DB Calls. */
#include <sys/types.h>
/* This include is to the ydb include, which is what mysql sees. */
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <toku_assert.h>
#include "bdbw.h"
#define barf() ({ fprintf(stderr, "YDB: BARF %s:%d in %s\n", __FILE__, __LINE__, __func__); })
#define barff(fmt,...) ({ fprintf(stderr, "YDB: BARF %s:%d in %s, ", __FILE__, __LINE__, __func__); fprintf(stderr, fmt, __VA_ARGS__); })
#define note() ({ fprintf(stderr, "YDB: Note %s:%d in %s\n", __FILE__, __LINE__, __func__); })
#define notef(fmt,...) ({ fprintf(stderr, "YDB: Note %s:%d in %s, ", __FILE__, __LINE__, __func__); fprintf(stderr, fmt, __VA_ARGS__); })
int db_env_create (DB_ENV **envp, u_int32_t flags) {
return db_env_create_bdbw(envp, flags);
}
int txn_abort (DB_TXN *txn) {
return txn_abort_bdbw(txn);
}
int txn_begin (DB_ENV *env, DB_TXN *stxn, DB_TXN **txn, u_int32_t flags) {
return txn_begin_bdbw(env, stxn, txn, flags);
}
int txn_commit (DB_TXN *txn, u_int32_t flags) {
return txn_commit_bdbw(txn, flags);
}
struct ydb_db_internal {
int foo;
};
void print_flags (u_int32_t flags) {
u_int32_t gotit=0;
int doneone=0;
#define doit(flag) if (flag & flags) { if (doneone) printf(" | "); printf("%s", #flag); doneone=1; gotit|=flag; }
printf(" flags=");
doit(DB_INIT_LOCK);
doit(DB_INIT_LOG);
doit(DB_INIT_MPOOL);
doit(DB_INIT_TXN);
doit(DB_CREATE);
doit(DB_THREAD);
doit(DB_RECOVER);
doit(DB_PRIVATE);
if (gotit!=flags) printf(" flags 0x%x not accounted for", flags&~gotit);
printf("\n");
}
int log_compare (const DB_LSN *a, const DB_LSN *b) {
fprintf(stderr, "%s:%d log_compare(%p,%p)\n", __FILE__, __LINE__, a, b);
abort();
}
static int yobi_db_close (DB *db, u_int32_t flags) {
barf();
abort();
}
int yobi_db_cursor (DB *db, DB_TXN *txn, DBC **c, u_int32_t flags) {
barf();
abort();
}
int yobi_db_del (DB *db, DB_TXN *txn, DBT *dbt, u_int32_t flags) {
barf();
abort();
}
int yobi_db_get (DB *db, DB_TXN *txn, DBT *dbta, DBT *dbtb, u_int32_t flags) {
barf();
abort();
}
int yobi_db_key_range (DB *db, DB_TXN *txn, DBT *dbt, DB_KEY_RANGE *kr, u_int32_t flags) {
barf();
abort();
}
int yobi_db_open (DB *db, DB_TXN *txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode) {
notef("txn=%p fname=%s dbname=%s dbtype=%d flags=0x%x mode=0%o\n", txn, fname, dbname, dbtype, flags, mode);
print_flags(flags);
return 0;
}
int yobi_db_put (DB *db, DB_TXN *txn, DBT *dbta, DBT *dbtb, u_int32_t flags) {
barf();
abort();
}
int yobi_db_remove (DB *db, const char *fname, const char *dbname, u_int32_t flags) {
barf();
abort();
}
int yobi_db_rename (DB *db, const char *namea, const char *nameb, const char *namec, u_int32_t flags) {
barf();
abort();
}
int yobi_db_set_flags (DB *db, u_int32_t flags) {
barf();
abort();
}
int yobi_db_stat (DB *db, void *v, u_int32_t flags) {
barf();
abort();
}
int db_create (DB **db, DB_ENV *env, u_int32_t flags) {
return db_create_bdbw(db, env, 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