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
ed7fd6ec
Commit
ed7fd6ec
authored
Apr 20, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.1-new-maint
into pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint
parents
354847e4
5e28fd3b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
79 deletions
+47
-79
client/mysql_upgrade.c
client/mysql_upgrade.c
+35
-76
mysql-test/r/mysql_upgrade.result
mysql-test/r/mysql_upgrade.result
+1
-1
mysql-test/t/mysql_upgrade.test
mysql-test/t/mysql_upgrade.test
+2
-2
scripts/comp_sql.c
scripts/comp_sql.c
+9
-0
No files found.
client/mysql_upgrade.c
View file @
ed7fd6ec
...
...
@@ -17,14 +17,25 @@
#include <sslopt-vars.h>
#include "../scripts/mysql_fix_privilege_tables_sql.c"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# ifdef __WIN__
# define WEXITSTATUS(stat_val) (stat_val)
# else
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
# endif
#endif
static
char
mysql_path
[
FN_REFLEN
];
static
char
mysqlcheck_path
[
FN_REFLEN
];
static
char
defaults_file_option
[
32
+
FN_REFLEN
];
static
my_bool
opt_force
,
opt_verbose
;
static
char
*
opt_user
=
(
char
*
)
"root"
;
static
DYNAMIC_STRING
ds_
option
s
;
static
DYNAMIC_STRING
ds_
arg
s
;
static
char
*
opt_password
=
0
;
static
my_bool
tty_password
=
0
;
...
...
@@ -35,8 +46,6 @@ static char *default_dbug_option= (char*) "d:t:O,/tmp/mysql_upgrade.trace";
static
char
**
defaults_argv
;
static
File
defaults_fd
=
-
1
;
static
my_bool
not_used
;
/* Can't use GET_BOOL without a value pointer */
#include <help_start.h>
...
...
@@ -105,14 +114,10 @@ static struct my_option my_long_options[]=
static
void
free_used_memory
(
void
)
{
/* Close the defaults file */
if
(
defaults_fd
!=
-
1
)
my_close
(
defaults_fd
,
MYF
(
0
));
/* Free memory allocated by 'load_defaults' */
free_defaults
(
defaults_argv
);
dynstr_free
(
&
ds_
option
s
);
dynstr_free
(
&
ds_
arg
s
);
}
...
...
@@ -159,30 +164,30 @@ static void verbose(const char *fmt, ...)
/*
Add one option - passed to mysql_upgrade on command line
or by defaults file(my.cnf) - to a dynamic string that later
can be written to a temporary file. In this way we pass the
same arguments on to mysql and mysql_check
or by defaults file(my.cnf) - to a dynamic string, in
this way we pass the same arguments on to mysql and mysql_check
*/
static
void
add_one_option
(
DYNAMIC_STRING
*
ds
,
const
struct
my_option
*
opt
,
const
char
*
argument
)
{
dynstr_append
(
ds
,
opt
->
name
);
{
const
char
*
eq
=
NullS
;
const
char
*
arg
=
NullS
;
if
(
opt
->
arg_type
!=
NO_ARG
)
{
dynstr_append
(
ds
,
"="
)
;
eq
=
"="
;
switch
(
opt
->
var_type
&
GET_TYPE_MASK
)
{
case
GET_STR
:
case
GET_STR_ALLOC
:
dynstr_append
(
ds
,
argument
);
arg
=
argument
;
break
;
default:
die
(
"internal error at %s: %d"
,
__FILE__
,
__LINE__
);
}
}
dynstr_append
(
ds
,
"
\n
"
);
dynstr_append_os_quoted
(
ds
,
"--"
,
opt
->
name
,
eq
,
arg
,
NullS
);
dynstr_append
(
&
ds_args
,
" "
);
}
...
...
@@ -211,8 +216,8 @@ get_one_option(int optid, const struct my_option *opt,
add_option
=
FALSE
;
if
(
argument
)
{
/* Add password to ds_
option
s before overwriting the arg with x's */
add_one_option
(
&
ds_
option
s
,
opt
,
argument
);
/* Add password to ds_
arg
s before overwriting the arg with x's */
add_one_option
(
&
ds_
arg
s
,
opt
,
argument
);
while
(
*
argument
)
*
argument
++=
'x'
;
/* Destroy argument */
tty_password
=
0
;
...
...
@@ -232,51 +237,14 @@ get_one_option(int optid, const struct my_option *opt,
/*
This is an option that is accpted by mysql_upgrade just so
it can be passed on to "mysql" and "mysqlcheck"
Save it in the ds_
option
s string
Save it in the ds_
arg
s string
*/
add_one_option
(
&
ds_
option
s
,
opt
,
argument
);
add_one_option
(
&
ds_
arg
s
,
opt
,
argument
);
}
return
0
;
}
/*
Write the options that should be passed on to
mysql and mysqlcheck to a temporary file
*/
static
void
create_defaults_file
(
void
)
{
static
char
defaults_file_path
[
FN_REFLEN
];
DBUG_ENTER
(
"create_defaults_file"
);
if
((
defaults_fd
=
create_temp_file
(
defaults_file_path
,
NULL
,
"cnf"
,
O_CREAT
|
O_SHARE
,
MYF
(
MY_WME
)))
<
0
)
die
(
"Failed to create temporary file for defaults"
);
DBUG_PRINT
(
"info"
,
(
"Writing options: %s"
,
ds_options
.
str
));
if
(
my_write
(
defaults_fd
,
ds_options
.
str
,
ds_options
.
length
,
MYF
(
MY_FNABP
|
MY_WME
)))
die
(
"Failed to write to '%s'"
,
defaults_file_path
);
/*
Dont close the temporary file yet, it will be used
by mysql and mysqlcheck
*/
/*
Create the option that should be added to
tools in order to use this file
*/
my_snprintf
(
defaults_file_option
,
sizeof
(
defaults_file_option
),
"--defaults-file=%s"
,
defaults_file_path
);
DBUG_PRINT
(
"info"
,
(
"defaults_file_option: %s"
,
defaults_file_option
));
DBUG_VOID_RETURN
;
}
static
int
run_command
(
char
*
cmd
,
DYNAMIC_STRING
*
ds_res
)
{
...
...
@@ -466,7 +434,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
DBUG_ENTER
(
"run_query"
);
DBUG_PRINT
(
"enter"
,
(
"query: %s"
,
query
));
if
((
fd
=
create_temp_file
(
query_file_path
,
NULL
,
"sql"
,
O_CREAT
|
O_SHARE
,
"sql"
,
O_CREAT
|
O_SHARE
|
O_RDWR
,
MYF
(
MY_WME
)))
<
0
)
die
(
"Failed to create temporary file for defaults"
);
...
...
@@ -476,7 +444,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
ret
=
run_tool
(
mysql_path
,
ds_res
,
d
efaults_file_option
,
d
s_args
.
str
,
"--database=mysql"
,
"--batch"
,
/* Turns off pager etc. */
force
?
"--force"
:
"--skip-force"
,
...
...
@@ -631,7 +599,7 @@ static int run_mysqlcheck_upgrade(void)
verbose
(
"Running 'mysqlcheck'..."
);
return
run_tool
(
mysqlcheck_path
,
NULL
,
/* Send output from mysqlcheck directly to screen */
d
efaults_file_option
,
d
s_args
.
str
,
"--check-upgrade"
,
"--all-databases"
,
"--auto-repair"
,
...
...
@@ -747,7 +715,7 @@ int main(int argc, char **argv)
setscreenmode
(
SCR_AUTOCLOSE_ON_EXIT
);
#endif
if
(
init_dynamic_string
(
&
ds_
options
,
"[client]
\n
"
,
512
,
256
))
if
(
init_dynamic_string
(
&
ds_
args
,
"
"
,
512
,
256
))
die
(
"Out of memory"
);
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
...
...
@@ -760,14 +728,12 @@ int main(int argc, char **argv)
{
opt_password
=
get_tty_password
(
NullS
);
/* add password to defaults file */
dynstr_append
(
&
ds_options
,
"password="
);
dynstr_append
(
&
ds_options
,
opt_password
);
dynstr_append
(
&
ds_options
,
"
\n
"
);
dynstr_append_os_quoted
(
&
ds_args
,
"--password="
,
opt_password
,
NullS
);
dynstr_append
(
&
ds_args
,
" "
);
}
/* add user to defaults file */
dynstr_append
(
&
ds_options
,
"user="
);
dynstr_append
(
&
ds_options
,
opt_user
);
dynstr_append
(
&
ds_options
,
"
\n
"
);
dynstr_append_os_quoted
(
&
ds_args
,
"--user="
,
opt_user
,
NullS
);
dynstr_append
(
&
ds_args
,
" "
);
/* Find mysql */
find_tool
(
mysql_path
,
IF_WIN
(
"mysql.exe"
,
"mysql"
));
...
...
@@ -775,13 +741,6 @@ int main(int argc, char **argv)
/* Find mysqlcheck */
find_tool
(
mysqlcheck_path
,
IF_WIN
(
"mysqlcheck.exe"
,
"mysqlcheck"
));
/*
Create the defaults file(a small my.cnf) which will pass
all arguments accepted by mysql_upgrade on to mysqlcheck
and mysql command line client
*/
create_defaults_file
();
/*
Read the mysql_upgrade_info file to check if mysql_upgrade
already has been run for this installation of MySQL
...
...
mysql-test/r/mysql_upgrade.result
View file @
ed7fd6ec
...
...
@@ -76,5 +76,5 @@ mysql.time_zone_transition_type OK
mysql.user OK
DROP USER mysqltest1@'%';
Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 200
2: Can't connect to local MySQL server through socket 'var/tmp/no_sock_here' (2
) when trying to connect
mysqlcheck: Got error: 200
5: Unknown MySQL server host 'not_existing_host' (errno
) when trying to connect
FATAL ERROR: Upgrade failed
mysql-test/t/mysql_upgrade.test
View file @
ed7fd6ec
...
...
@@ -52,6 +52,6 @@ DROP USER mysqltest1@'%';
--
echo
Run
mysql_upgrade
with
a
non
existing
server
socket
--
replace_result
$MYSQLTEST_VARDIR
var
--
replace_regex
/.*
mysqlcheck
.*:
Got
/
mysqlcheck
:
Got
/
--
replace_regex
/.*
mysqlcheck
.*:
Got
/
mysqlcheck
:
Got
/
/
\
([
0
-
9
]
*
\
)
/
(
errno
)
/
--
error
1
--
exec
$MYSQL_UPGRADE
--
skip
-
verbose
--
force
--
socket
=
$MYSQLTEST_VARDIR
/
tmp
/
no_sock_here
2
>&
1
--
exec
$MYSQL_UPGRADE
--
skip
-
verbose
--
force
--
host
=
not_existing_host
2
>&
1
scripts/comp_sql.c
View file @
ed7fd6ec
...
...
@@ -106,6 +106,15 @@ int main(int argc, char *argv[])
curr
++
;
}
}
if
(
*
(
curr
-
1
)
!=
'\n'
)
{
/*
Some compilers have a max string length,
insert a newline at every 512th char in long
strings
*/
fprintf
(
out
,
"
\"\n\"
"
);
}
}
fprintf
(
out
,
"
\\\n\"
};
\n
"
);
...
...
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