1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge branch 'mysql/5.5' into 5.5

This commit is contained in:
Sergei Golubchik
2016-06-14 13:55:28 +02:00
26 changed files with 304 additions and 114 deletions

View File

@ -238,7 +238,7 @@ static void dbDisconnect(char *host);
static void DBerror(MYSQL *mysql, const char *when);
static void safe_exit(int error);
static void print_result();
static uint fixed_name_length(const char *name);
static size_t fixed_name_length(const char *name);
static char *fix_table_name(char *dest, char *src);
int what_to_do = 0;
@ -583,10 +583,10 @@ static int process_selected_tables(char *db, char **table_names, int tables)
} /* process_selected_tables */
static uint fixed_name_length(const char *name)
static size_t fixed_name_length(const char *name)
{
const char *p;
uint extra_length= 2; /* count the first/last backticks */
size_t extra_length= 2; /* count the first/last backticks */
DBUG_ENTER("fixed_name_length");
for (p= name; *p; p++)
@ -594,7 +594,7 @@ static uint fixed_name_length(const char *name)
if (*p == '`')
extra_length++;
}
DBUG_RETURN((uint) ((p - name) + extra_length));
DBUG_RETURN((size_t) ((p - name) + extra_length));
}
@ -653,7 +653,7 @@ static int process_all_tables_in_db(char *database)
*/
char *tables, *end;
uint tot_length = 0;
size_t tot_length = 0;
char *views, *views_end;
uint tot_views_length = 0;
@ -756,7 +756,9 @@ static int fix_table_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE `%s` TO `%s`",
name, name + 9);
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@ -771,7 +773,8 @@ static int fix_database_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY "
"NAME", name);
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@ -791,7 +794,7 @@ static int rebuild_table(char *name)
ptr= strmov(query, "ALTER TABLE ");
ptr= fix_table_name(ptr, name);
ptr= strxmov(ptr, " FORCE", NullS);
if (mysql_real_query(sock, query, (uint)(ptr - query)))
if (mysql_real_query(sock, query, (ulong)(ptr - query)))
{
fprintf(stderr, "Failed to %s\n", query);
fprintf(stderr, "Error: %s\n", mysql_error(sock));
@ -850,7 +853,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
{
char *query, *end, options[100], message[100];
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
uint query_length= 0;
size_t query_length= 0, query_size= sizeof(char)*(length+110);
const char *op = 0;
const char *tab_view;
DBUG_ENTER("handle_request_for_tables");
@ -902,10 +905,12 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
DBUG_RETURN(fix_table_storage_name(tables));
}
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
DBUG_RETURN(1);
if (opt_all_in_1)
{
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
/* No backticks here as we added them before */
query_length= sprintf(query, "%s%s%s %s", op,
tab_view, tables, options);
@ -921,7 +926,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
(int) (ptr - org)));
table_name= table_name_buff;
ptr= strxmov(ptr, " ", options, NullS);
query_length= (uint) (ptr - query);
query_length= (size_t) (ptr - query);
}
if (mysql_real_query(sock, query, query_length))
{
@ -1040,7 +1045,10 @@ static void print_result()
prev_alter[0]= 0;
}
else
strcpy(prev_alter, alter_txt);
{
strncpy(prev_alter, alter_txt, MAX_ALTER_STR_SIZE-1);
prev_alter[MAX_ALTER_STR_SIZE-1]= 0;
}
}
}
}
@ -1193,7 +1201,7 @@ int main(int argc, char **argv)
process_databases(argv);
if (opt_auto_repair)
{
uint i;
size_t i;
if (!opt_silent && (tables4repair.elements || tables4rebuild.elements))
puts("\nRepairing tables");