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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0a11bc2a
Commit
0a11bc2a
authored
Oct 31, 2007
by
ramil/ram@ramil.myoffice.izhnet.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/ram/work/b30654/b30654.5.0
into mysql.com:/home/ram/work/b30654/b30654.5.1
parents
3286de1d
38b3b367
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
16 deletions
+54
-16
client/mysqlcheck.c
client/mysqlcheck.c
+38
-14
mysql-test/r/mysqlcheck.result
mysql-test/r/mysqlcheck.result
+6
-1
mysql-test/t/mysqlcheck.test
mysql-test/t/mysqlcheck.test
+10
-1
No files found.
client/mysqlcheck.c
View file @
0a11bc2a
...
@@ -206,6 +206,7 @@ static void dbDisconnect(char *host);
...
@@ -206,6 +206,7 @@ static void dbDisconnect(char *host);
static
void
DBerror
(
MYSQL
*
mysql
,
const
char
*
when
);
static
void
DBerror
(
MYSQL
*
mysql
,
const
char
*
when
);
static
void
safe_exit
(
int
error
);
static
void
safe_exit
(
int
error
);
static
void
print_result
();
static
void
print_result
();
static
uint
fixed_name_length
(
const
char
*
name
);
static
char
*
fix_table_name
(
char
*
dest
,
char
*
src
);
static
char
*
fix_table_name
(
char
*
dest
,
char
*
src
);
int
what_to_do
=
0
;
int
what_to_do
=
0
;
...
@@ -438,14 +439,14 @@ static int process_selected_tables(char *db, char **table_names, int tables)
...
@@ -438,14 +439,14 @@ static int process_selected_tables(char *db, char **table_names, int tables)
{
{
/*
/*
We need table list in form `a`, `b`, `c`
We need table list in form `a`, `b`, `c`
that's why we need
4
more chars added to to each table name
that's why we need
2
more chars added to to each table name
space is for more readable output in logs and in case of error
space is for more readable output in logs and in case of error
*/
*/
char
*
table_names_comma_sep
,
*
end
;
char
*
table_names_comma_sep
,
*
end
;
int
i
,
tot_length
=
0
;
int
i
,
tot_length
=
0
;
for
(
i
=
0
;
i
<
tables
;
i
++
)
for
(
i
=
0
;
i
<
tables
;
i
++
)
tot_length
+=
strlen
(
*
(
table_names
+
i
))
+
4
;
tot_length
+=
fixed_name_length
(
*
(
table_names
+
i
))
+
2
;
if
(
!
(
table_names_comma_sep
=
(
char
*
)
if
(
!
(
table_names_comma_sep
=
(
char
*
)
my_malloc
((
sizeof
(
char
)
*
tot_length
)
+
4
,
MYF
(
MY_WME
))))
my_malloc
((
sizeof
(
char
)
*
tot_length
)
+
4
,
MYF
(
MY_WME
))))
...
@@ -463,23 +464,46 @@ static int process_selected_tables(char *db, char **table_names, int tables)
...
@@ -463,23 +464,46 @@ static int process_selected_tables(char *db, char **table_names, int tables)
}
}
else
else
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
handle_request_for_tables
(
*
table_names
,
strlen
(
*
table_names
));
handle_request_for_tables
(
*
table_names
,
fixed_name_length
(
*
table_names
));
return
0
;
return
0
;
}
/* process_selected_tables */
}
/* process_selected_tables */
static
char
*
fix_table_name
(
char
*
dest
,
char
*
src
)
static
uint
fixed_name_length
(
const
char
*
name
)
{
{
char
*
db_sep
;
const
char
*
p
;
uint
extra_length
=
2
;
/* count the first/last backticks */
for
(
p
=
name
;
*
p
;
p
++
)
{
if
(
*
p
==
'`'
)
extra_length
++
;
else
if
(
*
p
==
'.'
)
extra_length
+=
2
;
}
return
(
p
-
name
)
+
extra_length
;
}
static
char
*
fix_table_name
(
char
*
dest
,
char
*
src
)
{
*
dest
++=
'`'
;
*
dest
++=
'`'
;
if
((
db_sep
=
strchr
(
src
,
'.'
))
)
for
(;
*
src
;
src
++
)
{
{
dest
=
strmake
(
dest
,
src
,
(
uint
)
(
db_sep
-
src
));
switch
(
*
src
)
{
dest
=
strmov
(
dest
,
"`.`"
);
case
'.'
:
/* add backticks around '.' */
src
=
db_sep
+
1
;
*
dest
++=
'`'
;
*
dest
++=
'.'
;
*
dest
++=
'`'
;
break
;
case
'`'
:
/* escape backtick character */
*
dest
++=
'`'
;
/* fall through */
default:
*
dest
++=
*
src
;
}
}
}
dest
=
strxmov
(
dest
,
src
,
"`"
,
NullS
)
;
*
dest
++=
'`'
;
return
dest
;
return
dest
;
}
}
...
@@ -500,7 +524,7 @@ static int process_all_tables_in_db(char *database)
...
@@ -500,7 +524,7 @@ static int process_all_tables_in_db(char *database)
{
{
/*
/*
We need table list in form `a`, `b`, `c`
We need table list in form `a`, `b`, `c`
that's why we need
4
more chars added to to each table name
that's why we need
2
more chars added to to each table name
space is for more readable output in logs and in case of error
space is for more readable output in logs and in case of error
*/
*/
...
@@ -508,7 +532,7 @@ static int process_all_tables_in_db(char *database)
...
@@ -508,7 +532,7 @@ static int process_all_tables_in_db(char *database)
uint
tot_length
=
0
;
uint
tot_length
=
0
;
while
((
row
=
mysql_fetch_row
(
res
)))
while
((
row
=
mysql_fetch_row
(
res
)))
tot_length
+=
strlen
(
row
[
0
])
+
4
;
tot_length
+=
fixed_name_length
(
row
[
0
])
+
2
;
mysql_data_seek
(
res
,
0
);
mysql_data_seek
(
res
,
0
);
if
(
!
(
tables
=
(
char
*
)
my_malloc
(
sizeof
(
char
)
*
tot_length
+
4
,
MYF
(
MY_WME
))))
if
(
!
(
tables
=
(
char
*
)
my_malloc
(
sizeof
(
char
)
*
tot_length
+
4
,
MYF
(
MY_WME
))))
...
@@ -536,7 +560,7 @@ static int process_all_tables_in_db(char *database)
...
@@ -536,7 +560,7 @@ static int process_all_tables_in_db(char *database)
/* Skip tables with an engine of NULL (probably a view). */
/* Skip tables with an engine of NULL (probably a view). */
if
(
row
[
1
])
if
(
row
[
1
])
{
{
handle_request_for_tables
(
row
[
0
],
strlen
(
row
[
0
]));
handle_request_for_tables
(
row
[
0
],
fixed_name_length
(
row
[
0
]));
}
}
}
}
mysql_free_result
(
res
);
mysql_free_result
(
res
);
...
@@ -809,7 +833,7 @@ int main(int argc, char **argv)
...
@@ -809,7 +833,7 @@ int main(int argc, char **argv)
for
(
i
=
0
;
i
<
tables4repair
.
elements
;
i
++
)
for
(
i
=
0
;
i
<
tables4repair
.
elements
;
i
++
)
{
{
char
*
name
=
(
char
*
)
dynamic_array_ptr
(
&
tables4repair
,
i
);
char
*
name
=
(
char
*
)
dynamic_array_ptr
(
&
tables4repair
,
i
);
handle_request_for_tables
(
name
,
strlen
(
name
));
handle_request_for_tables
(
name
,
fixed_name_length
(
name
));
}
}
}
}
end:
end:
...
...
mysql-test/r/mysqlcheck.result
View file @
0a11bc2a
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1
, `t``1`, `t 1`
;
drop view if exists v1;
drop view if exists v1;
drop database if exists client_test_db;
drop database if exists client_test_db;
mysql.columns_priv OK
mysql.columns_priv OK
...
@@ -57,4 +57,9 @@ test.t1 OK
...
@@ -57,4 +57,9 @@ test.t1 OK
test.t1 OK
test.t1 OK
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create table `t``1`(a int);
create table `t 1`(a int);
test.t 1 OK
test.t`1 OK
drop table `t``1`, `t 1`;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/mysqlcheck.test
View file @
0a11bc2a
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
--
disable_warnings
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t1
,
`t``1`
,
`t 1`
;
drop
view
if
exists
v1
;
drop
view
if
exists
v1
;
drop
database
if
exists
client_test_db
;
drop
database
if
exists
client_test_db
;
--
enable_warnings
--
enable_warnings
...
@@ -37,4 +37,13 @@ create view v1 as select * from t1;
...
@@ -37,4 +37,13 @@ create view v1 as select * from t1;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
#
create
table
`t``1`
(
a
int
);
create
table
`t 1`
(
a
int
);
--
replace_result
'Table is already up to date'
OK
--
exec
$MYSQL_CHECK
--
databases
test
drop
table
`t``1`
,
`t 1`
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
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