From faa5f3e00754f326eed456b9d7b36be751fd11b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Apr 2006 22:51:34 -0400 Subject: [PATCH 01/43] BUG#16002: Make partition functions that are unsigned work properly mysql-test/r/partition.result: A number of new test cases for unsigned partition functions mysql-test/r/partition_error.result: A number of new test cases for unsigned partition functions mysql-test/r/partition_range.result: A number of new test cases for unsigned partition functions mysql-test/t/partition.test: A number of new test cases for unsigned partition functions mysql-test/t/partition_error.test: A number of new test cases for unsigned partition functions mysql-test/t/partition_range.test: A number of new test cases for unsigned partition functions sql/ha_partition.cc: Error message for no partition found needs to take signed/unsigned into account when printing erroneus value sql/partition_element.h: Introduced signed_flag and max_value flag on partition elements Also list is now a list of a struct rather than simply longlong values Small rearranges of order sql/partition_info.cc: Introduced signed_flag and max_value flag on partition elements Also list is now a list of a struct rather than simply longlong values Small rearranges of order Lots of new code to handle checks of proper definition of table when partition function is unsigned sql/partition_info.h: Mostly rearrangement of code and some addition of a THD object in check_partition_info call plus a new method for comparing unsigned values sql/share/errmsg.txt: Negative values not ok for unsigned partition functions sql/sql_partition.cc: Fixed a multi-thread bug (when defining several partitioned tables in parallel) New code to generate partition syntax that takes into account sign of constants. Made function fix_fields_part_func more reusable. Fixed a number of get_partition_id functions for range and list and similar functions for partition pruning code. Unfortunately fairly much duplication of code with just small changes. sql/sql_partition.h: New function headers sql/sql_show.cc: Changed list of values for LIST partitioned tables Also fixed printing of unsigned values in INFORMATION SCHEMA for partitioned table sql/sql_table.cc: Fixed for new interface sql/sql_yacc.yy: Moved definition of struct to partition_element.h Added code to keep track of sign of constants in RANGE and LIST partitions sql/table.cc: Fixed for new interface --- mysql-test/r/partition.result | 20 ++ mysql-test/r/partition_error.result | 4 + mysql-test/r/partition_range.result | 12 + mysql-test/t/partition.test | 23 ++ mysql-test/t/partition_error.test | 5 + mysql-test/t/partition_range.test | 17 + sql/ha_partition.cc | 17 +- sql/partition_element.h | 22 +- sql/partition_info.cc | 115 ++++--- sql/partition_info.h | 23 +- sql/share/errmsg.txt | 3 + sql/sql_partition.cc | 463 ++++++++++++++++++++-------- sql/sql_partition.h | 7 +- sql/sql_show.cc | 9 +- sql/sql_table.cc | 4 +- sql/sql_yacc.yy | 23 +- sql/table.cc | 3 +- 17 files changed, 563 insertions(+), 207 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 2e293df50e2..e14cd3b8fe8 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,14 @@ drop table if exists t1; +create table t1 (a bigint unsigned); +insert into t1 values (0xFFFFFFFFFFFFFFFD); +insert into t1 values (0xFFFFFFFFFFFFFFFE); +select * from t1 where (a + 1) < 10; +a +select * from t1 where (a + 1) > 10; +a +18446744073709551613 +18446744073709551614 +drop table t1; CREATE TABLE t1 ( a int not null, b int not null, @@ -839,4 +849,14 @@ SHOW TABLE STATUS; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment t1 MyISAM 10 Dynamic 0 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned DROP TABLE t1; +create table t1 (a bigint unsigned) +partition by list (a) +(partition p0 values in (0-1)); +ERROR HY000: Partition function is unsigned, cannot have negative constants +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (10)); +insert into t1 values (0xFFFFFFFFFFFFFFFF); +ERROR HY000: Table has no partition for value 18446744073709551615 +drop table t1; End of 5.1 tests diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 1a0b1dd9b3a..cc51b909c51 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -554,3 +554,7 @@ PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN(5)); insert into t1 values (10); ERROR HY000: Table has no partition for value 10 drop table t1; +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (-1)); +ERROR HY000: Partition function is unsigned, cannot have negative constants diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index fc9350f5902..4d071c0edc1 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -363,3 +363,15 @@ SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; COUNT(*) 10 DROP TABLE t1; +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (0), +partition p1 values less than (10)); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (2), +partition p1 values less than (10)); +insert into t1 values (0xFFFFFFFFFFFFFFFF); +ERROR HY000: Table has no partition for value 18446744073709551615 +drop table t1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index a3aa3f6f025..a916e4c34a9 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,13 @@ drop table if exists t1; --enable_warnings +create table t1 (a bigint unsigned); +insert into t1 values (0xFFFFFFFFFFFFFFFD); +insert into t1 values (0xFFFFFFFFFFFFFFFE); +select * from t1 where (a + 1) < 10; +select * from t1 where (a + 1) > 10; +drop table t1; + # # Partition by key no partition defined => OK # @@ -956,4 +963,20 @@ PARTITION p2 VALUES LESS THAN (30) ENGINE = MyISAM); SHOW TABLE STATUS; DROP TABLE t1; +# +#BUG 16002 Erroneus handling of unsigned partition functions +# +--error ER_SIGNED_PARTITION_CONSTANT_ERROR +create table t1 (a bigint unsigned) +partition by list (a) +(partition p0 values in (0-1)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (10)); + +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (0xFFFFFFFFFFFFFFFF); +drop table t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 03a2ab41807..dad2d2beda6 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -747,3 +747,8 @@ CREATE TABLE t1(a int) --error ER_NO_PARTITION_FOR_GIVEN_VALUE insert into t1 values (10); drop table t1; + +--error ER_SIGNED_PARTITION_CONSTANT_ERROR +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (-1)); diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index a4d8c3740b7..239c6cc8144 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -388,3 +388,20 @@ SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31'; SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; DROP TABLE t1; +# +# BUG 16002: Unsigned partition functions not handled correctly +# +--error ER_RANGE_NOT_INCREASING_ERROR +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (0), + partition p1 values less than (10)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (2), + partition p1 values less than (10)); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (0xFFFFFFFFFFFFFFFF); + +drop table t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 7cf841a5d71..c9f4c6b02e9 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5165,9 +5165,20 @@ void ha_partition::print_error(int error, myf errflag) if (error == HA_ERR_NO_PARTITION_FOUND) { char buf[100]; - my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), - m_part_info->part_expr->null_value ? "NULL" : - llstr(m_part_info->part_expr->val_int(), buf)); + longlong value= m_part_info->part_expr->val_int(); + if (!m_part_info->part_expr->unsigned_flag || + m_part_info->part_expr->null_value) + { + my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), + m_part_info->part_expr->null_value ? "NULL" : + llstr(m_part_info->part_expr->val_int(), buf)); + } + else + { + ulonglong value= m_part_info->part_expr->val_int(); + longlong2str(value, buf, 10); + my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), buf); + } } else m_file[0]->print_error(error, errflag); diff --git a/sql/partition_element.h b/sql/partition_element.h index d20715d2408..7063e514901 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -36,15 +36,22 @@ enum partition_state { PART_IS_ADDED= 8 }; +typedef struct p_elem_val +{ + longlong value; + bool null_value; + bool unsigned_flag; +} part_elem_value; + class partition_element :public Sql_alloc { public: List subpartitions; - List list_val_list; + List list_val_list; ulonglong part_max_rows; ulonglong part_min_rows; + longlong range_value; char *partition_name; char *tablespace_name; - longlong range_value; char* part_comment; char* data_file_name; char* index_file_name; @@ -52,13 +59,16 @@ public: enum partition_state part_state; uint16 nodegroup_id; bool has_null_value; + bool signed_flag; + bool max_value; partition_element() - : part_max_rows(0), part_min_rows(0), partition_name(NULL), - tablespace_name(NULL), range_value(0), part_comment(NULL), + : part_max_rows(0), part_min_rows(0), range_value(0), + partition_name(NULL), tablespace_name(NULL), part_comment(NULL), data_file_name(NULL), index_file_name(NULL), - engine_type(NULL),part_state(PART_NORMAL), - nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE) + engine_type(NULL), part_state(PART_NORMAL), + nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE), + signed_flag(FALSE), max_value(FALSE) { subpartitions.empty(); list_val_list.empty(); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index ad0aa053ae2..7f2fea252f1 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -445,10 +445,12 @@ bool partition_info::check_range_constants() { partition_element* part_def; longlong current_largest_int= LONGLONG_MIN; + ulonglong current_largest_uint= 0; longlong part_range_value_int; uint i; List_iterator it(partitions); bool result= TRUE; + bool signed_flag= !part_expr->unsigned_flag; DBUG_ENTER("partition_info::check_range_constants"); DBUG_PRINT("enter", ("INT_RESULT with %d parts", no_parts)); @@ -463,19 +465,40 @@ bool partition_info::check_range_constants() do { part_def= it++; - if ((i != (no_parts - 1)) || !defined_max_value) - part_range_value_int= part_def->range_value; - else - part_range_value_int= LONGLONG_MAX; - if (likely(current_largest_int < part_range_value_int)) + if (signed_flag) { - current_largest_int= part_range_value_int; - range_int_array[i]= part_range_value_int; + if ((i != (no_parts - 1)) || !defined_max_value) + part_range_value_int= part_def->range_value; + else + part_range_value_int= LONGLONG_MAX; + if (likely(current_largest_int < part_range_value_int)) + { + current_largest_int= part_range_value_int; + range_int_array[i]= part_range_value_int; + } + else + { + my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); + goto end; + } } else { - my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); - goto end; + ulonglong upart_range_value_int; + if ((i != (no_parts - 1)) || !defined_max_value) + upart_range_value_int= part_def->range_value; + else + upart_range_value_int= ULONGLONG_MAX; + if (likely(current_largest_uint < upart_range_value_int)) + { + current_largest_uint= upart_range_value_int; + range_int_array[i]= part_range_value_int; + } + else + { + my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); + goto end; + } } } while (++i < no_parts); result= FALSE; @@ -485,8 +508,8 @@ end: /* - A support routine for check_list_constants used by qsort to sort the - constant list expressions. + Support routines for check_list_constants used by qsort to sort the + constant list expressions. One routine for unsigned and one for signed. SYNOPSIS list_part_cmp() @@ -511,6 +534,18 @@ int partition_info::list_part_cmp(const void* a, const void* b) return 0; } +int partition_info::list_part_cmp_unsigned(const void* a, const void* b) +{ + ulonglong a1= ((LIST_PART_ENTRY*)a)->list_value; + ulonglong b1= ((LIST_PART_ENTRY*)b)->list_value; + if (a1 < b1) + return -1; + else if (a1 > b1) + return +1; + else + return 0; +} + /* This routine allocates an array for all list constants to achieve a fast @@ -536,7 +571,7 @@ bool partition_info::check_list_constants() { uint i; uint list_index= 0; - longlong *list_value; + part_elem_value *list_value; bool not_first; bool result= TRUE; longlong curr_value, prev_value; @@ -577,7 +612,7 @@ bool partition_info::check_list_constants() has_null_part_id= i; found_null= TRUE; } - List_iterator list_val_it1(part_def->list_val_list); + List_iterator list_val_it1(part_def->list_val_list); while (list_val_it1++) no_list_values++; } while (++i < no_parts); @@ -593,33 +628,40 @@ bool partition_info::check_list_constants() do { part_def= list_func_it++; - List_iterator list_val_it2(part_def->list_val_list); + List_iterator list_val_it2(part_def->list_val_list); while ((list_value= list_val_it2++)) { - list_array[list_index].list_value= *list_value; + list_array[list_index].list_value= list_value->value; list_array[list_index++].partition_id= i; } } while (++i < no_parts); - qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), - &list_part_cmp); - - not_first= FALSE; - i= prev_value= 0; //prev_value initialised to quiet compiler - do + if (fixed) { - curr_value= list_array[i].list_value; - if (likely(!not_first || prev_value != curr_value)) - { - prev_value= curr_value; - not_first= TRUE; - } + if (!part_expr->unsigned_flag) + qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), + &list_part_cmp); else + qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), + &list_part_cmp_unsigned); + + not_first= FALSE; + i= prev_value= 0; //prev_value initialised to quiet compiler + do { - my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); - goto end; - } - } while (++i < no_list_values); + curr_value= list_array[i].list_value; + if (likely(!not_first || prev_value != curr_value)) + { + prev_value= curr_value; + not_first= TRUE; + } + else + { + my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); + goto end; + } + } while (++i < no_list_values); + } result= FALSE; end: DBUG_RETURN(result); @@ -647,7 +689,7 @@ end: */ -bool partition_info::check_partition_info(handlerton **eng_type, +bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, handler *file, ulonglong max_rows) { handlerton **engine_array= NULL; @@ -733,9 +775,12 @@ bool partition_info::check_partition_info(handlerton **eng_type, list constants. */ - if (unlikely((part_type == RANGE_PARTITION && check_range_constants()) || - (part_type == LIST_PARTITION && check_list_constants()))) - goto end; + if (fixed) + { + if (unlikely((part_type == RANGE_PARTITION && check_range_constants()) || + (part_type == LIST_PARTITION && check_list_constants()))) + goto end; + } result= FALSE; end: my_free((char*)engine_array,MYF(MY_ALLOW_ZERO_PTR)); diff --git a/sql/partition_info.h b/sql/partition_info.h index 664c8834b0b..5a2cacd3c71 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -163,6 +163,7 @@ public: uint no_subpart_fields; uint no_full_part_fields; + uint has_null_part_id; /* This variable is used to calculate the partition id when using LINEAR KEY/HASH. This functionality is kept in the MySQL Server @@ -182,7 +183,6 @@ public: bool fixed; bool from_openfrm; bool has_null_value; - uint has_null_part_id; partition_info() @@ -204,19 +204,13 @@ public: no_parts(0), no_subparts(0), count_curr_subparts(0), part_error_code(0), no_list_values(0), no_part_fields(0), no_subpart_fields(0), - no_full_part_fields(0), linear_hash_mask(0), - use_default_partitions(TRUE), - use_default_no_partitions(TRUE), - use_default_subpartitions(TRUE), - use_default_no_subpartitions(TRUE), - default_partitions_setup(FALSE), - defined_max_value(FALSE), + no_full_part_fields(0), has_null_part_id(0), linear_hash_mask(0), + use_default_partitions(TRUE), use_default_no_partitions(TRUE), + use_default_subpartitions(TRUE), use_default_no_subpartitions(TRUE), + default_partitions_setup(FALSE), defined_max_value(FALSE), list_of_part_fields(FALSE), list_of_subpart_fields(FALSE), - linear_hash_ind(FALSE), - fixed(FALSE), - from_openfrm(FALSE), - has_null_value(FALSE), - has_null_part_id(0) + linear_hash_ind(FALSE), fixed(FALSE), from_openfrm(FALSE), + has_null_value(FALSE) { all_fields_in_PF.clear_all(); all_fields_in_PPF.clear_all(); @@ -248,10 +242,11 @@ public: static bool check_engine_mix(handlerton **engine_array, uint no_parts); bool check_range_constants(); bool check_list_constants(); - bool check_partition_info(handlerton **eng_type, + bool check_partition_info(THD *thd, handlerton **eng_type, handler *file, ulonglong max_rows); private: static int list_part_cmp(const void* a, const void* b); + static int list_part_cmp_unsigned(const void* a, const void* b); bool set_up_default_partitions(handler *file, ulonglong max_rows, uint start_no); bool set_up_default_subpartitions(handler *file, ulonglong max_rows); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index e8766b3d882..3724ff464f2 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5826,3 +5826,6 @@ ER_NDB_CANT_SWITCH_BINLOG_FORMAT eng "The NDB cluster engine does not support changing the binlog format on the fly yet" ER_PARTITION_NO_TEMPORARY eng "Cannot create temporary table with partitions" +ER_SIGNED_PARTITION_CONSTANT_ERROR + eng "Partition function is unsigned, cannot have negative constants" + swe "Partitionsfunktionen är positiv, kan inte ha negativa konstanter" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5cae38f2773..4605a4dc28c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -61,7 +61,6 @@ static const char *equal_str= "="; static const char *end_paren_str= ")"; static const char *begin_paren_str= "("; static const char *comma_str= ","; -static char buff[22]; int get_partition_id_list(partition_info *part_info, uint32 *part_id, @@ -189,9 +188,9 @@ bool is_name_in_list(char *name, SYNOPSIS partition_default_handling() table Table object - table_name Table name to use when getting no_parts - db_name Database name to use when getting no_parts part_info Partition info to set up + is_create_table_ind Is this part of a table creation + normalized_path Normalized path name of table and database RETURN VALUES TRUE Error @@ -793,6 +792,43 @@ end: } +/* + Support function to check if all VALUES * (expression) is of the + right sign (no signed constants when unsigned partition function) + + SYNOPSIS + check_signed_flag() + part_info Partition info object + + RETURN VALUES + 0 No errors due to sign errors + >0 Sign error +*/ + +int check_signed_flag(partition_info *part_info) +{ + int error= 0; + uint i= 0; + if (part_info->part_type != HASH_PARTITION && + part_info->part_expr->unsigned_flag) + { + List_iterator part_it(part_info->partitions); + do + { + partition_element *part_elem= part_it++; + + if (part_elem->signed_flag) + { + my_error(ER_SIGNED_PARTITION_CONSTANT_ERROR, MYF(0)); + error= ER_SIGNED_PARTITION_CONSTANT_ERROR; + break; + } + } while (++i < part_info->no_parts); + } + return error; +} + + /* The function uses a new feature in fix_fields where the flag GET_FIXED_FIELDS_FLAG is set for all fields in the item tree. @@ -802,10 +838,11 @@ end: SYNOPSIS fix_fields_part_func() thd The thread object - tables A list of one table, the partitioned table func_expr The item tree reference of the partition function + table The table object part_info Reference to partitioning data structure sub_part Is the table subpartitioned as well + set_up_fields Flag if we are to set-up field arrays RETURN VALUE TRUE An error occurred, something was wrong with the @@ -828,26 +865,54 @@ end: on the field object. */ -static bool fix_fields_part_func(THD *thd, TABLE_LIST *tables, - Item* func_expr, partition_info *part_info, - bool is_sub_part) +bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, + bool is_sub_part, bool is_field_to_be_setup) { + partition_info *part_info= table->part_info; + uint dir_length, home_dir_length; bool result= TRUE; - TABLE *table= tables->table; + TABLE_LIST tables; TABLE_LIST *save_table_list, *save_first_table, *save_last_table; int error; Name_resolution_context *context; const char *save_where; + char* db_name; + char db_name_string[FN_REFLEN]; DBUG_ENTER("fix_fields_part_func"); + if (part_info->fixed) + { + if (!(is_sub_part || (error= check_signed_flag(part_info)))) + result= FALSE; + goto end; + } + + /* + Set-up the TABLE_LIST object to be a list with a single table + Set the object to zero to create NULL pointers and set alias + and real name to table name and get database name from file name. + */ + + bzero((void*)&tables, sizeof(TABLE_LIST)); + tables.alias= tables.table_name= (char*) table->s->table_name.str; + tables.table= table; + tables.next_local= 0; + tables.next_name_resolution_table= 0; + strmov(db_name_string, table->s->normalized_path.str); + dir_length= dirname_length(db_name_string); + db_name_string[dir_length - 1]= 0; + home_dir_length= dirname_length(db_name_string); + db_name= &db_name_string[home_dir_length]; + tables.db= db_name; + context= thd->lex->current_context(); table->map= 1; //To ensure correct calculation of const item table->get_fields_in_item_tree= TRUE; save_table_list= context->table_list; save_first_table= context->first_name_resolution_table; save_last_table= context->last_name_resolution_table; - context->table_list= tables; - context->first_name_resolution_table= tables; + context->table_list= &tables; + context->first_name_resolution_table= &tables; context->last_name_resolution_table= NULL; func_expr->walk(&Item::change_context_processor, (byte*) context); save_where= thd->where; @@ -859,7 +924,8 @@ static bool fix_fields_part_func(THD *thd, TABLE_LIST *tables, if (unlikely(error)) { DBUG_PRINT("info", ("Field in partition function not part of table")); - clear_field_flag(table); + if (is_field_to_be_setup) + clear_field_flag(table); goto end; } thd->where= save_where; @@ -869,7 +935,13 @@ static bool fix_fields_part_func(THD *thd, TABLE_LIST *tables, clear_field_flag(table); goto end; } - result= set_up_field_array(table, is_sub_part); + if ((!is_sub_part) && (error= check_signed_flag(part_info))) + goto end; + result= FALSE; + if (is_field_to_be_setup) + result= set_up_field_array(table, is_sub_part); + if (!is_sub_part) + part_info->fixed= TRUE; end: table->get_fields_in_item_tree= FALSE; table->map= 0; //Restore old value @@ -1303,7 +1375,6 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask, SYNOPSIS fix_partition_func() thd The thread object - name The name of the partitioned table table TABLE object for which partition fields are set-up create_table_ind Indicator of whether openfrm was called as part of CREATE or ALTER TABLE @@ -1325,15 +1396,10 @@ NOTES of an error that is not discovered until here. */ -bool fix_partition_func(THD *thd, const char* name, TABLE *table, +bool fix_partition_func(THD *thd, TABLE *table, bool is_create_table_ind) { bool result= TRUE; - uint dir_length, home_dir_length; - TABLE_LIST tables; - TABLE_SHARE *share= table->s; - char db_name_string[FN_REFLEN]; - char* db_name; partition_info *part_info= table->part_info; ulong save_set_query_id= thd->set_query_id; Item *thd_free_list= thd->free_list; @@ -1345,23 +1411,6 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, } thd->set_query_id= 0; DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); - /* - Set-up the TABLE_LIST object to be a list with a single table - Set the object to zero to create NULL pointers and set alias - and real name to table name and get database name from file name. - */ - - bzero((void*)&tables, sizeof(TABLE_LIST)); - tables.alias= tables.table_name= (char*) share->table_name.str; - tables.table= table; - tables.next_local= 0; - tables.next_name_resolution_table= 0; - strmov(db_name_string, name); - dir_length= dirname_length(db_name_string); - db_name_string[dir_length - 1]= 0; - home_dir_length= dirname_length(db_name_string); - db_name= &db_name_string[home_dir_length]; - tables.db= db_name; if (!is_create_table_ind || thd->lex->sql_command != SQLCOM_CREATE_TABLE) @@ -1391,9 +1440,8 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, } else { - if (unlikely(fix_fields_part_func(thd, &tables, - part_info->subpart_expr, part_info, - TRUE))) + if (unlikely(fix_fields_part_func(thd, part_info->subpart_expr, + table, TRUE, TRUE))) goto end; if (unlikely(part_info->subpart_expr->result_type() != INT_RESULT)) { @@ -1420,8 +1468,8 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, } else { - if (unlikely(fix_fields_part_func(thd, &tables, part_info->part_expr, - part_info, FALSE))) + if (unlikely(fix_fields_part_func(thd, part_info->part_expr, + table, FALSE, TRUE))) goto end; if (unlikely(part_info->part_expr->result_type() != INT_RESULT)) { @@ -1434,6 +1482,9 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, else { const char *error_str; + if (unlikely(fix_fields_part_func(thd, part_info->part_expr, + table, FALSE, TRUE))) + goto end; if (part_info->part_type == RANGE_PARTITION) { error_str= partition_keywords[PKW_RANGE].str; @@ -1457,9 +1508,6 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), error_str); goto end; } - if (unlikely(fix_fields_part_func(thd, &tables, part_info->part_expr, - part_info, FALSE))) - goto end; if (unlikely(part_info->part_expr->result_type() != INT_RESULT)) { my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), part_str); @@ -1479,7 +1527,6 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, check_range_capable_PF(table); set_up_partition_key_maps(table, part_info); set_up_partition_func_pointers(part_info); - part_info->fixed= TRUE; set_up_range_analysis_info(part_info); result= FALSE; end: @@ -1563,6 +1610,7 @@ static int add_hash(File fptr) static int add_partition(File fptr) { + char buff[22]; strxmov(buff, part_str, space_str, NullS); return add_string(fptr, buff); } @@ -1576,6 +1624,7 @@ static int add_subpartition(File fptr) static int add_partition_by(File fptr) { + char buff[22]; strxmov(buff, part_str, space_str, by_str, space_str, NullS); return add_string(fptr, buff); } @@ -1616,10 +1665,18 @@ static int add_key_partition(File fptr, List field_list) static int add_int(File fptr, longlong number) { + char buff[32]; llstr(number, buff); return add_string(fptr, buff); } +static int add_uint(File fptr, ulonglong number) +{ + char buff[32]; + longlong2str(number, buff, 10); + return add_string(fptr, buff); +} + static int add_keyword_string(File fptr, const char *keyword, bool should_use_quotes, const char *keystr) @@ -1681,28 +1738,43 @@ static int add_partition_options(File fptr, partition_element *p_elem) } static int add_partition_values(File fptr, partition_info *part_info, - partition_element *p_elem) + partition_element *p_elem) { int err= 0; if (part_info->part_type == RANGE_PARTITION) { err+= add_string(fptr, "VALUES LESS THAN "); - if (p_elem->range_value != LONGLONG_MAX) + if (p_elem->signed_flag) { - err+= add_begin_parenthesis(fptr); - err+= add_int(fptr, p_elem->range_value); - err+= add_end_parenthesis(fptr); + if (!p_elem->max_value) + { + err+= add_begin_parenthesis(fptr); + err+= add_int(fptr, p_elem->range_value); + err+= add_end_parenthesis(fptr); + } + else + err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); } else - err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); + { + if (!p_elem->max_value) + { + err+= add_begin_parenthesis(fptr); + err+= add_uint(fptr, (ulonglong)p_elem->range_value); + err+= add_end_parenthesis(fptr); + } + else + err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); + } } else if (part_info->part_type == LIST_PARTITION) { uint i; - List_iterator list_val_it(p_elem->list_val_list); + List_iterator list_val_it(p_elem->list_val_list); err+= add_string(fptr, "VALUES IN "); uint no_items= p_elem->list_val_list.elements; + err+= add_begin_parenthesis(fptr); if (p_elem->has_null_value) { @@ -1717,8 +1789,12 @@ static int add_partition_values(File fptr, partition_info *part_info, i= 0; do { - longlong *list_value= list_val_it++; - err+= add_int(fptr, *list_value); + part_elem_value *list_value= list_val_it++; + + if (!list_value->unsigned_flag) + err+= add_int(fptr, list_value->value); + else + err+= add_uint(fptr, list_value->value); if (i != (no_items-1)) err+= add_comma(fptr); } while (++i < no_items); @@ -2294,15 +2370,15 @@ static uint32 get_part_id_linear_key(partition_info *part_info, int get_partition_id_list(partition_info *part_info, - uint32 *part_id, - longlong *func_value) + uint32 *part_id, + longlong *func_value) { LIST_PART_ENTRY *list_array= part_info->list_array; int list_index; - longlong list_value; int min_list_index= 0; int max_list_index= part_info->no_list_values - 1; longlong part_func_value= part_val_int(part_info->part_expr); + bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_partition_id_list"); if (part_info->part_expr->null_value) @@ -2315,22 +2391,49 @@ int get_partition_id_list(partition_info *part_info, goto notfound; } *func_value= part_func_value; - while (max_list_index >= min_list_index) + if (!unsigned_flag) { - list_index= (max_list_index + min_list_index) >> 1; - list_value= list_array[list_index].list_value; - if (list_value < part_func_value) - min_list_index= list_index + 1; - else if (list_value > part_func_value) + longlong list_value; + while (max_list_index >= min_list_index) { - if (!list_index) - goto notfound; - max_list_index= list_index - 1; + list_index= (max_list_index + min_list_index) >> 1; + list_value= list_array[list_index].list_value; + if (list_value < part_func_value) + min_list_index= list_index + 1; + else if (list_value > part_func_value) + { + if (!list_index) + goto notfound; + max_list_index= list_index - 1; + } + else + { + *part_id= (uint32)list_array[list_index].partition_id; + DBUG_RETURN(0); + } } - else + } + else + { + ulonglong ulist_value; + ulonglong upart_func_value= part_func_value; + while (max_list_index >= min_list_index) { - *part_id= (uint32)list_array[list_index].partition_id; - DBUG_RETURN(0); + list_index= (max_list_index + min_list_index) >> 1; + ulist_value= list_array[list_index].list_value; + if (ulist_value < upart_func_value) + min_list_index= list_index + 1; + else if (ulist_value > upart_func_value) + { + if (!list_index) + goto notfound; + max_list_index= list_index - 1; + } + else + { + *part_id= (uint32)list_array[list_index].partition_id; + DBUG_RETURN(0); + } } } notfound: @@ -2381,34 +2484,65 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info, bool left_endpoint, bool include_endpoint) { - DBUG_ENTER("get_list_array_idx_for_endpoint"); LIST_PART_ENTRY *list_array= part_info->list_array; uint list_index; - longlong list_value; uint min_list_index= 0, max_list_index= part_info->no_list_values - 1; /* Get the partitioning function value for the endpoint */ longlong part_func_value= part_val_int(part_info->part_expr); - while (max_list_index >= min_list_index) + bool unsigned_flag= part_info->part_expr->unsigned_flag; + DBUG_ENTER("get_list_array_idx_for_endpoint"); + + if (!unsigned_flag) { - list_index= (max_list_index + min_list_index) >> 1; - list_value= list_array[list_index].list_value; + longlong list_value; + while (max_list_index >= min_list_index) + { + list_index= (max_list_index + min_list_index) >> 1; + list_value= list_array[list_index].list_value; + if (list_value < part_func_value) + min_list_index= list_index + 1; + else if (list_value > part_func_value) + { + if (!list_index) + goto notfound_signed; + max_list_index= list_index - 1; + } + else + { + DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); + } + } + notfound_signed: if (list_value < part_func_value) - min_list_index= list_index + 1; - else if (list_value > part_func_value) - { - if (!list_index) - goto notfound; - max_list_index= list_index - 1; - } - else - { - DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); - } + list_index++; + DBUG_RETURN(list_index); + } + else + { + ulonglong upart_func_value= part_func_value; + ulonglong ulist_value; + while (max_list_index >= min_list_index) + { + list_index= (max_list_index + min_list_index) >> 1; + ulist_value= list_array[list_index].list_value; + if (ulist_value < upart_func_value) + min_list_index= list_index + 1; + else if (ulist_value > upart_func_value) + { + if (!list_index) + goto notfound_unsigned; + max_list_index= list_index - 1; + } + else + { + DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); + } + } + notfound_unsigned: + if (ulist_value < upart_func_value) + list_index++; + DBUG_RETURN(list_index); } -notfound: - if (list_value < part_func_value) - list_index++; - DBUG_RETURN(list_index); } @@ -2422,6 +2556,7 @@ int get_partition_id_range(partition_info *part_info, uint max_part_id= max_partition; uint loc_part_id; longlong part_func_value= part_val_int(part_info->part_expr); + bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_partition_id_int_range"); if (part_info->part_expr->null_value) @@ -2429,24 +2564,52 @@ int get_partition_id_range(partition_info *part_info, *part_id= 0; DBUG_RETURN(0); } - while (max_part_id > min_part_id) - { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - if (range_array[loc_part_id] <= part_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - if (part_func_value >= range_array[loc_part_id]) - if (loc_part_id != max_partition) - loc_part_id++; - *part_id= (uint32)loc_part_id; *func_value= part_func_value; - if (loc_part_id == max_partition) - if (range_array[loc_part_id] != LONGLONG_MAX) - if (part_func_value >= range_array[loc_part_id]) - DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + if (!unsigned_flag) + { + while (max_part_id > min_part_id) + { + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + if (range_array[loc_part_id] <= part_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; + } + loc_part_id= max_part_id; + if (part_func_value >= range_array[loc_part_id]) + if (loc_part_id != max_partition) + loc_part_id++; + *part_id= (uint32)loc_part_id; + if (loc_part_id == max_partition) + if (range_array[loc_part_id] != LONGLONG_MAX) + if (part_func_value >= range_array[loc_part_id]) + DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + } + else + { + ulonglong upart_func_value= part_func_value; + ulonglong urange_value; + while (max_part_id > min_part_id) + { + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + urange_value= range_array[loc_part_id]; + if (urange_value <= upart_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; + } + loc_part_id= max_part_id; + urange_value= range_array[loc_part_id]; + if (upart_func_value >= urange_value) + if (loc_part_id != max_partition) + loc_part_id++; + *part_id= (uint32)loc_part_id; + urange_value= range_array[loc_part_id]; + if (loc_part_id == max_partition) + if (urange_value != ULONGLONG_MAX) + if (upart_func_value >= urange_value) + DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + } DBUG_RETURN(0); } @@ -2496,39 +2659,79 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, bool left_endpoint, bool include_endpoint) { - DBUG_ENTER("get_partition_id_range_for_endpoint"); longlong *range_array= part_info->range_int_array; uint max_partition= part_info->no_parts - 1; uint min_part_id= 0, max_part_id= max_partition, loc_part_id; /* Get the partitioning function value for the endpoint */ longlong part_func_value= part_val_int(part_info->part_expr); + bool unsigned_flag= part_info->part_expr->unsigned_flag; + DBUG_ENTER("get_partition_id_range_for_endpoint"); - while (max_part_id > min_part_id) + if (!unsigned_flag) { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - if (range_array[loc_part_id] <= part_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - if (loc_part_id < max_partition && - part_func_value >= range_array[loc_part_id+1]) - { - loc_part_id++; - } - if (left_endpoint) - { - if (part_func_value >= range_array[loc_part_id]) + while (max_part_id > min_part_id) + { + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + if (range_array[loc_part_id] <= part_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; + } + loc_part_id= max_part_id; + if (loc_part_id < max_partition && + part_func_value >= range_array[loc_part_id+1]) + { + loc_part_id++; + } + if (left_endpoint) + { + if (part_func_value >= range_array[loc_part_id]) + loc_part_id++; + } + else + { + if (part_func_value == range_array[loc_part_id]) + loc_part_id += test(include_endpoint); + else if (part_func_value > range_array[loc_part_id]) + loc_part_id++; loc_part_id++; + } } - else + else { - if (part_func_value == range_array[loc_part_id]) - loc_part_id += test(include_endpoint); - else if (part_func_value > range_array[loc_part_id]) + ulonglong upart_func_value= part_func_value; + ulonglong urange_value; + while (max_part_id > min_part_id) + { + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + urange_value= range_array[loc_part_id]; + if (urange_value <= upart_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; + } + loc_part_id= max_part_id; + urange_value= range_array[loc_part_id+1]; + if (loc_part_id < max_partition && + upart_func_value >= urange_value) + { + loc_part_id++; + } + if (left_endpoint) + { + urange_value= range_array[loc_part_id]; + if (upart_func_value >= urange_value) + loc_part_id++; + } + else + { + urange_value= range_array[loc_part_id]; + if (upart_func_value == urange_value) + loc_part_id += test(include_endpoint); + else if (upart_func_value > urange_value) + loc_part_id++; loc_part_id++; - loc_part_id++; + } } DBUG_RETURN(loc_part_id); } @@ -4497,8 +4700,8 @@ the generated partition syntax in a correct manner. tab_part_info->use_default_subpartitions= FALSE; tab_part_info->use_default_no_subpartitions= FALSE; } - if (tab_part_info->check_partition_info((handlerton**)NULL, - table->file, ULL(0))) + if (tab_part_info->check_partition_info(thd, (handlerton**)NULL, + table->file, ULL(0))) { DBUG_RETURN(TRUE); } diff --git a/sql/sql_partition.h b/sql/sql_partition.h index fd2c474236f..9fde3db2883 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -65,9 +65,8 @@ int get_part_for_delete(const byte *buf, const byte *rec0, partition_info *part_info, uint32 *part_id); void prune_partition_set(const TABLE *table, part_id_range *part_spec); bool check_partition_info(partition_info *part_info,handlerton **eng_type, - handler *file, ulonglong max_rows); -bool fix_partition_func(THD *thd, const char *name, TABLE *table, - bool create_table_ind); + TABLE *table, handler *file, ulonglong max_rows); +bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind); char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, bool write_all); @@ -91,6 +90,8 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info, uint32 get_partition_id_range_for_endpoint(partition_info *part_info, bool left_endpoint, bool include_endpoint); +bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, + bool is_sub_part, bool is_field_to_be_setup); /* A "Get next" function for partition iterator. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 19535f3182a..86515355936 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3851,8 +3851,8 @@ static int get_schema_partitions_record(THD *thd, struct st_table_list *tables, } else if (part_info->part_type == LIST_PARTITION) { - List_iterator list_val_it(part_elem->list_val_list); - longlong *list_value; + List_iterator list_val_it(part_elem->list_val_list); + part_elem_value *list_value; uint no_items= part_elem->list_val_list.elements; tmp_str.length(0); tmp_res.length(0); @@ -3864,7 +3864,10 @@ static int get_schema_partitions_record(THD *thd, struct st_table_list *tables, } while ((list_value= list_val_it++)) { - tmp_res.set(*list_value, cs); + if (!list_value->unsigned_flag) + tmp_res.set(list_value->value, cs); + else + tmp_res.set((ulonglong)list_value->value, cs); tmp_str.append(tmp_res); if (--no_items != 0) tmp_str.append(","); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2687b64841f..71ffb4d28b7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2141,8 +2141,8 @@ bool mysql_create_table_internal(THD *thd, } DBUG_PRINT("info", ("db_type = %d", ha_legacy_type(part_info->default_engine_type))); - if (part_info->check_partition_info( &engine_type, file, - create_info->max_rows)) + if (part_info->check_partition_info(thd, &engine_type, file, + create_info->max_rows)) goto err; part_info->default_engine_type= engine_type; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e48748bcfa5..8037eaa5b21 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -42,12 +42,6 @@ #include #include -typedef struct p_elem_val -{ - longlong value; - bool null_value; -} part_elem_value; - int yylex(void *yylval, void *yythd); const LEX_STRING null_lex_str={0,0}; @@ -3712,6 +3706,7 @@ part_func_max: YYABORT; } lex->part_info->defined_max_value= TRUE; + lex->part_info->curr_part_elem->max_value= TRUE; lex->part_info->curr_part_elem->range_value= LONGLONG_MAX; } | part_range_func @@ -3727,7 +3722,10 @@ part_func_max: part_range_func: '(' part_bit_expr ')' { - Lex->part_info->curr_part_elem->range_value= $2->value; + partition_info *part_info= Lex->part_info; + if (!($2->unsigned_flag)) + part_info->curr_part_elem->signed_flag= TRUE; + part_info->curr_part_elem->range_value= $2->value; } ; @@ -3740,9 +3738,12 @@ part_list_item: part_bit_expr { part_elem_value *value_ptr= $1; + partition_info *part_info= Lex->part_info; + if (!value_ptr->unsigned_flag) + part_info->curr_part_elem->signed_flag= TRUE; if (!value_ptr->null_value && - Lex->part_info->curr_part_elem-> - list_val_list.push_back((longlong*) &value_ptr->value)) + part_info->curr_part_elem-> + list_val_list.push_back(value_ptr)) { mem_alloc_error(sizeof(part_elem_value)); YYABORT; @@ -3783,6 +3784,10 @@ part_bit_expr: } thd->where= save_where; value_ptr->value= part_expr->val_int(); + value_ptr->unsigned_flag= TRUE; + if (!part_expr->unsigned_flag && + value_ptr->value < 0) + value_ptr->unsigned_flag= FALSE; if ((value_ptr->null_value= part_expr->null_value)) { if (Lex->part_info->curr_part_elem->has_null_value) diff --git a/sql/table.cc b/sql/table.cc index 41621a19900..7252940eb27 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1488,8 +1488,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, Fix the partition functions and ensure they are not constant functions */ - if (fix_partition_func(thd, share->normalized_path.str, outparam, - is_create_table)) + if (fix_partition_func(thd, outparam, is_create_table)) goto err; } #endif From 409fb4895fd08e876b33c4d809919952871996a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 May 2006 18:00:44 +0500 Subject: [PATCH 02/43] Fix for bug #16546: DATETIME+0 not always coerced the same way mysql-test/r/func_time.result: Fix for bug #16546: DATETIME+0 not always coerced the same way - test case mysql-test/t/func_time.test: Fix for bug #16546: DATETIME+0 not always coerced the same way - test case sql/item_timefunc.cc: Fix for bug #16546: DATETIME+0 not always coerced the same way - set decimals to DATETIME_DEC sql/item_timefunc.h: Fix for bug #16546: DATETIME+0 not always coerced the same way - set decimals to DATETIME_DEC --- mysql-test/r/func_time.result | 12 ++++++++---- mysql-test/t/func_time.test | 8 ++++++++ sql/item_timefunc.cc | 6 +++--- sql/item_timefunc.h | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index fc872285acb..d3375dee8b6 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -7,20 +7,20 @@ period_add("9602",-12) period_diff(199505,"9404") 199502 13 select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now()); now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(now()) -0 0 0 +0.000000 0 0 select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0; from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0 -1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112 +1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112.000000 select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"), sec_to_time(time_to_sec("0:30:47")/6.21); sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21) -02:30:01 23001 54742 00:04:57 +02:30:01 23001.000000 54742 00:04:57 select sec_to_time(time_to_sec('-838:59:59')); sec_to_time(time_to_sec('-838:59:59')) -838:59:59 select now()-curdate()*1000000-curtime(); now()-curdate()*1000000-curtime() -0 +0.000000 select strcmp(current_timestamp(),concat(current_date()," ",current_time())); strcmp(current_timestamp(),concat(current_date()," ",current_time())) 0 @@ -626,3 +626,7 @@ last_day('2005-01-00') NULL Warnings: Warning 1292 Truncated incorrect datetime value: '2005-01-00' +select now() - now() + 0, curtime() - curtime() + 0, +sec_to_time(1) + 0, from_unixtime(1) + 0; +now() - now() + 0 curtime() - curtime() + 0 sec_to_time(1) + 0 from_unixtime(1) + 0 +0.000000 0.000000 1.000000 19700101030001.000000 diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 68a33afd85c..d9a8579ce0f 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -315,4 +315,12 @@ select last_day('2005-00-00'); select last_day('2005-00-01'); select last_day('2005-01-00'); +# +# Bug #16546 +# + +select now() - now() + 0, curtime() - curtime() + 0, + sec_to_time(1) + 0, from_unixtime(1) + 0; + + # End of 4.1 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f3d6858755c..34850d4efdd 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1372,7 +1372,7 @@ void Item_func_curtime::fix_length_and_dec() { TIME ltime; - decimals=0; + decimals= DATETIME_DEC; collation.set(&my_charset_bin); store_now_in_TIME(<ime); value= TIME_to_ulonglong_time(<ime); @@ -1419,7 +1419,7 @@ String *Item_func_now::val_str(String *str) void Item_func_now::fix_length_and_dec() { - decimals=0; + decimals= DATETIME_DEC; collation.set(&my_charset_bin); store_now_in_TIME(<ime); @@ -1680,7 +1680,7 @@ void Item_func_from_unixtime::fix_length_and_dec() { thd= current_thd; collation.set(&my_charset_bin); - decimals=0; + decimals= DATETIME_DEC; max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; maybe_null= 1; thd->time_zone_used= 1; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 163b1591e52..ac26455371d 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -580,6 +580,7 @@ public: { collation.set(&my_charset_bin); maybe_null=1; + decimals= DATETIME_DEC; max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; } From 10c5b8b6fd63365d5d3812964912752a6a89510b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 May 2006 00:08:48 -0400 Subject: [PATCH 03/43] BUG#19801: Valgrind error in check_list_constants Needed some special handling of the case when no_list_values == 0 mysql-test/r/partition.result: Added a couple of new test cases mysql-test/t/partition.test: Added a couple of new test cases sql/partition_info.cc: Rearranged some code to handle case where no_list_values == 0 which happens when one partition with only one value == NULL. sql/sql_partition.cc: Rearranged code to remove compiler warning and also since we now have handled the case where no_list_values == 0 in a special case before coming here Added code for handling the special case where no_list_values == 0 --- mysql-test/r/partition.result | 12 ++++++++++ mysql-test/t/partition.test | 6 +++++ sql/partition_info.cc | 41 ++++++++++++++++++++--------------- sql/sql_partition.cc | 21 ++++++++++++++---- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 3be9f3edee2..a4f40a130b5 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -757,6 +757,18 @@ insert into t1 values (null); select * from t1 where f1 is null; f1 NULL +select * from t1 where f1 < 1; +f1 +select * from t1 where f1 <= NULL; +f1 +select * from t1 where f1 < NULL; +f1 +select * from t1 where f1 >= NULL; +f1 +select * from t1 where f1 > NULL; +f1 +select * from t1 where f1 > 1; +f1 drop table t1; create table t1 (f1 smallint) partition by range (f1) (partition p0 values less than (0)); diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index a24124d3fb5..75defdeccf1 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -895,6 +895,12 @@ create table t1 (f1 smallint) partition by list (f1) (partition p0 values in (null)); insert into t1 values (null); select * from t1 where f1 is null; +select * from t1 where f1 < 1; +select * from t1 where f1 <= NULL; +select * from t1 where f1 < NULL; +select * from t1 where f1 >= NULL; +select * from t1 where f1 > NULL; +select * from t1 where f1 > 1; drop table t1; create table t1 (f1 smallint) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 0924a8adf6e..6e3023289d8 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -612,7 +612,8 @@ bool partition_info::check_list_constants() no_list_values++; } while (++i < no_parts); list_func_it.rewind(); - list_array= (LIST_PART_ENTRY*)sql_alloc(no_list_values*sizeof(LIST_PART_ENTRY)); + list_array= (LIST_PART_ENTRY*)sql_alloc((no_list_values+1) * + sizeof(LIST_PART_ENTRY)); if (unlikely(list_array == NULL)) { mem_alloc_error(no_list_values * sizeof(LIST_PART_ENTRY)); @@ -631,25 +632,29 @@ bool partition_info::check_list_constants() } } while (++i < no_parts); - qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), - &list_part_cmp); - - not_first= FALSE; - i= prev_value= 0; //prev_value initialised to quiet compiler - do + if (no_list_values) { - curr_value= list_array[i].list_value; - if (likely(!not_first || prev_value != curr_value)) + qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), + &list_part_cmp); + + not_first= FALSE; + i= prev_value= 0; //prev_value initialised to quiet compiler + do { - prev_value= curr_value; - not_first= TRUE; - } - else - { - my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); - goto end; - } - } while (++i < no_list_values); + DBUG_ASSERT(i < no_list_values); + curr_value= list_array[i].list_value; + if (likely(!not_first || prev_value != curr_value)) + { + prev_value= curr_value; + not_first= TRUE; + } + else + { + my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); + goto end; + } + } while (++i < no_list_values); + } result= FALSE; end: DBUG_RETURN(result); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e946e972968..b6756821245 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2257,8 +2257,8 @@ static uint32 get_part_id_linear_key(partition_info *part_info, int get_partition_id_list(partition_info *part_info, - uint32 *part_id, - longlong *func_value) + uint32 *part_id, + longlong *func_value) { LIST_PART_ENTRY *list_array= part_info->list_array; int list_index; @@ -2351,7 +2351,8 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info, uint min_list_index= 0, max_list_index= part_info->no_list_values - 1; /* Get the partitioning function value for the endpoint */ longlong part_func_value= part_val_int(part_info->part_expr); - while (max_list_index >= min_list_index) + DBUG_ASSERT(part_info->no_list_values); + do { list_index= (max_list_index + min_list_index) >> 1; list_value= list_array[list_index].list_value; @@ -2367,7 +2368,7 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info, { DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); } - } + } while (max_list_index >= min_list_index); notfound: if (list_value < part_func_value) list_index++; @@ -6194,6 +6195,18 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, part_iter->get_next= get_next_partition_id_list; part_iter->part_info= part_info; part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; + if (max_endpoint_val == 0) + { + /* + We handle this special case without optimisations since it is + of little practical value but causes a great number of complex + checks later in the code. + */ + part_iter->part_nums.start= part_iter->part_nums.end= 0; + part_iter->part_nums.cur= 0; + part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE; + return -1; + } } else DBUG_ASSERT(0); From 59a33015b461216c22fdf51585a53c9afecf9bfb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Jun 2006 12:34:44 +0300 Subject: [PATCH 04/43] Fixed Bug#19479:mysqldump creates invalid dump. Only check for FN_DEVCHAR in filenames if FN_DEVCHAR is defined. This allows to use table names with ":" on non windows platforms. On Windows platform get an error if you use table name that contains FN_DEVCHAR include/config-win.h: Moved FN_DEVCHAR to config-win.h include/my_global.h: Moved FN_DEVCHAR to config-win.h mysql-test/r/create.result: Added testcase for Bug#19479:mysqldump creates invalid dump BitKeeper/etc/ignore: Added sql/share/iso639-2.txt sql/share/fixerrmsg.pl to the ignore list mysql-test/t/create.test: Added testcase for Bug#19479:mysqldump creates invalid dump mysys/mf_fn_ext.c: Added checking of BASKSLASH_MBTAIL as dirname_part depends on it. Fixed cast and indentation. sql/table.cc: Only check for FN_DEVCHAR in filenames if FN_DEVCHAR is defined. This allows to use table names with ":" on non windows platforms. On Windows platform get an error if you use table name that contains FN_DEVCHAR --- .bzrignore | 2 ++ include/config-win.h | 1 + include/my_global.h | 1 - mysql-test/r/create.result | 14 ++++++++++++++ mysql-test/t/create.test | 15 +++++++++++++++ mysys/mf_fn_ext.c | 6 +++--- sql/table.cc | 8 ++++++++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.bzrignore b/.bzrignore index 80ed7872005..5eb09b07063 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1282,3 +1282,5 @@ extra/yassl/taocrypt/benchmark/benchmark extra/yassl/taocrypt/test/test extra/yassl/testsuite/testsuite client/mysql_upgrade +sql/share/iso639-2.txt +sql/share/fixerrmsg.pl diff --git a/include/config-win.h b/include/config-win.h index 8d937ffed22..75133ddc837 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -384,6 +384,7 @@ inline double ulonglong2double(ulonglong value) #define FN_LIBCHAR '\\' #define FN_ROOTDIR "\\" +#define FN_DEVCHAR ':' #define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ #define FN_NO_CASE_SENCE /* Files are not case-sensitive */ #define OS_FILE_LIMIT 2048 diff --git a/include/my_global.h b/include/my_global.h index 7adf4845984..e7205c94c18 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -599,7 +599,6 @@ typedef SOCKET_SIZE_TYPE size_socket; #define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ #define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ #define FN_PARENTDIR ".." /* Parent directory; Must be a string */ -#define FN_DEVCHAR ':' #ifndef FN_LIBCHAR #ifdef __EMX__ diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 27a6c8a9d03..57ec76a0b53 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -773,3 +773,17 @@ Warnings: Warning 1071 Specified key was too long; max key length is 765 bytes insert into t1 values('aaa'); drop table t1; +drop table if exists `about:text`; +create table `about:text` ( +_id int not null auto_increment, +`about:text` varchar(255) not null default '', +primary key (_id) +); +show create table `about:text`; +Table Create Table +about:text CREATE TABLE `about:text` ( + `_id` int(11) NOT NULL auto_increment, + `about:text` varchar(255) NOT NULL default '', + PRIMARY KEY (`_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table `about:text`; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index e22c2b5c426..d1e9818088d 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -674,4 +674,19 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb insert into t1 values('aaa'); drop table t1; +# +# Bug#19479:mysqldump creates invalid dump +# +--disable_warnings +drop table if exists `about:text`; +--enable_warnings +create table `about:text` ( +_id int not null auto_increment, +`about:text` varchar(255) not null default '', +primary key (_id) +); + +show create table `about:text`; +drop table `about:text`; + # End of 5.0 tests diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c index 9c86a8072ef..d7b1f8c1d61 100644 --- a/mysys/mf_fn_ext.c +++ b/mysys/mf_fn_ext.c @@ -40,14 +40,14 @@ my_string fn_ext(const char *name) DBUG_ENTER("fn_ext"); DBUG_PRINT("mfunkt",("name: '%s'",name)); -#if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) +#if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) || defined(BASKSLASH_MBTAIL) { char buff[FN_REFLEN]; gpos=(my_string) name+dirname_part(buff,(char*) name); } #else - if (!(gpos=strrchr(name,FNLIBCHAR))) - gpos=name; + if (!(gpos= strrchr(name, FN_LIBCHAR))) + gpos= (my_string) name; #endif pos=strchr(gpos,FN_EXTCHAR); DBUG_RETURN (pos ? pos : strend(gpos)); diff --git a/sql/table.cc b/sql/table.cc index 8e23bea2540..a71435ac0db 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1614,6 +1614,10 @@ bool check_db_name(char *name) if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR || *name == FN_EXTCHAR) return 1; +#ifdef FN_DEVCHAR + if (*name == FN_DEVCHAR) + return 1; +#endif name++; } return last_char_is_space || (uint) (name - start) > NAME_LEN; @@ -1656,6 +1660,10 @@ bool check_table_name(const char *name, uint length) #endif if (*name == '/' || *name == '\\' || *name == FN_EXTCHAR) return 1; +#ifdef FN_DEVCHAR + if (*name == FN_DEVCHAR) + return 1; +#endif name++; } #if defined(USE_MB) && defined(USE_MB_IDENT) From eeb8d4c8b4e43e672286d4a148c808816f4aa83f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Jun 2006 18:08:57 +0500 Subject: [PATCH 05/43] BUG#19192 - CHECK TABLE EXTENDED / REPAIR TABLE show no errors. ALTER TABLE crashes Executing fast alter table (one that doesn't need to copy data) on tables created by mysql versions prior to 4.0.25 could result in posterior server crash when accessing these tables. There was a bug prior to mysql-4.0.25. Number of null fields was calculated incorrectly. As a result frm and data files gets out of sync after fast alter table. There is no way to determine by which mysql version (in 4.0 and 4.1 branches) table was created, thus we disable fast alter table for all tables created by mysql versions prior to 5.0 branch. See BUG#6236. sql/sql_table.cc: There was a bug prior to mysql-4.0.25. Number of null fields was calculated incorrectly. As a result frm and data files gets out of sync after fast alter table. There is no way to determine by which mysql version (in 4.0 and 4.1 branches) table was created, thus we disable fast alter table for all tables created by mysql versions prior to 5.0 branch. See BUG#6236. --- sql/sql_table.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9ec8e8db1fb..275cfbaa088 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3614,12 +3614,21 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, their layout. See Field_string::type() for details. Thus, if the table is too old we may have to rebuild the data to update the layout. + + There was a bug prior to mysql-4.0.25. Number of null fields was + calculated incorrectly. As a result frm and data files gets out of + sync after fast alter table. There is no way to determine by which + mysql version (in 4.0 and 4.1 branches) table was created, thus we + disable fast alter table for all tables created by mysql versions + prior to 5.0 branch. + See BUG#6236. */ need_copy_table= (alter_info->flags & ~(ALTER_CHANGE_COLUMN_DEFAULT|ALTER_OPTIONS) || (create_info->used_fields & ~(HA_CREATE_USED_COMMENT|HA_CREATE_USED_PASSWORD)) || table->s->tmp_table || + !table->s->mysql_version || (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar)); create_info->frm_only= !need_copy_table; From 88ed77f2b772063b50438c9ba388f95989e5c990 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Jun 2006 22:03:39 +0300 Subject: [PATCH 06/43] BUG#19363: mysql --no_pager makes core dump. The problem was missing break; operator. BitKeeper/etc/ignore: Added client/#mysql.cc# to the ignore list client/mysql.cc: Fixed bug #19363: mysql --no_pager makes core dump. There was break; missing in the case statement. --- .bzrignore | 1 + client/mysql.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 80ed7872005..2bd67528bdc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1282,3 +1282,4 @@ extra/yassl/taocrypt/benchmark/benchmark extra/yassl/taocrypt/test/test extra/yassl/testsuite/testsuite client/mysql_upgrade +client/#mysql.cc# diff --git a/client/mysql.cc b/client/mysql.cc index 900df825b25..6fcda6d766f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -823,6 +823,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_NOPAGER: printf("WARNING: option deprecated; use --disable-pager instead.\n"); opt_nopager= 1; + break; case OPT_MYSQL_PROTOCOL: { if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) From 8b6806800ada3472ae678ead6d9d52e89bc7fa05 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 4 Jun 2006 21:27:41 +0300 Subject: [PATCH 07/43] BUG#19479: mysqldump creates invalid dump Moved the test case to separate non-windows specific file. mysql-test/r/create.result: Moved non-windows specific test case to create_not_windows.test. mysql-test/t/create.test: Moved non-windows specific test case to create_not_windows.test. mysql-test/r/create_not_windows.result: #19479: mysqldump creates invalid dump Moved the non-windows specific test case from create.test. mysql-test/t/create_not_windows.test: #19479: mysqldump creates invalid dump Moved the non-windows specific test case from create.test. --- mysql-test/r/create.result | 14 -------------- mysql-test/r/create_not_windows.result | 14 ++++++++++++++ mysql-test/t/create.test | 15 --------------- mysql-test/t/create_not_windows.test | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 mysql-test/r/create_not_windows.result create mode 100644 mysql-test/t/create_not_windows.test diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 57ec76a0b53..27a6c8a9d03 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -773,17 +773,3 @@ Warnings: Warning 1071 Specified key was too long; max key length is 765 bytes insert into t1 values('aaa'); drop table t1; -drop table if exists `about:text`; -create table `about:text` ( -_id int not null auto_increment, -`about:text` varchar(255) not null default '', -primary key (_id) -); -show create table `about:text`; -Table Create Table -about:text CREATE TABLE `about:text` ( - `_id` int(11) NOT NULL auto_increment, - `about:text` varchar(255) NOT NULL default '', - PRIMARY KEY (`_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table `about:text`; diff --git a/mysql-test/r/create_not_windows.result b/mysql-test/r/create_not_windows.result new file mode 100644 index 00000000000..b975c98c2b1 --- /dev/null +++ b/mysql-test/r/create_not_windows.result @@ -0,0 +1,14 @@ +drop table if exists `about:text`; +create table `about:text` ( +_id int not null auto_increment, +`about:text` varchar(255) not null default '', +primary key (_id) +); +show create table `about:text`; +Table Create Table +about:text CREATE TABLE `about:text` ( + `_id` int(11) NOT NULL auto_increment, + `about:text` varchar(255) NOT NULL default '', + PRIMARY KEY (`_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table `about:text`; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d1e9818088d..e22c2b5c426 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -674,19 +674,4 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb insert into t1 values('aaa'); drop table t1; -# -# Bug#19479:mysqldump creates invalid dump -# ---disable_warnings -drop table if exists `about:text`; ---enable_warnings -create table `about:text` ( -_id int not null auto_increment, -`about:text` varchar(255) not null default '', -primary key (_id) -); - -show create table `about:text`; -drop table `about:text`; - # End of 5.0 tests diff --git a/mysql-test/t/create_not_windows.test b/mysql-test/t/create_not_windows.test new file mode 100644 index 00000000000..71ad9ccd7fe --- /dev/null +++ b/mysql-test/t/create_not_windows.test @@ -0,0 +1,20 @@ +# Non-windows specific create tests. + +--source include/not_windows.inc + +# +# Bug#19479:mysqldump creates invalid dump +# +--disable_warnings +drop table if exists `about:text`; +--enable_warnings +create table `about:text` ( +_id int not null auto_increment, +`about:text` varchar(255) not null default '', +primary key (_id) +); + +show create table `about:text`; +drop table `about:text`; + +# End of 5.0 tests From 28e05fc752748844f1b8154239c6480c8a36f709 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jun 2006 15:41:29 +0200 Subject: [PATCH 08/43] Import patch for yassl 1.35 - Better check of required buffer size when processing incoming record headers extra/yassl/README: Import patch yassl.diff extra/yassl/src/handshake.cpp: Import patch yassl.diff extra/yassl/include/openssl/engine.h: Import patch yassl.diff extra/yassl/include/openssl/pkcs12.h: Import patch yassl.diff --- extra/yassl/README | 16 ++++++++++++--- extra/yassl/include/openssl/engine.h | 5 +++++ extra/yassl/include/openssl/pkcs12.h | 5 +++++ extra/yassl/src/handshake.cpp | 30 ++++++++++++++++++++++------ 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 extra/yassl/include/openssl/engine.h create mode 100644 extra/yassl/include/openssl/pkcs12.h diff --git a/extra/yassl/README b/extra/yassl/README index 62209723f66..a5ff70aa6f6 100644 --- a/extra/yassl/README +++ b/extra/yassl/README @@ -1,4 +1,14 @@ -yaSSL Release notes, version 1.3.0 (04/26/06) +yaSSL Release notes, version 1.3.5 (06/01/06) + + + This release of yaSSL contains bug fixes, portability enhancements, + better libcurl support, and improved non-blocking I/O. + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.3.0 (04/26/06) This release of yaSSL contains minor bug fixes, portability enhancements, @@ -17,8 +27,8 @@ See normal build instructions below under 1.0.6. make make openssl-links - (then go to your libcurl home and tell libcurl about yaSSL) - ./configure --with-ssl=/yaSSL-HomeDir + (then go to your libcurl home and tell libcurl about yaSSL build dir) + ./configure --with-ssl=/yaSSL-BuildDir LDFLAGS=-lm make diff --git a/extra/yassl/include/openssl/engine.h b/extra/yassl/include/openssl/engine.h new file mode 100644 index 00000000000..39952fcae84 --- /dev/null +++ b/extra/yassl/include/openssl/engine.h @@ -0,0 +1,5 @@ +/* engine.h for libcurl */ + +#undef HAVE_OPENSSL_ENGINE_H + + diff --git a/extra/yassl/include/openssl/pkcs12.h b/extra/yassl/include/openssl/pkcs12.h new file mode 100644 index 00000000000..e452fc879c4 --- /dev/null +++ b/extra/yassl/include/openssl/pkcs12.h @@ -0,0 +1,5 @@ +/* pkcs12.h for libcurl */ + + +#undef HAVE_OPENSSL_PKCS12_H + diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 2b099af930c..12b62f26e14 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -458,6 +458,11 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl) uint16 sz = ((b0 & 0x7f) << 8) | b1; + if (sz > input.get_remaining()) { + ssl.SetError(bad_input); + return; + } + // hashHandShake manually const opaque* buffer = input.get_buffer() + input.get_current(); ssl.useHashes().use_MD5().update(buffer, sz); @@ -681,25 +686,38 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) // old style sslv2 client hello? if (ssl.getSecurity().get_parms().entity_ == server_end && ssl.getStates().getServer() == clientNull) - if (buffer.peek() != handshake) + if (buffer.peek() != handshake) { ProcessOldClientHello(buffer, ssl); + if (ssl.GetError()) { + buffered.reset(0); + return buffered; + } + } while(!buffer.eof()) { // each record RecordLayerHeader hdr; + bool needHdr = false; + + if (static_cast(RECORD_HEADER) > buffer.get_remaining()) + needHdr = true; + else { buffer >> hdr; ssl.verifyState(hdr); + } // make sure we have enough input in buffer to process this record - if (hdr.length_ > buffer.get_remaining()) { - uint sz = buffer.get_remaining() + RECORD_HEADER; + if (needHdr || hdr.length_ > buffer.get_remaining()) { + // put header in front for next time processing + uint extra = needHdr ? 0 : RECORD_HEADER; + uint sz = buffer.get_remaining() + extra; buffered.reset(NEW_YS input_buffer(sz, buffer.get_buffer() + - buffer.get_current() - RECORD_HEADER, sz)); + buffer.get_current() - extra, sz)); break; } while (buffer.get_current() < hdr.length_ + RECORD_HEADER + offset) { - // each message in record + // each message in record, can be more than 1 if not encrypted if (ssl.getSecurity().get_parms().pending_ == false) // cipher on decrypt_message(ssl, buffer, hdr.length_); mySTL::auto_ptr msg(mf.CreateObject(hdr.type_), ysDelete); @@ -717,7 +735,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) } offset += hdr.length_ + RECORD_HEADER; } - return buffered; // done, don't call again + return buffered; } From e05d2d06cb4adfe27dc4c0c4cb8f445332e9ab80 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jun 2006 14:55:22 -0400 Subject: [PATCH 09/43] BUG#16002: Handle unsigned integer partition functions mysql-test/r/partition.result: Added new test cases mysql-test/r/partition_error.result: Fixed test case mysql-test/t/partition.test: Added new test cases mysql-test/t/partition_error.test: Fixed test case sql/ha_partition.cc: Review fixes sql/partition_element.h: Review fixes sql/partition_info.cc: Review fixes sql/share/errmsg.txt: Review fixes sql/sql_partition.cc: Review fixes sql/sql_yacc.yy: Enabled possibility to use (MAXVALUE) as well as MAXVALUE. --- mysql-test/r/partition.result | 23 ++++++++++++++++++-- mysql-test/r/partition_error.result | 2 +- mysql-test/t/partition.test | 28 ++++++++++++++++++++++-- mysql-test/t/partition_error.test | 2 +- sql/ha_partition.cc | 11 ++++------ sql/partition_element.h | 11 ++++++++-- sql/partition_info.cc | 14 ++++++------ sql/share/errmsg.txt | 6 +++--- sql/sql_partition.cc | 33 ++++++++++------------------- sql/sql_yacc.yy | 7 +++++- 10 files changed, 88 insertions(+), 49 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index b76896f720f..50570894a51 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,5 +1,24 @@ drop table if exists t1; -create table t1 (a bigint unsigned); +create table t1 (a bigint) +partition by range (a) +(partition p0 values less than (0xFFFFFFFFFFFFFFFF), +partition p1 values less than (10)); +ERROR 42000: VALUES value must be of same type as partition function near '), +partition p1 values less than (10))' at line 3 +create table t1 (a bigint) +partition by list (a) +(partition p0 values in (0xFFFFFFFFFFFFFFFF), +partition p1 values in (10)); +ERROR 42000: VALUES value must be of same type as partition function near '), +partition p1 values in (10))' at line 3 +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (100), +partition p1 values less than MAXVALUE); +insert into t1 values (1); +drop table t1; +create table t1 (a bigint unsigned) +partition by hash (a); insert into t1 values (0xFFFFFFFFFFFFFFFD); insert into t1 values (0xFFFFFFFFFFFFFFFE); select * from t1 where (a + 1) < 10; @@ -852,7 +871,7 @@ DROP TABLE t1; create table t1 (a bigint unsigned) partition by list (a) (partition p0 values in (0-1)); -ERROR HY000: Partition function is unsigned, cannot have negative constants +ERROR HY000: Partition constant is out of partition function domain create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (10)); diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index cc51b909c51..1295eba16ae 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -557,4 +557,4 @@ drop table t1; create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (-1)); -ERROR HY000: Partition function is unsigned, cannot have negative constants +ERROR HY000: Partition constant is out of partition function domain diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 3714a4a3346..b57fc6420f0 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,7 +9,29 @@ drop table if exists t1; --enable_warnings -create table t1 (a bigint unsigned); +# +# BUG 16002: Handle unsigned integer functions properly +# +--error 1064 +create table t1 (a bigint) +partition by range (a) +(partition p0 values less than (0xFFFFFFFFFFFFFFFF), + partition p1 values less than (10)); +--error 1064 +create table t1 (a bigint) +partition by list (a) +(partition p0 values in (0xFFFFFFFFFFFFFFFF), + partition p1 values in (10)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (100), + partition p1 values less than MAXVALUE); +insert into t1 values (1); +drop table t1; + +create table t1 (a bigint unsigned) +partition by hash (a); insert into t1 values (0xFFFFFFFFFFFFFFFD); insert into t1 values (0xFFFFFFFFFFFFFFFE); select * from t1 where (a + 1) < 10; @@ -966,7 +988,7 @@ DROP TABLE t1; # #BUG 16002 Erroneus handling of unsigned partition functions # ---error ER_SIGNED_PARTITION_CONSTANT_ERROR +--error ER_PARTITION_CONST_DOMAIN_ERROR create table t1 (a bigint unsigned) partition by list (a) (partition p0 values in (0-1)); @@ -978,6 +1000,8 @@ partition by range (a) --error ER_NO_PARTITION_FOR_GIVEN_VALUE insert into t1 values (0xFFFFFFFFFFFFFFFF); +drop table t1; + # #BUG 18750 Problems with partition names # diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index dad2d2beda6..35aef969ad6 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -748,7 +748,7 @@ CREATE TABLE t1(a int) insert into t1 values (10); drop table t1; ---error ER_SIGNED_PARTITION_CONSTANT_ERROR +--error ER_PARTITION_CONST_DOMAIN_ERROR create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (-1)); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 3014c0317be..bedda6b4fe7 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5162,17 +5162,14 @@ void ha_partition::print_error(int error, myf errflag) { char buf[100]; longlong value= m_part_info->part_expr->val_int(); - if (!m_part_info->part_expr->unsigned_flag || - m_part_info->part_expr->null_value) + if (m_part_info->part_expr->null_value) { - my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), - m_part_info->part_expr->null_value ? "NULL" : - llstr(m_part_info->part_expr->val_int(), buf)); + my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0),"NULL"); } else { - ulonglong value= m_part_info->part_expr->val_int(); - longlong2str(value, buf, 10); + longlong2str(value, buf, + m_part_info->part_expr->unsigned_flag ? 10 : -10); my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), buf); } } diff --git a/sql/partition_element.h b/sql/partition_element.h index 7063e514901..7818c25c2f6 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -36,6 +36,13 @@ enum partition_state { PART_IS_ADDED= 8 }; +/* + This struct is used to contain the value of an element + in the VALUES IN struct. It needs to keep knowledge of + whether it is a signed/unsigned value and whether it is + NULL or not. +*/ + typedef struct p_elem_val { longlong value; @@ -59,8 +66,8 @@ public: enum partition_state part_state; uint16 nodegroup_id; bool has_null_value; - bool signed_flag; - bool max_value; + bool signed_flag;/* Indicate whether this partition uses signed constants */ + bool max_value; /* Indicate whether this partition uses MAXVALUE */ partition_element() : part_max_rows(0), part_min_rows(0), range_value(0), diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 97cac37c00e..a6ca1e0107e 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -485,10 +485,9 @@ bool partition_info::check_range_constants() else { ulonglong upart_range_value_int; - if ((i != (no_parts - 1)) || !defined_max_value) - upart_range_value_int= part_def->range_value; - else - upart_range_value_int= ULONGLONG_MAX; + if ((i == (no_parts - 1)) && defined_max_value) + part_def->range_value= ULONGLONG_MAX; + upart_range_value_int= part_def->range_value; if (likely(current_largest_uint < upart_range_value_int)) { current_largest_uint= upart_range_value_int; @@ -572,7 +571,6 @@ bool partition_info::check_list_constants() uint i; uint list_index= 0; part_elem_value *list_value; - bool not_first; bool result= TRUE; longlong curr_value, prev_value; partition_element* part_def; @@ -638,6 +636,7 @@ bool partition_info::check_list_constants() if (fixed) { + bool first= TRUE; if (!part_expr->unsigned_flag) qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), &list_part_cmp); @@ -645,15 +644,14 @@ bool partition_info::check_list_constants() qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), &list_part_cmp_unsigned); - not_first= FALSE; i= prev_value= 0; //prev_value initialised to quiet compiler do { curr_value= list_array[i].list_value; - if (likely(!not_first || prev_value != curr_value)) + if (likely(first || prev_value != curr_value)) { prev_value= curr_value; - not_first= TRUE; + first= FALSE; } else { diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 203f58ba108..148a4402ccd 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5826,9 +5826,9 @@ ER_NDB_CANT_SWITCH_BINLOG_FORMAT eng "The NDB cluster engine does not support changing the binlog format on the fly yet" ER_PARTITION_NO_TEMPORARY eng "Cannot create temporary table with partitions" -ER_SIGNED_PARTITION_CONSTANT_ERROR - eng "Partition function is unsigned, cannot have negative constants" - swe "Partitionsfunktionen är positiv, kan inte ha negativa konstanter" +ER_PARTITION_CONST_DOMAIN_ERROR + eng "Partition constant is out of partition function domain" + swe "Partitionskonstanten är utanför partitioneringsfunktionens domän" ER_NULL_IN_VALUES_LESS_THAN eng "Not allowed to use NULL value in VALUES LESS THAN" swe "Det är inte tillåtet att använda NULL-värden i VALUES LESS THAN" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 05f99110f61..45cd13ce854 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -819,8 +819,8 @@ int check_signed_flag(partition_info *part_info) if (part_elem->signed_flag) { - my_error(ER_SIGNED_PARTITION_CONSTANT_ERROR, MYF(0)); - error= ER_SIGNED_PARTITION_CONSTANT_ERROR; + my_error(ER_PARTITION_CONST_DOMAIN_ERROR, MYF(0)); + error= ER_PARTITION_CONST_DOMAIN_ERROR; break; } } while (++i < part_info->no_parts); @@ -841,8 +841,8 @@ int check_signed_flag(partition_info *part_info) func_expr The item tree reference of the partition function table The table object part_info Reference to partitioning data structure - sub_part Is the table subpartitioned as well - set_up_fields Flag if we are to set-up field arrays + is_sub_part Is the table subpartitioned as well + is_field_to_be_setup Flag if we are to set-up field arrays RETURN VALUE TRUE An error occurred, something was wrong with the @@ -1376,7 +1376,7 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask, fix_partition_func() thd The thread object table TABLE object for which partition fields are set-up - create_table_ind Indicator of whether openfrm was called as part of + is_create_table_ind Indicator of whether openfrm was called as part of CREATE or ALTER TABLE RETURN VALUE @@ -1760,28 +1760,17 @@ static int add_partition_values(File fptr, partition_info *part_info, if (part_info->part_type == RANGE_PARTITION) { err+= add_string(fptr, "VALUES LESS THAN "); - if (p_elem->signed_flag) + if (!p_elem->max_value) { - if (!p_elem->max_value) - { - err+= add_begin_parenthesis(fptr); + err+= add_begin_parenthesis(fptr); + if (p_elem->signed_flag) err+= add_int(fptr, p_elem->range_value); - err+= add_end_parenthesis(fptr); - } else - err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); + err+= add_uint(fptr, (ulonglong)p_elem->range_value); + err+= add_end_parenthesis(fptr); } else - { - if (!p_elem->max_value) - { - err+= add_begin_parenthesis(fptr); - err+= add_uint(fptr, (ulonglong)p_elem->range_value); - err+= add_end_parenthesis(fptr); - } - else - err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); - } + err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); } else if (part_info->part_type == LIST_PARTITION) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9e2fa96fec7..0fcb80c0d79 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3697,7 +3697,7 @@ opt_part_values: ; part_func_max: - MAX_VALUE_SYM + max_value_sym { LEX *lex= Lex; if (lex->part_info->defined_max_value) @@ -3724,6 +3724,11 @@ part_func_max: } ; +max_value_sym: + MAX_VALUE_SYM + | '(' MAX_VALUE_SYM ')' + ; + part_range_func: '(' part_bit_expr ')' { From 6c431a5ecdd3f1f94de650217877b9c9b2d9a7ac Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 11:25:31 +0500 Subject: [PATCH 10/43] Bug#17661 information_schema.SCHEMATA returns uppercase with lower_case_table_names = 1 fix: return db name for I_S.TABLES(and others) in original letter case. if mysql starts with lower_case_table_names=1 | 2 then original db name is converted to lower case(for I_S tables). It happens when we perform add_table_to_list. to avoid this we make a copy of original db name and use the copy hereafter. mysql-test/r/lowercase_table2.result: Bug#17661 information_schema.SCHEMATA returns uppercase with lower_case_table_names = 1 test case mysql-test/t/lowercase_table2.test: Bug#17661 information_schema.SCHEMATA returns uppercase with lower_case_table_names = 1 test case --- mysql-test/r/lowercase_table2.result | 9 +++++++++ mysql-test/t/lowercase_table2.test | 11 +++++++++++ sql/sql_show.cc | 8 +++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 44235cbf900..e369fb7e482 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -165,3 +165,12 @@ create table t1Aa (col1 int); select t1Aa.col1 from t1aA,t2Aa where t1Aa.col1 = t2aA.col1; col1 drop table t2aA, t1Aa; +create database mysqltest_LC2; +use mysqltest_LC2; +create table myUC (i int); +select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES +where TABLE_SCHEMA ='mysqltest_LC2'; +TABLE_SCHEMA TABLE_NAME +mysqltest_LC2 myUC +use test; +drop database mysqltest_LC2; diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test index c02ae8f5073..521df01cc9b 100644 --- a/mysql-test/t/lowercase_table2.test +++ b/mysql-test/t/lowercase_table2.test @@ -139,3 +139,14 @@ select t1Aa.col1 from t1aA,t2Aa where t1Aa.col1 = t2aA.col1; drop table t2aA, t1Aa; # End of 4.1 tests + +# +# Bug#17661 information_schema.SCHEMATA returns uppercase with lower_case_table_names = 1 +# +create database mysqltest_LC2; +use mysqltest_LC2; +create table myUC (i int); +select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES +where TABLE_SCHEMA ='mysqltest_LC2'; +use test; +drop database mysqltest_LC2; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 246da4dfeec..ca6a8ddfb6b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2070,7 +2070,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ST_SCHEMA_TABLE *schema_table= tables->schema_table; SELECT_LEX sel; INDEX_FIELD_VALUES idx_field_vals; - char path[FN_REFLEN], *end, *base_name, *file_name; + char path[FN_REFLEN], *end, *base_name, *orig_base_name, *file_name; uint len; bool with_i_schema; enum enum_schema_tables schema_table_idx; @@ -2150,7 +2150,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) partial_cond= make_cond_for_info_schema(cond, tables); it.rewind(); /* To get access to new elements in basis list */ - while ((base_name= it++) || + while ((orig_base_name= base_name= it++) || /* generate error for non existing database. (to save old behaviour for SHOW TABLES FROM db) @@ -2181,6 +2181,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) if (mysql_find_files(thd, &files, base_name, path, idx_field_vals.table_value, 0)) goto err; + if (lower_case_table_names) + orig_base_name= thd->strdup(base_name); } List_iterator_fast it_files(files); @@ -2249,7 +2251,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) in this case. */ res= schema_table->process_table(thd, show_table_list, table, - res, base_name, + res, orig_base_name, show_table_list->alias); close_tables_for_reopen(thd, &show_table_list); DBUG_ASSERT(!lex->query_tables_own_last); From 581d4d23a15f10ec3457493074741f3753a26841 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 12:51:04 +0500 Subject: [PATCH 11/43] Bug#19599 duplication of information_schema column value in a CONCAT expr with user var mark result string using String::mark_as_const() which prevents CONCAT from reusing it as a buffer for concatenation result. mysql-test/r/information_schema.result: Bug#19599 duplication of information_schema column value in a CONCAT expr with user var test case mysql-test/t/information_schema.test: Bug#19599 duplication of information_schema column value in a CONCAT expr with user var test case --- mysql-test/r/information_schema.result | 9 +++++++++ mysql-test/t/information_schema.test | 10 ++++++++++ sql/item_strfunc.h | 1 + 3 files changed, 20 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index e2d265d7ab9..b80abc7d2d3 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1121,3 +1121,12 @@ NULL test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER drop view v1, v2; drop table t1; drop user mysqltest_1@localhost; +set @a:= '.'; +create table t1(f1 char(5)); +create table t2(f1 char(5)); +select concat(@a, table_name), @a, table_name +from information_schema.tables where table_schema = 'test'; +concat(@a, table_name) @a table_name +.t1 . t1 +.t2 . t2 +drop table t1,t2; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 48dd28bf6da..bc74bfbf20f 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -838,3 +838,13 @@ connection default; drop view v1, v2; drop table t1; drop user mysqltest_1@localhost; + +# +# Bug#19599 duplication of information_schema column value in a CONCAT expr with user var +# +set @a:= '.'; +create table t1(f1 char(5)); +create table t2(f1 char(5)); +select concat(@a, table_name), @a, table_name +from information_schema.tables where table_schema = 'test'; +drop table t1,t2; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 90d421a2c68..af59b8d740b 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -674,6 +674,7 @@ public: str->charset(), conv_charset, &errors)) null_value= 1; use_cached_value= 1; + str_value.mark_as_const(); safe= (errors == 0); } else From 57e7bc551300b224404b3ce1a5498917f9ead689 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 12:57:50 +0500 Subject: [PATCH 12/43] Bug#18035 Information Schema: Output is not Sorted added 'order by' to avoid result order difference --- mysql-test/r/information_schema.result | 36 ++++++++++++++------------ mysql-test/t/information_schema.test | 36 ++++++++++++++------------ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index b80abc7d2d3..6da07922251 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -866,58 +866,62 @@ grant select (f1) on mysqltest.t1 to user1@localhost; grant select on mysqltest.t2 to user2@localhost; grant select on mysqltest.* to user3@localhost; grant select on *.* to user4@localhost; -select * from information_schema.column_privileges; +select * from information_schema.column_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE 'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO -select * from information_schema.table_privileges; +select * from information_schema.table_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.schema_privileges; +select * from information_schema.schema_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.user_privileges; +select * from information_schema.user_privileges order by grantee; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'user1'@'localhost' NULL USAGE NO show grants; Grants for user1@localhost GRANT USAGE ON *.* TO 'user1'@'localhost' GRANT SELECT (f1) ON `mysqltest`.`t1` TO 'user1'@'localhost' -select * from information_schema.column_privileges; +select * from information_schema.column_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.table_privileges; +select * from information_schema.table_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'user2'@'localhost' NULL mysqltest t2 SELECT NO -select * from information_schema.schema_privileges; +select * from information_schema.schema_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.user_privileges; +select * from information_schema.user_privileges order by grantee; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'user2'@'localhost' NULL USAGE NO show grants; Grants for user2@localhost GRANT USAGE ON *.* TO 'user2'@'localhost' GRANT SELECT ON `mysqltest`.`t2` TO 'user2'@'localhost' -select * from information_schema.column_privileges; +select * from information_schema.column_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.table_privileges; +select * from information_schema.table_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE -select * from information_schema.schema_privileges; +select * from information_schema.schema_privileges order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE 'user3'@'localhost' NULL mysqltest SELECT NO -select * from information_schema.user_privileges; +select * from information_schema.user_privileges order by grantee; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'user3'@'localhost' NULL USAGE NO show grants; Grants for user3@localhost GRANT USAGE ON *.* TO 'user3'@'localhost' GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost' -select * from information_schema.column_privileges where grantee like '%user%'; +select * from information_schema.column_privileges where grantee like '%user%' +order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE 'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO -select * from information_schema.table_privileges where grantee like '%user%'; +select * from information_schema.table_privileges where grantee like '%user%' +order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'user2'@'localhost' NULL mysqltest t2 SELECT NO -select * from information_schema.schema_privileges where grantee like '%user%'; +select * from information_schema.schema_privileges where grantee like '%user%' +order by grantee; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE 'user3'@'localhost' NULL mysqltest SELECT NO -select * from information_schema.user_privileges where grantee like '%user%'; +select * from information_schema.user_privileges where grantee like '%user%' +order by grantee; GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'user1'@'localhost' NULL USAGE NO 'user2'@'localhost' NULL USAGE NO diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index bc74bfbf20f..0bcd9ef8c0b 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -576,28 +576,32 @@ connect (con2,localhost,user2,,mysqltest); connect (con3,localhost,user3,,mysqltest); connect (con4,localhost,user4,,); connection con1; -select * from information_schema.column_privileges; -select * from information_schema.table_privileges; -select * from information_schema.schema_privileges; -select * from information_schema.user_privileges; +select * from information_schema.column_privileges order by grantee; +select * from information_schema.table_privileges order by grantee; +select * from information_schema.schema_privileges order by grantee; +select * from information_schema.user_privileges order by grantee; show grants; connection con2; -select * from information_schema.column_privileges; -select * from information_schema.table_privileges; -select * from information_schema.schema_privileges; -select * from information_schema.user_privileges; +select * from information_schema.column_privileges order by grantee; +select * from information_schema.table_privileges order by grantee; +select * from information_schema.schema_privileges order by grantee; +select * from information_schema.user_privileges order by grantee; show grants; connection con3; -select * from information_schema.column_privileges; -select * from information_schema.table_privileges; -select * from information_schema.schema_privileges; -select * from information_schema.user_privileges; +select * from information_schema.column_privileges order by grantee; +select * from information_schema.table_privileges order by grantee; +select * from information_schema.schema_privileges order by grantee; +select * from information_schema.user_privileges order by grantee; show grants; connection con4; -select * from information_schema.column_privileges where grantee like '%user%'; -select * from information_schema.table_privileges where grantee like '%user%'; -select * from information_schema.schema_privileges where grantee like '%user%'; -select * from information_schema.user_privileges where grantee like '%user%'; +select * from information_schema.column_privileges where grantee like '%user%' +order by grantee; +select * from information_schema.table_privileges where grantee like '%user%' +order by grantee; +select * from information_schema.schema_privileges where grantee like '%user%' +order by grantee; +select * from information_schema.user_privileges where grantee like '%user%' +order by grantee; show grants; connection default; drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost; From 5239cba4b58071ea1aa16ff823305f0498078e0a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 11:54:21 -0400 Subject: [PATCH 13/43] BUG#16002: More review fixes mysql-test/r/partition_range.result: Changed test cases mysql-test/t/partition_range.test: Changed test cases sql/partition_info.cc: Changes to resue signed integer code for unsigned integer partition functions Basic idea is to store value - 0x8000000000000000 in list_array and range_int_array and also perform this subtraction before applying get_partition_id_range and so forth. sql/sql_partition.cc: Changes to resue signed integer code for unsigned integer partition functions Basic idea is to store value - 0x8000000000000000 in list_array and range_int_array and also perform this subtraction before applying get_partition_id_range and so forth. --- mysql-test/r/partition_range.result | 17 +- mysql-test/t/partition_range.test | 10 +- sql/partition_info.cc | 76 ++++---- sql/sql_partition.cc | 269 ++++++++-------------------- 4 files changed, 133 insertions(+), 239 deletions(-) diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index 4d071c0edc1..4a3ed6b6164 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -365,13 +365,28 @@ COUNT(*) DROP TABLE t1; create table t1 (a bigint unsigned) partition by range (a) +(partition p0 values less than (10), +partition p1 values less than (0)); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +create table t1 (a bigint unsigned) +partition by range (a) (partition p0 values less than (0), partition p1 values less than (10)); -ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (0) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM) +drop table t1; create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (2), partition p1 values less than (10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (2) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM) insert into t1 values (0xFFFFFFFFFFFFFFFF); ERROR HY000: Table has no partition for value 18446744073709551615 drop table t1; diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index 239c6cc8144..ebe249eb072 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -392,16 +392,24 @@ DROP TABLE t1; # BUG 16002: Unsigned partition functions not handled correctly # --error ER_RANGE_NOT_INCREASING_ERROR +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (10), + partition p1 values less than (0)); + create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (0), partition p1 values less than (10)); +show create table t1; +drop table t1; create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (2), partition p1 values less than (10)); +show create table t1; --error ER_NO_PARTITION_FOR_GIVEN_VALUE insert into t1 values (0xFFFFFFFFFFFFFFFF); - drop table t1; + diff --git a/sql/partition_info.cc b/sql/partition_info.cc index a6ca1e0107e..a7ab59adb81 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -444,9 +444,9 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts) bool partition_info::check_range_constants() { partition_element* part_def; - longlong current_largest_int= LONGLONG_MIN; - ulonglong current_largest_uint= 0; - longlong part_range_value_int; + longlong current_largest; + longlong part_range_value; + bool first= TRUE; uint i; List_iterator it(partitions); bool result= TRUE; @@ -465,33 +465,26 @@ bool partition_info::check_range_constants() do { part_def= it++; - if (signed_flag) + if ((i != (no_parts - 1)) || !defined_max_value) { - if ((i != (no_parts - 1)) || !defined_max_value) - part_range_value_int= part_def->range_value; - else - part_range_value_int= LONGLONG_MAX; - if (likely(current_largest_int < part_range_value_int)) - { - current_largest_int= part_range_value_int; - range_int_array[i]= part_range_value_int; - } - else - { - my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); - goto end; - } + part_range_value= part_def->range_value; + if (!signed_flag) + part_range_value-= 0x8000000000000000ULL; + } + else + part_range_value= LONGLONG_MAX; + if (first) + { + current_largest= part_range_value; + range_int_array[0]= part_range_value; + first= FALSE; } else { - ulonglong upart_range_value_int; - if ((i == (no_parts - 1)) && defined_max_value) - part_def->range_value= ULONGLONG_MAX; - upart_range_value_int= part_def->range_value; - if (likely(current_largest_uint < upart_range_value_int)) + if (likely(current_largest < part_range_value)) { - current_largest_uint= upart_range_value_int; - range_int_array[i]= part_range_value_int; + current_largest= part_range_value; + range_int_array[i]= part_range_value; } else { @@ -533,18 +526,6 @@ int partition_info::list_part_cmp(const void* a, const void* b) return 0; } -int partition_info::list_part_cmp_unsigned(const void* a, const void* b) -{ - ulonglong a1= ((LIST_PART_ENTRY*)a)->list_value; - ulonglong b1= ((LIST_PART_ENTRY*)b)->list_value; - if (a1 < b1) - return -1; - else if (a1 > b1) - return +1; - else - return 0; -} - /* This routine allocates an array for all list constants to achieve a fast @@ -572,7 +553,7 @@ bool partition_info::check_list_constants() uint list_index= 0; part_elem_value *list_value; bool result= TRUE; - longlong curr_value, prev_value; + longlong curr_value, prev_value, type_add, calc_value; partition_element* part_def; bool found_null= FALSE; List_iterator list_func_it(partitions); @@ -623,13 +604,22 @@ bool partition_info::check_list_constants() } i= 0; + /* + Fix to be able to reuse signed sort functions also for unsigned + partition functions. + */ + type_add= (longlong)(part_expr->unsigned_flag ? + 0x8000000000000000ULL : + 0ULL); + do { part_def= list_func_it++; List_iterator list_val_it2(part_def->list_val_list); while ((list_value= list_val_it2++)) { - list_array[list_index].list_value= list_value->value; + calc_value= list_value->value - type_add; + list_array[list_index].list_value= calc_value; list_array[list_index++].partition_id= i; } } while (++i < no_parts); @@ -637,12 +627,8 @@ bool partition_info::check_list_constants() if (fixed) { bool first= TRUE; - if (!part_expr->unsigned_flag) - qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), - &list_part_cmp); - else - qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), - &list_part_cmp_unsigned); + qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), + &list_part_cmp); i= prev_value= 0; //prev_value initialised to quiet compiler do diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 45cd13ce854..086b7f28b1e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1752,8 +1752,7 @@ static int add_partition_options(File fptr, partition_element *p_elem) return err + add_engine(fptr,p_elem->engine_type); } -static int add_partition_values(File fptr, partition_info *part_info, - partition_element *p_elem) +static int add_partition_values(File fptr, partition_info *part_info, partition_element *p_elem) { int err= 0; @@ -1766,7 +1765,7 @@ static int add_partition_values(File fptr, partition_info *part_info, if (p_elem->signed_flag) err+= add_int(fptr, p_elem->range_value); else - err+= add_uint(fptr, (ulonglong)p_elem->range_value); + err+= add_uint(fptr, p_elem->range_value); err+= add_end_parenthesis(fptr); } else @@ -2382,6 +2381,7 @@ int get_partition_id_list(partition_info *part_info, int min_list_index= 0; int max_list_index= part_info->no_list_values - 1; longlong part_func_value= part_val_int(part_info->part_expr); + longlong list_value; bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_partition_id_list"); @@ -2394,50 +2394,25 @@ int get_partition_id_list(partition_info *part_info, } goto notfound; } + if (unsigned_flag) + part_func_value-= 0x8000000000000000ULL; *func_value= part_func_value; - if (!unsigned_flag) + while (max_list_index >= min_list_index) { - longlong list_value; - while (max_list_index >= min_list_index) + list_index= (max_list_index + min_list_index) >> 1; + list_value= list_array[list_index].list_value; + if (list_value < part_func_value) + min_list_index= list_index + 1; + else if (list_value > part_func_value) { - list_index= (max_list_index + min_list_index) >> 1; - list_value= list_array[list_index].list_value; - if (list_value < part_func_value) - min_list_index= list_index + 1; - else if (list_value > part_func_value) - { - if (!list_index) - goto notfound; - max_list_index= list_index - 1; - } - else - { - *part_id= (uint32)list_array[list_index].partition_id; - DBUG_RETURN(0); - } + if (!list_index) + goto notfound; + max_list_index= list_index - 1; } - } - else - { - ulonglong ulist_value; - ulonglong upart_func_value= part_func_value; - while (max_list_index >= min_list_index) + else { - list_index= (max_list_index + min_list_index) >> 1; - ulist_value= list_array[list_index].list_value; - if (ulist_value < upart_func_value) - min_list_index= list_index + 1; - else if (ulist_value > upart_func_value) - { - if (!list_index) - goto notfound; - max_list_index= list_index - 1; - } - else - { - *part_id= (uint32)list_array[list_index].partition_id; - DBUG_RETURN(0); - } + *part_id= (uint32)list_array[list_index].partition_id; + DBUG_RETURN(0); } } notfound: @@ -2496,57 +2471,30 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info, bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_list_array_idx_for_endpoint"); - if (!unsigned_flag) + if (unsigned_flag) + part_func_value-= 0x8000000000000000ULL; + longlong list_value; + while (max_list_index >= min_list_index) { - longlong list_value; - while (max_list_index >= min_list_index) - { - list_index= (max_list_index + min_list_index) >> 1; - list_value= list_array[list_index].list_value; - if (list_value < part_func_value) - min_list_index= list_index + 1; - else if (list_value > part_func_value) - { - if (!list_index) - goto notfound_signed; - max_list_index= list_index - 1; - } - else - { - DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); - } - } - notfound_signed: + list_index= (max_list_index + min_list_index) >> 1; + list_value= list_array[list_index].list_value; if (list_value < part_func_value) - list_index++; - DBUG_RETURN(list_index); - } - else - { - ulonglong upart_func_value= part_func_value; - ulonglong ulist_value; - while (max_list_index >= min_list_index) + min_list_index= list_index + 1; + else if (list_value > part_func_value) { - list_index= (max_list_index + min_list_index) >> 1; - ulist_value= list_array[list_index].list_value; - if (ulist_value < upart_func_value) - min_list_index= list_index + 1; - else if (ulist_value > upart_func_value) - { - if (!list_index) - goto notfound_unsigned; - max_list_index= list_index - 1; - } - else - { - DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); - } + if (!list_index) + goto notfound; + max_list_index= list_index - 1; + } + else + { + DBUG_RETURN(list_index + test(left_endpoint ^ include_endpoint)); } - notfound_unsigned: - if (ulist_value < upart_func_value) - list_index++; - DBUG_RETURN(list_index); } +notfound: + if (list_value < part_func_value) + list_index++; + DBUG_RETURN(list_index); } @@ -2568,52 +2516,26 @@ int get_partition_id_range(partition_info *part_info, *part_id= 0; DBUG_RETURN(0); } + if (unsigned_flag) + part_func_value-= 0x8000000000000000ULL; *func_value= part_func_value; - if (!unsigned_flag) + while (max_part_id > min_part_id) { - while (max_part_id > min_part_id) - { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - if (range_array[loc_part_id] <= part_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - if (part_func_value >= range_array[loc_part_id]) - if (loc_part_id != max_partition) - loc_part_id++; - *part_id= (uint32)loc_part_id; - if (loc_part_id == max_partition) - if (range_array[loc_part_id] != LONGLONG_MAX) - if (part_func_value >= range_array[loc_part_id]) - DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); - } - else - { - ulonglong upart_func_value= part_func_value; - ulonglong urange_value; - while (max_part_id > min_part_id) - { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - urange_value= range_array[loc_part_id]; - if (urange_value <= upart_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - urange_value= range_array[loc_part_id]; - if (upart_func_value >= urange_value) - if (loc_part_id != max_partition) - loc_part_id++; - *part_id= (uint32)loc_part_id; - urange_value= range_array[loc_part_id]; - if (loc_part_id == max_partition) - if (urange_value != ULONGLONG_MAX) - if (upart_func_value >= urange_value) - DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + if (range_array[loc_part_id] <= part_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; } + loc_part_id= max_part_id; + if (part_func_value >= range_array[loc_part_id]) + if (loc_part_id != max_partition) + loc_part_id++; + *part_id= (uint32)loc_part_id; + if (loc_part_id == max_partition) + if (range_array[loc_part_id] != LONGLONG_MAX) + if (part_func_value >= range_array[loc_part_id]) + DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); DBUG_RETURN(0); } @@ -2671,71 +2593,34 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_partition_id_range_for_endpoint"); - if (!unsigned_flag) + if (unsigned_flag) + part_func_value-= 0x8000000000000000ULL; + while (max_part_id > min_part_id) { - while (max_part_id > min_part_id) - { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - if (range_array[loc_part_id] <= part_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - if (loc_part_id < max_partition && - part_func_value >= range_array[loc_part_id+1]) - { - loc_part_id++; - } - if (left_endpoint) - { - if (part_func_value >= range_array[loc_part_id]) - loc_part_id++; - } - else - { - if (part_func_value == range_array[loc_part_id]) - loc_part_id += test(include_endpoint); - else if (part_func_value > range_array[loc_part_id]) - loc_part_id++; - loc_part_id++; - } + loc_part_id= (max_part_id + min_part_id + 1) >> 1; + if (range_array[loc_part_id] <= part_func_value) + min_part_id= loc_part_id + 1; + else + max_part_id= loc_part_id - 1; } - else + loc_part_id= max_part_id; + if (loc_part_id < max_partition && + part_func_value >= range_array[loc_part_id+1]) { - ulonglong upart_func_value= part_func_value; - ulonglong urange_value; - while (max_part_id > min_part_id) - { - loc_part_id= (max_part_id + min_part_id + 1) >> 1; - urange_value= range_array[loc_part_id]; - if (urange_value <= upart_func_value) - min_part_id= loc_part_id + 1; - else - max_part_id= loc_part_id - 1; - } - loc_part_id= max_part_id; - urange_value= range_array[loc_part_id+1]; - if (loc_part_id < max_partition && - upart_func_value >= urange_value) - { - loc_part_id++; - } - if (left_endpoint) - { - urange_value= range_array[loc_part_id]; - if (upart_func_value >= urange_value) - loc_part_id++; - } - else - { - urange_value= range_array[loc_part_id]; - if (upart_func_value == urange_value) - loc_part_id += test(include_endpoint); - else if (upart_func_value > urange_value) - loc_part_id++; + loc_part_id++; + } + if (left_endpoint) + { + if (part_func_value >= range_array[loc_part_id]) loc_part_id++; - } + } + else + { + if (part_func_value == range_array[loc_part_id]) + loc_part_id += test(include_endpoint); + else if (part_func_value > range_array[loc_part_id]) + loc_part_id++; + loc_part_id++; } DBUG_RETURN(loc_part_id); } From 5efb70d7771c905b61e5e01e2f0643a5953adb83 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 09:59:45 -0700 Subject: [PATCH 14/43] Fixed some problems for Windows build VC++Files/client/mysql.dsp: Fixed omission of mysys\my_conio.c. VC++Files/client/mysql_ia64.dsp: Fixed omission of mysys\my_conio.c. client/mysqldump.c: VS compiler does not accept variable declarations within blocks. Such a behaviour complies with the Standard C. --- VC++Files/client/mysql.dsp | 4 ++++ VC++Files/client/mysql_ia64.dsp | 4 ++++ client/mysqldump.c | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index 8298e62d8ad..c19e7b7d7fe 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -144,6 +144,10 @@ SOURCE=.\readline.cpp # End Source File # Begin Source File +SOURCE=..\mysys\my_conio.c +# End Source File +# Begin Source File + SOURCE=.\sql_string.cpp # End Source File # End Target diff --git a/VC++Files/client/mysql_ia64.dsp b/VC++Files/client/mysql_ia64.dsp index 3fe2e2a2328..8de283d1e0b 100644 --- a/VC++Files/client/mysql_ia64.dsp +++ b/VC++Files/client/mysql_ia64.dsp @@ -130,6 +130,10 @@ SOURCE=.\readline.cpp # End Source File # Begin Source File +SOURCE=..\mysys\my_conio.c +# End Source File +# Begin Source File + SOURCE=.\sql_string.cpp # End Source File # End Target diff --git a/client/mysqldump.c b/client/mysqldump.c index e8f96016153..3445a23eb5e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2222,6 +2222,7 @@ static int dump_all_tables_in_db(char *database) static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root) { char *name= 0; + ulong *lengths; MYSQL_RES *tableRes; MYSQL_ROW row; char query[50 + 2*NAME_LEN]; @@ -2246,7 +2247,7 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root) if (numRows > 0) { row= mysql_fetch_row( tableRes ); - ulong *lengths= mysql_fetch_lengths(tableRes); + lengths= mysql_fetch_lengths(tableRes); name= strmake_root(root, row[0], lengths[0]); } mysql_free_result(tableRes); From 7fafb1eaff524266125eb5c54f35f51eda46a677 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jun 2006 13:19:46 -0400 Subject: [PATCH 15/43] BUG#16002: After review fixes Fixes for NDB sql/ha_ndbcluster.cc: Fixes for NDB sql/sql_partition.cc: Fixes for NDB --- sql/ha_ndbcluster.cc | 6 ++++++ sql/sql_partition.cc | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 587eabb82d2..32f41bbb689 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -9499,6 +9499,7 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info) MYF(0)); uint i; int error= 0; + bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("set_range_data"); if (!range_data) @@ -9509,6 +9510,8 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info) for (i= 0; i < part_info->no_parts; i++) { longlong range_val= part_info->range_int_array[i]; + if (unsigned_flag) + range_val-= 0x8000000000000000ULL; if (range_val < INT_MIN32 || range_val >= INT_MAX32) { if ((i != part_info->no_parts - 1) || @@ -9535,6 +9538,7 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info) * sizeof(int32), MYF(0)); uint32 *part_id, i; int error= 0; + bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("set_list_data"); if (!list_data) @@ -9546,6 +9550,8 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info) { LIST_PART_ENTRY *list_entry= &part_info->list_array[i]; longlong list_val= list_entry->list_value; + if (unsigned_flag) + list_val-= 0x8000000000000000ULL; if (list_val < INT_MIN32 || list_val > INT_MAX32) { my_error(ER_LIMITED_PART_RANGE, MYF(0), "NDB"); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 086b7f28b1e..a9f9e59c0cc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2394,9 +2394,9 @@ int get_partition_id_list(partition_info *part_info, } goto notfound; } + *func_value= part_func_value; if (unsigned_flag) part_func_value-= 0x8000000000000000ULL; - *func_value= part_func_value; while (max_list_index >= min_list_index) { list_index= (max_list_index + min_list_index) >> 1; @@ -2509,16 +2509,16 @@ int get_partition_id_range(partition_info *part_info, uint loc_part_id; longlong part_func_value= part_val_int(part_info->part_expr); bool unsigned_flag= part_info->part_expr->unsigned_flag; - DBUG_ENTER("get_partition_id_int_range"); + DBUG_ENTER("get_partition_id_range"); if (part_info->part_expr->null_value) { *part_id= 0; DBUG_RETURN(0); } + *func_value= part_func_value; if (unsigned_flag) part_func_value-= 0x8000000000000000ULL; - *func_value= part_func_value; while (max_part_id > min_part_id) { loc_part_id= (max_part_id + min_part_id + 1) >> 1; From 8da354ea7db426fc3a5bde9fc946547b956b19f7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jun 2006 14:46:10 +0200 Subject: [PATCH 16/43] Import from yaSSL to fix bild problems on AIX(already fixed but was lost during last import) extra/yassl/taocrypt/include/runtime.hpp: Import patch yassl.diff --- extra/yassl/taocrypt/include/runtime.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 3a5cf62865a..88559cb0ca0 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -28,6 +28,9 @@ #ifndef yaSSL_NEW_HPP #define yaSSL_NEW_HPP +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #ifdef __sun From a74154f4de0b4f3765eb06932fb9ec3e79f764e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Jun 2006 19:29:39 -0700 Subject: [PATCH 17/43] Post-merge fixes --- mysql-test/r/sysdate_is_now.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/sysdate_is_now.result b/mysql-test/r/sysdate_is_now.result index 82861436ff6..1ebbb8c1588 100644 --- a/mysql-test/r/sysdate_is_now.result +++ b/mysql-test/r/sysdate_is_now.result @@ -1,4 +1,4 @@ set timestamp=1; SELECT sleep(1),NOW()-SYSDATE() as zero; sleep(1) zero -0 0 +0 0.000000 From 01e8913e7751a04fa7045974147e6fec5f7c150d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jun 2006 06:50:11 -0700 Subject: [PATCH 18/43] Bug#20168 "Change in behavior --default-storage-engine=ndb or ndbcluster" Reduce use of legacy_db_type, some code cleanup (serg read my mind and implemented desired mysqld.cc changes) sql/handler.cc: Bug#20168 remove some use of legacy_db_type cleanup code, new func for default type sql/handler.h: Bug#20168 remove some use of legacy_db_type cleanup code, new func for default type sql/sql_plugin.cc: compiler hints, consts sql/sql_plugin.h: compiler hints, consts sql/sql_tablespace.cc: use ha_default_handlerton instead of resolving DB_TYPE_DEFAULT --- sql/handler.cc | 84 ++++++++++++++++++++++++++++++------------- sql/handler.h | 7 ++-- sql/sql_plugin.cc | 22 ++++++------ sql/sql_plugin.h | 10 +++--- sql/sql_tablespace.cc | 2 +- 5 files changed, 78 insertions(+), 47 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 81c42f9da15..47bcf1caba1 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -68,14 +68,14 @@ ulong total_ha_2pc= 0; /* size of savepoint storage area (see ha_init) */ ulong savepoint_alloc_size= 0; -struct show_table_alias_st sys_table_aliases[]= +static const LEX_STRING sys_table_aliases[]= { - {"INNOBASE", DB_TYPE_INNODB}, - {"NDB", DB_TYPE_NDBCLUSTER}, - {"BDB", DB_TYPE_BERKELEY_DB}, - {"HEAP", DB_TYPE_HEAP}, - {"MERGE", DB_TYPE_MRG_MYISAM}, - {NullS, DB_TYPE_UNKNOWN} + {(char*)STRING_WITH_LEN("INNOBASE")}, {(char*)STRING_WITH_LEN("INNODB")}, + {(char*)STRING_WITH_LEN("NDB")}, {(char*)STRING_WITH_LEN("NDBCLUSTER")}, + {(char*)STRING_WITH_LEN("BDB")}, {(char*)STRING_WITH_LEN("BERKELEYDB")}, + {(char*)STRING_WITH_LEN("HEAP")}, {(char*)STRING_WITH_LEN("MEMORY")}, + {(char*)STRING_WITH_LEN("MERGE")}, {(char*)STRING_WITH_LEN("MRG_MYISAM")}, + {NullS, 0} }; const char *ha_row_type[] = { @@ -91,15 +91,50 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"", static TYPELIB known_extensions= {0,"known_exts", NULL, NULL}; uint known_extensions_id= 0; -handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name) + +/* + Return the default storage engine handlerton for thread + + SYNOPSIS + ha_default_handlerton(thd) + thd current thread + + RETURN + pointer to handlerton +*/ + +handlerton *ha_default_handlerton(THD *thd) { - show_table_alias_st *table_alias; + return (thd->variables.table_type != NULL) ? + thd->variables.table_type : + (global_system_variables.table_type != NULL ? + global_system_variables.table_type : &myisam_hton); +} + + +/* + Return the storage engine handlerton for the supplied name + + SYNOPSIS + ha_resolve_by_name(thd, name) + thd current thread + name name of storage engine + + RETURN + pointer to handlerton +*/ + +handlerton *ha_resolve_by_name(THD *thd, const LEX_STRING *name) +{ + const LEX_STRING *table_alias; st_plugin_int *plugin; - if (thd && !my_strnncoll(&my_charset_latin1, +redo: + /* my_strnncoll is a macro and gcc doesn't do early expansion of macro */ + if (thd && !my_charset_latin1.coll->strnncoll(&my_charset_latin1, (const uchar *)name->str, name->length, - (const uchar *)"DEFAULT", 7)) - return ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT); + (const uchar *)STRING_WITH_LEN("DEFAULT"), 0)) + return ha_default_handlerton(thd); if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN))) { @@ -112,13 +147,15 @@ handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name) /* We check for the historical aliases. */ - for (table_alias= sys_table_aliases; table_alias->type; table_alias++) + for (table_alias= sys_table_aliases; table_alias->str; table_alias+= 2) { if (!my_strnncoll(&my_charset_latin1, (const uchar *)name->str, name->length, - (const uchar *)table_alias->alias, - strlen(table_alias->alias))) - return ha_resolve_by_legacy_type(thd, table_alias->type); + (const uchar *)table_alias->str, table_alias->length)) + { + name= table_alias + 1; + goto redo; + } } return NULL; @@ -130,20 +167,20 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type) switch (db_type) { case DB_TYPE_DEFAULT: return "DEFAULT"; - case DB_TYPE_UNKNOWN: - return "UNKNOWN"; default: if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT && installed_htons[db_type]) return hton2plugin[installed_htons[db_type]->slot]->name.str; - return "*NONE*"; + /* fall through */ + case DB_TYPE_UNKNOWN: + return "UNKNOWN"; } } static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root) { - handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT); + handlerton *hton= ha_default_handlerton(current_thd); return (hton && hton->create) ? hton->create(table, mem_root) : NULL; } @@ -152,10 +189,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type) { switch (db_type) { case DB_TYPE_DEFAULT: - return (thd->variables.table_type != NULL) ? - thd->variables.table_type : - (global_system_variables.table_type != NULL ? - global_system_variables.table_type : &myisam_hton); + return ha_default_handlerton(thd); case DB_TYPE_UNKNOWN: return NULL; default: @@ -196,7 +230,7 @@ handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type, break; } - return ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT); + return ha_default_handlerton(thd); } /* ha_checktype */ diff --git a/sql/handler.h b/sql/handler.h index f459d52fdeb..52843b78266 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -667,10 +667,6 @@ struct handlerton struct handler_iterator *fill_this_in); }; -struct show_table_alias_st { - const char *alias; - enum legacy_db_type type; -}; /* Possible flags of a handlerton */ #define HTON_NO_FLAGS 0 @@ -1545,7 +1541,8 @@ extern ulong total_ha, total_ha_2pc; #define ha_rollback(thd) (ha_rollback_trans((thd), TRUE)) /* lookups */ -handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name); +handlerton *ha_default_handlerton(THD *thd); +handlerton *ha_resolve_by_name(THD *thd, const LEX_STRING *name); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); const char *ha_get_storage_engine(enum legacy_db_type db_type); handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index c15b484f448..f7205470abd 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -23,7 +23,7 @@ extern struct st_mysql_plugin *mysqld_builtins[]; char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; -LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]= +const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]= { { (char *)STRING_WITH_LEN("UDF") }, { (char *)STRING_WITH_LEN("STORAGE ENGINE") }, @@ -63,7 +63,7 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM]; static rw_lock_t THR_LOCK_plugin; static bool initialized= 0; -static struct st_plugin_dl *plugin_dl_find(LEX_STRING *dl) +static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl) { uint i; DBUG_ENTER("plugin_dl_find"); @@ -112,7 +112,7 @@ static inline void free_plugin_mem(struct st_plugin_dl *p) my_free((gptr)p->plugins, MYF(MY_ALLOW_ZERO_PTR)); } -static st_plugin_dl *plugin_dl_add(LEX_STRING *dl, int report) +static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) { #ifdef HAVE_DLOPEN char dlpath[FN_REFLEN]; @@ -294,7 +294,7 @@ static st_plugin_dl *plugin_dl_add(LEX_STRING *dl, int report) } -static void plugin_dl_del(LEX_STRING *dl) +static void plugin_dl_del(const LEX_STRING *dl) { #ifdef HAVE_DLOPEN uint i; @@ -322,7 +322,7 @@ static void plugin_dl_del(LEX_STRING *dl) } -static struct st_plugin_int *plugin_find_internal(LEX_STRING *name, int type) +static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type) { uint i; DBUG_ENTER("plugin_find_internal"); @@ -345,7 +345,7 @@ static struct st_plugin_int *plugin_find_internal(LEX_STRING *name, int type) } -my_bool plugin_is_ready(LEX_STRING *name, int type) +my_bool plugin_is_ready(const LEX_STRING *name, int type) { my_bool rc= FALSE; struct st_plugin_int *plugin; @@ -359,7 +359,7 @@ my_bool plugin_is_ready(LEX_STRING *name, int type) } -struct st_plugin_int *plugin_lock(LEX_STRING *name, int type) +struct st_plugin_int *plugin_lock(const LEX_STRING *name, int type) { struct st_plugin_int *rc; DBUG_ENTER("plugin_lock"); @@ -396,7 +396,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) struct st_plugin_int *)); } -static my_bool plugin_add(LEX_STRING *name, LEX_STRING *dl, int report) +static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int report) { struct st_plugin_int tmp; struct st_mysql_plugin *plugin; @@ -479,7 +479,7 @@ err: } -static void plugin_del(LEX_STRING *name) +static void plugin_del(const LEX_STRING *name) { uint i; struct st_plugin_int *plugin; @@ -811,7 +811,7 @@ void plugin_free(void) } -my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl) +my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl) { TABLE_LIST tables; TABLE *table; @@ -866,7 +866,7 @@ err: } -my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name) +my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) { TABLE *table; TABLE_LIST tables; diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index b013beaba1f..df7c9a39495 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -66,15 +66,15 @@ typedef int (*plugin_type_init)(struct st_plugin_int *); extern char *opt_plugin_dir_ptr; extern char opt_plugin_dir[FN_REFLEN]; -extern LEX_STRING plugin_type_names[]; +extern const LEX_STRING plugin_type_names[]; extern int plugin_init(void); extern void plugin_load(void); extern void plugin_free(void); -extern my_bool plugin_is_ready(LEX_STRING *name, int type); -extern st_plugin_int *plugin_lock(LEX_STRING *name, int type); +extern my_bool plugin_is_ready(const LEX_STRING *name, int type); +extern st_plugin_int *plugin_lock(const LEX_STRING *name, int type); extern void plugin_unlock(struct st_plugin_int *plugin); -extern my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl); -extern my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name); +extern my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl); +extern my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name); extern my_bool plugin_register_builtin(struct st_mysql_plugin *plugin); diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc index 94318a67575..13dfb491af4 100644 --- a/sql/sql_tablespace.cc +++ b/sql/sql_tablespace.cc @@ -30,7 +30,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) */ if (hton == NULL || hton->state != SHOW_OPTION_YES) { - hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT); + hton= ha_default_handlerton(thd); if (ts_info->storage_engine != 0) push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_WARN_USING_OTHER_HANDLER, From 55559673f3a7fb44707bff2db8f10f402d1f1ec9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 16:44:30 +0200 Subject: [PATCH 19/43] Fixed incorrect handling of renamed fields, forcing copy of table if needed and added optional system variable ndb_use_copying_alter_table --- sql/ha_ndbcluster.cc | 11 +++++++++++ sql/mysqld.cc | 7 +++++++ sql/set_var.cc | 4 ++++ sql/sql_class.h | 1 + 4 files changed, 23 insertions(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 94fb7e6eb5c..b3ff91cb823 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -9824,10 +9824,21 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *info, uint i; const NDBTAB *tab= (const NDBTAB *) m_table; + if (current_thd->variables.ndb_use_copying_alter_table) + { + DBUG_PRINT("info", ("On-line alter table disabled")); + DBUG_RETURN(COMPATIBLE_DATA_NO); + } + for (i= 0; i < table->s->fields; i++) { Field *field= table->field[i]; const NDBCOL *col= tab->getColumn(field->field_name); + if (!col) + { + DBUG_PRINT("info", ("Field has been renamed, copy table")); + DBUG_RETURN(COMPATIBLE_DATA_NO); + } if ((field->flags & FIELD_IN_ADD_INDEX) && col->getStorageType() == NdbDictionary::Column::StorageTypeDisk) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 56c3b1857a8..1a576616966 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4695,6 +4695,7 @@ enum options_mysqld OPT_NDB_EXTRA_LOGGING, OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, + OPT_NDB_USE_COPYING_ALTER_TABLE, OPT_SKIP_SAFEMALLOC, OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE, OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS, @@ -5430,6 +5431,12 @@ Disable with --skip-ndbcluster (will save memory).", (gptr*) &max_system_variables.ndb_index_stat_update_freq, 0, GET_ULONG, OPT_ARG, 20, 0, ~0L, 0, 0, 0}, #endif + {"nb-use-copying-alter-table", + OPT_NDB_USE_COPYING_ALTER_TABLE, + "Force ndbcluster to always copy tables at alter table (used for ensuring that operations such as renaming fields are propagated to ndb data dictionary).", + (gptr*) &global_system_variables.ndb_use_copying_alter_table, + (gptr*) &global_system_variables.ndb_use_copying_alter_table, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"new", 'n', "Use very new possible 'unsafe' functions.", (gptr*) &global_system_variables.new_mode, (gptr*) &max_system_variables.new_mode, diff --git a/sql/set_var.cc b/sql/set_var.cc index 53b4b395c37..a44395c74ca 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -548,6 +548,8 @@ sys_ndb_index_stat_update_freq("ndb_index_stat_update_freq", &SV::ndb_index_stat_update_freq); sys_var_long_ptr sys_ndb_extra_logging("ndb_extra_logging", &ndb_extra_logging); +sys_var_thd_bool +sys_ndb_use_copying_alter_table("ndb_use_copying_alter_table", &SV::ndb_use_copying_alter_table); /* Time/date/datetime formats */ @@ -917,6 +919,8 @@ SHOW_VAR init_vars[]= { {sys_ndb_report_thresh_binlog_mem_usage.name, (char*) &sys_ndb_report_thresh_binlog_mem_usage, SHOW_SYS}, #endif + {sys_ndb_use_copying_alter_table.name, + (char*) &sys_ndb_use_copying_alter_table, SHOW_SYS}, {sys_ndb_use_exact_count.name,(char*) &sys_ndb_use_exact_count, SHOW_SYS}, {sys_ndb_use_transactions.name,(char*) &sys_ndb_use_transactions, SHOW_SYS}, {sys_net_buffer_length.name,(char*) &sys_net_buffer_length, SHOW_SYS}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 03a8439db58..450a8d041c9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -244,6 +244,7 @@ struct system_variables my_bool innodb_table_locks; my_bool innodb_support_xa; my_bool ndb_force_send; + my_bool ndb_use_copying_alter_table; my_bool ndb_use_exact_count; my_bool ndb_use_transactions; my_bool ndb_index_stat_enable; From 60be734e52dfa96aa4cec371d1b41c2ba1efcbb8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 14:36:23 -0400 Subject: [PATCH 20/43] BUG#19307: CSV engine can cause crashes in partitioned tables (due to its conversion of NULLs to 0) mysql-test/r/partition.result: New test case mysql-test/t/partition.test: New test case sql/partition_info.cc: Disable CSV engine for partitioned tables sql/share/errmsg.txt: Update error message for more flexibility sql/sql_partition.cc: Editing fixes --- mysql-test/r/partition.result | 5 +++++ mysql-test/t/partition.test | 12 ++++++++++++ sql/partition_info.cc | 6 ++++-- sql/share/errmsg.txt | 4 ++-- sql/sql_partition.cc | 6 +++--- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 3be9f3edee2..2aacbd23b1e 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,5 +1,10 @@ drop table if exists t1; create table t1 (a int) +engine = csv +partition by list (a) +(partition p0 values in (null)); +ERROR HY000: CSV handler cannot be used in partitioned tables +create table t1 (a int) partition by key(a) (partition p0 engine = MEMORY); drop table t1; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index a24124d3fb5..8773eb2f2e3 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,17 @@ drop table if exists t1; --enable_warnings +# +# Bug 19307: CSV engine crashes +# +--error ER_PARTITION_MERGE_ERROR +create table t1 (a int) +engine = csv +partition by list (a) +(partition p0 values in (null)); + +# +# create table t1 (a int) partition by key(a) (partition p0 engine = MEMORY); @@ -1077,4 +1088,5 @@ OPTIMIZE TABLE t1; drop table t1; + --echo End of 5.1 tests diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 0924a8adf6e..0af200dc4d2 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -442,9 +442,11 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts) DBUG_RETURN(TRUE); } } while (++i < no_parts); - if (engine_array[0] == &myisammrg_hton) + if (engine_array[0] == &myisammrg_hton || + engine_array[0] == &tina_hton) { - my_error(ER_PARTITION_MERGE_ERROR, MYF(0)); + my_error(ER_PARTITION_MERGE_ERROR, MYF(0), + engine_array[0] == &myisammrg_hton ? "MyISAM Merge" : "CSV"); DBUG_RETURN(TRUE); } DBUG_RETURN(FALSE); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 5aab951b2ca..9a0319a88b5 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5849,5 +5849,5 @@ ER_EVENT_MODIFY_QUEUE_ERROR ER_EVENT_SET_VAR_ERROR eng "Error during starting/stopping of the scheduler. Error code %u" ER_PARTITION_MERGE_ERROR - eng "MyISAM Merge handler cannot be used in partitioned tables" - swe "MyISAM Merge kan inte anändas i en partitionerad tabell" + eng "%s handler cannot be used in partitioned tables" + swe "%s kan inte användas i en partitionerad tabell" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e946e972968..73fc699989e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (C) 2005, 2006 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -238,8 +238,8 @@ bool partition_default_handling(TABLE *table, partition_info *part_info, check_reorganise_list() new_part_info New partition info old_part_info Old partition info - list_part_names The list of partition names that will go away and can be reused in the - new table. + list_part_names The list of partition names that will go away and + can be reused in the new table. RETURN VALUES TRUE Inacceptable name conflict detected. From b4b3f31d5207700305cdc0c66e6420c383bb7db8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 13:00:06 -0700 Subject: [PATCH 21/43] Bug#20168 "--default-storage-engine=XXX" doesn't work typo in the code and forgotten changes sql/mysqld.cc: Bug#20168 typo and forgotten changes --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 56c3b1857a8..b1d77a87191 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4983,11 +4983,12 @@ Disable with --skip-bdb (will save memory).", (gptr*) &default_collation_name, (gptr*) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"default-storage-engine", OPT_STORAGE_ENGINE, - "Set the default storage engine (table type) for tables.", 0, 0, + "Set the default storage engine (table type) for tables.", + (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-table-type", OPT_STORAGE_ENGINE, "(deprecated) Use --default-storage-engine.", - (gptr*)default_storage_engine_str, (gptr*)default_storage_engine_str, + (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.", (gptr*) &default_tz_name, (gptr*) &default_tz_name, From 748f589ecde3fca1610db5e5512daacc6e14aba2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 01:19:13 +0200 Subject: [PATCH 22/43] correct initialization of event operation to enable early delete --- storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index c8f05f3a96c..e0b8043a8ff 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -79,7 +79,8 @@ NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &f, NdbEventOperation(*this), m_facade(&f), m_ndb(theNdb), - m_state(EO_ERROR) + m_state(EO_ERROR), + m_oid(~(Uint32)0) { DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl"); @@ -88,7 +89,11 @@ NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &f, assert(myDict != NULL); const NdbDictionary::Event *myEvnt = myDict->getEvent(eventName); - if (!myEvnt) { m_error.code= myDict->getNdbError().code; DBUG_VOID_RETURN; } + if (!myEvnt) + { + m_error.code= myDict->getNdbError().code; + DBUG_VOID_RETURN; + } init(myEvnt->m_impl); DBUG_VOID_RETURN; @@ -99,7 +104,8 @@ NdbEventOperationImpl::NdbEventOperationImpl(Ndb *theNdb, NdbEventOperation(*this), m_facade(this), m_ndb(theNdb), - m_state(EO_ERROR) + m_state(EO_ERROR), + m_oid(~(Uint32)0) { DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl [evnt]"); init(evnt); @@ -113,7 +119,6 @@ NdbEventOperationImpl::init(NdbEventImpl& evnt) m_magic_number = 0; mi_type = 0; - m_oid = ~(Uint32)0; m_change_mask = 0; #ifdef VM_TRACE m_data_done_count = 0; @@ -173,6 +178,9 @@ NdbEventOperationImpl::~NdbEventOperationImpl() DBUG_ENTER("NdbEventOperationImpl::~NdbEventOperationImpl"); m_magic_number= 0; + if (m_oid == ~(Uint32)0) + DBUG_VOID_RETURN; + stop(); // m_bufferHandle->dropSubscribeEvent(m_bufferId); ; // ToDo? We should send stop signal here From 17f566506efaed3edd6d37e9ca2bed98dc402715 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 01:20:39 +0200 Subject: [PATCH 23/43] ndb: add missing LOCK_open --- sql/ha_ndbcluster.cc | 2 ++ sql/ha_ndbcluster_binlog.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 94fb7e6eb5c..d8f4ddac73c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -5848,6 +5848,7 @@ int ndbcluster_drop_database_impl(const char *path) while ((tabname=it++)) { tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1); + VOID(pthread_mutex_lock(&LOCK_open)); if (ha_ndbcluster::delete_table(0, ndb, full_path, dbname, tabname)) { const NdbError err= dict->getNdbError(); @@ -5857,6 +5858,7 @@ int ndbcluster_drop_database_impl(const char *path) ret= ndb_to_mysql_error(&err); } } + VOID(pthread_mutex_unlock(&LOCK_open)); } DBUG_RETURN(ret); } diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index af6eb74a236..022c8a021cb 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -286,6 +286,7 @@ ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share, int error; DBUG_ENTER("ndbcluster_binlog_open_table"); + safe_mutex_assert_owner(&LOCK_open); init_tmp_table_share(table_share, share->db, 0, share->table_name, share->key); if ((error= open_table_def(thd, table_share, 0))) From 6e53baebcbb501329f42b4c3db4212f40775ff31 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 22:40:05 -0400 Subject: [PATCH 24/43] BUG#19307: Removed non-static test case mysql-test/r/partition_mgm.result: Removed non-static test case mysql-test/t/partition_mgm.test: Removed non-static test case --- mysql-test/r/partition_mgm.result | 10 ---------- mysql-test/t/partition_mgm.test | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 7b7b5729112..48bbdf57b93 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -7,12 +7,6 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2 -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYD -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYI -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p1.MYD -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p1.MYI -/home/pappa/bug19305/mysql-test/var/master-data/test/t1.frm -/home/pappa/bug19305/mysql-test/var/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; Table Create Table @@ -20,7 +14,3 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1 -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYD -/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYI -/home/pappa/bug19305/mysql-test/var/master-data/test/t1.frm -/home/pappa/bug19305/mysql-test/var/master-data/test/t1.par diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index aa9a6459a1a..67c0619f28c 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -5,10 +5,10 @@ CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2; SHOW CREATE TABLE t1; ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; ---exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* From 2252f6a7f0eec42810437339154b6934b2b9207f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 10:23:08 +0200 Subject: [PATCH 25/43] Update test result to 5.1 format mysql-test/r/create_not_windows.result: Update test result to use uppercase for keywords --- mysql-test/r/create_not_windows.result | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/create_not_windows.result b/mysql-test/r/create_not_windows.result index b975c98c2b1..2d7fd30dfdd 100644 --- a/mysql-test/r/create_not_windows.result +++ b/mysql-test/r/create_not_windows.result @@ -7,8 +7,8 @@ primary key (_id) show create table `about:text`; Table Create Table about:text CREATE TABLE `about:text` ( - `_id` int(11) NOT NULL auto_increment, - `about:text` varchar(255) NOT NULL default '', - PRIMARY KEY (`_id`) + `_id` int(11) NOT NULL AUTO_INCREMENT, + `about:text` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table `about:text`; From 1025a02ac143fcb88f7a27db54ff06fbf711bfaf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 13:52:16 +0500 Subject: [PATCH 26/43] after merege fix --- mysql-test/r/information_schema.result | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 7bd8fefbdde..070049b303a 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1158,14 +1158,6 @@ routine_name delete from proc where name=''; use test; -select * from information_schema.engines WHERE ENGINE="MyISAM"; -ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO -grant select on *.* to user3148@localhost; -select user,db from information_schema.processlist; -user db -user3148 test -drop user user3148@localhost; grant select on test.* to mysqltest_1@localhost; create table t1 (id int); create view v1 as select * from t1; @@ -1188,3 +1180,11 @@ concat(@a, table_name) @a table_name .t1 . t1 .t2 . t2 drop table t1,t2; +select * from information_schema.engines WHERE ENGINE="MyISAM"; +ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS +MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO +grant select on *.* to user3148@localhost; +select user,db from information_schema.processlist; +user db +user3148 test +drop user user3148@localhost; From cf0374854b09e9e634964efef91325d2e61f3938 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 11:08:36 +0200 Subject: [PATCH 27/43] Added flag to detect renaming of fields (not supported as fast alter table for ndbcluster) --- include/mysql_com.h | 1 + sql/ha_ndbcluster.cc | 4 ++-- sql/sql_table.cc | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index 623aaf43783..c65f5944747 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -99,6 +99,7 @@ enum enum_server_command #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */ #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */ #define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */ +#define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */ #define REFRESH_GRANT 1 /* Refresh grant tables */ #define REFRESH_LOG 2 /* Start on new log file */ diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index b3ff91cb823..e07c696d46e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -9833,8 +9833,8 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *info, for (i= 0; i < table->s->fields; i++) { Field *field= table->field[i]; - const NDBCOL *col= tab->getColumn(field->field_name); - if (!col) + const NDBCOL *col= tab->getColumn(i); + if (field->flags & FIELD_IS_RENAMED) { DBUG_PRINT("info", ("Field has been renamed, copy table")); DBUG_RETURN(COMPATIBLE_DATA_NO); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e9c89b4983d..c0db7120b86 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4744,6 +4744,11 @@ static uint compare_tables(TABLE *table, List *create_list, create_info->row_type != ROW_TYPE_FIXED) create_info->table_options|= HA_OPTION_PACK_RECORD; + /* Check if field was renamed */ + if (my_strcasecmp(system_charset_info, + field->field_name, + new_field->field_name)) + field->flags|= FIELD_IS_RENAMED; /* Evaluate changes bitmap and send to check_if_incompatible_data() */ if (!(tmp= field->is_equal(new_field))) DBUG_RETURN(ALTER_TABLE_DATA_CHANGED); From d70df431284f76771f9965b6d620626b5f03392b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 11:38:55 +0200 Subject: [PATCH 28/43] Added flag to detect renaming of fields (not supported as fast alter table for ndbcluster): added test case --- mysql-test/r/ndb_alter_table.result | 7 ++++++- mysql-test/t/ndb_alter_table.test | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index e506973f347..7facb5fa286 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -320,8 +320,13 @@ LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; set @t1_id = (select id from ndb_show_tables where name like '%t1%'); truncate ndb_show_tables; alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; +no_copy +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; create index i1 on t1(medium); -alter table t1 add index i2(long_int); +alter table t1 add index i2(new_tiny); drop index i1 on t1; LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 8e3b4a6ca89..73c612b203f 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -367,12 +367,23 @@ CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR( LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; --enable_warnings +# Ndb doesn't support renaming attributes on-line set @t1_id = (select id from ndb_show_tables where name like '%t1%'); truncate ndb_show_tables; alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--enable_warnings + +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; + +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; + create index i1 on t1(medium); -alter table t1 add index i2(long_int); +alter table t1 add index i2(new_tiny); drop index i1 on t1; --disable_warnings From 0795b20b625e1df969e29585b70ed3e57e130203 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 12:01:06 +0200 Subject: [PATCH 29/43] Added flag to detect renaming of fields (not supported as fast alter table for ndbcluster): psot review comment: cleared flag before checking --- sql/sql_table.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c0db7120b86..3ac41d2910f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4745,10 +4745,12 @@ static uint compare_tables(TABLE *table, List *create_list, create_info->table_options|= HA_OPTION_PACK_RECORD; /* Check if field was renamed */ + field->flags&= ~FIELD_IS_RENAMED; if (my_strcasecmp(system_charset_info, field->field_name, new_field->field_name)) field->flags|= FIELD_IS_RENAMED; + /* Evaluate changes bitmap and send to check_if_incompatible_data() */ if (!(tmp= field->is_equal(new_field))) DBUG_RETURN(ALTER_TABLE_DATA_CHANGED); From 2bd4fb46695c565459a41da1cc53860751d50703 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 12:21:18 +0200 Subject: [PATCH 30/43] Bug #18595 repeated create, insert, drop can cause MySQL table definition cache to corrupt - add infinite retry on drop table temporary error mysql-test/r/ndb_restore_partition.result: New BitKeeper file ``mysql-test/r/ndb_restore_partition.result'' mysql-test/t/ndb_restore_partition-master.opt: New BitKeeper file ``mysql-test/t/ndb_restore_partition-master.opt'' mysql-test/t/ndb_restore_partition.test: New BitKeeper file ``mysql-test/t/ndb_restore_partition.test'' --- mysql-test/r/ndb_restore_partition.result | 469 ++++++++++++++++++ mysql-test/t/ndb_restore_partition-master.opt | 1 + mysql-test/t/ndb_restore_partition.test | 375 ++++++++++++++ sql/ha_ndbcluster.cc | 78 ++- 4 files changed, 906 insertions(+), 17 deletions(-) create mode 100644 mysql-test/r/ndb_restore_partition.result create mode 100644 mysql-test/t/ndb_restore_partition-master.opt create mode 100644 mysql-test/t/ndb_restore_partition.test diff --git a/mysql-test/r/ndb_restore_partition.result b/mysql-test/r/ndb_restore_partition.result new file mode 100644 index 00000000000..7dc4057e615 --- /dev/null +++ b/mysql-test/r/ndb_restore_partition.result @@ -0,0 +1,469 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +CREATE TABLE `t1_c` ( +`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, +`goaledatta` char(2) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); +CREATE TABLE `t2_c` ( +`capgotod` smallint(5) unsigned NOT NULL auto_increment, +`gotod` smallint(5) unsigned NOT NULL default '0', +`goaledatta` char(2) default NULL, +`maturegarbagefa` varchar(32) default NULL, +`descrpooppo` varchar(64) default NULL, +`svcutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capgotod`), +KEY `i_quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +CREATE TABLE `t3_c` ( +`CapGoaledatta` smallint(5) unsigned NOT NULL default '0', +`capgotod` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4_c` ( +`capfa` bigint(20) unsigned NOT NULL auto_increment, +`realm` varchar(32) NOT NULL default '', +`authpwchap` varchar(32) default NULL, +`fa` varchar(32) NOT NULL default '', +`payyingatta` tinyint(4) NOT NULL default '0', +`status` char(1) default NULL, +PRIMARY KEY (`fa`,`realm`), +KEY `capfa` (`capfa`), +KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +CREATE TABLE `t5_c` ( +`capfa` bigint(20) unsigned NOT NULL default '0', +`gotod` smallint(5) unsigned NOT NULL default '0', +`orderutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6_c` ( +`capfa_parent` bigint(20) unsigned NOT NULL default '0', +`capfa_child` bigint(20) unsigned NOT NULL default '0', +`relatta` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +CREATE TABLE `t7_c` ( +`dardpo` char(15) NOT NULL default '', +`dardtestard` tinyint(3) unsigned NOT NULL default '0', +`FastFA` char(5) NOT NULL default '', +`FastCode` char(6) NOT NULL default '', +`Fastca` char(1) NOT NULL default '', +`Fastmag` char(1) NOT NULL default '', +`Beareratta` char(2) NOT NULL default '', +PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8_c` ( +`kattjame` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`aaaproxysessfa` varchar(255) default NULL, +`autologonallowed` char(1) default NULL, +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`acctoutputoctets` bigint(20) unsigned default NULL, +`acctinputoctets` bigint(20) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), +KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9_c` ( +`kattjame` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`actcoutpuocttets` bigint(20) unsigned default NULL, +`actinputocctets` bigint(20) unsigned default NULL, +`terminateraste` tinyint(3) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id + +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +ALTER TABLE t1_c +PARTITION BY RANGE (`capgoaledatta`) +(PARTITION p0 VALUES LESS THAN MAXVALUE); +ALTER TABLE t2_c +PARTITION BY LIST(`capgotod`) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6)); +ALTER TABLE t3_c +PARTITION BY HASH (`CapGoaledatta`); +ALTER TABLE t5_c +PARTITION BY HASH (`capfa`) +PARTITIONS 4; +ALTER TABLE t6_c +PARTITION BY LINEAR HASH (`relatta`) +PARTITIONS 4; +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id + +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id + +DROP TABLE test.backup_info; +Create table test/def/t2_c failed: Translate frm error +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t2_c; +520093696, diff --git a/mysql-test/t/ndb_restore_partition-master.opt b/mysql-test/t/ndb_restore_partition-master.opt new file mode 100644 index 00000000000..075c6392dde --- /dev/null +++ b/mysql-test/t/ndb_restore_partition-master.opt @@ -0,0 +1 @@ +--new diff --git a/mysql-test/t/ndb_restore_partition.test b/mysql-test/t/ndb_restore_partition.test new file mode 100644 index 00000000000..f11324492c2 --- /dev/null +++ b/mysql-test/t/ndb_restore_partition.test @@ -0,0 +1,375 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--enable_warnings + +CREATE TABLE `t1_c` ( + `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, + `goaledatta` char(2) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); + +CREATE TABLE `t2_c` ( + `capgotod` smallint(5) unsigned NOT NULL auto_increment, + `gotod` smallint(5) unsigned NOT NULL default '0', + `goaledatta` char(2) default NULL, + `maturegarbagefa` varchar(32) default NULL, + `descrpooppo` varchar(64) default NULL, + `svcutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capgotod`), + KEY `i_quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); + +CREATE TABLE `t3_c` ( + `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', + `capgotod` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); + +CREATE TABLE `t4_c` ( + `capfa` bigint(20) unsigned NOT NULL auto_increment, + `realm` varchar(32) NOT NULL default '', + `authpwchap` varchar(32) default NULL, + `fa` varchar(32) NOT NULL default '', + `payyingatta` tinyint(4) NOT NULL default '0', + `status` char(1) default NULL, + PRIMARY KEY (`fa`,`realm`), + KEY `capfa` (`capfa`), + KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); + +CREATE TABLE `t5_c` ( + `capfa` bigint(20) unsigned NOT NULL default '0', + `gotod` smallint(5) unsigned NOT NULL default '0', + `orderutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); + +CREATE TABLE `t6_c` ( + `capfa_parent` bigint(20) unsigned NOT NULL default '0', + `capfa_child` bigint(20) unsigned NOT NULL default '0', + `relatta` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); + +CREATE TABLE `t7_c` ( + `dardpo` char(15) NOT NULL default '', + `dardtestard` tinyint(3) unsigned NOT NULL default '0', + `FastFA` char(5) NOT NULL default '', + `FastCode` char(6) NOT NULL default '', + `Fastca` char(1) NOT NULL default '', + `Fastmag` char(1) NOT NULL default '', + `Beareratta` char(2) NOT NULL default '', + PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); + +CREATE TABLE `t8_c` ( + `kattjame` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `aaaproxysessfa` varchar(255) default NULL, + `autologonallowed` char(1) default NULL, + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `acctoutputoctets` bigint(20) unsigned default NULL, + `acctinputoctets` bigint(20) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), + KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); + +CREATE TABLE `t9_c` ( + `kattjame` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `actcoutpuocttets` bigint(20) unsigned default NULL, + `actinputocctets` bigint(20) unsigned default NULL, + `terminateraste` tinyint(3) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); + +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; + + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +# random output order?? +#show tables; + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# +# Try Partitioned tables as well +# +ALTER TABLE t1_c +PARTITION BY RANGE (`capgoaledatta`) +(PARTITION p0 VALUES LESS THAN MAXVALUE); + +ALTER TABLE t2_c +PARTITION BY LIST(`capgotod`) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6)); + +ALTER TABLE t3_c +PARTITION BY HASH (`CapGoaledatta`); + +ALTER TABLE t5_c +PARTITION BY HASH (`capfa`) +PARTITIONS 4; + +ALTER TABLE t6_c +PARTITION BY LINEAR HASH (`relatta`) +PARTITIONS 4; + +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# +# Drop all table except t2_c +# This to make sure that error returned from ndb_restore above is +# guaranteed to be from t2_c, this since order of tables in backup +# is none deterministic +# +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--source include/ndb_backup.inc +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id 2>&1 | grep Translate || true + +# +# Cleanup +# + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t2_c; +--enable_warnings + +# +# Test BUG#10287 +# + +--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,/" + +# End of 4.1 tests diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d8f4ddac73c..27fe2e889af 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4468,12 +4468,13 @@ int ha_ndbcluster::create(const char *name, TABLE *form, HA_CREATE_INFO *info) { + THD *thd= current_thd; NDBTAB tab; NDBCOL col; uint pack_length, length, i, pk_length= 0; const void *data, *pack_data; bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE); - bool is_truncate= (current_thd->lex->sql_command == SQLCOM_TRUNCATE); + bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE); DBUG_ENTER("ha_ndbcluster::create"); DBUG_PRINT("enter", ("name: %s", name)); @@ -4661,10 +4662,20 @@ int ha_ndbcluster::create(const char *name, Failed to create an index, drop the table (and all it's indexes) */ - if (dict->dropTableGlobal(*m_table) == 0) + while (dict->dropTableGlobal(*m_table)) { - m_table = 0; + switch (dict->getNdbError().status) + { + case NdbError::TemporaryError: + if (!thd->killed) + continue; // retry indefinitly + break; + default: + break; + } } + m_table = 0; + DBUG_RETURN(my_errno); } #ifdef HAVE_NDB_BINLOG @@ -4727,8 +4738,8 @@ int ha_ndbcluster::create(const char *name, */ if (share && !do_event_op) share->flags|= NSF_NO_BINLOG; - ndbcluster_log_schema_op(current_thd, share, - current_thd->query, current_thd->query_length, + ndbcluster_log_schema_op(thd, share, + thd->query, thd->query_length, share->db, share->table_name, m_table->getObjectId(), m_table->getObjectVersion(), @@ -5177,9 +5188,9 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb, THD *thd= current_thd; DBUG_ENTER("ha_ndbcluster::ndbcluster_delete_table"); NDBDICT *dict= ndb->getDictionary(); -#ifdef HAVE_NDB_BINLOG int ndb_table_id= 0; int ndb_table_version= 0; +#ifdef HAVE_NDB_BINLOG /* Don't allow drop table unless schema distribution table is setup @@ -5197,15 +5208,25 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb, int res= 0; if (h && h->m_table) { - if (dict->dropTableGlobal(*h->m_table)) - res= ndb_to_mysql_error(&dict->getNdbError()); -#ifdef HAVE_NDB_BINLOG - if (res == 0) +retry_temporary_error1: + if (dict->dropTableGlobal(*h->m_table) == 0) { ndb_table_id= h->m_table->getObjectId(); ndb_table_version= h->m_table->getObjectVersion(); } -#endif + else + { + switch (dict->getNdbError().status) + { + case NdbError::TemporaryError: + if (!thd->killed) + goto retry_temporary_error1; // retry indefinitly + break; + default: + break; + } + res= ndb_to_mysql_error(&dict->getNdbError()); + } h->release_metadata(thd, ndb); } else @@ -5216,17 +5237,28 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb, Ndb_table_guard ndbtab_g(dict, table_name); if (ndbtab_g.get_table()) { + retry_temporary_error2: if (dict->dropTableGlobal(*ndbtab_g.get_table()) == 0) { -#ifdef HAVE_NDB_BINLOG ndb_table_id= ndbtab_g.get_table()->getObjectId(); ndb_table_version= ndbtab_g.get_table()->getObjectVersion(); -#endif } - else if (dict->getNdbError().code == NDB_INVALID_SCHEMA_OBJECT) + else { - ndbtab_g.invalidate(); - continue; + switch (dict->getNdbError().status) + { + case NdbError::TemporaryError: + if (!thd->killed) + goto retry_temporary_error2; // retry indefinitly + break; + default: + if (dict->getNdbError().code == NDB_INVALID_SCHEMA_OBJECT) + { + ndbtab_g.invalidate(); + continue; + } + break; + } } } else @@ -9747,7 +9779,19 @@ uint ha_ndbcluster::set_up_partition_info(partition_info *part_info, } else { - /* +#ifdef NOT_YET + if (!current_thd->variables.new_mode) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ILLEGAL_HA_CREATE_OPTION, + ER(ER_ILLEGAL_HA_CREATE_OPTION), + ndbcluster_hton_name, + "LIST, RANGE and HASH partition disabled by default," + " use --new option to enable"); + return HA_ERR_UNSUPPORTED; + } +#endif + /* Create a shadow field for those tables that have user defined partitioning. This field stores the value of the partition function such that NDB can handle reorganisations of the data From 234de474750c637f4b9d6f609af94e10ccaf3a42 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 12:54:28 +0200 Subject: [PATCH 31/43] Bug #18595 repeated create, insert, drop can cause MySQL table definition cache to corrupt - add infinite retry on drop table temporary error --- sql/ha_ndbcluster.cc | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c0eae685a52..b2f60fdaf2e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4036,20 +4036,30 @@ int ha_ndbcluster::delete_table(const char *name) int ha_ndbcluster::drop_table() { + THD *thd= current_thd; Ndb *ndb= get_ndb(); NdbDictionary::Dictionary *dict= ndb->getDictionary(); DBUG_ENTER("drop_table"); DBUG_PRINT("enter", ("Deleting %s", m_tabname)); - if (dict->dropTable(m_tabname)) + while (dict->dropTable(m_tabname)) { const NdbError err= dict->getNdbError(); - if (err.code == 709) - ; // 709: No such table existed - else + switch (err.status) + { + case NdbError::TemporaryError: + if (!thd->killed) + continue; // retry indefinitly + break; + default: + break; + } + if (err.code != 709) // 709: No such table existed ERR_RETURN(dict->getNdbError()); - } + break; + } + release_metadata(); DBUG_RETURN(0); } @@ -4453,14 +4463,24 @@ int ndbcluster_drop_database(const char *path) List_iterator_fast it(drop_list); while ((tabname=it++)) { - if (dict->dropTable(tabname)) + while (dict->dropTable(tabname)) { const NdbError err= dict->getNdbError(); - if (err.code != 709) + switch (err.status) + { + case NdbError::TemporaryError: + if (!thd->killed) + continue; // retry indefinitly + break; + default: + break; + } + if (err.code != 709) // 709: No such table existed { ERR_PRINT(err); ret= ndb_to_mysql_error(&err); } + break; } } DBUG_RETURN(ret); From dcd5786c16f8f95b772a84e66507a5915dfc9960 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 13:32:29 +0200 Subject: [PATCH 32/43] corrected merge error --- sql/ha_ndbcluster.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 27fe2e889af..b12ae2cdd89 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4673,6 +4673,7 @@ int ha_ndbcluster::create(const char *name, default: break; } + break; } m_table = 0; DBUG_RETURN(my_errno); From 708740c8bb5e80a6b5e32f196c2bd14b5da03855 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 16:45:29 +0500 Subject: [PATCH 33/43] After merge fix. --- sql/sql_table.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a49b7a2cc42..e5e671cabf1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4709,6 +4709,14 @@ static uint compare_tables(TABLE *table, List *create_list, At the moment we can't handle altering temporary tables without a copy. We also test if OPTIMIZE TABLE was given and was mapped to alter table. In that case we always do full copy. + + There was a bug prior to mysql-4.0.25. Number of null fields was + calculated incorrectly. As a result frm and data files gets out of + sync after fast alter table. There is no way to determine by which + mysql version (in 4.0 and 4.1 branches) table was created, thus we + disable fast alter table for all tables created by mysql versions + prior to 5.0 branch. + See BUG#6236. */ if (table->s->fields != create_list->elements || table->s->db_type != create_info->db_type || @@ -4718,6 +4726,7 @@ static uint compare_tables(TABLE *table, List *create_list, create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET || (alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) || order_num || + !table->s->mysql_version || (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar)) DBUG_RETURN(ALTER_TABLE_DATA_CHANGED); From 5436a16e436e4a97720cd884f646d2b8fa713e9c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 14:13:45 +0200 Subject: [PATCH 34/43] Fixed variable description --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1a576616966..dda2fbc3588 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5433,7 +5433,7 @@ Disable with --skip-ndbcluster (will save memory).", #endif {"nb-use-copying-alter-table", OPT_NDB_USE_COPYING_ALTER_TABLE, - "Force ndbcluster to always copy tables at alter table (used for ensuring that operations such as renaming fields are propagated to ndb data dictionary).", + "Force ndbcluster to always copy tables at alter table (should only be used if on-line alter table fails).", (gptr*) &global_system_variables.ndb_use_copying_alter_table, (gptr*) &global_system_variables.ndb_use_copying_alter_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, From 6e9bdcc9e91db27ca37535f7d4989d08727d1902 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 08:31:38 -0400 Subject: [PATCH 35/43] BUG#16002: Unsigned partition function support After review fix sql/sql_partition.cc: After review fix --- sql/sql_partition.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index a9f9e59c0cc..6b111f8406d 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2532,10 +2532,10 @@ int get_partition_id_range(partition_info *part_info, if (loc_part_id != max_partition) loc_part_id++; *part_id= (uint32)loc_part_id; - if (loc_part_id == max_partition) - if (range_array[loc_part_id] != LONGLONG_MAX) - if (part_func_value >= range_array[loc_part_id]) - DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); + if (loc_part_id == max_partition && + range_array[loc_part_id] != LONGLONG_MAX && + part_func_value >= range_array[loc_part_id]) + DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); DBUG_RETURN(0); } From a4c2d33ed976de778f1ff526b6d524a3ffe844c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 08:35:19 -0400 Subject: [PATCH 36/43] BUG#19801: Problems with single partition with only NULL allowed in LIST partitioning After review fix sql/partition_info.cc: After review fix --- sql/partition_info.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 6e3023289d8..988c24ae344 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -567,7 +567,6 @@ bool partition_info::check_list_constants() uint i; uint list_index= 0; longlong *list_value; - bool not_first; bool result= TRUE; longlong curr_value, prev_value; partition_element* part_def; @@ -634,19 +633,19 @@ bool partition_info::check_list_constants() if (no_list_values) { + bool first= TRUE; qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), &list_part_cmp); - not_first= FALSE; i= prev_value= 0; //prev_value initialised to quiet compiler do { DBUG_ASSERT(i < no_list_values); curr_value= list_array[i].list_value; - if (likely(!not_first || prev_value != curr_value)) + if (likely(first || prev_value != curr_value)) { prev_value= curr_value; - not_first= TRUE; + first= FALSE; } else { From f10fa9711bd0a6f8d575b7dd7814fad47ec611fc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 16:54:54 +0200 Subject: [PATCH 37/43] support-files/mysql.server.sh : Fix the startup sequence. bug#18810 + bug#20118 support-files/mysql.server.sh: Ensure that some necessary / useful system services have been started already, when the MySQL server is started. This fixes bug#18810 and bug#20118 --- support-files/mysql.server.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 150a8a151ba..0a18fbff78e 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -17,6 +17,7 @@ ### BEGIN INIT INFO # Provides: mysql # Required-Start: $local_fs $network $remote_fs +# Should-Start: ypbind nscd ldap ntpd xntpd # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 From ca1fd91f160a812f5da149cfb9a8065cf78bf8ad Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 20:16:32 +0200 Subject: [PATCH 38/43] Bug #19493 NDB does not ignore duplicate keys when using LOAD DATA LOCAL - make sure to disable bulk insert when check for duplicate key is needed mysql-test/r/ndb_loaddatalocal.result: New BitKeeper file ``mysql-test/r/ndb_loaddatalocal.result'' mysql-test/t/ndb_loaddatalocal.test: New BitKeeper file ``mysql-test/t/ndb_loaddatalocal.test'' --- mysql-test/r/ndb_loaddatalocal.result | 46 ++++++++++++++++++ mysql-test/t/ndb_loaddatalocal.test | 70 +++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 18 +++++++ 3 files changed, 134 insertions(+) create mode 100644 mysql-test/r/ndb_loaddatalocal.result create mode 100644 mysql-test/t/ndb_loaddatalocal.test diff --git a/mysql-test/r/ndb_loaddatalocal.result b/mysql-test/r/ndb_loaddatalocal.result new file mode 100644 index 00000000000..1d15c608f03 --- /dev/null +++ b/mysql-test/r/ndb_loaddatalocal.result @@ -0,0 +1,46 @@ +DROP TABLE IF EXISTS t1; +create table t1(a int) engine=myisam; +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select count(*) from t1; +count(*) +10000 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (2), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (1), (2), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (3), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; diff --git a/mysql-test/t/ndb_loaddatalocal.test b/mysql-test/t/ndb_loaddatalocal.test new file mode 100644 index 00000000000..47054ecfbf5 --- /dev/null +++ b/mysql-test/t/ndb_loaddatalocal.test @@ -0,0 +1,70 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +create table t1(a int) engine=myisam; +let $1=10000; +disable_query_log; +set SQL_LOG_BIN=0; +while ($1) +{ + insert into t1 values(1); + dec $1; +} +set SQL_LOG_BIN=1; +enable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +#This will generate a 20KB file, now test LOAD DATA LOCAL +drop table t1; + +create table t1(a int) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select count(*) from t1; +system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile ; +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (2), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; +select * from t1 order by a; +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (1), (2), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; +select * from t1 order by a; +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (3), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; +select * from t1 order by a; +drop table t1; + +# End of 4.1 tests diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index b2f60fdaf2e..5be09f697a0 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1836,6 +1836,11 @@ int ha_ndbcluster::write_row(byte *record) if(m_ignore_dup_key && table->primary_key != MAX_KEY) { + /* + compare if expression with that in start_bulk_insert() + start_bulk_insert will set parameters to ensure that each + write_row is committed individually + */ int peek_res= peek_row(record); if (!peek_res) @@ -2996,6 +3001,19 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_PRINT("enter", ("rows: %d", (int)rows)); m_rows_inserted= (ha_rows) 0; + if (!m_use_write && m_ignore_dup_key) + { + /* + compare if expression with that in write_row + we have a situation where peek_row() will be called + so we cannot batch + */ + DBUG_PRINT("info", ("Batching turned off as duplicate key is " + "ignored by using peek_row")); + m_rows_to_insert= 1; + m_bulk_insert_rows= 1; + DBUG_VOID_RETURN; + } if (rows == (ha_rows) 0) { /* We don't know how many will be inserted, guess */ From f3a286cc5466f04c4c72a81f15f80c2f03a175a3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 20:22:03 +0200 Subject: [PATCH 39/43] Bug #19493 NDB does not ignore duplicate keys when using LOAD DATA LOCAL - correction of backport error --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5be09f697a0..e3dca77ba2f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3001,7 +3001,7 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_PRINT("enter", ("rows: %d", (int)rows)); m_rows_inserted= (ha_rows) 0; - if (!m_use_write && m_ignore_dup_key) + if (m_ignore_dup_key && table->primary_key != MAX_KEY) { /* compare if expression with that in write_row From 4414b56d85d937354e2fb384604394ec3d1ffc56 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 19:40:06 -0400 Subject: [PATCH 40/43] merge update mysql-test/t/partition.test: merge error --- mysql-test/t/partition.test | 1 + sql/ha_ndbcluster.cc | 9 +-------- sql/ha_partition.cc | 9 +-------- sql/partition_info.cc | 24 ++++++++++++++++++++++++ sql/partition_info.h | 3 ++- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 9b85d6e023e..f62bb2dcd01 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -36,6 +36,7 @@ insert into t1 values (0xFFFFFFFFFFFFFFFD); insert into t1 values (0xFFFFFFFFFFFFFFFE); select * from t1 where (a + 1) < 10; select * from t1 where (a + 1) > 10; +drop table t1; # # Bug 19307: CSV engine crashes diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d1bd4e057ae..caeb0631d85 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6420,14 +6420,7 @@ void ha_ndbcluster::print_error(int error, myf errflag) DBUG_PRINT("enter", ("error = %d", error)); if (error == HA_ERR_NO_PARTITION_FOUND) - { - char buf[100]; - my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); - my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), - m_part_info->part_expr->null_value ? "NULL" : - llstr(m_part_info->part_expr->val_int(), buf)); - dbug_tmp_restore_column_map(table->read_set, old_map); - } + m_part_info->print_no_partition_found(table); else handler::print_error(error, errflag); DBUG_VOID_RETURN; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index f151d89bb1a..93fb6409f9f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5097,14 +5097,7 @@ void ha_partition::print_error(int error, myf errflag) DBUG_PRINT("enter", ("error: %d", error)); if (error == HA_ERR_NO_PARTITION_FOUND) - { - char buf[100]; - my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); - my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), - m_part_info->part_expr->null_value ? "NULL" : - llstr(m_part_info->part_expr->val_int(), buf)); - dbug_tmp_restore_column_map(table->read_set, old_map); - } + m_part_info->print_no_partition_found(table); else m_file[0]->print_error(error, errflag); DBUG_VOID_RETURN; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 51230a0f5c0..39c8d976732 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -827,4 +827,28 @@ end: } +/* + Print error for no partition found + SYNOPSIS + print_no_partition_found() + table Table object + RETURN VALUES + NONE +*/ + +void partition_info::print_no_partition_found(TABLE *table) +{ + char buf[100]; + char *buf_ptr= (char*)&buf; + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); + + if (part_expr->null_value) + buf_ptr= (char*)"NULL"; + else + longlong2str(part_expr->val_int(), buf, + part_expr->unsigned_flag ? 10 : -10); + my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), buf_ptr); + dbug_tmp_restore_column_map(table->read_set, old_map); +} + #endif /* WITH_PARTITION_STORAGE_ENGINE */ diff --git a/sql/partition_info.h b/sql/partition_info.h index f195e555934..3d8c6a40221 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -217,7 +217,7 @@ public: list_of_part_fields(FALSE), list_of_subpart_fields(FALSE), linear_hash_ind(FALSE), fixed(FALSE), is_auto_partitioned(FALSE), from_openfrm(FALSE), - has_null_value(FALSE), has_null_part_id(0) + has_null_value(FALSE) { all_fields_in_PF.clear_all(); all_fields_in_PPF.clear_all(); @@ -251,6 +251,7 @@ public: bool check_list_constants(); bool check_partition_info(THD *thd, handlerton **eng_type, handler *file, ulonglong max_rows); + void print_no_partition_found(TABLE *table); private: static int list_part_cmp(const void* a, const void* b); static int list_part_cmp_unsigned(const void* a, const void* b); From 7431df6031227b7948765baf230a7a3eb54d4339 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 22:37:20 -0400 Subject: [PATCH 41/43] merge fixes --- mysql-test/r/partition.result | 1 + mysql-test/r/partition_range.result | 1 + mysql-test/t/partition_range.test | 1 + 3 files changed, 3 insertions(+) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index dce1e1969f2..fa1baaec07e 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -27,6 +27,7 @@ select * from t1 where (a + 1) > 10; a 18446744073709551613 18446744073709551614 +drop table t1; create table t1 (a int) engine = csv partition by list (a) diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index ff17abe0ffb..152f91f0887 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -389,6 +389,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (2) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM) insert into t1 values (0xFFFFFFFFFFFFFFFF); ERROR HY000: Table has no partition for value 18446744073709551615 +drop table t1; create table t1 (a int) partition by range (MOD(a,3)) subpartition by hash(a) diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index 5c1c17dc511..8e1e2e72e69 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -411,6 +411,7 @@ partition by range (a) show create table t1; --error ER_NO_PARTITION_FOR_GIVEN_VALUE insert into t1 values (0xFFFFFFFFFFFFFFFF); +drop table t1; # # BUG 18962 Errors in DROP PARTITION From 57096e94cf2a5fc021dabea25e04e258efa0f86f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jun 2006 11:40:53 +0200 Subject: [PATCH 42/43] Removed stray bracket --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 026a6013180..be6f3c8eaec 100644 --- a/configure.in +++ b/configure.in @@ -15,7 +15,7 @@ DOT_FRM_VERSION=6 # See the libtool docs for information on how to do shared lib versions. SHARED_LIB_MAJOR_VERSION=15 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0 -} + # Set all version vars based on $VERSION. How do we do this more elegant ? # Remember that regexps needs to quote [ and ] since this is run through m4 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"` From ed849efcc176b4d7b500ca69cf0ee7b1ec39f8ab Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jun 2006 11:59:21 +0200 Subject: [PATCH 43/43] Fixed typo in variable name --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 851c3111a79..ad6f7401965 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5432,7 +5432,7 @@ Disable with --skip-ndbcluster (will save memory).", (gptr*) &max_system_variables.ndb_index_stat_update_freq, 0, GET_ULONG, OPT_ARG, 20, 0, ~0L, 0, 0, 0}, #endif - {"nb-use-copying-alter-table", + {"ndb-use-copying-alter-table", OPT_NDB_USE_COPYING_ALTER_TABLE, "Force ndbcluster to always copy tables at alter table (should only be used if on-line alter table fails).", (gptr*) &global_system_variables.ndb_use_copying_alter_table,