Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
9033aa02
Commit
9033aa02
authored
Jan 28, 2015
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names
Backport from mysql 5.7. The patch reviewed, test added.
parent
cb9c116a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
17 deletions
+42
-17
client/mysqlcheck.c
client/mysqlcheck.c
+21
-13
mysql-test/r/mysqlcheck.result
mysql-test/r/mysqlcheck.result
+9
-2
mysql-test/t/mysqlcheck.test
mysql-test/t/mysqlcheck.test
+12
-2
No files found.
client/mysqlcheck.c
View file @
9033aa02
...
@@ -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
;
...
...
mysql-test/r/mysqlcheck.result
View file @
9033aa02
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`;
mysql-test/t/mysqlcheck.test
View file @
9033aa02
...
@@ -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`
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment