Commit 9033aa02 authored by unknown's avatar unknown

MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names

Backport from mysql 5.7. The patch reviewed, test added.
parent cb9c116a
...@@ -514,9 +514,6 @@ static uint fixed_name_length(const char *name) ...@@ -514,9 +514,6 @@ static uint fixed_name_length(const char *name)
{ {
if (*p == '`') if (*p == '`')
extra_length++; extra_length++;
else if (*p == '.')
extra_length+= 2;
} }
DBUG_RETURN((uint) ((p - name) + extra_length)); DBUG_RETURN((uint) ((p - name) + extra_length));
} }
...@@ -530,11 +527,6 @@ static char *fix_table_name(char *dest, char *src) ...@@ -530,11 +527,6 @@ static char *fix_table_name(char *dest, char *src)
for (; *src; src++) for (; *src; src++)
{ {
switch (*src) { switch (*src) {
case '.': /* add backticks around '.' */
*dest++= '`';
*dest++= '.';
*dest++= '`';
break;
case '`': /* escape backtick character */ case '`': /* escape backtick character */
*dest++= '`'; *dest++= '`';
/* fall through */ /* fall through */
...@@ -818,13 +810,17 @@ static void print_result() ...@@ -818,13 +810,17 @@ 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)*3+2];
char prev_alter[MAX_ALTER_STR_SIZE]; char prev_alter[MAX_ALTER_STR_SIZE];
char *db_name;
uint length_of_db;
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");
res = mysql_use_result(sock); res = mysql_use_result(sock);
db_name= sock->db;
length_of_db= strlen(db_name);
prev[0] = '\0'; prev[0] = '\0';
prev_alter[0]= 0; prev_alter[0]= 0;
...@@ -848,10 +844,16 @@ static void print_result() ...@@ -848,10 +844,16 @@ static void print_result()
if (prev_alter[0]) if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter); insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else else
insert_dynamic(&tables4rebuild, (uchar*) prev); {
char *table_name= prev + (length_of_db+1);
insert_dynamic(&tables4rebuild, (uchar*) table_name);
}
} }
else else
insert_dynamic(&tables4repair, (uchar*) prev); {
char *table_name= prev + (length_of_db+1);
insert_dynamic(&tables4repair, (uchar*) table_name);
}
} }
found_error=0; found_error=0;
table_rebuild=0; table_rebuild=0;
...@@ -911,10 +913,16 @@ static void print_result() ...@@ -911,10 +913,16 @@ static void print_result()
if (prev_alter[0]) if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter); insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else else
insert_dynamic(&tables4rebuild, (uchar*) prev); {
char *table_name= prev + (length_of_db+1);
insert_dynamic(&tables4rebuild, (uchar*) table_name);
}
} }
else else
insert_dynamic(&tables4repair, (uchar*) prev); {
char *table_name= prev + (length_of_db+1);
insert_dynamic(&tables4repair, (uchar*) table_name);
}
} }
mysql_free_result(res); mysql_free_result(res);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
DROP TABLE IF EXISTS t1, `t``1`, `t 1`; DROP TABLE IF EXISTS t1, `t``1`, `t 1`, test.`t.1`, v1;
drop view if exists v1; drop view if exists t1, `t``1`, `t 1`, test.`t.1`, v1;
drop database if exists client_test_db; drop database if exists client_test_db;
mtr.global_suppressions OK mtr.global_suppressions OK
mtr.test_suppressions OK mtr.test_suppressions OK
...@@ -309,3 +309,10 @@ CHECK TABLE bug47205 FOR UPGRADE; ...@@ -309,3 +309,10 @@ CHECK TABLE bug47205 FOR UPGRADE;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.bug47205 check status OK test.bug47205 check status OK
DROP TABLE bug47205; DROP TABLE bug47205;
#
#MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names
#
CREATE TABLE test.`t.1` (id int);
mysqlcheck test t.1
test.t.1 OK
drop table test.`t.1`;
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
# #
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1, `t``1`, `t 1`; DROP TABLE IF EXISTS t1, `t``1`, `t 1`, test.`t.1`, v1;
drop view if exists v1; drop view if exists t1, `t``1`, `t 1`, test.`t.1`, v1;
drop database if exists client_test_db; drop database if exists client_test_db;
# Repair any tables in mysql, sometimes the slow_log is marked as crashed # Repair any tables in mysql, sometimes the slow_log is marked as crashed
# after server has been killed # after server has been killed
...@@ -313,3 +313,13 @@ CHECK TABLE bug47205 FOR UPGRADE; ...@@ -313,3 +313,13 @@ CHECK TABLE bug47205 FOR UPGRADE;
CHECK TABLE bug47205 FOR UPGRADE; CHECK TABLE bug47205 FOR UPGRADE;
DROP TABLE bug47205; DROP TABLE bug47205;
--echo #
--echo #MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names
--echo #
CREATE TABLE test.`t.1` (id int);
--echo mysqlcheck test t.1
--exec $MYSQL_CHECK test t.1
drop table test.`t.1`;
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