diff --git a/include/db.h b/include/db.h index 6ee5645ed7a..0f3ec999452 100644 --- a/include/db.h +++ b/include/db.h @@ -109,7 +109,13 @@ struct yobi_db_env { 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); +#ifdef _YDB_WRAP_H +#undef txn_begin +#endif int (*txn_begin) (DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t); +#ifdef _YDB_WRAP_H +#define txn_begin txn_begin_ydb +#endif // Internal state struct db_env_ydb_internal *i; }; diff --git a/src-bdbwrap/Makefile b/src-bdbwrap/Makefile index 9640f98c0bd..c8f0d2f17ba 100644 --- a/src-bdbwrap/Makefile +++ b/src-bdbwrap/Makefile @@ -37,9 +37,9 @@ C_OBJS= mut_pthread.lo \ install: libdb.so cp libdb.so ../src/ -libdb.so: ydb.lo bdbw.lo +libdb.so: ydb.lo bdbw.lo noticecall.lo echo cc ydb.lo bdbw.lo BDB-OBJS -shared -fPIC -o libdb.so $(CFLAGS) - @cc ydb.lo bdbw.lo $(patsubst %,/home/bradley/mysql/build-bdb-with-uniquename/bdb/build_unix/%,$(C_OBJS)) -shared -fPIC -o libdb.so $(CFLAGS) + @cc ydb.lo bdbw.lo noticecall.lo $(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 diff --git a/src-bdbwrap/noticecall.c b/src-bdbwrap/noticecall.c new file mode 100644 index 00000000000..da96451a4b8 --- /dev/null +++ b/src-bdbwrap/noticecall.c @@ -0,0 +1,35 @@ +#include +#include + +#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); +}