Commit 406233b6 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.1-new-maint

into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


BitKeeper/etc/ignore:
  auto-union
Makefile.am:
  Auto merged
parents 4e6e8a39 5a144fcd
...@@ -1810,6 +1810,7 @@ repl-tests/test-repl/sum-wlen-slave.master.re ...@@ -1810,6 +1810,7 @@ repl-tests/test-repl/sum-wlen-slave.master.re
repl-tests/test-repl/sum-wlen-slave.master.reje repl-tests/test-repl/sum-wlen-slave.master.reje
replace/*.ds? replace/*.ds?
replace/*.vcproj replace/*.vcproj
scripts/comp_sql
scripts/fill_func_tables scripts/fill_func_tables
scripts/fill_func_tables.sql scripts/fill_func_tables.sql
scripts/fill_help_tables scripts/fill_help_tables
...@@ -1827,6 +1828,7 @@ scripts/mysql_find_rows ...@@ -1827,6 +1828,7 @@ scripts/mysql_find_rows
scripts/mysql_fix_extensions scripts/mysql_fix_extensions
scripts/mysql_fix_privilege_tables scripts/mysql_fix_privilege_tables
scripts/mysql_fix_privilege_tables.sql scripts/mysql_fix_privilege_tables.sql
scripts/mysql_fix_privilege_tables_sql.c
scripts/mysql_install_db scripts/mysql_install_db
scripts/mysql_secure_installation scripts/mysql_secure_installation
scripts/mysql_setpermission scripts/mysql_setpermission
......
...@@ -21,9 +21,9 @@ AUTOMAKE_OPTIONS = foreign ...@@ -21,9 +21,9 @@ AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
README COPYING EXCEPTIONS-CLIENT CMakeLists.txt README COPYING EXCEPTIONS-CLIENT CMakeLists.txt
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common \ @readline_topdir@ sql-common scripts \
@thread_dirs@ pstack \ @thread_dirs@ pstack \
@sql_union_dirs@ unittest storage plugin \ @sql_union_dirs@ scripts unittest storage plugin \
@sql_server@ scripts @man_dirs@ tests \ @sql_server@ scripts @man_dirs@ tests \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
mysql-test support-files sql-bench @tools_dirs@ \ mysql-test support-files sql-bench @tools_dirs@ \
......
...@@ -14,57 +14,42 @@ ...@@ -14,57 +14,42 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "client_priv.h" #include "client_priv.h"
#include <my_dir.h>
#include <my_list.h>
#include <sslopt-vars.h> #include <sslopt-vars.h>
#include "../scripts/mysql_fix_privilege_tables_sql.c"
#define UPGRADE_DEFAULTS_NAME "mysql_upgrade_defaults" static char mysql_path[FN_REFLEN];
#define MYSQL_UPGRADE_INFO_NAME "mysql_upgrade_info" static char mysqlcheck_path[FN_REFLEN];
#define MYSQL_FIX_PRIV_TABLES_NAME "mysql_fix_privilege_tables.sql" static char defaults_file_option[32+FN_REFLEN];
#define MY_PARENT (1 << 0) static my_bool opt_force, opt_verbose;
#define MY_ISDIR (1 << 1) static char *opt_user= (char*)"root";
#define MY_SEARCH_SELF (1 << 2)
static DYNAMIC_STRING ds_options;
static char *opt_password= 0;
static my_bool tty_password= 0;
#ifdef __WIN__
const char *mysqlcheck_name= "mysqlcheck.exe";
const char *mysql_name= "mysql.exe";
const char *mysqld_name= "mysqld.exe";
#define EXTRA_CLIENT_PATHS "client/release", "client/debug"
#else
const char *mysqlcheck_name= "mysqlcheck";
const char *mysql_name= "mysql";
const char *mysqld_name= "mysqld";
#define EXTRA_CLIENT_PATHS "client"
#endif /*__WIN__*/
extern TYPELIB sql_protocol_typelib;
static my_bool opt_force= 0, opt_verbose= 0, opt_compress= 0;
static char *user= (char*) "root", *basedir= 0, *datadir= 0, *opt_password= 0;
static char *current_host= 0;
static char *opt_default_charset= 0, *opt_charsets_dir= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name= 0;
#endif
static char *opt_protocol= 0;
static my_string opt_mysql_port= 0, opt_mysql_unix_port= 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
static char *default_dbug_option= (char*) "d:t:O,/tmp/mysql_upgrade.trace"; static char *default_dbug_option= (char*) "d:t:O,/tmp/mysql_upgrade.trace";
#endif #endif
static my_bool info_flag= 0, tty_password= 0;
static char **defaults_argv; 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>
static struct my_option my_long_options[]= static struct my_option my_long_options[]=
{ {
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"basedir", 'b', "Specifies the directory where MySQL is installed", {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty",
(gptr*) &basedir, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd',
{"datadir", 'd', "Specifies the data directory", (gptr*) &datadir, "Not used by mysql_upgrade. Only for backward compatibilty",
(gptr*) &datadir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF #ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit", {"debug", '#', "This is a non-debug version. Catch this and exit",
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
...@@ -72,629 +57,759 @@ static struct my_option my_long_options[]= ...@@ -72,629 +57,759 @@ static struct my_option my_long_options[]=
{"debug", '#', "Output debug log", (gptr *) & default_dbug_option, {"debug", '#', "Output debug log", (gptr *) & default_dbug_option,
(gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", 'T', "Print some debug info at exit.", (gptr *) & info_flag,
(gptr *) & info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &opt_default_charset, "Set the default character set.", 0,
(gptr*) &opt_default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
"has already been executed for the current version of MySQL.",
(gptr*) &opt_force, (gptr*) &opt_force, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &opt_charsets_dir, "Directory where character sets are.", 0,
(gptr*) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.", {"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, (gptr*)&not_used, (gptr*)&not_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
0, 0, 0}, {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
{"host",'h', "Connect to host.", (gptr*) &current_host, "has already been executed for the current version of MySQL.",
(gptr*) &current_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*)&opt_force, (gptr*)&opt_force, 0,
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},
{"password", 'p', {"password", 'p',
"Password to use when connecting to server. If password is not given" "Password to use when connecting to server. If password is not given"
" it's solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, " it's solicited on the tty.", (gptr*) &opt_password,(gptr*) &opt_password,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__ #ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, {"port", 'P', "Port number to use for connection.", 0,
(gptr*) &opt_mysql_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, {"protocol", OPT_MYSQL_PROTOCOL,
"The protocol of connection (tcp,socket,pipe,memory).", "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (gptr*) &shared_memory_base_name, "Base name of shared memory.", 0,
(gptr*) &shared_memory_base_name, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "User for login if not current user.", (gptr*) &opt_user,
{"user", 'u', "User for login if not current user.", (gptr*) &user, (gptr*) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
{"verbose", 'v', "Display more output about the process", {"verbose", 'v', "Display more output about the process",
(gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static const char *load_default_groups[]=
{
"mysql_upgrade", 0
};
#include <help_end.h> #include <help_end.h>
static LIST *extra_defaults= NULL;
typedef struct _extra_default static void free_used_memory(void)
{ {
int id; /* Close the defaults file */
const char *name; if (defaults_fd != -1)
int n_len; my_close(defaults_fd, MYF(0));
const char *value;
int v_len; /* Free memory allocated by 'load_defaults' */
} extra_default_t; free_defaults(defaults_argv);
static inline dynstr_free(&ds_options);
void set_extra_default(int id, const struct my_option *opt) }
static void die(const char *fmt, ...)
{ {
switch (id) { va_list args;
case 'b': case 'd': /* these are ours */ DBUG_ENTER("die");
case 'f': /* --force is ours */
case 'u': /* --user passed on cmdline */
case 'T': /* --debug-info is not accepted by mysqlcheck */
case 'p': /* --password may change yet */
/* so, do nothing */
break;
default:
{
LIST *l;
extra_default_t *d;
/* /* Print the error message */
Remove any earlier duplicates: they can va_start(args, fmt);
refer to invalid memory addresses (stale pointers) if (fmt)
*/
l= extra_defaults;
while (l)
{ {
LIST *n= l->next; fprintf(stderr, "FATAL ERROR: ");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
fflush(stderr);
}
va_end(args);
free_used_memory();
my_end(MY_CHECK_ERROR);
exit(1);
}
d= l->data;
if (d->id == id) static void verbose(const char *fmt, ...)
{
va_list args;
if (!opt_verbose)
return;
/* Print the verbose message */
va_start(args, fmt);
if (fmt)
{ {
extra_defaults= list_delete(extra_defaults, l); vfprintf(stdout, fmt, args);
my_free((gptr)l, MYF(0)); fprintf(stdout, "\n");
my_free((gptr)d, MYF(0)); fflush(stdout);
}
l= n;
} }
va_end(args);
}
d= (extra_default_t *)my_malloc(sizeof(extra_default_t),
MYF(MY_FAE|MY_ZEROFILL)); /*
d->id= id; Add one option - passed to mysql_upgrade on command line
d->name= opt->name; or by defaults file(my.cnf) - to a dynamic string that later
d->n_len= strlen(opt->name); can be written to a temporary file. In this way we pass the
if (opt->arg_type != NO_ARG && opt->value) same arguments on to mysql and mysql_check
switch (opt->var_type & GET_TYPE_MASK) { */
case GET_BOOL:
if (*((int *)opt->value)) static void add_one_option(DYNAMIC_STRING* ds,
const struct my_option *opt,
const char* argument)
{
dynstr_append(ds, opt->name);
if (opt->arg_type != NO_ARG)
{ {
d->value= "true"; dynstr_append(ds, "=");
d->v_len= 4; switch (opt->var_type & GET_TYPE_MASK) {
}
break;
case GET_STR: case GET_STR:
case GET_STR_ALLOC: case GET_STR_ALLOC:
d->value= *opt->value; dynstr_append(ds, argument);
d->v_len= strlen(d->value);
break; break;
default: default:
my_printf_error(0, "Error: internal error at %s:%d", MYF(0), die("internal error at %s: %d",__FILE__, __LINE__);
__FILE__, __LINE__);
exit(1);
}
list_push(extra_defaults, d);
} }
} }
dynstr_append(ds, "\n");
} }
static my_bool static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__ ((unused)), get_one_option(int optid, const struct my_option *opt,
char *argument) char *argument)
{ {
my_bool add_option= TRUE;
switch (optid) { switch (optid) {
case '?': case '?':
puts printf("MySQL utility for upgrading database to MySQL version %s\n",
("MySQL utility to upgrade database to the current server version"); MYSQL_SERVER_VERSION);
puts("");
my_print_help(my_long_options); my_print_help(my_long_options);
exit(0); exit(0);
break;
case '#': case '#':
DBUG_PUSH(argument ? argument : default_dbug_option); DBUG_PUSH(argument ? argument : default_dbug_option);
add_option= FALSE;
break; break;
case 'p': case 'p':
tty_password= 1; tty_password= 1;
add_option= FALSE;
if (argument) if (argument)
{ {
char *start= argument; /* Add password to ds_options before overwriting the arg with x's */
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); add_one_option(&ds_options, opt, argument);
opt_password= my_strdup(argument, MYF(MY_FAE));
while (*argument) while (*argument)
*argument++= 'x'; /* Destroy argument */ *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]= 0; /* Cut length of argument */
tty_password= 0; tty_password= 0;
} }
break; break;
#ifdef __WIN__
case 'W': case 'b': /* --basedir */
my_free(opt_protocol, MYF(MY_ALLOW_ZERO_PTR)); case 'v': /* --verbose */
opt_protocol= my_strdup("pipe", MYF(MY_FAE)); case 'd': /* --datadir */
case 'f': /* --force */
add_option= FALSE;
break; break;
#endif
case OPT_MYSQL_PROTOCOL:
if (find_type(argument, &sql_protocol_typelib, 0) > 0)
{
my_free(opt_protocol, MYF(MY_ALLOW_ZERO_PTR));
opt_protocol= my_strdup(argument, MYF(MY_FAE));
} }
else
if (add_option)
{ {
fprintf(stderr, "Unknown option to protocol: %s\n", argument); /*
exit(1); This is an option that is accpted by mysql_upgrade just so
} it can be passed on to "mysql" and "mysqlcheck"
break; Save it in the ds_options string
#include <sslopt-case.h> */
default:; add_one_option(&ds_options, opt, argument);
} }
set_extra_default(opt->id, opt);
return 0; return 0;
} }
static int create_check_file(const char *path) /*
Write the options that should be passed on to
mysql and mysqlcheck to a temporary file
*/
static void create_defaults_file(void)
{ {
int ret; static char defaults_file_path[FN_REFLEN];
File fd; DBUG_ENTER("create_defaults_file");
fd= my_open(path, O_CREAT | O_WRONLY, MYF(MY_FAE | MY_WME)); if ((defaults_fd= create_temp_file(defaults_file_path, NULL,
if (fd < 0) { "cnf", O_CREAT | O_SHARE,
ret= 1; MYF(MY_WME))) < 0)
goto error; die("Failed to create temporary file for defaults");
}
ret= my_write(fd, MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION) - 1,
MYF(MY_WME | MY_FNABP));
ret|= my_close(fd, MYF(MY_FAE | MY_WME));
error:
return ret;
}
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);
static int create_defaults_file(const char *path, const char *forced_path) /*
{ Dont close the temporary file yet, it will be used
int ret; by mysql and mysqlcheck
uint cnt; */
File forced_file, defaults_file;
DYNAMIC_STRING buf; /*
extra_default_t *d; Create the option that should be added to
tools in order to use this file
*/
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_ENTER("create_defaults_file"); DBUG_VOID_RETURN;
DBUG_PRINT("enter", ("path: %s, forced_path: %s", path, forced_path)); }
/* Delete any previous defaults file generated by mysql_upgrade */
my_delete(path, MYF(0));
defaults_file= my_open(path, O_BINARY | O_CREAT | O_WRONLY | O_EXCL, static int run_command(char* cmd,
MYF(MY_FAE | MY_WME)); DYNAMIC_STRING *ds_res)
if (defaults_file < 0) {
{ char buf[512]= {0};
ret= 1; FILE *res_file;
goto out;
}
if (init_dynamic_string(&buf, NULL, my_getpagesize(), FN_REFLEN)) if (!(res_file= popen(cmd, "r")))
{ die("popen(\"%s\", \"r\") failed", cmd);
ret= 1;
goto error;
}
/* Copy forced_path file into the defaults_file being generated */ while (fgets(buf, sizeof(buf), res_file))
if (forced_path)
{ {
forced_file= my_open(forced_path, O_RDONLY, MYF(MY_FAE | MY_WME)); DBUG_PRINT("info", ("buf: %s", buf));
if (forced_file < 0) if(ds_res)
{ {
ret= 1; /* Save the output of this command in the supplied string */
goto error; dynstr_append(ds_res, buf);
} }
DBUG_PRINT("info", ("Copying from %s to %s", forced_path, path)); else
do
{
cnt= my_read(forced_file, buf.str, buf.max_length, MYF(MY_WME));
if ((cnt == MY_FILE_ERROR)
|| my_write(defaults_file, buf.str, cnt, MYF(MY_FNABP | MY_WME)))
{ {
ret= 1; /* Print it directly on screen */
my_close(forced_file, MYF(0)); fprintf(stdout, "%s", buf);
goto error;
} }
DBUG_PRINT("info", ("%s", buf.str));
} while (cnt == buf.max_length);
my_close(forced_file, MYF(0));
} }
/* Write all extra_default options into the [client] section */ return WEXITSTATUS(pclose(res_file));
dynstr_set(&buf, "\n[client]"); }
if (opt_password)
{
if (dynstr_append(&buf, "\npassword=") static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
|| dynstr_append(&buf, opt_password)) {
int ret;
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 *)))
{ {
ret = 1; /* Options should be os quoted */
goto error; if (strncmp(arg, "--", 2) == 0)
} dynstr_append_os_quoted(&ds_cmdline, arg, NullS);
else
dynstr_append(&ds_cmdline, arg);
dynstr_append(&ds_cmdline, " ");
} }
DBUG_PRINT("info", ("Writing extra_defaults to file"));
while (extra_defaults)
{
int len;
d= extra_defaults->data; va_end(args);
len= d->n_len + d->v_len + 1;
if (buf.length + len >= buf.max_length) /* to avoid realloc() */ 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);
}
if (my_write(defaults_file, buf.str, buf.length, MYF(MY_FNABP | MY_WME)))
/*
Try to get the full path to this exceutable
Return 0 if path found
*/
static my_bool get_full_path_to_executable(char* path)
{
my_bool ret;
DBUG_ENTER("get_full_path_to_executable");
#ifdef WIN
ret= GetModuleFileName(NULL, path, FN_REFLEN) != 0;
#else
/* my_readlink returns 0 if a symlink was read */
ret= my_readlink(path, "/proc/self/exe", MYF(0)) != 0;
/* Might also want to try with /proc/$$/exe if the above fails */
#endif
DBUG_PRINT("exit", ("path: %s", path));
DBUG_RETURN(ret);
}
/*
Look for the tool in the same directory as mysql_upgrade.
When running in a not yet installed build the the program
will exist but it need to be invoked via it's libtool wrapper.
Check if the found tool can executed and if not look in the
directory one step higher up where the libtool wrapper normally
is found
*/
static void find_tool(char *tool_path, const char *tool_name)
{
char path[FN_REFLEN];
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");
/* Initialize path with the full path to this program */
if (get_full_path_to_executable(path))
{
/*
Easy way to get full executable path failed, try
other methods
*/
if (my_progname[0] == FN_LIBCHAR)
{ {
ret= 1; /* 1. my_progname contains full path */
goto error; strmake(path, my_progname, FN_REFLEN);
} }
dynstr_set(&buf, NULL); else if (my_progname[0] == '.')
{
/* 2. my_progname contains relative path, prepend wd */
char buf[FN_REFLEN];
my_getwd(buf, FN_REFLEN, MYF(0));
snprintf(path, FN_REFLEN, "%s%s", buf, my_progname);
} }
if (dynstr_append_mem(&buf, "\n", 1) || else
dynstr_append_mem(&buf, d->name, d->n_len) ||
(d->v_len && (dynstr_append_mem(&buf, "=", 1) ||
dynstr_append_mem(&buf, d->value, d->v_len))))
{ {
ret= 1; /* 3. Just go for it and hope tool is in path */
goto error; path[0]= 0;
} }
DBUG_PRINT("info", ("%s", buf.str));
my_free((gptr)d, MYF(0));
list_pop(extra_defaults); /* pop off the head */
} }
if (my_write(defaults_file, buf.str, buf.length, MYF(MY_FNABP | MY_WME))) do
{ {
ret= 1; DBUG_PRINT("enter", ("path: %s", path));
goto error;
}
/* everything's all right */
ret= 0;
error:
dynstr_free(&buf);
if (defaults_file >= 0) /* Chop off last char(since it might be a /) */
ret|= my_close(defaults_file, MYF(MY_WME)); size_t pos= max((strlen(path)-1), 0);
path[pos]= 0;
if (ret) /* Chop off last dir part */
my_delete(path, MYF(0)); dirname_part(path, path);
out: /* Format name of the tool to search for */
DBUG_RETURN(ret); fn_format(tool_path, tool_name,
path, "", MYF(MY_REPLACE_DIR));
verbose("Looking for '%s' in: %s", tool_name, tool_path);
/* Make sure the tool exists */
if (my_access(tool_path, F_OK) != 0)
die("Can't find '%s'", tool_path);
/*
Make sure it can be executed, otherwise try again
in higher level directory
*/
}
while(run_tool(tool_path,
&ds_tmp, /* Get output from command, discard*/
"--help",
"2>&1",
IF_WIN("> NUL", "> /dev/null"),
NULL));
dynstr_free(&ds_tmp);
DBUG_VOID_RETURN;
} }
/* Compare filenames */ /*
static int comp_names(struct fileinfo *a, struct fileinfo *b) Run query using "mysql"
*/
static int run_query(const char *query, DYNAMIC_STRING *ds_res,
my_bool force)
{ {
return (strcmp(a->name,b->name)); int ret;
File fd;
char query_file_path[FN_REFLEN];
DBUG_ENTER("run_query");
DBUG_PRINT("enter", ("query: %s", query));
if ((fd= create_temp_file(query_file_path, NULL,
"sql", O_CREAT | O_SHARE,
MYF(MY_WME))) < 0)
die("Failed to create temporary file for defaults");
if (my_write(fd, query, strlen(query),
MYF(MY_FNABP | MY_WME)))
die("Failed to write to '%s'", query_file_path);
ret= run_tool(mysql_path,
ds_res,
defaults_file_option,
"--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));
DBUG_RETURN(ret);
} }
static int find_file(const char *name, const char *root, /*
uint flags, char *result, size_t len, ...) Extract the value returned from result of "show variable like ..."
*/
static int extract_variable_from_show(DYNAMIC_STRING* ds, char* value)
{ {
int ret= 1; char *value_start, *value_end;
va_list va; /*
const char *subdir; The query returns "datadir\t<datadir>\n", skip past
char *cp; the tab
FILEINFO key; */
if ((value_start= strchr(ds->str, '\t')) == NULL)
return 1; /* Unexpected result */
value_start++;
/* Init key with name of the file to look for */ /* Don't copy the ending newline */
key.name= (char*)name; if (value_start && (value_end= strchr(value_start, '\n')) == NULL)
return 1; /* Unexpected result */
DBUG_ASSERT(root != NULL); strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
return 0;
}
cp= strmake(result, root, len);
if (cp[-1] != FN_LIBCHAR)
*cp++= FN_LIBCHAR;
va_start(va, len); static int get_upgrade_info_file_name(char* name)
subdir= (!(flags & MY_SEARCH_SELF)) ? va_arg(va, char *) : ""; {
while (subdir) DYNAMIC_STRING ds_datadir;
{ DBUG_ENTER("get_upgrade_info_file_name");
MY_DIR *dir;
FILEINFO *match;
char *cp1;
cp1= strnmov(cp, subdir, len - (cp - result) - 1); if (init_dynamic_string(&ds_datadir, NULL, 32, 32))
die("Out of memory");
dir= my_dir(result, (flags & MY_ISDIR) ? MY_WANT_STAT : MYF(0)); if (run_query("show variables like 'datadir'",
if (dir) &ds_datadir, FALSE) ||
{ extract_variable_from_show(&ds_datadir, name))
match= bsearch(&key, dir->dir_entry, dir->number_off_files,
sizeof(FILEINFO), (qsort_cmp)comp_names);
if (match)
{
ret= (flags & MY_ISDIR) ? !MY_S_ISDIR(match->mystat->st_mode) : 0;
if (!ret)
{ {
if (cp1[-1] != FN_LIBCHAR) dynstr_free(&ds_datadir);
*cp1++= FN_LIBCHAR; DBUG_RETURN(1); /* Query failed */
}
if (!(flags & MY_PARENT)) dynstr_free(&ds_datadir);
strnmov(cp1, name, len - (cp1 - result));
else
*cp1= '\0';
my_dirend(dir); fn_format(name, "mysql_upgrade_info", name, "", MYF(0));
break; DBUG_PRINT("exit", ("name: %s", name));
} DBUG_RETURN(0);
}
my_dirend(dir);
}
subdir= va_arg(va, char *);
}
va_end(va);
return ret;
} }
int main(int argc, char **argv) /*
{ Read the content of mysql_upgrade_info file and
int ret; compare the version number form file against
version number wich mysql_upgrade was compiled for
char *forced_defaults_file; NOTE
char *forced_extra_defaults; This is an optimization to avoid running mysql_upgrade
char *local_defaults_group_suffix; when it's already been performed for the particular
version of MySQL.
char path[FN_REFLEN], upgrade_defaults_path[FN_REFLEN]; In case the MySQL server can't return the upgrade info
DYNAMIC_STRING cmdline; file it's always better to report that the upgrade hasn't
been performed.
MY_INIT(argv[0]); */
#ifdef __NETWARE__
setscreenmode(SCR_AUTOCLOSE_ON_EXIT); static int upgrade_already_done(void)
#endif {
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
char buf[sizeof(MYSQL_SERVER_VERSION)+1];
/* Check if we are forced to use specific defaults */ if (get_upgrade_info_file_name(upgrade_info_file))
get_defaults_options(argc, argv, return 0; /* Could not get filename => not sure */
&forced_defaults_file, &forced_extra_defaults,
&local_defaults_group_suffix);
load_defaults("my", load_default_groups, &argc, &argv); if (!(in= my_fopen(upgrade_info_file, O_RDONLY, MYF(0))))
defaults_argv= argv; return 0; /* Could not open file => not sure */
/* /*
Must init_dynamic_string before handle_options because string is freed Read from file, don't care if it fails since it
at error label. will be detected by the strncmp
*/ */
if (init_dynamic_string(&cmdline, NULL, 2 * FN_REFLEN + 128, FN_REFLEN) || bzero(buf, sizeof(buf));
handle_options(&argc, &argv, my_long_options, get_one_option)) fgets(buf, sizeof(buf), in);
{
ret= 1;
goto error;
}
if (tty_password)
opt_password= get_tty_password(NullS);
if (!basedir) my_fclose(in, MYF(0));
{
my_getwd(path, sizeof(path), MYF(0)); return (strncmp(buf, MYSQL_SERVER_VERSION,
basedir= my_strdup(path, MYF(0)); sizeof(MYSQL_SERVER_VERSION)-1)==0);
if (find_file("errmsg.sys", basedir, MYF(0), path, sizeof(path), }
"share/mysql/english", NullS)
|| find_file(mysqld_name, basedir, MYF(0), path, sizeof(path),
"bin", "libexec", NullS)) /*
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))))
{ {
my_free((gptr)basedir, MYF(0)); fprintf(stderr,
basedir= (char *)DEFAULT_MYSQL_HOME; "Could not create the upgrade info file '%s' in "
} "the MySQL Servers datadir, errno: %d\n",
upgrade_info_file, errno);
return;
} }
if (!datadir) /* Write new version to file, just print a message if it fails */
if (!fputs(MYSQL_SERVER_VERSION, out))
fprintf(stderr,
"Could not write to the upgrade info file '%s' in "
"the MySQL Servers datadir, errno: %d\n",
upgrade_info_file, errno);
my_fclose(out, MYF(0));
}
/*
Check and upgrade(if neccessary) all tables
in the server using "mysqlcheck --check-upgrade .."
*/
static int run_mysqlcheck_upgrade(void)
{
verbose("Running 'mysqlcheck'...");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
defaults_file_option,
"--check-upgrade",
"--all-databases",
"--auto-repair",
NULL);
}
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)
{ {
if (!find_file("mysql", basedir, MYF(MY_ISDIR|MY_PARENT), /*
path, sizeof(path), Check if lines starting with ERROR
"data", "var", NullS)) are in the list of expected errors
datadir= my_strdup(path, MYF(0)); */
else if (strncmp(line, "ERROR", 5) != 0 ||
datadir= (char *)DATADIR; strncmp(line, *error, strlen(*error)) == 0)
return 1; /* Found expected error */
error++;
} }
if (find_file("user.frm", datadir, MYF(0), path, sizeof(path), return 0;
"mysql", NullS)) }
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')
{ {
ret= 1; fputc(*line, stderr);
fprintf(stderr, line++;
"Can't find data directory. Please restart with"
" --datadir=path-to-writable-data-dir");
goto error;
} }
fputc('\n', stderr);
}
/*
Create the modified defaults file to be used by mysqlcheck
and mysql command line client
*/
fn_format(upgrade_defaults_path, UPGRADE_DEFAULTS_NAME, datadir, "", MYF(0));
create_defaults_file(upgrade_defaults_path, forced_extra_defaults);
/*
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);
{
/* /*
Read the mysql_upgrade_info file to check if mysql_upgrade Scan each line of the result for real errors
already has been done and ignore the expected one(s) like "Duplicate column name",
Maybe this could be done a little earlier? "Unknown column" and "Duplicate key name" since they just
indicate the system tables are already up to date
*/ */
if (!find_file(MYSQL_UPGRADE_INFO_NAME, datadir, MY_SEARCH_SELF, char *line= ds_result.str;
path, sizeof(path), NULL, NullS) do
&& !opt_force)
{ {
char buf[sizeof(MYSQL_SERVER_VERSION)]; if (!is_expected_error(line))
int fd, cnt;
fd= my_open(path, O_RDONLY, MYF(0));
cnt= my_read(fd, buf, sizeof(buf) - 1, MYF(0));
my_close(fd, MYF(0));
buf[cnt]= 0;
if (!strcmp(buf, MYSQL_SERVER_VERSION))
{ {
if (opt_verbose) /* Something unexpected failed, dump error line to screen */
puts("mysql_upgrade has already been done for this version"); found_real_errors++;
goto fix_priv_tables; print_line(line);
} }
} while ((line= get_line(line)) && *line);
} }
dynstr_free(&ds_result);
return found_real_errors;
}
/* Find mysqlcheck */
if (find_file(mysqlcheck_name, basedir, MYF(0), path, sizeof(path), static const char *load_default_groups[]=
"bin", EXTRA_CLIENT_PATHS, NullS)) {
{ "client", /* Read settings how to connect to server */
ret= 1; "mysql_upgrade", /* Read special settings for mysql_upgrade*/
fprintf(stderr, 0
"Can't find program '%s'\n" };
"Please restart with --basedir=mysql-install-directory",
mysqlcheck_name);
goto error; int main(int argc, char **argv)
} {
else MY_INIT(argv[0]);
#ifdef __NETWARE__
setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
#endif
if (init_dynamic_string(&ds_options, "[client]\n", 512, 256))
die("Out of memory");
load_defaults("my", load_default_groups, &argc, &argv);
defaults_argv= argv; /* Must be freed by 'free_defaults' */
if (handle_options(&argc, &argv, my_long_options, get_one_option))
die(NULL);
if (tty_password)
{ {
#ifdef __WIN__ opt_password= get_tty_password(NullS);
/* Windows requires an extra pair of quotes around the entire string. */ /* add password to defaults file */
dynstr_set(&cmdline, "\""); dynstr_append(&ds_options, "password=");
#else dynstr_append(&ds_options, opt_password);
dynstr_set(&cmdline, ""); dynstr_append(&ds_options, "\n");
#endif /* __WIN__ */
dynstr_append_os_quoted(&cmdline, path, NullS);
} }
/* add user to defaults file */
dynstr_append(&ds_options, "user=");
dynstr_append(&ds_options, opt_user);
dynstr_append(&ds_options, "\n");
/* Find mysql */
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"));
/* Find mysqlcheck */
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"));
/* /*
All settings have been written to the "upgrade_defaults_path" Create the defaults file(a small my.cnf) which will pass
instruct mysqlcheck to only read options from that file all arguments accepted by mysql_upgrade on to mysqlcheck
and mysql command line client
*/ */
dynstr_append(&cmdline, " "); create_defaults_file();
dynstr_append_os_quoted(&cmdline, "--defaults-file=",
upgrade_defaults_path, NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--check-upgrade", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--all-databases", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--auto-repair", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--user=", user, NullS);
#ifdef __WIN__
dynstr_append(&cmdline, "\"");
#endif /* __WIN__ */
/* Execute mysqlcheck */
if (opt_verbose)
printf("Running %s\n", cmdline.str);
DBUG_PRINT("info", ("Running: %s", cmdline.str));
ret= system(cmdline.str);
if (ret)
{
fprintf(stderr, "Error executing '%s'\n", cmdline.str);
goto error;
}
fn_format(path, MYSQL_UPGRADE_INFO_NAME, datadir, "", MYF(0)); /*
ret= create_check_file(path); Read the mysql_upgrade_info file to check if mysql_upgrade
if (ret) already has been run for this installation of MySQL
goto error; */
if (!opt_force && upgrade_already_done())
fix_priv_tables:
/* Find mysql */
if (find_file(mysql_name, basedir, MYF(0), path, sizeof(path),
"bin", EXTRA_CLIENT_PATHS, NullS))
{
ret= 1;
fprintf(stderr,
"Could not find MySQL command-line client (mysql).\n"
"Please use --basedir to specify the directory"
" where MySQL is installed.");
goto error;
}
else
{ {
#ifdef __WIN__ printf("This installation of MySQL is already upgraded to %s, "
/* Windows requires an extra pair of quotes around the entire string. */ "use --force if you still need to run mysql_upgrade\n",
dynstr_set(&cmdline, "\""); MYSQL_SERVER_VERSION);
#else die(NULL);
dynstr_set(&cmdline, "");
#endif /* __WIN__ */
dynstr_append_os_quoted(&cmdline, path, NullS);
} }
/* Find mysql_fix_privililege_tables.sql */ /*
if (find_file(MYSQL_FIX_PRIV_TABLES_NAME, basedir, MYF(0), Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
path, sizeof(path), */
"support_files", "share", "share/mysql", "scripts", if (run_mysqlcheck_upgrade() ||
NullS) run_sql_fix_privilege_tables())
&& find_file(MYSQL_FIX_PRIV_TABLES_NAME, "/usr/local/mysql", MYF(0),
path, sizeof(path),
"share/mysql", NullS))
{ {
ret= 1;
fprintf(stderr,
"Could not find file " MYSQL_FIX_PRIV_TABLES_NAME "\n"
"Please use --basedir to specify the directory"
" where MySQL is installed");
goto error;
}
/* /*
All settings have been written to the "upgrade_defaults_path", The upgrade failed to complete in some way or another,
instruct mysql to only read options from that file significant error message should have been printed to the screen
*/ */
dynstr_append(&cmdline, " "); die("Upgrade failed" );
dynstr_append_os_quoted(&cmdline, "--defaults-file=", }
upgrade_defaults_path, NullS); verbose("OK");
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--force", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--no-auto-rehash", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--batch", NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--user=", user, NullS);
dynstr_append(&cmdline, " ");
dynstr_append_os_quoted(&cmdline, "--database=mysql", NullS);
dynstr_append(&cmdline, " < ");
dynstr_append_os_quoted(&cmdline, path, NullS);
#ifdef __WIN__
dynstr_append(&cmdline, "\"");
#endif /* __WIN__ */
/* Execute "mysql --force < mysql_fix_privilege_tables.sql" */
if (opt_verbose)
printf("Running %s\n", cmdline.str);
DBUG_PRINT("info", ("Running: %s", cmdline.str));
ret= system(cmdline.str);
if (ret)
fprintf(stderr, "Error executing '%s'\n", cmdline.str);
error:
dynstr_free(&cmdline);
/* Delete the generated defaults file */ /* Create a file indicating upgrade has been performed */
my_delete(upgrade_defaults_path, MYF(0)); create_mysql_upgrade_info_file();
free_defaults(defaults_argv); free_used_memory();
my_end(info_flag ? MY_CHECK_ERROR : 0); my_end(MY_CHECK_ERROR);
return ret; exit(0);
} }
...@@ -1329,23 +1329,31 @@ void var_set(const char *var_name, const char *var_name_end, ...@@ -1329,23 +1329,31 @@ void var_set(const char *var_name, const char *var_name_end,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void var_set_string(const char* name, const char* value)
{
var_set(name, name + strlen(name), value, value + strlen(value));
}
void var_set_int(const char* name, int value)
{
char buf[21];
snprintf(buf, sizeof(buf), "%d", value);
var_set_string(name, buf);
}
/* /*
Store an integer (typically the returncode of the last SQL) Store an integer (typically the returncode of the last SQL)
statement in the mysqltest builtin variable $mysql_errno, by statement in the mysqltest builtin variable $mysql_errno
simulating of a user statement "let $mysql_errno= <integer>"
*/ */
void var_set_errno(int sql_errno) void var_set_errno(int sql_errno)
{ {
/* TODO MASV make easier */ var_set_int("$mysql_errno", sql_errno);
const char *var_name= "$mysql_errno";
char var_val[21];
uint length= my_sprintf(var_val, (var_val, "%d", sql_errno));
var_set(var_name, var_name + 12, var_val, var_val + length);
return;
} }
/* /*
Set variable from the result of a query Set variable from the result of a query
...@@ -6011,6 +6019,8 @@ int main(int argc, char **argv) ...@@ -6011,6 +6019,8 @@ int main(int argc, char **argv)
1024, 0, 0, get_var_key, var_free, MYF(0))) 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed"); die("Variable hash initialization failed");
var_set_string("$MYSQL_SERVER_VERSION", MYSQL_SERVER_VERSION);
memset(&master_pos, 0, sizeof(master_pos)); memset(&master_pos, 0, sizeof(master_pos));
parser.current_line= parser.read_lines= 0; parser.current_line= parser.read_lines= 0;
......
...@@ -77,6 +77,13 @@ ...@@ -77,6 +77,13 @@
#endif #endif
#endif /* _WIN32... */ #endif /* _WIN32... */
/* Make it easier to add conditionl code for windows */
#ifdef __WIN__
#define IF_WIN(A,B) (A)
#else
#define IF_WIN(A,B) (B)
#endif
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
#ifdef WITH_NDB_BINLOG #ifdef WITH_NDB_BINLOG
#define HAVE_NDB_BINLOG 1 #define HAVE_NDB_BINLOG 1
......
...@@ -354,6 +354,13 @@ sub collect_one_test_case($$$$$$$) { ...@@ -354,6 +354,13 @@ sub collect_one_test_case($$$$$$$) {
next; next;
} }
$value= mtr_match_prefix($opt, "--slave-num=");
if ( defined $value )
{
$tinfo->{'slave_num'}= $value;
next;
}
$value= mtr_match_prefix($opt, "--result-file="); $value= mtr_match_prefix($opt, "--result-file=");
if ( defined $value ) if ( defined $value )
{ {
......
...@@ -22,64 +22,9 @@ mysql.time_zone_name OK ...@@ -22,64 +22,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK mysql.time_zone_transition OK
mysql.time_zone_transition_type OK mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
@hadGrantPriv:=1
1
1
1
@hadShowDbPriv:=1
1
1
1
@hadCreateViewPriv:=1
1
1
1
@hadCreateRoutinePriv:=1
1
1
1
@hadCreateUserPriv:=1
1
1
1
@hadEventPriv :=1
1
1
1
@hadTriggerPriv :=1
1
1
1
Run it again - should say already completed Run it again - should say already completed
@hadGrantPriv:=1 This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
1 Force should run it regardless of wether it's been run before
1
1
@hadShowDbPriv:=1
1
1
1
@hadCreateViewPriv:=1
1
1
1
@hadCreateRoutinePriv:=1
1
1
1
@hadCreateUserPriv:=1
1
1
1
@hadEventPriv :=1
1
1
1
@hadTriggerPriv :=1
1
1
1
Force should run it regardless of wheter it's been run before
mysql.columns_priv OK mysql.columns_priv OK
mysql.db OK mysql.db OK
mysql.event OK mysql.event OK
...@@ -103,31 +48,33 @@ mysql.time_zone_name OK ...@@ -103,31 +48,33 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK mysql.time_zone_transition OK
mysql.time_zone_transition_type OK mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
@hadGrantPriv:=1 CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
1 GRANT ALL ON *.* TO mysqltest1@'%';
1 Run mysql_upgrade with password protected account
1 mysql.columns_priv OK
@hadShowDbPriv:=1 mysql.db OK
1 mysql.event OK
1 mysql.func OK
1 mysql.general_log OK
@hadCreateViewPriv:=1 mysql.help_category OK
1 mysql.help_keyword OK
1 mysql.help_relation OK
1 mysql.help_topic OK
@hadCreateRoutinePriv:=1 mysql.host OK
1 mysql.ndb_binlog_index OK
1 mysql.plugin OK
1 mysql.proc OK
@hadCreateUserPriv:=1 mysql.procs_priv OK
1 mysql.servers OK
1 mysql.slow_log OK
1 mysql.tables_priv OK
@hadEventPriv :=1 mysql.time_zone OK
1 mysql.time_zone_leap_second OK
1 mysql.time_zone_name OK
1 mysql.time_zone_transition OK
@hadTriggerPriv :=1 mysql.time_zone_transition_type OK
1 mysql.user OK
1 DROP USER mysqltest1@'%';
1 Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket 'var/tmp/no_sock_here' (2) when trying to connect
FATAL ERROR: Upgrade failed
...@@ -8,16 +8,50 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; ...@@ -8,16 +8,50 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
--enable_query_log --enable_query_log
# #
# Basic test thta we can run mysql_upgrde and that it finds the # Basic test that we can run mysql_upgrde and that it finds the
# expected binaries it uses. # expected binaries it uses.
# #
--echo Run mysql_upgrade once --echo Run mysql_upgrade once
--exec $MYSQL_UPGRADE 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err --exec $MYSQL_UPGRADE --skip-verbose 2>&1
# It should have created a file in the MySQL Servers datadir
file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info;
--echo Run it again - should say already completed --echo Run it again - should say already completed
--exec $MYSQL_UPGRADE 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err --replace_result $MYSQL_SERVER_VERSION VERSION
--error 1
--exec $MYSQL_UPGRADE --skip-verbose 2>&1
# It should have created a file in the MySQL Servers datadir
file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info;
--echo Force should run it regardless of wether it's been run before
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
# It should have created a file in the MySQL Servers datadir
file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info;
--echo Force should run it regardless of wheter it's been run before
--exec $MYSQL_UPGRADE --force 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err
#
# Bug #25452 mysql_upgrade access denied.
#
# Password protect a root account and run mysql_upgrade
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
--echo Run mysql_upgrade with password protected account
--exec $MYSQL_UPGRADE --skip-verbose --force --user=mysqltest1 --password=sakila 2>&1
DROP USER mysqltest1@'%';
#
# Bug #26639 mysql_upgrade exits successfully even if external command failed
#
--echo Run mysql_upgrade with a non existing server socket
--replace_result $MYSQLTEST_VARDIR var
--replace_regex /.*mysqlcheck.*: Got/mysqlcheck: Got/
--error 1
--exec $MYSQL_UPGRADE --skip-verbose --force --socket=$MYSQLTEST_VARDIR/tmp/no_sock_here 2>&1
# Copyright (C) 2006 MySQL AB
#
# 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
# the Free Software Foundation; version 2 of the License.
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_EXECUTABLE(comp_sql comp_sql.c)
TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings)
# Build comp_sql - used for embedding SQL in C or C++ programs
GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/client/mysql_fix_privilege_tables_sql.c
COMMAND ${COMP_SQL_EXE}
${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
${PROJECT_SOURCE_DIR}/client/mysql_fix_privilege_tables_sql.c
DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
...@@ -154,5 +154,19 @@ SUFFIXES = .sh ...@@ -154,5 +154,19 @@ SUFFIXES = .sh
@CHMOD@ +x $@-t @CHMOD@ +x $@-t
@MV@ $@-t $@ @MV@ $@-t $@
BUILT_SOURCES = mysql_fix_privilege_tables_sql.c
noinst_PROGRAMS = comp_sql
#
# Build mysql_fix_privilege_tables_sql.c from
# mysql_fix_privileges_tables.sql using comp_sql
#
mysql_fix_privilege_tables_sql.c: comp_sql.c mysql_fix_privilege_tables.sql
$(MAKE) $(AM_MAKEFLAGS) comp_sql$(EXEEXT)
$(top_builddir)/scripts/comp_sql$(EXEEXT) \
mysql_fix_privilege_tables.sql $@
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
/* Copyright (C) 2004 MySQL AB
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
the Free Software Foundation; version 2 of the License.
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 */
/*
Written by Magnus Svensson
*/
/*
Converts a SQL file into a C file that can be compiled and linked
into other programs
*/
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
FILE *in, *out;
static void die(const char *fmt, ...)
{
va_list args;
/* Print the error message */
fprintf(stderr, "FATAL ERROR: ");
if (fmt)
{
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
else
fprintf(stderr, "unknown error");
fprintf(stderr, "\n");
fflush(stderr);
/* Close any open files */
if (in)
fclose(in);
if (out)
fclose(out);
exit(1);
}
int main(int argc, char *argv[])
{
char buff[512];
char* infile_name= argv[1];
char* outfile_name= argv[2];
char* end= infile_name;
if (argc != 3)
die("Usage: comp_sql <sql_filename> <c_filename>");
/* Open input and output file */
if (!(in= fopen(infile_name, "r")))
die("Failed to open SQL file '%s'", infile_name);
if (!(out= fopen(outfile_name, "w")))
die("Failed to open output file '%s'", outfile_name);
while(*end && *end != '.')
end++;
*end= 0;
fprintf(out, "const char* %s={\"\\\n", infile_name);
while (fgets(buff, sizeof(buff), in))
{
char *curr= buff;
while (*curr)
{
if (*curr == '\n')
{
/*
Reached end of line, add escaped newline, escaped
backslash and a newline to outfile
*/
fprintf(out, "\\n\\\n");
curr++;
}
else if (*curr == '\r')
{
curr++; /* Skip */
}
else
{
if (*curr == '"')
{
/* Needs escape */
fputc('\\', out);
}
fputc(*curr, out);
curr++;
}
}
}
fprintf(out, "\\\n\"};\n");
fclose(in);
fclose(out);
exit(0);
}
...@@ -65,15 +65,15 @@ CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NU ...@@ -65,15 +65,15 @@ CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NU
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE PROCEDURE create_general_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT, thread_id INTEGER, server_id INTEGER, command_type VARCHAR(64), argument MEDIUMTEXT) engine=CSV CHARACTER SET utf8 comment='General log'; END IF; END; delimiter ;;
CALL create_general_log_table(); CREATE PROCEDURE create_general_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT, thread_id INTEGER, server_id INTEGER, command_type VARCHAR(64), argument MEDIUMTEXT) engine=CSV CHARACTER SET utf8 comment='General log'; END IF; END;;
DROP PROCEDURE create_general_log_table; CALL create_general_log_table();;
DROP PROCEDURE create_general_log_table;;
CREATE PROCEDURE create_slow_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512), last_insert_id INTEGER, insert_id INTEGER, server_id INTEGER, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment='Slow log'; END IF; END; CREATE PROCEDURE create_slow_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512), last_insert_id INTEGER, insert_id INTEGER, server_id INTEGER, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment='Slow log'; END IF; END;;
CALL create_slow_log_table(); CALL create_slow_log_table();;
DROP PROCEDURE create_slow_log_table; DROP PROCEDURE create_slow_log_table;;
delimiter ;
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
......
...@@ -388,43 +388,6 @@ ALTER TABLE proc MODIFY db ...@@ -388,43 +388,6 @@ ALTER TABLE proc MODIFY db
MODIFY comment MODIFY comment
char(64) collate utf8_bin DEFAULT '' NOT NULL; char(64) collate utf8_bin DEFAULT '' NOT NULL;
#
# Create missing log tables (5.1)
#
delimiter //
CREATE PROCEDURE create_log_tables()
BEGIN
DECLARE is_csv_enabled int DEFAULT 0;
SELECT @@have_csv = 'YES' INTO is_csv_enabled;
IF (is_csv_enabled) THEN
CREATE TABLE IF NOT EXISTS general_log (
event_time TIMESTAMP NOT NULL,
user_host MEDIUMTEXT,
thread_id INTEGER,
server_id INTEGER,
command_type VARCHAR(64),
argument MEDIUMTEXT
) engine=CSV CHARACTER SET utf8 comment='General log';
CREATE TABLE IF NOT EXISTS slow_log (
start_time TIMESTAMP NOT NULL,
user_host MEDIUMTEXT NOT NULL,
query_time TIME NOT NULL,
lock_time TIME NOT NULL,
rows_sent INTEGER NOT NULL,
rows_examined INTEGER NOT NULL,
db VARCHAR(512),
last_insert_id INTEGER,
insert_id INTEGER,
server_id INTEGER,
sql_text MEDIUMTEXT NOT NULL
) engine=CSV CHARACTER SET utf8 comment='Slow log';
END IF;
END//
delimiter ;
CALL create_log_tables();
DROP PROCEDURE create_log_tables;
# #
# EVENT privilege # EVENT privilege
# #
...@@ -503,8 +466,6 @@ ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete ...@@ -503,8 +466,6 @@ ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete
UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0;
CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
# Activate the new, possible modified privilege tables # Activate the new, possible modified privilege tables
# This should not be needed, but gives us some extra testing that the above # This should not be needed, but gives us some extra testing that the above
# changes was correct # changes was correct
......
...@@ -263,7 +263,6 @@ MY_LOCALE *my_locale_by_number(uint number); ...@@ -263,7 +263,6 @@ MY_LOCALE *my_locale_by_number(uint number);
#endif #endif
#if defined(__WIN__) #if defined(__WIN__)
#define IF_WIN(A,B) (A)
#undef FLUSH_TIME #undef FLUSH_TIME
#define FLUSH_TIME 1800 /* Flush every half hour */ #define FLUSH_TIME 1800 /* Flush every half hour */
...@@ -272,7 +271,6 @@ MY_LOCALE *my_locale_by_number(uint number); ...@@ -272,7 +271,6 @@ MY_LOCALE *my_locale_by_number(uint number);
#define WAIT_PRIOR 0 #define WAIT_PRIOR 0
#define QUERY_PRIOR 2 #define QUERY_PRIOR 2
#else #else
#define IF_WIN(A,B) (B)
#define INTERRUPT_PRIOR 10 #define INTERRUPT_PRIOR 10
#define CONNECT_PRIOR 9 #define CONNECT_PRIOR 9
#define WAIT_PRIOR 8 #define WAIT_PRIOR 8
......
...@@ -364,6 +364,11 @@ pthread_handler_t handle_bootstrap(void *arg) ...@@ -364,6 +364,11 @@ pthread_handler_t handle_bootstrap(void *arg)
buff[length-1] == ';')) buff[length-1] == ';'))
length--; length--;
buff[length]=0; buff[length]=0;
/* Skip lines starting with delimiter */
if (strncmp(buff, STRING_WITH_LEN("delimiter")) == 0)
continue;
thd->query_length=length; thd->query_length=length;
thd->query= thd->memdup_w_gap(buff, length+1, thd->query= thd->memdup_w_gap(buff, length+1,
thd->db_length+1+QUERY_CACHE_FLAGS_SIZE); thd->db_length+1+QUERY_CACHE_FLAGS_SIZE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment