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
336da6e2
Commit
336da6e2
authored
Apr 09, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
02c712aa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
66 deletions
+53
-66
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/partition_info.cc
sql/partition_info.cc
+13
-16
sql/sql_parse.cc
sql/sql_parse.cc
+33
-1
sql/sql_parse.h
sql/sql_parse.h
+1
-0
sql/sql_table.cc
sql/sql_table.cc
+5
-48
No files found.
sql/mysqld.cc
View file @
336da6e2
...
@@ -8065,7 +8065,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
...
@@ -8065,7 +8065,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
global_system_variables
.
sql_mode
=
global_system_variables
.
sql_mode
=
expand_sql_mode
(
global_system_variables
.
sql_mode
);
expand_sql_mode
(
global_system_variables
.
sql_mode
);
#if defined(HAVE_BROKEN_REALPATH)
#if
!defined(HAVE_REALPATH) ||
defined(HAVE_BROKEN_REALPATH)
my_use_symdir
=
0
;
my_use_symdir
=
0
;
my_disable_symlinks
=
1
;
my_disable_symlinks
=
1
;
have_symlink
=
SHOW_OPTION_NO
;
have_symlink
=
SHOW_OPTION_NO
;
...
...
sql/partition_info.cc
View file @
336da6e2
...
@@ -1582,29 +1582,21 @@ bool check_partition_dirs(partition_info *part_info)
...
@@ -1582,29 +1582,21 @@ bool check_partition_dirs(partition_info *part_info)
partition_element
*
subpart_elem
;
partition_element
*
subpart_elem
;
while
((
subpart_elem
=
sub_it
++
))
while
((
subpart_elem
=
sub_it
++
))
{
{
if
(
test_if_data_home_dir
(
subpart_elem
->
data_file_name
))
if
(
error_if_data_home_dir
(
subpart_elem
->
data_file_name
,
goto
dd_err
;
"DATA DIRECTORY"
)
||
if
(
test_if_data_home_dir
(
subpart_elem
->
index_file_name
))
error_if_data_home_dir
(
subpart_elem
->
index_file_name
,
goto
id_err
;
"INDEX DIRECTORY"
))
return
1
;
}
}
}
}
else
else
{
{
if
(
test_if_data_home_dir
(
part_elem
->
data_file_name
))
if
(
error_if_data_home_dir
(
part_elem
->
data_file_name
,
"DATA DIRECTORY"
)
||
goto
dd_err
;
error_if_data_home_dir
(
part_elem
->
index_file_name
,
"INDEX DIRECTORY"
))
if
(
test_if_data_home_dir
(
part_elem
->
index_file_name
))
return
1
;
goto
id_err
;
}
}
}
}
return
0
;
return
0
;
dd_err:
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"DATA DIRECTORY"
);
return
1
;
id_err:
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"INDEX DIRECTORY"
);
return
1
;
}
}
...
@@ -2286,4 +2278,9 @@ void partition_info::print_debug(const char *str, uint *value)
...
@@ -2286,4 +2278,9 @@ void partition_info::print_debug(const char *str, uint *value)
{
{
}
}
bool
check_partition_dirs
(
partition_info
*
part_info
)
{
return
0
;
}
#endif
/* WITH_PARTITION_STORAGE_ENGINE */
#endif
/* WITH_PARTITION_STORAGE_ENGINE */
sql/sql_parse.cc
View file @
336da6e2
...
@@ -7683,6 +7683,7 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
...
@@ -7683,6 +7683,7 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
return
TRUE
;
return
TRUE
;
}
}
C_MODE_START
/*
/*
Check if path does not contain mysql data home directory
Check if path does not contain mysql data home directory
...
@@ -7695,7 +7696,6 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
...
@@ -7695,7 +7696,6 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
0 ok
0 ok
1 error ; Given path contains data directory
1 error ; Given path contains data directory
*/
*/
C_MODE_START
int
test_if_data_home_dir
(
const
char
*
dir
)
int
test_if_data_home_dir
(
const
char
*
dir
)
{
{
...
@@ -7706,6 +7706,22 @@ int test_if_data_home_dir(const char *dir)
...
@@ -7706,6 +7706,22 @@ int test_if_data_home_dir(const char *dir)
if
(
!
dir
)
if
(
!
dir
)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
/*
data_file_name and index_file_name include the table name without
extension. Mostly this does not refer to an existing file. When
comparing data_file_name or index_file_name against the data
directory, we try to resolve all symbolic links. On some systems,
we use realpath(3) for the resolution. This returns ENOENT if the
resolved path does not refer to an existing file. my_realpath()
does then copy the requested path verbatim, without symlink
resolution. Thereafter the comparison can fail even if the
requested path is within the data directory. E.g. if symlinks to
another file system are used. To make realpath(3) return the
resolved path, we strip the table name and compare the directory
path only. If the directory doesn't exist either, table creation
will fail anyway.
*/
(
void
)
fn_format
(
path
,
dir
,
""
,
""
,
(
void
)
fn_format
(
path
,
dir
,
""
,
""
,
(
MY_RETURN_REAL_PATH
|
MY_RESOLVE_SYMLINKS
));
(
MY_RETURN_REAL_PATH
|
MY_RESOLVE_SYMLINKS
));
dir_len
=
strlen
(
path
);
dir_len
=
strlen
(
path
);
...
@@ -7739,6 +7755,22 @@ int test_if_data_home_dir(const char *dir)
...
@@ -7739,6 +7755,22 @@ int test_if_data_home_dir(const char *dir)
C_MODE_END
C_MODE_END
int
error_if_data_home_dir
(
const
char
*
path
,
const
char
*
what
)
{
size_t
dirlen
;
char
dirpath
[
FN_REFLEN
];
if
(
path
)
{
dirname_part
(
dirpath
,
path
,
&
dirlen
);
if
(
test_if_data_home_dir
(
dirpath
))
{
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
what
);
return
1
;
}
}
return
0
;
}
/**
/**
Check that host name string is valid.
Check that host name string is valid.
...
...
sql/sql_parse.h
View file @
336da6e2
...
@@ -34,6 +34,7 @@ enum enum_mysql_completiontype {
...
@@ -34,6 +34,7 @@ enum enum_mysql_completiontype {
};
};
extern
"C"
int
test_if_data_home_dir
(
const
char
*
dir
);
extern
"C"
int
test_if_data_home_dir
(
const
char
*
dir
);
int
error_if_data_home_dir
(
const
char
*
path
,
const
char
*
what
);
bool
multi_update_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_update_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_delete_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
multi_delete_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
...
...
sql/sql_table.cc
View file @
336da6e2
...
@@ -4346,55 +4346,7 @@ bool mysql_create_table_no_lock(THD *thd,
...
@@ -4346,55 +4346,7 @@ bool mysql_create_table_no_lock(THD *thd,
if
(
!
file
)
if
(
!
file
)
goto
err
;
goto
err
;
#ifdef HAVE_READLINK
{
size_t
dirlen
;
char
dirpath
[
FN_REFLEN
];
/*
data_file_name and index_file_name include the table name without
extension. Mostly this does not refer to an existing file. When
comparing data_file_name or index_file_name against the data
directory, we try to resolve all symbolic links. On some systems,
we use realpath(3) for the resolution. This returns ENOENT if the
resolved path does not refer to an existing file. my_realpath()
does then copy the requested path verbatim, without symlink
resolution. Thereafter the comparison can fail even if the
requested path is within the data directory. E.g. if symlinks to
another file system are used. To make realpath(3) return the
resolved path, we strip the table name and compare the directory
path only. If the directory doesn't exist either, table creation
will fail anyway.
*/
if
(
create_info
->
data_file_name
)
{
dirname_part
(
dirpath
,
create_info
->
data_file_name
,
&
dirlen
);
if
(
test_if_data_home_dir
(
dirpath
))
{
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"DATA DIRECTORY"
);
goto
err
;
}
}
if
(
create_info
->
index_file_name
)
{
dirname_part
(
dirpath
,
create_info
->
index_file_name
,
&
dirlen
);
if
(
test_if_data_home_dir
(
dirpath
))
{
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"INDEX DIRECTORY"
);
goto
err
;
}
}
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
if
(
check_partition_dirs
(
thd
->
lex
->
part_info
))
{
goto
err
;
}
#endif
/* WITH_PARTITION_STORAGE_ENGINE */
if
(
!
my_use_symdir
||
(
thd
->
variables
.
sql_mode
&
MODE_NO_DIR_IN_CREATE
))
if
(
!
my_use_symdir
||
(
thd
->
variables
.
sql_mode
&
MODE_NO_DIR_IN_CREATE
))
#endif
/* HAVE_READLINK */
{
{
if
(
create_info
->
data_file_name
)
if
(
create_info
->
data_file_name
)
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
...
@@ -4406,6 +4358,11 @@ bool mysql_create_table_no_lock(THD *thd,
...
@@ -4406,6 +4358,11 @@ bool mysql_create_table_no_lock(THD *thd,
"INDEX DIRECTORY"
);
"INDEX DIRECTORY"
);
create_info
->
data_file_name
=
create_info
->
index_file_name
=
0
;
create_info
->
data_file_name
=
create_info
->
index_file_name
=
0
;
}
}
else
if
(
error_if_data_home_dir
(
create_info
->
data_file_name
,
"DATA DIRECTORY"
)
||
error_if_data_home_dir
(
create_info
->
index_file_name
,
"INDEX DIRECTORY"
)
||
check_partition_dirs
(
thd
->
lex
->
part_info
))
goto
err
;
/* Check if table exists */
/* Check if table exists */
if
(
create_info
->
tmp_table
())
if
(
create_info
->
tmp_table
())
...
...
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