Commit b8d7ee97 authored by Rich Prohaska's avatar Rich Prohaska

basic tokudb running in mysql 5.7

parent eef01795
This diff is collapsed.
......@@ -92,6 +92,8 @@ PATENT RIGHTS GRANT:
#if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100099
#define TOKU_ALTER_RENAME ALTER_RENAME_56
#elif 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
#define TOKU_ALTER_RENAME ALTER_RENAME
#elif 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#define TOKU_ALTER_RENAME ALTER_RENAME
#elif 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
......@@ -492,7 +494,8 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha
if (error == 0 && ctx->reset_card)
tokudb::set_card_from_status(share->status_block, ctx->alter_txn, table->s, altered_table->s);
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
if (error == 0 && (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL)) {
error = write_frm_data(share->status_block, ctx->alter_txn, altered_table->s->path.str);
}
......@@ -510,7 +513,7 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha
int ha_tokudb::alter_table_add_index(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
// sort keys in add index order
KEY *key_info = (KEY*) my_malloc(sizeof (KEY) * ha_alter_info->index_add_count, MYF(MY_WME));
KEY *key_info = (KEY*) tokudb_my_malloc(sizeof (KEY) * ha_alter_info->index_add_count, MYF(MY_WME));
for (uint i = 0; i < ha_alter_info->index_add_count; i++) {
KEY *key = &key_info[i];
*key = ha_alter_info->key_info_buffer[ha_alter_info->index_add_buffer[i]];
......@@ -529,7 +532,7 @@ int ha_tokudb::alter_table_add_index(TABLE *altered_table, Alter_inplace_info *h
last_dup_key = MAX_KEY;
}
my_free(key_info);
tokudb_my_free(key_info);
if (error == 0)
ctx->reset_card = true;
......@@ -619,7 +622,7 @@ int ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplac
4 + num_columns*(1+1+4+1+1+4) + altered_table->s->reclength + // max dynamic row_mutator
(4 + share->kc_info.num_blobs) + // max static blob size
(num_columns*(1+4+1+4)); // max dynamic blob size
column_extra = (uchar *)my_malloc(max_column_extra_size, MYF(MY_WME));
column_extra = (uchar *)tokudb_my_malloc(max_column_extra_size, MYF(MY_WME));
if (column_extra == NULL) { error = ENOMEM; goto cleanup; }
for (uint32_t i = 0; i < curr_num_DBs; i++) {
......@@ -629,7 +632,7 @@ int ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplac
if (error)
goto cleanup;
error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0);
my_free(row_descriptor.data);
tokudb_my_free(row_descriptor.data);
if (error)
goto cleanup;
......@@ -660,7 +663,7 @@ int ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplac
error = 0;
cleanup:
my_free(column_extra);
tokudb_my_free(column_extra);
return error;
}
......@@ -674,12 +677,13 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i
bool result = false; // success
if (commit) {
#if 50613 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50613 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
if (ha_alter_info->group_commit_ctx) {
ha_alter_info->group_commit_ctx = NULL;
}
#endif
#if 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
#if (50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599)
if (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL) {
int error = write_frm_data(share->status_block, ctx->alter_txn, altered_table->s->path.str);
if (error) {
......@@ -753,7 +757,7 @@ int ha_tokudb::alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_in
if (error)
break;
error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0);
my_free(row_descriptor.data);
tokudb_my_free(row_descriptor.data);
if (error)
break;
......@@ -766,7 +770,7 @@ int ha_tokudb::alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_in
// make the expand variable offsets message
DBT expand; memset(&expand, 0, sizeof expand);
expand.size = sizeof (uchar) + sizeof offset_start + sizeof offset_end;
expand.data = my_malloc(expand.size, MYF(MY_WME));
expand.data = tokudb_my_malloc(expand.size, MYF(MY_WME));
if (!expand.data) {
error = ENOMEM;
break;
......@@ -783,7 +787,7 @@ int ha_tokudb::alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_in
// and broadcast it into the tree
error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP);
my_free(expand.data);
tokudb_my_free(expand.data);
if (error)
break;
}
......@@ -935,7 +939,7 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace
if (error)
break;
error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0);
my_free(row_descriptor.data);
tokudb_my_free(row_descriptor.data);
if (error)
break;
......@@ -955,7 +959,7 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace
expand.size = sizeof operation + sizeof new_offset + sizeof old_length + sizeof new_length;
if (operation == UPDATE_OP_EXPAND_CHAR || operation == UPDATE_OP_EXPAND_BINARY)
expand.size += sizeof pad_char;
expand.data = my_malloc(expand.size, MYF(MY_WME));
expand.data = tokudb_my_malloc(expand.size, MYF(MY_WME));
if (!expand.data) {
error = ENOMEM;
break;
......@@ -984,7 +988,7 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace
// and broadcast it into the tree
error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP);
my_free(expand.data);
tokudb_my_free(expand.data);
if (error)
break;
}
......@@ -1014,7 +1018,7 @@ int ha_tokudb::alter_table_expand_blobs(TABLE *altered_table, Alter_inplace_info
if (error)
break;
error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0);
my_free(row_descriptor.data);
tokudb_my_free(row_descriptor.data);
if (error)
break;
......@@ -1144,7 +1148,7 @@ int ha_tokudb::new_row_descriptor(TABLE *table, TABLE *altered_table, Alter_inpl
int error = 0;
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
row_descriptor->size = get_max_desc_size(ctx->altered_table_kc_info, altered_table);
row_descriptor->data = (uchar *) my_malloc(row_descriptor->size, MYF(MY_WME));
row_descriptor->data = (uchar *) tokudb_my_malloc(row_descriptor->size, MYF(MY_WME));
if (row_descriptor->data == NULL) {
error = ENOMEM;
} else {
......
......@@ -117,7 +117,8 @@ bool field_valid_for_tokudb_table(Field* field) {
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_FLOAT:
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_TIME2:
......@@ -264,7 +265,8 @@ TOKU_TYPE mysql_to_toku_type (Field* field) {
case MYSQL_TYPE_FLOAT:
ret_val = toku_type_float;
goto exit;
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_TIME2:
......@@ -3224,7 +3226,8 @@ bool fields_are_same_type(
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_TIMESTAMP:
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_TIME2:
......
......@@ -263,7 +263,8 @@ static inline const uchar* unpack_toku_field_blob(
}
static inline uint get_null_offset(TABLE* table, Field* field) {
#if 50606 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#if (50606 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
return field->null_offset(table->record[0]);
#else
return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]);
......
......@@ -121,7 +121,13 @@ PATENT RIGHTS GRANT:
#if defined(TOKUDB_PATCHES) && TOKUDB_PATCHES == 0
#elif 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
#define TOKU_USE_DB_TYPE_UNKNOWN 1
#define TOKU_INCLUDE_ALTER_56 1
#define TOKU_PARTITION_WRITE_FRM_DATA 0
#elif 50613 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
#define TOKU_USE_DB_TYPE_TOKUDB 1
#define TOKU_INCLUDE_ALTER_56 1
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
#define TOKU_INCLUDE_XA 1
......@@ -133,6 +139,7 @@ PATENT RIGHTS GRANT:
#endif
#elif 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
#define TOKU_USE_OTHER_DB_TYPE 1
#define TOKU_INCLUDE_ALTER_56 1
#define TOKU_INCLUDE_ALTER_55 1
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
......@@ -143,7 +150,6 @@ PATENT RIGHTS GRANT:
#if defined(MARIADB_BASE_VERSION)
#define TOKU_INCLUDE_EXTENDED_KEYS 1
#endif
#define TOKU_INCLUDE_OTHER_DB_TYPE 1
#define TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL 1
#else
......@@ -354,4 +360,60 @@ void toku_hton_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,con
#undef assert
#define assert(expr) ((expr) ? (void)0 : toku_hton_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__, errno))
static inline void *tokudb_my_malloc(size_t s, myf flags) {
#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
return my_malloc(0, s, flags);
#else
return my_malloc(s, flags);
#endif
}
static inline void *tokudb_my_realloc(void *p, size_t s, myf flags) {
#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
return my_realloc(0, p, s, flags);
#else
return my_realloc(p, s, flags);
#endif
}
static inline void tokudb_my_free(void *ptr) {
my_free(ptr);
}
static inline char *tokudb_my_strdup(const char *p, myf flags) {
#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
return my_strdup(0, p, flags);
#else
return my_strdup(p, flags);
#endif
}
static inline void* tokudb_my_multi_malloc(myf myFlags, ...) {
va_list args;
char **ptr,*start,*res;
size_t tot_length,length;
va_start(args,myFlags);
tot_length=0;
while ((ptr=va_arg(args, char **))) {
length=va_arg(args,uint);
tot_length+=ALIGN_SIZE(length);
}
va_end(args);
if (!(start=(char *) tokudb_my_malloc(tot_length,myFlags))) {
return 0;
}
va_start(args,myFlags);
res=start;
while ((ptr=va_arg(args, char **))) {
*ptr=res;
length=va_arg(args,uint);
res+=ALIGN_SIZE(length);
}
va_end(args);
return start;
}
#endif
......@@ -315,7 +315,7 @@ static int tokudb_init_func(void *p) {
// tokudb_hton->flags= HTON_CAN_RECREATE; // QQQ this came from skeleton
tokudb_hton->flags = HTON_CLOSE_CURSORS_AT_COMMIT;
#if TOKU_INCLUDE_EXTENDED_KEYS
#if defined(TOKU_INCLUDE_EXTENDED_KEYS) && TOKU_INCLUDE_EXTENDED_KEYS
#if defined(HTON_SUPPORTS_EXTENDED_KEYS)
tokudb_hton->flags |= HTON_SUPPORTS_EXTENDED_KEYS;
#endif
......@@ -324,13 +324,16 @@ static int tokudb_init_func(void *p) {
#endif
#endif
#if TOKU_INCLUDE_OTHER_DB_TYPE
// we have historically been a dynamic storage engine, so we set db_type according.
// however, extended keys is triggered off of the db_type, so tokudb adds another type so that extended keys works
#if defined(TOKU_USE_DB_TYPE_TOKUDB) && TOKU_USE_DB_TYPE_TOKUDB
tokudb_hton->db_type = DB_TYPE_TOKUDB;
#elif defined(TOKU_USE_DB_TYPE_UNKNOWN) && TOKU_USE_DB_TYPE_UNKNOWN
tokudb_hton->db_type = DB_TYPE_UNKNOWN;
#elif defined(TOKU_USE_OTHER_DB_TYPE) && TOKU_USE_OTHER_DB_TYPE
// extended keys is triggered off of the db_type, so tokudb adds another type so that extended keys works
tokudb_hton->db_type = DB_TYPE_UNKNOWN;
tokudb_hton->other_db_type = DB_TYPE_TOKUDB;
#else
tokudb_hton->db_type = DB_TYPE_TOKUDB;
#error
#endif
tokudb_hton->create = tokudb_create_handler;
......@@ -491,8 +494,8 @@ static int tokudb_init_func(void *p) {
{
const myf mem_flags = MY_FAE|MY_WME|MY_ZEROFILL|MY_ALLOW_ZERO_PTR|MY_FREE_ON_ERROR;
toku_global_status_variables = (SHOW_VAR*)my_malloc(sizeof(*toku_global_status_variables)*toku_global_status_max_rows, mem_flags);
toku_global_status_rows = (TOKU_ENGINE_STATUS_ROW_S*)my_malloc(sizeof(*toku_global_status_rows)*toku_global_status_max_rows, mem_flags);
toku_global_status_variables = (SHOW_VAR*)tokudb_my_malloc(sizeof(*toku_global_status_variables)*toku_global_status_max_rows, mem_flags);
toku_global_status_rows = (TOKU_ENGINE_STATUS_ROW_S*)tokudb_my_malloc(sizeof(*toku_global_status_rows)*toku_global_status_max_rows, mem_flags);
}
r = db_create(&metadata_db, db_env, 0);
......@@ -550,9 +553,9 @@ static int tokudb_init_func(void *p) {
static int tokudb_done_func(void *p) {
TOKUDB_DBUG_ENTER("tokudb_done_func");
my_free(toku_global_status_variables);
tokudb_my_free(toku_global_status_variables);
toku_global_status_variables = NULL;
my_free(toku_global_status_rows);
tokudb_my_free(toku_global_status_rows);
toku_global_status_rows = NULL;
my_hash_free(&tokudb_open_tables);
pthread_mutex_destroy(&tokudb_mutex);
......@@ -604,7 +607,7 @@ static int tokudb_close_connection(handlerton * hton, THD * thd) {
if (trx && trx->checkpoint_lock_taken) {
error = db_env->checkpointing_resume(db_env);
}
my_free(trx);
tokudb_my_free(trx);
return error;
}
......@@ -1595,10 +1598,10 @@ static int tokudb_report_fractal_tree_block_map_iterator(uint64_t checkpoint_cou
assert(num_rows > 0);
if (e->num_rows == 0) {
e->checkpoint_counts = (uint64_t *) my_malloc(num_rows * (sizeof *e->checkpoint_counts), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->blocknums = (int64_t *) my_malloc(num_rows * (sizeof *e->blocknums), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->diskoffs = (int64_t *) my_malloc(num_rows * (sizeof *e->diskoffs), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->sizes = (int64_t *) my_malloc(num_rows * (sizeof *e->sizes), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->checkpoint_counts = (uint64_t *) tokudb_my_malloc(num_rows * (sizeof *e->checkpoint_counts), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->blocknums = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->blocknums), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->diskoffs = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->diskoffs), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->sizes = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->sizes), MYF(MY_WME|MY_ZEROFILL|MY_FAE));
e->num_rows = num_rows;
}
......@@ -1678,19 +1681,19 @@ static int tokudb_report_fractal_tree_block_map_for_db(const DBT *dname, const D
exit:
if (e.checkpoint_counts != NULL) {
my_free(e.checkpoint_counts);
tokudb_my_free(e.checkpoint_counts);
e.checkpoint_counts = NULL;
}
if (e.blocknums != NULL) {
my_free(e.blocknums);
tokudb_my_free(e.blocknums);
e.blocknums = NULL;
}
if (e.diskoffs != NULL) {
my_free(e.diskoffs);
tokudb_my_free(e.diskoffs);
e.diskoffs = NULL;
}
if (e.sizes != NULL) {
my_free(e.sizes);
tokudb_my_free(e.sizes);
e.sizes = NULL;
}
return error;
......@@ -1848,9 +1851,9 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons
// set last_lock_timeout
if (lock_timeout_debug & 1) {
char *old_lock_timeout = THDVAR(thd, last_lock_timeout);
char *new_lock_timeout = my_strdup(log_str.c_ptr(), MY_FAE);
char *new_lock_timeout = tokudb_my_strdup(log_str.c_ptr(), MY_FAE);
THDVAR(thd, last_lock_timeout) = new_lock_timeout;
my_free(old_lock_timeout);
tokudb_my_free(old_lock_timeout);
}
// dump to stderr
if (lock_timeout_debug & 2) {
......
......@@ -485,7 +485,7 @@ static int tokudb_hcad_update_fun(
extra_pos += sizeof(uint32_t);
max_num_bytes = old_val->size + extra->size + new_len_of_offsets + new_fixed_field_size;
new_val_data = (uchar *)my_malloc(
new_val_data = (uchar *)tokudb_my_malloc(
max_num_bytes,
MYF(MY_FAE)
);
......@@ -815,7 +815,7 @@ static int tokudb_hcad_update_fun(
error = 0;
cleanup:
my_free(new_val_data);
tokudb_my_free(new_val_data);
return error;
}
......@@ -856,7 +856,7 @@ static int tokudb_expand_variable_offsets(
uchar *old_val_ptr = (uchar *)old_val->data;
// allocate space for the new val's data
uchar *new_val_ptr = (uchar *)my_malloc(number_of_offsets + old_val->size, MYF(MY_FAE));
uchar *new_val_ptr = (uchar *)tokudb_my_malloc(number_of_offsets + old_val->size, MYF(MY_FAE));
if (!new_val_ptr) {
error = ENOMEM;
goto cleanup;
......@@ -893,7 +893,7 @@ static int tokudb_expand_variable_offsets(
error = 0;
cleanup:
my_free(new_val.data);
tokudb_my_free(new_val.data);
return error;
}
......@@ -932,7 +932,7 @@ static int tokudb_expand_int_field(
uchar *old_val_ptr = (uchar *)old_val->data;
// allocate space for the new val's data
uchar *new_val_ptr = (uchar *)my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE));
uchar *new_val_ptr = (uchar *)tokudb_my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE));
if (!new_val_ptr) {
error = ENOMEM;
goto cleanup;
......@@ -980,7 +980,7 @@ static int tokudb_expand_int_field(
error = 0;
cleanup:
my_free(new_val.data);
tokudb_my_free(new_val.data);
return error;
}
......@@ -1021,7 +1021,7 @@ static int tokudb_expand_char_field(
uchar *old_val_ptr = (uchar *)old_val->data;
// allocate space for the new val's data
uchar *new_val_ptr = (uchar *)my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE));
uchar *new_val_ptr = (uchar *)tokudb_my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE));
if (!new_val_ptr) {
error = ENOMEM;
goto cleanup;
......@@ -1062,7 +1062,7 @@ static int tokudb_expand_char_field(
error = 0;
cleanup:
my_free(new_val.data);
tokudb_my_free(new_val.data);
return error;
}
......
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