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
dc42b3c4
Commit
dc42b3c4
authored
Jan 11, 2019
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport MDEV-17504 to 5.5
mysql_install_db.exe should not remove datadir, if it was not created by it.
parent
2450fd67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
7 deletions
+67
-7
sql/CMakeLists.txt
sql/CMakeLists.txt
+1
-1
sql/mysql_install_db.cc
sql/mysql_install_db.cc
+66
-6
No files found.
sql/CMakeLists.txt
View file @
dc42b3c4
...
...
@@ -351,7 +351,7 @@ IF(WIN32)
${
CMAKE_CURRENT_BINARY_DIR
}
/mysql_bootstrap_sql.c
COMPONENT Server
)
TARGET_LINK_LIBRARIES
(
mysql_install_db mysys
)
TARGET_LINK_LIBRARIES
(
mysql_install_db mysys
shlwapi
)
ADD_LIBRARY
(
winservice STATIC winservice.c
)
TARGET_LINK_LIBRARIES
(
winservice shell32
)
...
...
sql/mysql_install_db.cc
View file @
dc42b3c4
...
...
@@ -28,6 +28,8 @@
#include <shellapi.h>
#include <accctrl.h>
#include <aclapi.h>
struct
IUnknown
;
#include <shlwapi.h>
#define USAGETEXT \
"mysql_install_db.exe Ver 1.00 for Windows\n" \
...
...
@@ -532,20 +534,78 @@ static int create_db_instance()
DWORD
cwd_len
=
MAX_PATH
;
char
cmdline
[
3
*
MAX_PATH
];
FILE
*
in
;
bool
cleanup_datadir
=
true
;
DWORD
last_error
;
verbose
(
"Running bootstrap"
);
GetCurrentDirectory
(
cwd_len
,
cwd
);
CreateDirectory
(
opt_datadir
,
NULL
);
/*ignore error, it might already exist */
/* Create datadir and datadir/mysql, if they do not already exist. */
if
(
!
CreateDirectory
(
opt_datadir
,
NULL
)
&&
(
GetLastError
()
!=
ERROR_ALREADY_EXISTS
))
{
last_error
=
GetLastError
();
switch
(
last_error
)
{
case
ERROR_ACCESS_DENIED
:
die
(
"Can't create data directory '%s' (access denied)
\n
"
,
opt_datadir
);
break
;
case
ERROR_PATH_NOT_FOUND
:
die
(
"Can't create data directory '%s' "
"(one or more intermediate directories do not exist)
\n
"
,
opt_datadir
);
break
;
default:
die
(
"Can't create data directory '%s', last error %u
\n
"
,
opt_datadir
,
last_error
);
break
;
}
}
if
(
!
SetCurrentDirectory
(
opt_datadir
))
{
die
(
"Cannot set current directory to '%s'
\n
"
,
opt_datadir
);
return
-
1
;
last_error
=
GetLastError
();
switch
(
last_error
)
{
case
ERROR_DIRECTORY
:
die
(
"Can't set current directory to '%s', the path is not a valid directory
\n
"
,
opt_datadir
);
break
;
default:
die
(
"Can' set current directory to '%s', last error %u
\n
"
,
opt_datadir
,
last_error
);
break
;
}
}
if
(
PathIsDirectoryEmpty
(
opt_datadir
))
{
cleanup_datadir
=
false
;
}
CreateDirectory
(
"mysql"
,
NULL
);
CreateDirectory
(
"test"
,
NULL
);
if
(
!
CreateDirectory
(
"mysql"
,
NULL
))
{
last_error
=
GetLastError
();
DWORD
attributes
;
switch
(
last_error
)
{
case
ERROR_ACCESS_DENIED
:
die
(
"Can't create subdirectory 'mysql' in '%s' (access denied)
\n
"
,
opt_datadir
);
break
;
case
ERROR_ALREADY_EXISTS
:
attributes
=
GetFileAttributes
(
"mysql"
);
if
(
attributes
==
INVALID_FILE_ATTRIBUTES
)
die
(
"GetFileAttributes() failed for existing file '%s
\\
mysql', last error %u"
,
opt_datadir
,
GetLastError
());
else
if
(
!
(
attributes
&
FILE_ATTRIBUTE_DIRECTORY
))
die
(
"File '%s
\\
mysql' exists, but it is not a directory"
,
opt_datadir
);
break
;
}
}
/*
Set data directory permissions for both current user and
...
...
@@ -642,7 +702,7 @@ static int create_db_instance()
}
end:
if
(
ret
)
if
(
ret
&&
cleanup_datadir
)
{
SetCurrentDirectory
(
cwd
);
clean_directory
(
opt_datadir
);
...
...
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