2010-10-06 17:06:13 +02:00
|
|
|
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
2006-04-28 06:07:25 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-04-28 06:07:25 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
#include "client_priv.h"
|
2006-11-08 03:45:50 +01:00
|
|
|
#include <sslopt-vars.h>
|
2007-04-18 13:21:39 +02:00
|
|
|
#include "../scripts/mysql_fix_privilege_tables_sql.c"
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2010-10-06 17:06:13 +02:00
|
|
|
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
|
|
|
|
|
2007-08-01 21:59:05 +02:00
|
|
|
#define VER "1.1"
|
|
|
|
|
2007-04-19 21:30:46 +02:00
|
|
|
#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
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static char mysql_path[FN_REFLEN];
|
|
|
|
static char mysqlcheck_path[FN_REFLEN];
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2009-10-28 11:02:00 +01:00
|
|
|
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag,
|
|
|
|
opt_systables_only;
|
2007-08-01 21:59:05 +02:00
|
|
|
static uint my_end_arg= 0;
|
2007-04-18 13:21:39 +02:00
|
|
|
static char *opt_user= (char*)"root";
|
|
|
|
|
2007-04-19 21:30:46 +02:00
|
|
|
static DYNAMIC_STRING ds_args;
|
2009-05-27 10:24:25 +02:00
|
|
|
static DYNAMIC_STRING conn_args;
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
static char *opt_password= 0;
|
2011-01-16 04:59:05 +01:00
|
|
|
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static my_bool tty_password= 0;
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2010-03-09 10:18:46 +01:00
|
|
|
static char opt_tmpdir[FN_REFLEN] = "";
|
2008-05-02 14:41:19 +02:00
|
|
|
|
2006-11-08 03:45:50 +01:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
static char *default_dbug_option= (char*) "d:t:O,/tmp/mysql_upgrade.trace";
|
|
|
|
#endif
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2007-02-28 21:05:39 +01:00
|
|
|
static char **defaults_argv;
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static my_bool not_used; /* Can't use GET_BOOL without a value pointer */
|
|
|
|
|
2009-09-28 08:24:19 +02:00
|
|
|
static my_bool opt_write_binlog;
|
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
static struct my_option my_long_options[]=
|
|
|
|
{
|
|
|
|
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
|
|
|
|
NO_ARG, 0, 0, 0, 0, 0, 0},
|
2010-02-04 13:39:42 +01:00
|
|
|
{"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibility.",
|
2007-04-18 13:21:39 +02:00
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2007-08-01 21:59:05 +02:00
|
|
|
{"character-sets-dir", OPT_CHARSETS_DIR,
|
2010-02-04 13:39:42 +01:00
|
|
|
"Directory for character set files.", 0,
|
2007-08-01 21:59:05 +02:00
|
|
|
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
¬_used, ¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
2007-04-18 13:21:39 +02:00
|
|
|
{"datadir", 'd',
|
2010-02-04 13:39:42 +01:00
|
|
|
"Not used by mysql_upgrade. Only for backward compatibility.",
|
2007-04-18 13:21:39 +02:00
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2006-04-28 06:07:25 +02:00
|
|
|
#ifdef DBUG_OFF
|
2010-02-04 13:39:42 +01:00
|
|
|
{"debug", '#', "This is a non-debug version. Catch this and exit.",
|
2006-04-28 06:07:25 +02:00
|
|
|
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
#else
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
{"debug", '#', "Output debug log.", &default_dbug_option,
|
|
|
|
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
2006-04-28 06:07:25 +02:00
|
|
|
#endif
|
2007-10-01 14:32:07 +02:00
|
|
|
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
&debug_check_flag, &debug_check_flag, 0,
|
2007-08-01 21:59:05 +02:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
{"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
|
|
|
|
&debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
2006-11-08 03:45:50 +01:00
|
|
|
{"default-character-set", OPT_DEFAULT_CHARSET,
|
2007-04-18 13:21:39 +02:00
|
|
|
"Set the default character set.", 0,
|
|
|
|
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2011-01-16 04:59:05 +01:00
|
|
|
{"default_auth", OPT_DEFAULT_AUTH,
|
|
|
|
"Default authentication client-side plugin to use.",
|
|
|
|
(uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
|
|
|
|
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2007-04-18 13:21:39 +02:00
|
|
|
{"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
|
|
|
|
"has already been executed for the current version of MySQL.",
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
&opt_force, &opt_force, 0,
|
2007-04-18 13:21:39 +02:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
{"host",'h', "Connect to host.", 0,
|
|
|
|
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2006-04-28 06:07:25 +02:00
|
|
|
{"password", 'p',
|
2010-02-04 13:39:42 +01:00
|
|
|
"Password to use when connecting to server. If password is not given,"
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
" it's solicited on the tty.", &opt_password,&opt_password,
|
2007-04-18 13:21:39 +02:00
|
|
|
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
2006-11-08 03:45:50 +01:00
|
|
|
#ifdef __WIN__
|
2007-04-18 13:21:39 +02:00
|
|
|
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
|
2006-11-08 03:45:50 +01:00
|
|
|
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
#endif
|
2011-01-16 04:59:05 +01:00
|
|
|
{"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
|
|
|
|
(uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
|
|
|
|
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
Bug #15327: configure: --with-tcp-port option being partially ignored
make sure that if builder configured with a non-standard (!= 3306)
default TCP port that value actually gets used throughout. if they
didn't configure a value, assume "use a sensible default", which
will be read from /etc/services or, failing that, from the factory
default. That makes the order of preference
- command-line option
- my.cnf, where applicable
- $MYSQL_TCP_PORT environment variable
- /etc/services (unless configured --with-tcp-port)
- default port (--with-tcp-port=... or factory default)
client/mysql.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysql_upgrade.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqladmin.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlbinlog.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlcheck.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqldump.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlimport.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlmanagerc.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
configure.in:
Bug #15327: configure: --with-tcp-port option being partially ignored
If MYSQL_TCP_PORT defaulted in configure (factory default 3306
at the time of this writing), set MYSQL_TCP_PORT to factory
default, then clear factory default after. That way, we lose no
information, and we can distinguish between "defaulted" and the
pathological case "builder specifically configured a port that
coincides with factory default." This can in theory happen if
builder configures and builds several servers from a script
(--with-tcp-port=3306, --with-tcp-port=3316, --with-tcp-port=3326).
Not all that probable, but much preferable to having more "magic"
happen in the server when we can solve this without any guesswork.
client/mysqlshow.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqltest.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
include/mysql_version.h.in:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
libmysql/libmysql.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
initialize default tcp port for client, like so:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
- environment variable MYSQL_TCP_PORT overrides this default
- command-line option overrides all of the above
mysql-test/Makefile.am:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
mysql-test/mysql-test-run-shell.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
netware/mysql_test_run.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
netware/mysqld_safe.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
scripts/Makefile.am:
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
scripts/mysql_config.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
scripts/mysql_fix_privilege_tables.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
clarifying notice only
scripts/mysqld_safe-watch.sh:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
server-tools/instance-manager/priv.h:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
sql/mysqld.cc:
Bug #15327: configure: --with-tcp-port option being partially ignored
if builder specifically requested a default port, use that
(even if it coincides with our factory default).
only if they didn't do we check /etc/services (and, failing
on that, fall back to the factory default of 3306).
either default can be overridden by the environment variable
MYSQL_TCP_PORT, which in turn can be overridden with command
line options.
tests/mysql_client_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
tests/ssl_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
tests/thread_test.c:
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
2007-09-13 16:19:46 +02:00
|
|
|
{"port", 'P', "Port number to use for connection or 0 for default to, in "
|
|
|
|
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
|
|
|
|
#if MYSQL_PORT_DEFAULT == 0
|
|
|
|
"/etc/services, "
|
|
|
|
#endif
|
|
|
|
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
|
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2006-04-28 06:07:25 +02:00
|
|
|
{"protocol", OPT_MYSQL_PROTOCOL,
|
2010-02-04 13:39:42 +01:00
|
|
|
"The protocol to use for connection (tcp, socket, pipe, memory).",
|
2006-04-28 06:07:25 +02:00
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2006-11-08 03:45:50 +01:00
|
|
|
#ifdef HAVE_SMEM
|
|
|
|
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
|
2007-04-18 13:21:39 +02:00
|
|
|
"Base name of shared memory.", 0,
|
|
|
|
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2006-11-08 03:45:50 +01:00
|
|
|
#endif
|
2010-02-04 13:39:42 +01:00
|
|
|
{"socket", 'S', "The socket file to use for connection.",
|
2007-04-18 13:21:39 +02:00
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2009-04-28 20:26:31 +02:00
|
|
|
#include <sslopt-longopts.h>
|
2010-02-04 13:39:42 +01:00
|
|
|
{"tmpdir", 't', "Directory for temporary files.",
|
2008-05-02 14:41:19 +02:00
|
|
|
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2009-10-28 11:02:00 +01:00
|
|
|
{"upgrade-system-tables", 's', "Only upgrade the system tables "
|
|
|
|
"do not try to upgrade the data.",
|
2010-06-11 03:30:49 +02:00
|
|
|
&opt_systables_only, &opt_systables_only, 0,
|
2009-10-28 11:02:00 +01:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
{"user", 'u', "User for login if not current user.", &opt_user,
|
|
|
|
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
2010-02-04 13:39:42 +01:00
|
|
|
{"verbose", 'v', "Display more output about the process.",
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
&opt_verbose, &opt_verbose, 0,
|
2007-04-18 13:21:39 +02:00
|
|
|
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
2009-09-28 08:24:19 +02:00
|
|
|
{"write-binlog", OPT_WRITE_BINLOG,
|
|
|
|
"All commands including mysqlcheck are binlogged. Enabled by default;"
|
|
|
|
"use --skip-write-binlog when commands should not be sent to replication slaves.",
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
&opt_write_binlog, &opt_write_binlog, 0, GET_BOOL, NO_ARG,
|
2009-09-28 08:24:19 +02:00
|
|
|
1, 0, 0, 0, 0, 0},
|
2006-04-28 06:07:25 +02:00
|
|
|
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
static void free_used_memory(void)
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/* Free memory allocated by 'load_defaults' */
|
|
|
|
free_defaults(defaults_argv);
|
|
|
|
|
2007-04-19 21:30:46 +02:00
|
|
|
dynstr_free(&ds_args);
|
2009-05-27 10:24:25 +02:00
|
|
|
dynstr_free(&conn_args);
|
2007-04-18 13:21:39 +02:00
|
|
|
}
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static void die(const char *fmt, ...)
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
va_list args;
|
|
|
|
DBUG_ENTER("die");
|
|
|
|
|
|
|
|
/* Print the error message */
|
|
|
|
va_start(args, fmt);
|
|
|
|
if (fmt)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "FATAL ERROR: ");
|
|
|
|
vfprintf(stderr, fmt, args);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
free_used_memory();
|
2007-08-01 21:59:05 +02:00
|
|
|
my_end(my_end_arg);
|
2007-04-18 13:21:39 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void verbose(const char *fmt, ...)
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
va_list args;
|
|
|
|
|
|
|
|
if (!opt_verbose)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Print the verbose message */
|
|
|
|
va_start(args, fmt);
|
|
|
|
if (fmt)
|
|
|
|
{
|
|
|
|
vfprintf(stdout, fmt, args);
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Add one option - passed to mysql_upgrade on command line
|
2007-04-19 21:30:46 +02:00
|
|
|
or by defaults file(my.cnf) - to a dynamic string, in
|
|
|
|
this way we pass the same arguments on to mysql and mysql_check
|
2007-04-18 13:21:39 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void add_one_option(DYNAMIC_STRING* ds,
|
|
|
|
const struct my_option *opt,
|
|
|
|
const char* argument)
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2007-04-19 21:30:46 +02:00
|
|
|
{
|
|
|
|
const char* eq= NullS;
|
|
|
|
const char* arg= NullS;
|
2007-04-18 13:21:39 +02:00
|
|
|
if (opt->arg_type != NO_ARG)
|
|
|
|
{
|
2007-04-19 21:30:46 +02:00
|
|
|
eq= "=";
|
2007-04-18 13:21:39 +02:00
|
|
|
switch (opt->var_type & GET_TYPE_MASK) {
|
|
|
|
case GET_STR:
|
2007-04-19 21:30:46 +02:00
|
|
|
arg= argument;
|
2007-04-18 13:21:39 +02:00
|
|
|
break;
|
fix for Bug #55672 "mysql_upgrade dies with internal error":
it couldn't parse the --ssl option.
client/mysql_upgrade.c:
mysql_upgrade parses its options and passes some of them to the underlying
tools (mysqlcheck etc). To do this passdown, it reconstructs a
command-line-suitable text from the my_option object (which
contains the option's name and option's value). For options
which expect no parameter, it just had to use the option's name;
for other options, it had to concatenate the option's name,
a "=" symbol, and the option's value; it had code to handle
this latter case, but only for GET_STR options (options taking a
string as value). But since the work on WL 4738, the --ssl
option, a GET_BOOL, which used to have no parameter (NO_ARG), can
now have one (OPT_ARG), so with --ssl we came to the "default"
label, error. Fixed by constructing the command-line-suitable
representation for GET_BOOL too. For --ssl it will produce
--ssl=1 ; for --ssl=0, it will produce --ssl=0.
mysql-test/include/mysql_upgrade_preparation.inc:
handles requirements of tests which use mysql_upgrade
mysql-test/r/mysql_upgrade_ssl.result:
result; without the code fix we would get "internal error".
mysql-test/t/mysql_upgrade.test:
This test has requirements before running; moved them
to an include file in order to share with mysql_upgrade_ssl.
mysql-test/t/mysql_upgrade_ssl.test:
test for bug. Couldn't go into mysql_upgrade.test as this new test requires
SSL support. --force is needed, in case mysql_upgrade.test run before
(in which case mysql_upgrade_ssl would say that upgrade has already been
done); --force forces the upgrade in all cases.
2010-08-11 19:56:56 +02:00
|
|
|
case GET_BOOL:
|
|
|
|
arg= (*(my_bool *)opt->value) ? "1" : "0";
|
|
|
|
break;
|
2007-04-18 13:21:39 +02:00
|
|
|
default:
|
|
|
|
die("internal error at %s: %d",__FILE__, __LINE__);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-19 21:30:46 +02:00
|
|
|
dynstr_append_os_quoted(ds, "--", opt->name, eq, arg, NullS);
|
2009-05-27 10:24:25 +02:00
|
|
|
dynstr_append(ds, " ");
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
static my_bool
|
2007-04-18 13:21:39 +02:00
|
|
|
get_one_option(int optid, const struct my_option *opt,
|
2006-04-28 06:07:25 +02:00
|
|
|
char *argument)
|
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
my_bool add_option= TRUE;
|
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
switch (optid) {
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
case '?':
|
2007-08-01 21:59:05 +02:00
|
|
|
printf("%s Ver %s Distrib %s, for %s (%s)\n",
|
|
|
|
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
|
2010-10-06 17:06:13 +02:00
|
|
|
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
|
2010-02-04 13:39:42 +01:00
|
|
|
puts("MySQL utility for upgrading databases to new MySQL versions.\n");
|
2006-04-28 06:07:25 +02:00
|
|
|
my_print_help(my_long_options);
|
|
|
|
exit(0);
|
2007-04-18 13:21:39 +02:00
|
|
|
break;
|
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
case '#':
|
|
|
|
DBUG_PUSH(argument ? argument : default_dbug_option);
|
2007-04-18 13:21:39 +02:00
|
|
|
add_option= FALSE;
|
2007-08-02 06:49:29 +02:00
|
|
|
debug_check_flag= 1;
|
2006-04-28 06:07:25 +02:00
|
|
|
break;
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
case 'p':
|
2009-05-07 19:51:55 +02:00
|
|
|
if (argument == disabled_my_option)
|
2009-06-03 13:18:12 +02:00
|
|
|
argument= (char*) ""; /* Don't require password */
|
2006-04-28 06:07:25 +02:00
|
|
|
tty_password= 1;
|
2007-04-18 13:21:39 +02:00
|
|
|
add_option= FALSE;
|
2006-04-28 06:07:25 +02:00
|
|
|
if (argument)
|
|
|
|
{
|
2007-04-19 21:30:46 +02:00
|
|
|
/* Add password to ds_args before overwriting the arg with x's */
|
|
|
|
add_one_option(&ds_args, opt, argument);
|
2006-04-28 06:07:25 +02:00
|
|
|
while (*argument)
|
|
|
|
*argument++= 'x'; /* Destroy argument */
|
|
|
|
tty_password= 0;
|
|
|
|
}
|
|
|
|
break;
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2008-05-02 14:41:19 +02:00
|
|
|
case 't':
|
|
|
|
strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir));
|
|
|
|
add_option= FALSE;
|
|
|
|
break;
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
case 'b': /* --basedir */
|
|
|
|
case 'd': /* --datadir */
|
2009-05-19 19:39:03 +02:00
|
|
|
fprintf(stderr, "%s: the '--%s' option is always ignored\n",
|
|
|
|
my_progname, optid == 'b' ? "basedir" : "datadir");
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
case 'v': /* --verbose */
|
2007-04-18 13:21:39 +02:00
|
|
|
case 'f': /* --force */
|
|
|
|
add_option= FALSE;
|
2006-11-08 03:45:50 +01:00
|
|
|
break;
|
2009-05-27 10:24:25 +02:00
|
|
|
|
|
|
|
case 'h': /* --host */
|
|
|
|
case 'W': /* --pipe */
|
|
|
|
case 'P': /* --port */
|
|
|
|
case 'S': /* --socket */
|
|
|
|
case OPT_MYSQL_PROTOCOL: /* --protocol */
|
|
|
|
case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */
|
2011-01-16 04:59:05 +01:00
|
|
|
case OPT_PLUGIN_DIR: /* --plugin-dir */
|
|
|
|
case OPT_DEFAULT_AUTH: /* --default-auth */
|
2009-05-27 10:24:25 +02:00
|
|
|
add_one_option(&conn_args, opt, argument);
|
|
|
|
break;
|
2007-04-18 13:21:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (add_option)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This is an option that is accpted by mysql_upgrade just so
|
|
|
|
it can be passed on to "mysql" and "mysqlcheck"
|
2007-04-19 21:30:46 +02:00
|
|
|
Save it in the ds_args string
|
2007-04-18 13:21:39 +02:00
|
|
|
*/
|
2007-04-19 21:30:46 +02:00
|
|
|
add_one_option(&ds_args, opt, argument);
|
2007-04-18 13:21:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
/**
|
|
|
|
Run a command using the shell, storing its output in the supplied dynamic
|
|
|
|
string.
|
|
|
|
*/
|
2007-04-18 13:21:39 +02:00
|
|
|
static int run_command(char* cmd,
|
|
|
|
DYNAMIC_STRING *ds_res)
|
|
|
|
{
|
|
|
|
char buf[512]= {0};
|
|
|
|
FILE *res_file;
|
2007-04-23 13:27:55 +02:00
|
|
|
int error;
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
if (!(res_file= popen(cmd, "r")))
|
|
|
|
die("popen(\"%s\", \"r\") failed", cmd);
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), res_file))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("info", ("buf: %s", buf));
|
|
|
|
if(ds_res)
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/* Save the output of this command in the supplied string */
|
|
|
|
dynstr_append(ds_res, buf);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
else
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/* Print it directly on screen */
|
|
|
|
fprintf(stdout, "%s", buf);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2007-04-23 13:27:55 +02:00
|
|
|
error= pclose(res_file);
|
|
|
|
return WEXITSTATUS(error);
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2006-11-08 03:45:50 +01:00
|
|
|
int ret;
|
2007-04-18 13:21:39 +02:00
|
|
|
const char* arg;
|
|
|
|
va_list args;
|
|
|
|
DYNAMIC_STRING ds_cmdline;
|
|
|
|
|
|
|
|
DBUG_ENTER("run_tool");
|
|
|
|
DBUG_PRINT("enter", ("tool_path: %s", tool_path));
|
|
|
|
|
|
|
|
if (init_dynamic_string(&ds_cmdline, IF_WIN("\"", ""), FN_REFLEN, FN_REFLEN))
|
|
|
|
die("Out of memory");
|
|
|
|
|
|
|
|
dynstr_append_os_quoted(&ds_cmdline, tool_path, NullS);
|
|
|
|
dynstr_append(&ds_cmdline, " ");
|
|
|
|
|
|
|
|
va_start(args, ds_res);
|
|
|
|
|
|
|
|
while ((arg= va_arg(args, char *)))
|
|
|
|
{
|
|
|
|
/* Options should be os quoted */
|
|
|
|
if (strncmp(arg, "--", 2) == 0)
|
|
|
|
dynstr_append_os_quoted(&ds_cmdline, arg, NullS);
|
|
|
|
else
|
|
|
|
dynstr_append(&ds_cmdline, arg);
|
|
|
|
dynstr_append(&ds_cmdline, " ");
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
2007-04-19 17:00:29 +02:00
|
|
|
#ifdef __WIN__
|
|
|
|
dynstr_append(&ds_cmdline, "\"");
|
|
|
|
#endif
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
DBUG_PRINT("info", ("Running: %s", ds_cmdline.str));
|
|
|
|
ret= run_command(ds_cmdline.str, ds_res);
|
|
|
|
DBUG_PRINT("exit", ("ret: %d", ret));
|
|
|
|
dynstr_free(&ds_cmdline);
|
|
|
|
DBUG_RETURN(ret);
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
/**
|
|
|
|
Look for the filename of given tool, with the presumption that it is in the
|
|
|
|
same directory as mysql_upgrade and that the same executable-searching
|
|
|
|
mechanism will be used when we run our sub-shells with popen() later.
|
2007-04-18 13:21:39 +02:00
|
|
|
*/
|
2008-08-07 18:24:39 +02:00
|
|
|
static void find_tool(char *tool_executable_name, const char *tool_name,
|
|
|
|
const char *self_name)
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2008-08-07 18:24:39 +02:00
|
|
|
char *last_fn_libchar;
|
2007-04-18 13:21:39 +02:00
|
|
|
DYNAMIC_STRING ds_tmp;
|
|
|
|
DBUG_ENTER("find_tool");
|
|
|
|
DBUG_PRINT("enter", ("progname: %s", my_progname));
|
|
|
|
|
|
|
|
if (init_dynamic_string(&ds_tmp, "", 32, 32))
|
|
|
|
die("Out of memory");
|
2007-02-28 21:05:39 +01:00
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
last_fn_libchar= strrchr(self_name, FN_LIBCHAR);
|
|
|
|
|
|
|
|
if (last_fn_libchar == NULL)
|
2006-12-08 10:23:03 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
2008-08-07 18:24:39 +02:00
|
|
|
mysql_upgrade was found by the shell searching the path. A sibling
|
|
|
|
next to us should be found the same way.
|
2007-04-18 13:21:39 +02:00
|
|
|
*/
|
2008-08-07 18:24:39 +02:00
|
|
|
strncpy(tool_executable_name, tool_name, FN_REFLEN);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
2008-08-07 18:24:39 +02:00
|
|
|
else
|
2007-08-27 10:25:34 +02:00
|
|
|
{
|
2009-03-20 15:27:53 +01:00
|
|
|
int len;
|
2008-08-11 15:08:21 +02:00
|
|
|
|
|
|
|
/*
|
2008-08-07 18:24:39 +02:00
|
|
|
mysql_upgrade was run absolutely or relatively. We can find a sibling
|
|
|
|
by replacing our name after the LIBCHAR with the new tool name.
|
|
|
|
*/
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
/*
|
|
|
|
When running in a not yet installed build and using libtool,
|
|
|
|
the program(mysql_upgrade) will be in .libs/ and executed
|
|
|
|
through a libtool wrapper in order to use the dynamic libraries
|
|
|
|
from this build. The same must be done for the tools(mysql and
|
|
|
|
mysqlcheck). Thus if path ends in .libs/, step up one directory
|
|
|
|
and execute the tools from there
|
|
|
|
*/
|
|
|
|
if (((last_fn_libchar - 6) >= self_name) &&
|
|
|
|
(strncmp(last_fn_libchar - 5, ".libs", 5) == 0) &&
|
|
|
|
(*(last_fn_libchar - 6) == FN_LIBCHAR))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("info", ("Chopping off \".libs\" from end of path"));
|
|
|
|
last_fn_libchar -= 6;
|
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2008-08-11 15:08:21 +02:00
|
|
|
len= last_fn_libchar - self_name;
|
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s",
|
2008-08-11 15:08:21 +02:00
|
|
|
len, self_name, FN_LIBCHAR, tool_name);
|
2008-08-07 18:24:39 +02:00
|
|
|
}
|
2007-08-27 10:25:34 +02:00
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
verbose("Looking for '%s' as: %s", tool_name, tool_executable_name);
|
2007-08-27 10:25:34 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Make sure it can be executed
|
|
|
|
*/
|
2008-08-07 18:24:39 +02:00
|
|
|
if (run_tool(tool_executable_name,
|
2007-08-27 10:25:34 +02:00
|
|
|
&ds_tmp, /* Get output from command, discard*/
|
|
|
|
"--help",
|
|
|
|
"2>&1",
|
|
|
|
IF_WIN("> NUL", "> /dev/null"),
|
|
|
|
NULL))
|
2008-08-07 18:24:39 +02:00
|
|
|
die("Can't execute '%s'", tool_executable_name);
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
dynstr_free(&ds_tmp);
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Run query using "mysql"
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int run_query(const char *query, DYNAMIC_STRING *ds_res,
|
|
|
|
my_bool force)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
File fd;
|
|
|
|
char query_file_path[FN_REFLEN];
|
2009-09-28 08:24:19 +02:00
|
|
|
const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;";
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
DBUG_ENTER("run_query");
|
|
|
|
DBUG_PRINT("enter", ("query: %s", query));
|
2010-03-09 10:18:46 +01:00
|
|
|
if ((fd= create_temp_file(query_file_path,
|
|
|
|
opt_tmpdir[0] ? opt_tmpdir : NULL,
|
2007-04-19 21:30:46 +02:00
|
|
|
"sql", O_CREAT | O_SHARE | O_RDWR,
|
2007-04-18 13:21:39 +02:00
|
|
|
MYF(MY_WME))) < 0)
|
|
|
|
die("Failed to create temporary file for defaults");
|
|
|
|
|
2009-09-28 08:24:19 +02:00
|
|
|
/*
|
|
|
|
Master and slave should be upgraded separately. All statements executed
|
|
|
|
by mysql_upgrade will not be binlogged.
|
|
|
|
'SET SQL_LOG_BIN=0' is executed before any other statements.
|
|
|
|
*/
|
|
|
|
if (!opt_write_binlog)
|
|
|
|
{
|
|
|
|
if (my_write(fd, sql_log_bin, sizeof(sql_log_bin)-1,
|
|
|
|
MYF(MY_FNABP | MY_WME)))
|
|
|
|
{
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
my_delete(query_file_path, MYF(0));
|
|
|
|
die("Failed to write to '%s'", query_file_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-13 15:11:25 +02:00
|
|
|
if (my_write(fd, (uchar*) query, strlen(query),
|
2007-04-18 13:21:39 +02:00
|
|
|
MYF(MY_FNABP | MY_WME)))
|
2007-10-09 04:30:41 +02:00
|
|
|
{
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
my_delete(query_file_path, MYF(0));
|
2007-04-18 13:21:39 +02:00
|
|
|
die("Failed to write to '%s'", query_file_path);
|
2007-10-09 04:30:41 +02:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
ret= run_tool(mysql_path,
|
|
|
|
ds_res,
|
2007-08-27 11:31:49 +02:00
|
|
|
"--no-defaults",
|
2007-04-20 07:20:26 +02:00
|
|
|
ds_args.str,
|
2007-04-18 13:21:39 +02:00
|
|
|
"--database=mysql",
|
|
|
|
"--batch", /* Turns off pager etc. */
|
|
|
|
force ? "--force": "--skip-force",
|
|
|
|
ds_res ? "--silent": "",
|
|
|
|
"<",
|
|
|
|
query_file_path,
|
|
|
|
"2>&1",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
my_close(fd, MYF(0));
|
2007-08-03 12:54:06 +02:00
|
|
|
my_delete(query_file_path, MYF(0));
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2007-02-28 21:05:39 +01:00
|
|
|
DBUG_RETURN(ret);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Extract the value returned from result of "show variable like ..."
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int extract_variable_from_show(DYNAMIC_STRING* ds, char* value)
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
char *value_start, *value_end;
|
|
|
|
/*
|
|
|
|
The query returns "datadir\t<datadir>\n", skip past
|
|
|
|
the tab
|
|
|
|
*/
|
|
|
|
if ((value_start= strchr(ds->str, '\t')) == NULL)
|
|
|
|
return 1; /* Unexpected result */
|
|
|
|
value_start++;
|
|
|
|
|
|
|
|
/* Don't copy the ending newline */
|
2007-04-18 19:00:42 +02:00
|
|
|
if ((value_end= strchr(value_start, '\n')) == NULL)
|
2007-04-18 13:21:39 +02:00
|
|
|
return 1; /* Unexpected result */
|
|
|
|
|
|
|
|
strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
|
|
|
|
return 0;
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static int get_upgrade_info_file_name(char* name)
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
DYNAMIC_STRING ds_datadir;
|
|
|
|
DBUG_ENTER("get_upgrade_info_file_name");
|
|
|
|
|
|
|
|
if (init_dynamic_string(&ds_datadir, NULL, 32, 32))
|
|
|
|
die("Out of memory");
|
|
|
|
|
|
|
|
if (run_query("show variables like 'datadir'",
|
|
|
|
&ds_datadir, FALSE) ||
|
|
|
|
extract_variable_from_show(&ds_datadir, name))
|
2006-11-08 03:45:50 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
dynstr_free(&ds_datadir);
|
|
|
|
DBUG_RETURN(1); /* Query failed */
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
dynstr_free(&ds_datadir);
|
|
|
|
|
|
|
|
fn_format(name, "mysql_upgrade_info", name, "", MYF(0));
|
|
|
|
DBUG_PRINT("exit", ("name: %s", name));
|
|
|
|
DBUG_RETURN(0);
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Read the content of mysql_upgrade_info file and
|
|
|
|
compare the version number form file against
|
|
|
|
version number wich mysql_upgrade was compiled for
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
This is an optimization to avoid running mysql_upgrade
|
|
|
|
when it's already been performed for the particular
|
|
|
|
version of MySQL.
|
|
|
|
|
|
|
|
In case the MySQL server can't return the upgrade info
|
|
|
|
file it's always better to report that the upgrade hasn't
|
|
|
|
been performed.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int upgrade_already_done(void)
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
FILE *in;
|
|
|
|
char upgrade_info_file[FN_REFLEN]= {0};
|
|
|
|
char buf[sizeof(MYSQL_SERVER_VERSION)+1];
|
2009-08-28 17:51:31 +02:00
|
|
|
char *res;
|
2007-03-01 18:12:56 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
if (get_upgrade_info_file_name(upgrade_info_file))
|
|
|
|
return 0; /* Could not get filename => not sure */
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
if (!(in= my_fopen(upgrade_info_file, O_RDONLY, MYF(0))))
|
|
|
|
return 0; /* Could not open file => not sure */
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Read from file, don't care if it fails since it
|
|
|
|
will be detected by the strncmp
|
|
|
|
*/
|
|
|
|
bzero(buf, sizeof(buf));
|
2009-08-28 17:51:31 +02:00
|
|
|
res= fgets(buf, sizeof(buf), in);
|
2007-02-28 21:23:35 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
my_fclose(in, MYF(0));
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2010-07-20 20:07:36 +02:00
|
|
|
if (!res)
|
|
|
|
return 0; /* Could not read from file => not sure */
|
|
|
|
|
|
|
|
return (strncmp(res, MYSQL_SERVER_VERSION,
|
2007-04-18 13:21:39 +02:00
|
|
|
sizeof(MYSQL_SERVER_VERSION)-1)==0);
|
|
|
|
}
|
2006-04-28 06:07:25 +02:00
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Write mysql_upgrade_info file in servers data dir indicating that
|
|
|
|
upgrade has been done for this version
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
This might very well fail but since it's just an optimization
|
|
|
|
to run mysql_upgrade only when necessary the error can be
|
|
|
|
ignored.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void create_mysql_upgrade_info_file(void)
|
|
|
|
{
|
|
|
|
FILE *out;
|
|
|
|
char upgrade_info_file[FN_REFLEN]= {0};
|
|
|
|
|
|
|
|
if (get_upgrade_info_file_name(upgrade_info_file))
|
|
|
|
return; /* Could not get filename => skip */
|
|
|
|
|
|
|
|
if (!(out= my_fopen(upgrade_info_file, O_TRUNC | O_WRONLY, MYF(0))))
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2006-11-21 00:46:13 +01:00
|
|
|
fprintf(stderr,
|
2007-04-18 13:21:39 +02:00
|
|
|
"Could not create the upgrade info file '%s' in "
|
|
|
|
"the MySQL Servers datadir, errno: %d\n",
|
|
|
|
upgrade_info_file, errno);
|
|
|
|
return;
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
|
|
|
|
2007-04-23 13:07:49 +02:00
|
|
|
/* Write new version to file */
|
|
|
|
fputs(MYSQL_SERVER_VERSION, out);
|
|
|
|
my_fclose(out, MYF(0));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check if the upgrad_info_file was properly created/updated
|
|
|
|
It's not a fatal error -> just print a message if it fails
|
|
|
|
*/
|
|
|
|
if (!upgrade_already_done())
|
2007-04-18 13:21:39 +02:00
|
|
|
fprintf(stderr,
|
|
|
|
"Could not write to the upgrade info file '%s' in "
|
|
|
|
"the MySQL Servers datadir, errno: %d\n",
|
|
|
|
upgrade_info_file, errno);
|
2007-04-23 13:07:49 +02:00
|
|
|
return;
|
2007-04-18 13:21:39 +02:00
|
|
|
}
|
2007-02-28 21:05:39 +01:00
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2009-05-27 10:24:25 +02:00
|
|
|
/*
|
|
|
|
Print connection-related arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void print_conn_args(const char *tool_name)
|
|
|
|
{
|
|
|
|
if (conn_args.str[0])
|
|
|
|
verbose("Running '%s' with connection arguments: %s", tool_name,
|
|
|
|
conn_args.str);
|
|
|
|
else
|
|
|
|
verbose("Running '%s with default connection arguments", tool_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Check and upgrade(if neccessary) all tables
|
|
|
|
in the server using "mysqlcheck --check-upgrade .."
|
|
|
|
*/
|
2007-02-28 21:05:39 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
static int run_mysqlcheck_upgrade(void)
|
|
|
|
{
|
2009-05-27 10:24:25 +02:00
|
|
|
print_conn_args("mysqlcheck");
|
2007-04-18 13:21:39 +02:00
|
|
|
return run_tool(mysqlcheck_path,
|
|
|
|
NULL, /* Send output from mysqlcheck directly to screen */
|
2007-08-27 11:31:49 +02:00
|
|
|
"--no-defaults",
|
2007-04-19 21:30:46 +02:00
|
|
|
ds_args.str,
|
2007-04-18 13:21:39 +02:00
|
|
|
"--check-upgrade",
|
|
|
|
"--all-databases",
|
|
|
|
"--auto-repair",
|
2009-09-28 08:24:19 +02:00
|
|
|
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
|
2008-12-09 09:30:49 +01:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int run_mysqlcheck_fixnames(void)
|
|
|
|
{
|
2009-05-27 10:24:25 +02:00
|
|
|
print_conn_args("mysqlcheck");
|
2008-12-09 09:30:49 +01:00
|
|
|
return run_tool(mysqlcheck_path,
|
|
|
|
NULL, /* Send output from mysqlcheck directly to screen */
|
|
|
|
"--no-defaults",
|
|
|
|
ds_args.str,
|
|
|
|
"--all-databases",
|
2008-06-15 15:01:07 +02:00
|
|
|
"--fix-db-names",
|
|
|
|
"--fix-table-names",
|
2009-09-28 08:24:19 +02:00
|
|
|
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
|
2007-04-18 13:21:39 +02:00
|
|
|
NULL);
|
|
|
|
}
|
2007-02-28 21:05:39 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
static const char *expected_errors[]=
|
|
|
|
{
|
|
|
|
"ERROR 1060", /* Duplicate column name */
|
|
|
|
"ERROR 1061", /* Duplicate key name */
|
|
|
|
"ERROR 1054", /* Unknown column */
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static my_bool is_expected_error(const char* line)
|
|
|
|
{
|
|
|
|
const char** error= expected_errors;
|
|
|
|
while (*error)
|
2007-01-18 17:38:05 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Check if lines starting with ERROR
|
|
|
|
are in the list of expected errors
|
|
|
|
*/
|
|
|
|
if (strncmp(line, "ERROR", 5) != 0 ||
|
|
|
|
strncmp(line, *error, strlen(*error)) == 0)
|
|
|
|
return 1; /* Found expected error */
|
|
|
|
error++;
|
2007-01-18 17:38:05 +01:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
static char* get_line(char* line)
|
|
|
|
{
|
|
|
|
while (*line && *line != '\n')
|
|
|
|
line++;
|
|
|
|
if (*line)
|
|
|
|
line++;
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Print the current line to stderr */
|
|
|
|
static void print_line(char* line)
|
|
|
|
{
|
|
|
|
while (*line && *line != '\n')
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
fputc(*line, stderr);
|
|
|
|
line++;
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
fputc('\n', stderr);
|
|
|
|
}
|
2006-04-28 06:07:25 +02:00
|
|
|
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Update all system tables in MySQL Server to current
|
|
|
|
version using "mysql" to execute all the SQL commands
|
|
|
|
compiled into the mysql_fix_privilege_tables array
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int run_sql_fix_privilege_tables(void)
|
|
|
|
{
|
|
|
|
int found_real_errors= 0;
|
|
|
|
DYNAMIC_STRING ds_result;
|
|
|
|
DBUG_ENTER("run_sql_fix_privilege_tables");
|
|
|
|
|
|
|
|
if (init_dynamic_string(&ds_result, "", 512, 512))
|
|
|
|
die("Out of memory");
|
|
|
|
|
|
|
|
verbose("Running 'mysql_fix_privilege_tables'...");
|
|
|
|
run_query(mysql_fix_privilege_tables,
|
|
|
|
&ds_result, /* Collect result */
|
|
|
|
TRUE);
|
|
|
|
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Scan each line of the result for real errors
|
|
|
|
and ignore the expected one(s) like "Duplicate column name",
|
|
|
|
"Unknown column" and "Duplicate key name" since they just
|
|
|
|
indicate the system tables are already up to date
|
|
|
|
*/
|
|
|
|
char *line= ds_result.str;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!is_expected_error(line))
|
|
|
|
{
|
|
|
|
/* Something unexpected failed, dump error line to screen */
|
|
|
|
found_real_errors++;
|
|
|
|
print_line(line);
|
|
|
|
}
|
2009-12-03 17:15:47 +01:00
|
|
|
else if (strncmp(line, "WARNING", 7) == 0)
|
|
|
|
{
|
|
|
|
print_line(line);
|
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
} while ((line= get_line(line)) && *line);
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
dynstr_free(&ds_result);
|
|
|
|
return found_real_errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *load_default_groups[]=
|
|
|
|
{
|
|
|
|
"client", /* Read settings how to connect to server */
|
|
|
|
"mysql_upgrade", /* Read special settings for mysql_upgrade*/
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2008-08-07 18:24:39 +02:00
|
|
|
char self_name[FN_REFLEN];
|
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
MY_INIT(argv[0]);
|
|
|
|
|
2008-08-07 18:24:39 +02:00
|
|
|
#if __WIN__
|
|
|
|
if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
strncpy(self_name, argv[0], FN_REFLEN);
|
|
|
|
}
|
|
|
|
|
2009-05-27 10:24:25 +02:00
|
|
|
if (init_dynamic_string(&ds_args, "", 512, 256) ||
|
|
|
|
init_dynamic_string(&conn_args, "", 512, 256))
|
2007-04-18 13:21:39 +02:00
|
|
|
die("Out of memory");
|
|
|
|
|
2009-10-09 16:44:22 +02:00
|
|
|
if (load_defaults("my", load_default_groups, &argc, &argv))
|
|
|
|
die(NULL);
|
2007-04-18 13:21:39 +02:00
|
|
|
defaults_argv= argv; /* Must be freed by 'free_defaults' */
|
|
|
|
|
|
|
|
if (handle_options(&argc, &argv, my_long_options, get_one_option))
|
|
|
|
die(NULL);
|
2007-08-01 21:59:05 +02:00
|
|
|
if (debug_info_flag)
|
|
|
|
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
|
|
|
|
if (debug_check_flag)
|
|
|
|
my_end_arg= MY_CHECK_ERROR;
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
if (tty_password)
|
2007-01-18 17:38:05 +01:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
opt_password= get_tty_password(NullS);
|
|
|
|
/* add password to defaults file */
|
2007-04-19 21:30:46 +02:00
|
|
|
dynstr_append_os_quoted(&ds_args, "--password=", opt_password, NullS);
|
|
|
|
dynstr_append(&ds_args, " ");
|
2007-01-18 17:38:05 +01:00
|
|
|
}
|
2007-04-18 13:21:39 +02:00
|
|
|
/* add user to defaults file */
|
2007-04-19 21:30:46 +02:00
|
|
|
dynstr_append_os_quoted(&ds_args, "--user=", opt_user, NullS);
|
|
|
|
dynstr_append(&ds_args, " ");
|
2007-04-18 13:21:39 +02:00
|
|
|
|
|
|
|
/* Find mysql */
|
2008-08-07 18:24:39 +02:00
|
|
|
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
|
2007-04-18 13:21:39 +02:00
|
|
|
|
2009-10-28 11:02:00 +01:00
|
|
|
if (!opt_systables_only)
|
|
|
|
{
|
|
|
|
/* Find mysqlcheck */
|
|
|
|
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("The --upgrade-system-tables option was used, databases won't be touched.\n");
|
|
|
|
}
|
2006-11-08 03:45:50 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/*
|
|
|
|
Read the mysql_upgrade_info file to check if mysql_upgrade
|
|
|
|
already has been run for this installation of MySQL
|
|
|
|
*/
|
|
|
|
if (!opt_force && upgrade_already_done())
|
2006-04-28 06:07:25 +02:00
|
|
|
{
|
2007-04-18 13:21:39 +02:00
|
|
|
printf("This installation of MySQL is already upgraded to %s, "
|
|
|
|
"use --force if you still need to run mysql_upgrade\n",
|
|
|
|
MYSQL_SERVER_VERSION);
|
|
|
|
die(NULL);
|
2006-04-28 06:07:25 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 21:05:39 +01:00
|
|
|
/*
|
2007-04-18 13:21:39 +02:00
|
|
|
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
|
2007-02-28 21:05:39 +01:00
|
|
|
*/
|
2009-10-28 11:02:00 +01:00
|
|
|
if ((!opt_systables_only &&
|
|
|
|
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
|
2007-04-18 13:21:39 +02:00
|
|
|
run_sql_fix_privilege_tables())
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The upgrade failed to complete in some way or another,
|
|
|
|
significant error message should have been printed to the screen
|
|
|
|
*/
|
|
|
|
die("Upgrade failed" );
|
|
|
|
}
|
|
|
|
verbose("OK");
|
2006-04-28 06:07:25 +02:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
/* Create a file indicating upgrade has been performed */
|
|
|
|
create_mysql_upgrade_info_file();
|
2007-02-28 21:05:39 +01:00
|
|
|
|
2007-04-18 13:21:39 +02:00
|
|
|
free_used_memory();
|
2007-08-01 21:59:05 +02:00
|
|
|
my_end(my_end_arg);
|
2007-04-18 13:21:39 +02:00
|
|
|
exit(0);
|
2006-11-08 03:45:50 +01:00
|
|
|
}
|
|
|
|
|