Commit 92939d2e authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #5333 fix handlerton comments

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@47488 c7de825b-a66e-492c-adef-691d508d4ae1
parent ed550e8c
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "ha_tokudb_alter_common.cc" #include "ha_tokudb_alter_common.cc"
#include <sql_array.h> #include <sql_array.h>
// The tokudb alter context contains the alter state that is set in the check if supported method and used
// later when the alter operation is executed.
class tokudb_alter_ctx : public inplace_alter_handler_ctx { class tokudb_alter_ctx : public inplace_alter_handler_ctx {
public: public:
tokudb_alter_ctx() { tokudb_alter_ctx() {
...@@ -116,13 +118,11 @@ find_changed_fields(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_a ...@@ -116,13 +118,11 @@ find_changed_fields(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_a
} }
} }
static bool static bool change_length_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx);
change_length_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx);
static bool static bool change_type_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx);
change_type_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx);
// The ha_alter_info->handler_flags can not be trusted. This function maps the bogus bits. // The ha_alter_info->handler_flags can not be trusted. This function maps the bogus handler flags to something we like.
static ulong static ulong
fix_handler_flags(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info) { fix_handler_flags(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
ulong handler_flags = ha_alter_info->handler_flags; ulong handler_flags = ha_alter_info->handler_flags;
...@@ -173,7 +173,7 @@ fix_handler_flags(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alt ...@@ -173,7 +173,7 @@ fix_handler_flags(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alt
return handler_flags; return handler_flags;
} }
// require that there is no intersection of add and drop names. // Require that there is no intersection of add and drop names.
static bool static bool
is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) { is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) {
for (uint d = 0; d < ha_alter_info->index_drop_count; d++) { for (uint d = 0; d < ha_alter_info->index_drop_count; d++) {
...@@ -188,8 +188,7 @@ is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) { ...@@ -188,8 +188,7 @@ is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) {
return true; return true;
} }
// true if some bit in mask is set and no bit in ~mask is set // Return true if some bit in mask is set and no bit in ~mask is set, otherwise return false.
// otherwise false
static bool static bool
only_flags(ulong bits, ulong mask) { only_flags(ulong bits, ulong mask) {
return (bits & mask) != 0 && (bits & ~mask) == 0; return (bits & mask) != 0 && (bits & ~mask) == 0;
...@@ -342,6 +341,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -342,6 +341,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
DBUG_RETURN(result); DBUG_RETURN(result);
} }
// Prepare for the alter operations. Currently, there is nothing to prepare.
bool bool
ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("prepare_inplace_alter_table"); TOKUDB_DBUG_ENTER("prepare_inplace_alter_table");
...@@ -349,6 +349,7 @@ ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info ...@@ -349,6 +349,7 @@ ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info
DBUG_RETURN(result); DBUG_RETURN(result);
} }
// Execute the alter operations.
bool bool
ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("inplace_alter_table"); TOKUDB_DBUG_ENTER("inplace_alter_table");
...@@ -597,8 +598,7 @@ ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_in ...@@ -597,8 +598,7 @@ ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_in
return error; return error;
} }
// Handle change column varchar expansion. // Handle change column varchar expansion. For all clustered keys, broadcast an update message to readjust the varchar offsets.
// For all clustered keys, broadcast an update message to readjust the varchar offsets.
int int
ha_tokudb::alter_table_change_varchar_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { ha_tokudb::alter_table_change_varchar_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
int error = 0; int error = 0;
...@@ -639,9 +639,9 @@ ha_tokudb::alter_table_change_varchar_column(TABLE *altered_table, Alter_inplace ...@@ -639,9 +639,9 @@ ha_tokudb::alter_table_change_varchar_column(TABLE *altered_table, Alter_inplace
return error; return error;
} }
// Implement the handler commit inplace alter table method // Commit or abort the alter operations.
// If commit then write the new frm data to the status using the alter transaction // If commit then write the new frm data to the status using the alter transaction.
// If abort then abort the alter transaction and try to rollback the non-transactional changes // If abort then abort the alter transaction and try to rollback the non-transactional changes.
bool bool
ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit) { ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit) {
TOKUDB_DBUG_ENTER("commit_inplace_alter_table"); TOKUDB_DBUG_ENTER("commit_inplace_alter_table");
...@@ -703,6 +703,7 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info * ...@@ -703,6 +703,7 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *
DBUG_RETURN(result); DBUG_RETURN(result);
} }
// Setup the altered table's key and col info.
int int
ha_tokudb::setup_kc_info(TABLE *altered_table, KEY_AND_COL_INFO *altered_kc_info) { ha_tokudb::setup_kc_info(TABLE *altered_table, KEY_AND_COL_INFO *altered_kc_info) {
int error = allocate_key_and_col_info(altered_table->s, altered_kc_info); int error = allocate_key_and_col_info(altered_table->s, altered_kc_info);
......
...@@ -616,11 +616,12 @@ tokudb_expand_varchar_offsets( ...@@ -616,11 +616,12 @@ tokudb_expand_varchar_offsets(
memcpy(&offset_start, extra_pos, sizeof offset_start); memcpy(&offset_start, extra_pos, sizeof offset_start);
extra_pos += sizeof offset_start; extra_pos += sizeof offset_start;
// decode the number of offsets // decode the offset end
uint32_t offset_end; uint32_t offset_end;
memcpy(&offset_end, extra_pos, sizeof offset_end); memcpy(&offset_end, extra_pos, sizeof offset_end);
extra_pos += sizeof offset_end; extra_pos += sizeof offset_end;
// number of variable fields is the diff of the offset end and start
uint32_t number_of_offsets = offset_end - offset_start; uint32_t number_of_offsets = offset_end - offset_start;
assert(extra_pos == (uchar *)extra->data + extra->size); assert(extra_pos == (uchar *)extra->data + extra->size);
...@@ -647,7 +648,7 @@ tokudb_expand_varchar_offsets( ...@@ -647,7 +648,7 @@ tokudb_expand_varchar_offsets(
new_val_ptr += offset_start; new_val_ptr += offset_start;
old_val_ptr += offset_start; old_val_ptr += offset_start;
// we just need to expand each offset from 1 to 2 bytes // expand each offset from 1 to 2 bytes
for (uint32_t i = 0; i < number_of_offsets; i++) { for (uint32_t i = 0; i < number_of_offsets; i++) {
uint16_t new_offset = *old_val_ptr; uint16_t new_offset = *old_val_ptr;
int2store(new_val_ptr, new_offset); int2store(new_val_ptr, new_offset);
......
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