Commit 62b658a4 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4786 merge 10.0-monty -> 10.0

remove half-applied "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING"
parent 23b4ccde
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
#define EX_USAGE 1 #define EX_USAGE 1
#define EX_MYSQLERR 2 #define EX_MYSQLERR 2
/* ALTER instead of repair. */
#define MAX_ALTER_STR_SIZE 128 * 1024
#define KEY_PARTITIONING_CHANGED_STR "KEY () partitioning changed"
static MYSQL mysql_connection, *sock = 0; static MYSQL mysql_connection, *sock = 0;
static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
opt_compress = 0, opt_databases = 0, opt_fast = 0, opt_compress = 0, opt_databases = 0, opt_fast = 0,
...@@ -51,7 +47,7 @@ static char *opt_password = 0, *current_user = 0, ...@@ -51,7 +47,7 @@ static char *opt_password = 0, *current_user = 0,
*default_charset= 0, *current_host= 0; *default_charset= 0, *current_host= 0;
static char *opt_plugin_dir= 0, *opt_default_auth= 0; static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static int first_error = 0; static int first_error = 0;
DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds; DYNAMIC_ARRAY tables4repair, tables4rebuild;
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
static uint opt_protocol=0; static uint opt_protocol=0;
...@@ -818,7 +814,6 @@ static void print_result() ...@@ -818,7 +814,6 @@ static void print_result()
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_ROW row; MYSQL_ROW row;
char prev[(NAME_LEN+9)*2+2]; char prev[(NAME_LEN+9)*2+2];
char prev_alter[MAX_ALTER_STR_SIZE];
uint i; uint i;
my_bool found_error=0, table_rebuild=0; my_bool found_error=0, table_rebuild=0;
DBUG_ENTER("print_result"); DBUG_ENTER("print_result");
...@@ -826,7 +821,6 @@ static void print_result() ...@@ -826,7 +821,6 @@ static void print_result()
res = mysql_use_result(sock); res = mysql_use_result(sock);
prev[0] = '\0'; prev[0] = '\0';
prev_alter[0]= 0;
for (i = 0; (row = mysql_fetch_row(res)); i++) for (i = 0; (row = mysql_fetch_row(res)); i++)
{ {
int changed = strcmp(prev, row[0]); int changed = strcmp(prev, row[0]);
...@@ -843,18 +837,12 @@ static void print_result() ...@@ -843,18 +837,12 @@ static void print_result()
strcmp(row[3],"OK")) strcmp(row[3],"OK"))
{ {
if (table_rebuild) if (table_rebuild)
{ insert_dynamic(&tables4rebuild, (uchar*) prev);
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else
insert_dynamic(&tables4rebuild, (uchar*) prev);
}
else else
insert_dynamic(&tables4repair, (uchar*) prev); insert_dynamic(&tables4repair, (uchar*) prev);
} }
found_error=0; found_error=0;
table_rebuild=0; table_rebuild=0;
prev_alter[0]= 0;
if (opt_silent) if (opt_silent)
continue; continue;
} }
...@@ -871,30 +859,11 @@ static void print_result() ...@@ -871,30 +859,11 @@ static void print_result()
printf("%-50s %s", row[0], "Needs upgrade"); printf("%-50s %s", row[0], "Needs upgrade");
else else
printf("%s\n%-9s: %s", row[0], row[2], row[3]); printf("%s\n%-9s: %s", row[0], row[2], row[3]);
if (opt_auto_repair && strcmp(row[2],"note")) if (strcmp(row[2],"note"))
{ {
const char *alter_txt= strstr(row[3], "ALTER TABLE");
found_error=1; found_error=1;
if (alter_txt) if (opt_auto_repair && strstr(row[3], "ALTER TABLE") != NULL)
{
table_rebuild=1; table_rebuild=1;
if (!strncmp(row[3], KEY_PARTITIONING_CHANGED_STR,
strlen(KEY_PARTITIONING_CHANGED_STR)) &&
strstr(alter_txt, "PARTITION BY"))
{
if (strlen(alter_txt) >= MAX_ALTER_STR_SIZE)
{
printf("Error: Alter command too long (>= %d),"
" please do \"%s\" or dump/reload to fix it!\n",
MAX_ALTER_STR_SIZE,
alter_txt);
table_rebuild= 0;
prev_alter[0]= 0;
}
else
strcpy(prev_alter, alter_txt);
}
}
} }
} }
else else
...@@ -906,12 +875,7 @@ static void print_result() ...@@ -906,12 +875,7 @@ static void print_result()
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR) if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
{ {
if (table_rebuild) if (table_rebuild)
{ insert_dynamic(&tables4rebuild, (uchar*) prev);
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else
insert_dynamic(&tables4rebuild, (uchar*) prev);
}
else else
insert_dynamic(&tables4repair, (uchar*) prev); insert_dynamic(&tables4repair, (uchar*) prev);
} }
...@@ -1030,9 +994,7 @@ int main(int argc, char **argv) ...@@ -1030,9 +994,7 @@ int main(int argc, char **argv)
(my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16, (my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,
64, MYF(0)) || 64, MYF(0)) ||
my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16, my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,
64, MYF(0)) || 64, MYF(0))))
my_init_dynamic_array(&alter_table_cmds, MAX_ALTER_STR_SIZE, 0,
1, MYF(0))))
goto end; goto end;
if (opt_alldbs) if (opt_alldbs)
...@@ -1057,8 +1019,6 @@ int main(int argc, char **argv) ...@@ -1057,8 +1019,6 @@ int main(int argc, char **argv)
} }
for (i = 0; i < tables4rebuild.elements ; i++) for (i = 0; i < tables4rebuild.elements ; i++)
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i)); rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
for (i = 0; i < alter_table_cmds.elements ; i++)
run_query((char*) dynamic_array_ptr(&alter_table_cmds, i));
} }
ret= test(first_error); ret= test(first_error);
......
...@@ -55,8 +55,6 @@ ...@@ -55,8 +55,6 @@
#include "sql_table.h" // tablename_to_filename #include "sql_table.h" // tablename_to_filename
#include "key.h" #include "key.h"
#include "sql_plugin.h" #include "sql_plugin.h"
#include "sql_show.h" // append_identifier
#include "sql_admin.h" // SQL_ADMIN_MSG_TEXT_SIZE
#include "debug_sync.h" #include "debug_sync.h"
......
...@@ -1192,6 +1192,7 @@ public: ...@@ -1192,6 +1192,7 @@ public:
private: private:
int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags); int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
public: public:
/* /*
------------------------------------------------------------------------- -------------------------------------------------------------------------
Admin commands not supported currently (almost purely MyISAM routines) Admin commands not supported currently (almost purely MyISAM routines)
......
...@@ -5805,8 +5805,6 @@ int handler::ha_write_row(uchar *buf) ...@@ -5805,8 +5805,6 @@ int handler::ha_write_row(uchar *buf)
m_lock_type == F_WRLCK); m_lock_type == F_WRLCK);
DBUG_ENTER("handler::ha_write_row"); DBUG_ENTER("handler::ha_write_row");
DEBUG_SYNC_C("ha_write_row_start"); DEBUG_SYNC_C("ha_write_row_start");
DBUG_EXECUTE_IF("inject_error_ha_write_row",
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); );
MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str); MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write(); mark_trx_read_write();
...@@ -5839,7 +5837,6 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) ...@@ -5839,7 +5837,6 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
(and the old record is in record[1]). (and the old record is in record[1]).
*/ */
DBUG_ASSERT(new_data == table->record[0]); DBUG_ASSERT(new_data == table->record[0]);
DBUG_ASSERT(old_data == table->record[1]);
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str); MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write(); mark_trx_read_write();
...@@ -5861,13 +5858,6 @@ int handler::ha_delete_row(const uchar *buf) ...@@ -5861,13 +5858,6 @@ int handler::ha_delete_row(const uchar *buf)
{ {
int error; int error;
Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function; Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
/*
Normally table->record[0] is used, but sometimes table->record[1] is used.
*/
DBUG_ASSERT(buf == table->record[0] ||
buf == table->record[1]);
DBUG_EXECUTE_IF("inject_error_ha_delete_row",
return HA_ERR_INTERNAL_ERROR; );
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type == F_WRLCK); m_lock_type == F_WRLCK);
......
...@@ -347,8 +347,8 @@ bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length) ...@@ -347,8 +347,8 @@ bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length)
@param prefix_key The field is used as a prefix key. @param prefix_key The field is used as a prefix key.
*/ */
void field_unpack(String *to, Field *field, const uchar *rec, uint max_length, static void field_unpack(String *to, Field *field, const uchar *rec,
bool prefix_key) uint max_length, bool prefix_key)
{ {
String tmp; String tmp;
DBUG_ENTER("field_unpack"); DBUG_ENTER("field_unpack");
......
...@@ -33,8 +33,6 @@ void key_restore(uchar *to_record, uchar *from_key, KEY *key_info, ...@@ -33,8 +33,6 @@ void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
uint key_length); uint key_length);
bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length); bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length);
void key_unpack(String *to, TABLE *form, KEY *key); void key_unpack(String *to, TABLE *form, KEY *key);
void field_unpack(String *to, Field *field, const uchar *rec, uint max_length,
bool prefix_key);
bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields); bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields);
int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length); int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length);
ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key); ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key);
......
...@@ -2759,36 +2759,9 @@ int partition_info::fix_parser_data(THD *thd) ...@@ -2759,36 +2759,9 @@ int partition_info::fix_parser_data(THD *thd)
if (!(part_type == RANGE_PARTITION || if (!(part_type == RANGE_PARTITION ||
part_type == LIST_PARTITION)) part_type == LIST_PARTITION))
{ {
if (part_type == HASH_PARTITION && list_of_part_fields) /* Nothing to do for HASH/KEY partitioning */
{
/* KEY partitioning, check ALGORITHM = N. Should not pass the parser! */
if (key_algorithm > KEY_ALGORITHM_55)
{
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
DBUG_RETURN(true);
}
/* If not set, use DEFAULT = 2 for CREATE and ALTER! */
if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
key_algorithm == KEY_ALGORITHM_NONE)
key_algorithm= KEY_ALGORITHM_55;
}
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
if (is_sub_partitioned() && list_of_subpart_fields)
{
/* KEY subpartitioning, check ALGORITHM = N. Should not pass the parser! */
if (key_algorithm > KEY_ALGORITHM_55)
{
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
DBUG_RETURN(true);
}
/* If not set, use DEFAULT = 2 for CREATE and ALTER! */
if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
key_algorithm == KEY_ALGORITHM_NONE)
key_algorithm= KEY_ALGORITHM_55;
}
do do
{ {
part_elem= it++; part_elem= it++;
......
...@@ -210,19 +210,6 @@ public: ...@@ -210,19 +210,6 @@ public:
but mainly of use to handlers supporting partitioning. but mainly of use to handlers supporting partitioning.
*/ */
uint16 linear_hash_mask; uint16 linear_hash_mask;
/*
PARTITION BY KEY ALGORITHM=N
Which algorithm to use for hashing the fields.
N = 1 - Use 5.1 hashing (numeric fields are hashed as binary)
N = 2 - Use 5.5 hashing (numeric fields are hashed like latin1 bytes)
*/
enum enum_key_algorithm
{
KEY_ALGORITHM_NONE= 0,
KEY_ALGORITHM_51= 1,
KEY_ALGORITHM_55= 2
};
enum_key_algorithm key_algorithm;
bool use_default_partitions; bool use_default_partitions;
bool use_default_num_partitions; bool use_default_num_partitions;
...@@ -273,7 +260,6 @@ public: ...@@ -273,7 +260,6 @@ public:
count_curr_subparts(0), part_error_code(0), count_curr_subparts(0), part_error_code(0),
num_list_values(0), num_part_fields(0), num_subpart_fields(0), num_list_values(0), num_part_fields(0), num_subpart_fields(0),
num_full_part_fields(0), has_null_part_id(0), linear_hash_mask(0), num_full_part_fields(0), has_null_part_id(0), linear_hash_mask(0),
key_algorithm(KEY_ALGORITHM_NONE),
use_default_partitions(TRUE), use_default_num_partitions(TRUE), use_default_partitions(TRUE), use_default_num_partitions(TRUE),
use_default_subpartitions(TRUE), use_default_num_subpartitions(TRUE), use_default_subpartitions(TRUE), use_default_num_subpartitions(TRUE),
default_partitions_setup(FALSE), defined_max_value(FALSE), default_partitions_setup(FALSE), defined_max_value(FALSE),
......
...@@ -4844,7 +4844,7 @@ partition: ...@@ -4844,7 +4844,7 @@ partition:
; ;
part_type_def: part_type_def:
opt_linear KEY_SYM opt_key_algo '(' part_field_list ')' opt_linear KEY_SYM '(' part_field_list ')'
{ {
partition_info *part_info= Lex->part_info; partition_info *part_info= Lex->part_info;
part_info->list_of_part_fields= TRUE; part_info->list_of_part_fields= TRUE;
...@@ -4870,25 +4870,6 @@ opt_linear: ...@@ -4870,25 +4870,6 @@ opt_linear:
{ Lex->part_info->linear_hash_ind= TRUE;} { Lex->part_info->linear_hash_ind= TRUE;}
; ;
opt_key_algo:
/* empty */
{ Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;}
| ALGORITHM_SYM EQ real_ulong_num
{
switch ($3) {
case 1:
Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_51;
break;
case 2:
Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_55;
break;
default:
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
}
}
;
part_field_list: part_field_list:
/* empty */ {} /* empty */ {}
| part_field_item_list {} | part_field_item_list {}
...@@ -4970,7 +4951,7 @@ opt_sub_part: ...@@ -4970,7 +4951,7 @@ opt_sub_part:
| SUBPARTITION_SYM BY opt_linear HASH_SYM sub_part_func | SUBPARTITION_SYM BY opt_linear HASH_SYM sub_part_func
{ Lex->part_info->subpart_type= HASH_PARTITION; } { Lex->part_info->subpart_type= HASH_PARTITION; }
opt_num_subparts {} opt_num_subparts {}
| SUBPARTITION_SYM BY opt_linear KEY_SYM opt_key_algo | SUBPARTITION_SYM BY opt_linear KEY_SYM
'(' sub_part_field_list ')' '(' sub_part_field_list ')'
{ {
partition_info *part_info= Lex->part_info; partition_info *part_info= Lex->part_info;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment