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
2361f835
Commit
2361f835
authored
Mar 29, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12392 Duplicate code cleanup: add function normalize_db_name()
parent
fb43180c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
sql/sql_db.cc
sql/sql_db.cc
+15
-18
sql/sql_db.h
sql/sql_db.h
+2
-0
No files found.
sql/sql_db.cc
View file @
2361f835
...
...
@@ -583,15 +583,8 @@ mysql_create_db_internal(THD *thd, char *db,
DBUG_RETURN
(
-
1
);
}
char
db_tmp
[
SAFE_NAME_LEN
],
*
dbnorm
;
if
(
lower_case_table_names
)
{
strmake_buf
(
db_tmp
,
db
);
my_casedn_str
(
system_charset_info
,
db_tmp
);
dbnorm
=
db_tmp
;
}
else
dbnorm
=
db
;
char
db_tmp
[
SAFE_NAME_LEN
];
char
*
dbnorm
=
normalize_db_name
(
db
,
db_tmp
,
sizeof
(
db_tmp
));
if
(
lock_schema_name
(
thd
,
dbnorm
))
DBUG_RETURN
(
-
1
);
...
...
@@ -824,15 +817,8 @@ mysql_rm_db_internal(THD *thd,char *db, bool if_exists, bool silent)
Drop_table_error_handler
err_handler
;
DBUG_ENTER
(
"mysql_rm_db"
);
char
db_tmp
[
SAFE_NAME_LEN
],
*
dbnorm
;
if
(
lower_case_table_names
)
{
strmake_buf
(
db_tmp
,
db
);
my_casedn_str
(
system_charset_info
,
db_tmp
);
dbnorm
=
db_tmp
;
}
else
dbnorm
=
db
;
char
db_tmp
[
SAFE_NAME_LEN
];
char
*
dbnorm
=
normalize_db_name
(
db
,
db_tmp
,
sizeof
(
db_tmp
));
if
(
lock_schema_name
(
thd
,
dbnorm
))
DBUG_RETURN
(
true
);
...
...
@@ -1891,3 +1877,14 @@ bool check_db_dir_existence(const char *db_name)
return
my_access
(
db_dir_path
,
F_OK
);
}
char
*
normalize_db_name
(
char
*
db
,
char
*
buffer
,
size_t
buffer_size
)
{
DBUG_ASSERT
(
buffer_size
>
1
);
if
(
!
lower_case_table_names
)
return
db
;
strmake
(
buffer
,
db
,
buffer_size
-
1
);
my_casedn_str
(
system_charset_info
,
buffer
);
return
buffer
;
}
sql/sql_db.h
View file @
2361f835
...
...
@@ -45,6 +45,8 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
bool
my_dbopt_init
(
void
);
void
my_dbopt_cleanup
(
void
);
char
*
normalize_db_name
(
char
*
db
,
char
*
buffer
,
size_t
buffer_size
);
#define MY_DB_OPT_FILE "db.opt"
#endif
/* SQL_DB_INCLUDED */
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