Commit 93a48c47 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1032

merge handlerton to main line

git-svn-id: file:///svn/mysql/tokudb-engine/src@8627 c7de825b-a66e-492c-adef-691d508d4ae1
parent 952cb220
...@@ -4,6 +4,7 @@ MYSQL_LIBDIR = $(HOME)/mysql-5.1.23-rc-build/lib/mysql ...@@ -4,6 +4,7 @@ MYSQL_LIBDIR = $(HOME)/mysql-5.1.23-rc-build/lib/mysql
TOKUDB = /usr/local/tokudb-4.4 TOKUDB = /usr/local/tokudb-4.4
TOKUDB_VERSION = "Tokudb" TOKUDB_VERSION = "Tokudb"
DEBUG = 1 DEBUG = 1
SYSTEM = $(shell uname -s | tr [A-Z] [a-z])
# sources to target # sources to target
SRCS = $(wildcard *.cc) SRCS = $(wildcard *.cc)
...@@ -15,7 +16,7 @@ GCOV_FLAGS = -ftest-coverage -fprofile-arcs ...@@ -15,7 +16,7 @@ GCOV_FLAGS = -ftest-coverage -fprofile-arcs
endif endif
ifeq ($(DEBUG),0) ifeq ($(DEBUG),0)
OPTFLAGS = -O3 OPTFLAGS = -O2
MYSQL_FLAGS = MYSQL_FLAGS =
CXXFLAGS = CXXFLAGS =
else else
...@@ -28,12 +29,18 @@ MYSQL_FLAGS += -DMYSQL_DYNAMIC_PLUGIN ...@@ -28,12 +29,18 @@ MYSQL_FLAGS += -DMYSQL_DYNAMIC_PLUGIN
MYSQL_CXXFLAGS = -fno-implicit-templates -fno-exceptions -fno-rtti MYSQL_CXXFLAGS = -fno-implicit-templates -fno-exceptions -fno-rtti
CPPFLAGS = -I. -I$(MYSQL_SRC)/sql -I$(MYSQL_SRC)/include -I$(MYSQL_SRC)/regex -I$(TOKUDB)/include CPPFLAGS = -I. -I$(MYSQL_SRC)/sql -I$(MYSQL_SRC)/include -I$(MYSQL_SRC)/regex -I$(TOKUDB)/include
ifeq ($(SYSTEM),linux)
CPPFLAGS += -I$(TOKUDB)/linux
endif
CPPFLAGS += $(MYSQL_FLAGS) CPPFLAGS += $(MYSQL_FLAGS)
CPPFLAGS += -DTOKUDB_VERSION=\"$(TOKUDB_VERSION)\" CPPFLAGS += -DTOKUDB_VERSION=\"$(TOKUDB_VERSION)\"
CXXFLAGS += -g $(OPTFLAGS) $(GCOV_FLAGS) $(MYSQL_CXXFLAGS) CXXFLAGS += -g $(OPTFLAGS) $(GCOV_FLAGS) $(MYSQL_CXXFLAGS)
CXXFLAGS += -fPIC CXXFLAGS += -fPIC
LDFLAGS = -fPIC -shared -Wl,-soname -Wl,libtokudb_engine.so LDFLAGS = -fPIC -shared -Wl,-soname -Wl,libtokudb_engine.so
LIBS = -L$(TOKUDB)/lib -ltokudb -lpthread -lz -lstdc++ -lm -lgcc_s -lc LIBS = -L$(TOKUDB)/lib -ltokudb -lpthread -lz -lstdc++ -lm -lgcc_s -lc
ifeq ($(SYSTEM),linux)
LIBS += -L$(TOKUDB)/lib -ltokuportability
endif
# LIBDIR = /usr/lib # LIBDIR = /usr/lib
# GCCLIBDIR = /usr/lib/gcc/i386-redhat-linux/4.1.1 # GCCLIBDIR = /usr/lib/gcc/i386-redhat-linux/4.1.1
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
#define MYSQL_SERVER 1 #define MYSQL_SERVER 1
#include "mysql_priv.h" #include "mysql_priv.h"
extern "C" {
#include "stdint.h"
#if defined(_WIN32)
#include "misc.h"
#endif
}
#if !defined(HA_END_SPACE_KEY) || HA_END_SPACE_KEY != 0 #if !defined(HA_END_SPACE_KEY) || HA_END_SPACE_KEY != 0
#error #error
...@@ -1386,7 +1392,7 @@ void ha_tokudb::unpack_row(uchar * record, DBT const *row, DBT const *key, bool ...@@ -1386,7 +1392,7 @@ void ha_tokudb::unpack_row(uchar * record, DBT const *row, DBT const *key, bool
for (Field ** field = table->field; *field; field++) { for (Field ** field = table->field; *field; field++) {
uint curr_field_offset = field_offset(*field, table); uint curr_field_offset = field_offset(*field, table);
if (primary_key_offsets && if (primary_key_offsets &&
pk_stripped && pk_stripped &&
curr_skip_index < table_share->key_info[table_share->primary_key].key_parts curr_skip_index < table_share->key_info[table_share->primary_key].key_parts
) { ) {
uint curr_skip_offset = primary_key_offsets[curr_skip_index].offset; uint curr_skip_offset = primary_key_offsets[curr_skip_index].offset;
...@@ -3681,7 +3687,7 @@ static int create_sub_table(const char *table_name, int flags) { ...@@ -3681,7 +3687,7 @@ static int create_sub_table(const char *table_name, int flags) {
static int mkdirpath(char *name, mode_t mode) { static int mkdirpath(char *name, mode_t mode) {
char* parent = NULL; char* parent = NULL;
int r = mkdir(name, mode); int r = toku_os_mkdir(name, mode);
if (r == -1 && errno == ENOENT) { if (r == -1 && errno == ENOENT) {
parent = (char *)my_malloc(strlen(name)+1,MYF(MY_WME)); parent = (char *)my_malloc(strlen(name)+1,MYF(MY_WME));
if (parent == NULL) { if (parent == NULL) {
...@@ -3692,9 +3698,9 @@ static int mkdirpath(char *name, mode_t mode) { ...@@ -3692,9 +3698,9 @@ static int mkdirpath(char *name, mode_t mode) {
char *cp = strrchr(parent, '/'); char *cp = strrchr(parent, '/');
if (cp) { if (cp) {
*cp = 0; *cp = 0;
r = mkdir(parent, 0755); r = toku_os_mkdir(parent, 0755);
if (r == 0) if (r == 0)
r = mkdir(name, mode); r = toku_os_mkdir(name, mode);
} }
} }
cleanup: cleanup:
...@@ -3702,8 +3708,9 @@ static int mkdirpath(char *name, mode_t mode) { ...@@ -3702,8 +3708,9 @@ static int mkdirpath(char *name, mode_t mode) {
return r; return r;
} }
extern "C" {
#include <dirent.h> #include <dirent.h>
}
static int rmall(const char *dname) { static int rmall(const char *dname) {
int error = 0; int error = 0;
......
#include "mysql_priv.h" #include "mysql_priv.h"
extern "C" {
#include "stdint.h"
}
#include "hatoku_cmptrace.h" #include "hatoku_cmptrace.h"
/* /*
Things that are required for ALL data types: Things that are required for ALL data types:
key_part->field->null_bit key_part->field->null_bit
......
#ifndef _HATOKU_DEF #ifndef _HATOKU_DEF
#define _HATOKU_DEF #define _HATOKU_DEF
#include <syscall.h>
#include "db.h" #include "db.h"
extern "C" {
#include "toku_os.h"
}
extern ulong tokudb_debug; extern ulong tokudb_debug;
...@@ -34,7 +35,7 @@ extern ulong tokudb_debug; ...@@ -34,7 +35,7 @@ extern ulong tokudb_debug;
inline unsigned int my_tid() { inline unsigned int my_tid() {
return syscall(__NR_gettid); return (unsigned int)toku_os_gettid();
} }
......
#define MYSQL_SERVER 1 #define MYSQL_SERVER 1
#include "mysql_priv.h" #include "mysql_priv.h"
extern "C" {
#include "stdint.h"
#if defined(_WIN32)
#include "misc.h"
#endif
#include "toku_os.h"
}
/* We define DTRACE after mysql_priv.h in case it disabled dtrace in the main server */ /* We define DTRACE after mysql_priv.h in case it disabled dtrace in the main server */
#ifdef HAVE_DTRACE #ifdef HAVE_DTRACE
#define _DTRACE_VERSION 1 #define _DTRACE_VERSION 1
...@@ -18,8 +28,6 @@ ...@@ -18,8 +28,6 @@
#undef HAVE_DTRACE #undef HAVE_DTRACE
#undef _DTRACE_VERSION #undef _DTRACE_VERSION
#include <syscall.h>
static inline void *thd_data_get(THD *thd, int slot) { static inline void *thd_data_get(THD *thd, int slot) {
#if MYSQL_VERSION_ID <= 50123 #if MYSQL_VERSION_ID <= 50123
...@@ -40,11 +48,6 @@ static inline void thd_data_set(THD *thd, int slot, void *data) { ...@@ -40,11 +48,6 @@ static inline void thd_data_set(THD *thd, int slot, void *data) {
unsigned long my_getphyspages() {
return sysconf(_SC_PHYS_PAGES);
}
static uchar *tokudb_get_key(TOKUDB_SHARE * share, size_t * length, my_bool not_used __attribute__ ((unused))) { static uchar *tokudb_get_key(TOKUDB_SHARE * share, size_t * length, my_bool not_used __attribute__ ((unused))) {
*length = share->table_name_length; *length = share->table_name_length;
return (uchar *) share->table_name; return (uchar *) share->table_name;
...@@ -109,10 +112,17 @@ static const int tokudb_hton_name_length = sizeof(tokudb_hton_name) - 1; ...@@ -109,10 +112,17 @@ static const int tokudb_hton_name_length = sizeof(tokudb_hton_name) - 1;
#endif #endif
struct st_mysql_storage_engine storage_engine_structure = { MYSQL_HANDLERTON_INTERFACE_VERSION }; struct st_mysql_storage_engine storage_engine_structure = { MYSQL_HANDLERTON_INTERFACE_VERSION };
#if defined(_WIN32)
extern "C" {
#include "ydb.h"
}
#endif
static int tokudb_init_func(void *p) { static int tokudb_init_func(void *p) {
TOKUDB_DBUG_ENTER("tokudb_init_func"); TOKUDB_DBUG_ENTER("tokudb_init_func");
#if defined(_WIN32)
toku_ydb_init();
#endif
tokudb_hton = (handlerton *) p; tokudb_hton = (handlerton *) p;
...@@ -199,10 +209,12 @@ static int tokudb_init_func(void *p) { ...@@ -199,10 +209,12 @@ static int tokudb_init_func(void *p) {
// config the cache table // config the cache table
if (tokudb_cache_size == 0) { if (tokudb_cache_size == 0) {
unsigned long pagesize = my_getpagesize(); unsigned long long physmem = (unsigned long)toku_os_get_phys_memory_size();
unsigned long long npages = my_getphyspages(); #if defined(_WIN32)
unsigned long long physmem = npages * pagesize; tokudb_cache_size = 256000000;
#else
tokudb_cache_size = (ulonglong) (physmem * (tokudb_cache_memory_percent / 100.0)); tokudb_cache_size = (ulonglong) (physmem * (tokudb_cache_memory_percent / 100.0));
#endif
} }
if (tokudb_cache_size) { if (tokudb_cache_size) {
DBUG_PRINT("info", ("tokudb_cache_size: %lld\n", tokudb_cache_size)); DBUG_PRINT("info", ("tokudb_cache_size: %lld\n", tokudb_cache_size));
...@@ -244,7 +256,7 @@ static int tokudb_init_func(void *p) { ...@@ -244,7 +256,7 @@ static int tokudb_init_func(void *p) {
if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env open:flags=%x\n", __FUNCTION__, tokudb_init_flags); if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env open:flags=%x\n", __FUNCTION__, tokudb_init_flags);
r = db_env->open(db_env, tokudb_home, tokudb_init_flags, 0666); r = db_env->open(db_env, tokudb_home, tokudb_init_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env opened:return=%d\n", __FUNCTION__, r); if (tokudb_debug & TOKUDB_DEBUG_INIT) TOKUDB_TRACE("%s:env opened:return=%d\n", __FUNCTION__, r);
...@@ -271,6 +283,9 @@ static int tokudb_done_func(void *p) { ...@@ -271,6 +283,9 @@ static int tokudb_done_func(void *p) {
error = 1; error = 1;
hash_free(&tokudb_open_tables); hash_free(&tokudb_open_tables);
pthread_mutex_destroy(&tokudb_mutex); pthread_mutex_destroy(&tokudb_mutex);
#if defined(_WIN32)
toku_ydb_destroy();
#endif
TOKUDB_DBUG_RETURN(0); TOKUDB_DBUG_RETURN(0);
} }
......
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