mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 23:25:34 +02:00
Merge MySQL-5.1.38 and XtraDB-7 into MariaDB.
Merge Percona microsec_process patch. Includes lots of after-merge fixes, Windows fixes, and other misc. small fixes.
This commit is contained in:
commit
44718ad445
1272 changed files with 289002 additions and 25859 deletions
|
|
@ -71,7 +71,7 @@ mysqldump_SOURCES= mysqldump.c \
|
|||
$(top_srcdir)/mysys/mf_getdate.c
|
||||
|
||||
mysqlimport_SOURCES= mysqlimport.c
|
||||
|
||||
mysqlimport_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK
|
||||
mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
||||
@CLIENT_EXTRA_LDFLAGS@ \
|
||||
$(LIBMYSQLCLIENT_LA) \
|
||||
|
|
@ -80,14 +80,14 @@ mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
|||
mysqlshow_SOURCES= mysqlshow.c
|
||||
|
||||
mysqlslap_SOURCES= mysqlslap.c
|
||||
mysqlslap_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK
|
||||
mysqlslap_CFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
|
||||
mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
||||
@CLIENT_EXTRA_LDFLAGS@ \
|
||||
$(LIBMYSQLCLIENT_LA) \
|
||||
$(top_builddir)/mysys/libmysys.a
|
||||
|
||||
mysqltest_SOURCES= mysqltest.cc
|
||||
mysqltest_CXXFLAGS= -DTHREAD -UUNDEF_THREADS_HACK
|
||||
mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
|
||||
mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
||||
@CLIENT_EXTRA_LDFLAGS@ \
|
||||
$(LIBMYSQLCLIENT_LA) \
|
||||
|
|
@ -99,9 +99,9 @@ mysql_upgrade_SOURCES= mysql_upgrade.c \
|
|||
$(top_srcdir)/mysys/my_getpagesize.c
|
||||
|
||||
# Fix for mit-threads
|
||||
DEFS = -DUNDEF_THREADS_HACK \
|
||||
DEFS = -DMYSQL_CLIENT_NO_THREADS \
|
||||
-DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \
|
||||
-DDATADIR="\"$(localstatedir)\""
|
||||
-DMYSQL_DATADIR="\"$(localstatedir)\""
|
||||
|
||||
sql_src=log_event.h mysql_priv.h rpl_constants.h \
|
||||
rpl_utility.h rpl_tblmap.h rpl_tblmap.cc \
|
||||
|
|
|
|||
164
client/mysql.cc
164
client/mysql.cc
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2000-2008 MySQL AB
|
||||
/* Copyright (C) 2000-2009 MySQL AB & Monty Program 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
|
||||
|
|
@ -115,7 +115,7 @@ extern "C" {
|
|||
#define PROMPT_CHAR '\\'
|
||||
#define DEFAULT_DELIMITER ";"
|
||||
|
||||
#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
|
||||
#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L)
|
||||
|
||||
typedef struct st_status
|
||||
{
|
||||
|
|
@ -143,7 +143,8 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
|||
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
|
||||
default_charset_used= 0, opt_secure_auth= 0,
|
||||
default_pager_set= 0, opt_sigint_ignore= 0,
|
||||
show_warnings= 0, executing_query= 0, interrupted_query= 0;
|
||||
show_warnings= 0, executing_query= 0, interrupted_query= 0,
|
||||
ignore_spaces= 0;
|
||||
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
|
||||
static my_bool column_types_flag;
|
||||
static my_bool preserve_comments= 0;
|
||||
|
|
@ -169,6 +170,8 @@ static const char *xmlmeta[] = {
|
|||
"<", "<",
|
||||
">", ">",
|
||||
"\"", """,
|
||||
/* Turn \0 into a space. Why not �? That's not valid XML or HTML. */
|
||||
"\0", " ",
|
||||
0, 0
|
||||
};
|
||||
static const char *day_names[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
|
||||
|
|
@ -248,7 +251,7 @@ typedef struct {
|
|||
|
||||
static COMMANDS commands[] = {
|
||||
{ "?", '?', com_help, 1, "Synonym for `help'." },
|
||||
{ "clear", 'c', com_clear, 0, "Clear command."},
|
||||
{ "clear", 'c', com_clear, 0, "Clear the current input statement."},
|
||||
{ "connect",'r', com_connect,1,
|
||||
"Reconnect to the server. Optional arguments are db and host." },
|
||||
{ "delimiter", 'd', com_delimiter, 1,
|
||||
|
|
@ -1183,7 +1186,12 @@ int main(int argc,char *argv[])
|
|||
histfile= 0;
|
||||
}
|
||||
}
|
||||
if (histfile)
|
||||
|
||||
/* We used to suggest setting MYSQL_HISTFILE=/dev/null. */
|
||||
if (histfile && strncmp(histfile, "/dev/null", 10) == 0)
|
||||
histfile= NULL;
|
||||
|
||||
if (histfile && histfile[0])
|
||||
{
|
||||
if (verbose)
|
||||
tee_fprintf(stdout, "Reading history-file %s\n",histfile);
|
||||
|
|
@ -1218,7 +1226,8 @@ sig_handler mysql_end(int sig)
|
|||
{
|
||||
mysql_close(&mysql);
|
||||
#ifdef HAVE_READLINE
|
||||
if (!status.batch && !quick && !opt_html && !opt_xml && histfile)
|
||||
if (!status.batch && !quick && !opt_html && !opt_xml &&
|
||||
histfile && histfile[0])
|
||||
{
|
||||
/* write-history */
|
||||
if (verbose)
|
||||
|
|
@ -1349,7 +1358,7 @@ static struct my_option my_long_options[] =
|
|||
{"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
|
||||
(uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
|
||||
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
|
||||
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
|
||||
|
|
@ -1376,8 +1385,9 @@ static struct my_option my_long_options[] =
|
|||
{"no-named-commands", 'g',
|
||||
"Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"ignore-spaces", 'i', "Ignore space after function names.",
|
||||
(uchar**) &ignore_spaces, (uchar**) &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",
|
||||
(uchar**) &opt_local_infile,
|
||||
(uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
|
|
@ -1801,6 +1811,10 @@ static int get_options(int argc, char **argv)
|
|||
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
|
||||
if (debug_check_flag)
|
||||
my_end_arg= MY_CHECK_ERROR;
|
||||
|
||||
if (ignore_spaces)
|
||||
connect_flag|= CLIENT_IGNORE_SPACE;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
@ -1974,7 +1988,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
|
|||
*/
|
||||
if (strstr(name, "\\g") || (strstr(name, delimiter) &&
|
||||
!(strlen(name) >= 9 &&
|
||||
!my_strnncoll(charset_info,
|
||||
!my_strnncoll(&my_charset_latin1,
|
||||
(uchar*) name, 9,
|
||||
(const uchar*) "delimiter",
|
||||
9))))
|
||||
|
|
@ -1995,8 +2009,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
|
|||
{
|
||||
if (commands[i].func &&
|
||||
(((name &&
|
||||
!my_strnncoll(charset_info,
|
||||
(uchar*) name, len,
|
||||
!my_strnncoll(&my_charset_latin1, (uchar*) name, len,
|
||||
(uchar*) commands[i].name, len) &&
|
||||
!commands[i].name[len] &&
|
||||
(!end || (end && commands[i].takes_params)))) ||
|
||||
|
|
@ -2300,8 +2313,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end);
|
|||
*/
|
||||
|
||||
#if defined(USE_NEW_READLINE_INTERFACE)
|
||||
static int fake_magic_space(int, int);
|
||||
extern "C" char *no_completion(const char*,int)
|
||||
#elif defined(USE_LIBEDIT_INTERFACE)
|
||||
static int fake_magic_space(const char *, int);
|
||||
extern "C" int no_completion(const char*,int)
|
||||
#else
|
||||
extern "C" char *no_completion()
|
||||
|
|
@ -2378,6 +2393,18 @@ static int not_in_history(const char *line)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_NEW_READLINE_INTERFACE)
|
||||
static int fake_magic_space(int, int)
|
||||
#else
|
||||
static int fake_magic_space(const char *, int)
|
||||
#endif
|
||||
{
|
||||
rl_insert(1, ' ');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void initialize_readline (char *name)
|
||||
{
|
||||
/* Allow conditional parsing of the ~/.inputrc file. */
|
||||
|
|
@ -2387,12 +2414,15 @@ static void initialize_readline (char *name)
|
|||
#if defined(USE_NEW_READLINE_INTERFACE)
|
||||
rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
|
||||
rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
|
||||
|
||||
rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1);
|
||||
#elif defined(USE_LIBEDIT_INTERFACE)
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL,""); /* so as libedit use isprint */
|
||||
#endif
|
||||
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
|
||||
rl_completion_entry_function= &no_completion;
|
||||
rl_add_defun("magic-space", (Function*)&fake_magic_space, -1);
|
||||
#else
|
||||
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
|
||||
rl_completion_entry_function= &no_completion;
|
||||
|
|
@ -2730,7 +2760,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
|
|||
{
|
||||
MYSQL_ROW cur;
|
||||
const char *server_cmd= buffer->ptr();
|
||||
char cmd_buf[100];
|
||||
char cmd_buf[100 + 1];
|
||||
MYSQL_RES *result;
|
||||
int error;
|
||||
|
||||
|
|
@ -3306,6 +3336,9 @@ print_table_data(MYSQL_RES *result)
|
|||
uint visible_length;
|
||||
uint extra_padding;
|
||||
|
||||
if (off)
|
||||
(void) tee_fputs(" ", PAGER);
|
||||
|
||||
if (cur[off] == NULL)
|
||||
{
|
||||
buffer= "NULL";
|
||||
|
|
@ -3340,7 +3373,7 @@ print_table_data(MYSQL_RES *result)
|
|||
else
|
||||
tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE);
|
||||
}
|
||||
tee_fputs(" | ", PAGER);
|
||||
tee_fputs(" |", PAGER);
|
||||
}
|
||||
(void) tee_fputs("\n", PAGER);
|
||||
}
|
||||
|
|
@ -3391,9 +3424,12 @@ print_table_data_html(MYSQL_RES *result)
|
|||
{
|
||||
while((field = mysql_fetch_field(result)))
|
||||
{
|
||||
tee_fprintf(PAGER, "<TH>%s</TH>", (field->name ?
|
||||
(field->name[0] ? field->name :
|
||||
" ") : "NULL"));
|
||||
tee_fputs("<TH>", PAGER);
|
||||
if (field->name && field->name[0])
|
||||
xmlencode_print(field->name, field->name_length);
|
||||
else
|
||||
tee_fputs(field->name ? " " : "NULL", PAGER);
|
||||
tee_fputs("</TH>", PAGER);
|
||||
}
|
||||
(void) tee_fputs("</TR>", PAGER);
|
||||
}
|
||||
|
|
@ -3406,7 +3442,7 @@ print_table_data_html(MYSQL_RES *result)
|
|||
for (uint i=0; i < mysql_num_fields(result); i++)
|
||||
{
|
||||
(void) tee_fputs("<TD>", PAGER);
|
||||
safe_put_field(cur[i],lengths[i]);
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
(void) tee_fputs("</TD>", PAGER);
|
||||
}
|
||||
(void) tee_fputs("</TR>", PAGER);
|
||||
|
|
@ -3477,11 +3513,29 @@ print_table_data_vertically(MYSQL_RES *result)
|
|||
mysql_field_seek(result,0);
|
||||
tee_fprintf(PAGER,
|
||||
"*************************** %d. row ***************************\n", row_count);
|
||||
|
||||
ulong *lengths= mysql_fetch_lengths(result);
|
||||
|
||||
for (uint off=0; off < mysql_num_fields(result); off++)
|
||||
{
|
||||
field= mysql_fetch_field(result);
|
||||
tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name);
|
||||
tee_fprintf(PAGER, "%s\n",cur[off] ? (char*) cur[off] : "NULL");
|
||||
if (cur[off])
|
||||
{
|
||||
unsigned int i;
|
||||
const char *p;
|
||||
|
||||
for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
|
||||
{
|
||||
if (*p == '\0')
|
||||
tee_putc((int)' ', PAGER);
|
||||
else
|
||||
tee_putc((int)*p, PAGER);
|
||||
}
|
||||
tee_putc('\n', PAGER);
|
||||
}
|
||||
else
|
||||
tee_fprintf(PAGER, "NULL\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3548,7 +3602,7 @@ xmlencode_print(const char *src, uint length)
|
|||
tee_fputs("NULL", PAGER);
|
||||
else
|
||||
{
|
||||
for (const char *p = src; *p && length; *p++, length--)
|
||||
for (const char *p = src; length; *p++, length--)
|
||||
{
|
||||
const char *t;
|
||||
if ((t = array_value(xmlmeta, *p)))
|
||||
|
|
@ -3568,7 +3622,12 @@ safe_put_field(const char *pos,ulong length)
|
|||
else
|
||||
{
|
||||
if (opt_raw_data)
|
||||
tee_fputs(pos, PAGER);
|
||||
{
|
||||
unsigned long i;
|
||||
/* Can't use tee_fputs(), it stops with NUL characters. */
|
||||
for (i= 0; i < length; i++, pos++)
|
||||
tee_putc(*pos, PAGER);
|
||||
}
|
||||
else for (const char *end=pos+length ; pos != end ; pos++)
|
||||
{
|
||||
#ifdef USE_MB
|
||||
|
|
@ -4269,41 +4328,36 @@ com_status(String *buffer __attribute__((unused)),
|
|||
MYSQL_RES *result;
|
||||
LINT_INIT(result);
|
||||
|
||||
if (mysql_real_query_for_lazy(
|
||||
C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
|
||||
return 0;
|
||||
|
||||
tee_puts("--------------", stdout);
|
||||
usage(1); /* Print version */
|
||||
if (connected)
|
||||
tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
|
||||
/*
|
||||
Don't remove "limit 1",
|
||||
it is protection againts SQL_SELECT_LIMIT=0
|
||||
*/
|
||||
if (mysql_store_result_for_lazy(&result))
|
||||
{
|
||||
tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
|
||||
/*
|
||||
Don't remove "limit 1",
|
||||
it is protection againts SQL_SELECT_LIMIT=0
|
||||
*/
|
||||
if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") &&
|
||||
(result=mysql_use_result(&mysql)))
|
||||
MYSQL_ROW cur=mysql_fetch_row(result);
|
||||
if (cur)
|
||||
{
|
||||
MYSQL_ROW cur=mysql_fetch_row(result);
|
||||
if (cur)
|
||||
{
|
||||
tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
|
||||
tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
|
||||
tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
if ((status_str= mysql_get_ssl_cipher(&mysql)))
|
||||
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
|
||||
status_str);
|
||||
else
|
||||
#endif /* HAVE_OPENSSL */
|
||||
tee_puts("SSL:\t\t\tNot in use", stdout);
|
||||
}
|
||||
if ((status_str= mysql_get_ssl_cipher(&mysql)))
|
||||
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
|
||||
status_str);
|
||||
else
|
||||
{
|
||||
vidattr(A_BOLD);
|
||||
tee_fprintf(stdout, "\nNo connection\n");
|
||||
vidattr(A_NORMAL);
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_OPENSSL */
|
||||
tee_puts("SSL:\t\t\tNot in use", stdout);
|
||||
|
||||
if (skip_updates)
|
||||
{
|
||||
vidattr(A_BOLD);
|
||||
|
|
@ -4322,8 +4376,14 @@ com_status(String *buffer __attribute__((unused)),
|
|||
tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
|
||||
|
||||
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
|
||||
if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") &&
|
||||
(result=mysql_use_result(&mysql)))
|
||||
if (mysql_real_query_for_lazy(C_STRING_WITH_LEN(
|
||||
"select @@character_set_client, @@character_set_connection, "
|
||||
"@@character_set_server, @@character_set_database limit 1")))
|
||||
{
|
||||
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
||||
return 0;
|
||||
}
|
||||
if (mysql_store_result_for_lazy(&result))
|
||||
{
|
||||
MYSQL_ROW cur=mysql_fetch_row(result);
|
||||
if (cur)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ static uint my_end_arg= 0;
|
|||
static char *opt_user= (char*)"root";
|
||||
|
||||
static DYNAMIC_STRING ds_args;
|
||||
static DYNAMIC_STRING conn_args;
|
||||
|
||||
static char *opt_password= 0;
|
||||
static my_bool tty_password= 0;
|
||||
|
|
@ -115,11 +116,11 @@ static struct my_option my_long_options[]=
|
|||
#endif
|
||||
{"socket", 'S', "Socket file to use for connection.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#include <sslopt-longopts.h>
|
||||
{"tmpdir", 't', "Directory for temporary files",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"user", 'u', "User for login if not current user.", (uchar**) &opt_user,
|
||||
(uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#include <sslopt-longopts.h>
|
||||
{"verbose", 'v', "Display more output about the process",
|
||||
(uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
|
||||
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
|
|
@ -135,6 +136,7 @@ static void free_used_memory(void)
|
|||
free_defaults(defaults_argv);
|
||||
|
||||
dynstr_free(&ds_args);
|
||||
dynstr_free(&conn_args);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -204,7 +206,7 @@ static void add_one_option(DYNAMIC_STRING* ds,
|
|||
}
|
||||
}
|
||||
dynstr_append_os_quoted(ds, "--", opt->name, eq, arg, NullS);
|
||||
dynstr_append(&ds_args, " ");
|
||||
dynstr_append(ds, " ");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -231,6 +233,8 @@ get_one_option(int optid, const struct my_option *opt,
|
|||
break;
|
||||
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
tty_password= 1;
|
||||
add_option= FALSE;
|
||||
if (argument)
|
||||
|
|
@ -249,11 +253,24 @@ get_one_option(int optid, const struct my_option *opt,
|
|||
break;
|
||||
|
||||
case 'b': /* --basedir */
|
||||
case 'v': /* --verbose */
|
||||
case 'd': /* --datadir */
|
||||
fprintf(stderr, "%s: the '--%s' option is always ignored\n",
|
||||
my_progname, optid == 'b' ? "basedir" : "datadir");
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 'v': /* --verbose */
|
||||
case 'f': /* --force */
|
||||
add_option= FALSE;
|
||||
break;
|
||||
|
||||
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 */
|
||||
add_one_option(&conn_args, opt, argument);
|
||||
break;
|
||||
}
|
||||
|
||||
if (add_option)
|
||||
|
|
@ -601,6 +618,20 @@ static void create_mysql_upgrade_info_file(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check and upgrade(if neccessary) all tables
|
||||
in the server using "mysqlcheck --check-upgrade .."
|
||||
|
|
@ -608,7 +639,7 @@ static void create_mysql_upgrade_info_file(void)
|
|||
|
||||
static int run_mysqlcheck_upgrade(void)
|
||||
{
|
||||
verbose("Running 'mysqlcheck'...");
|
||||
print_conn_args("mysqlcheck");
|
||||
return run_tool(mysqlcheck_path,
|
||||
NULL, /* Send output from mysqlcheck directly to screen */
|
||||
"--no-defaults",
|
||||
|
|
@ -622,7 +653,7 @@ static int run_mysqlcheck_upgrade(void)
|
|||
|
||||
static int run_mysqlcheck_fixnames(void)
|
||||
{
|
||||
verbose("Running 'mysqlcheck'...");
|
||||
print_conn_args("mysqlcheck");
|
||||
return run_tool(mysqlcheck_path,
|
||||
NULL, /* Send output from mysqlcheck directly to screen */
|
||||
"--no-defaults",
|
||||
|
|
@ -751,7 +782,8 @@ int main(int argc, char **argv)
|
|||
strncpy(self_name, argv[0], FN_REFLEN);
|
||||
}
|
||||
|
||||
if (init_dynamic_string(&ds_args, "", 512, 256))
|
||||
if (init_dynamic_string(&ds_args, "", 512, 256) ||
|
||||
init_dynamic_string(&conn_args, "", 512, 256))
|
||||
die("Out of memory");
|
||||
|
||||
load_defaults("my", load_default_groups, &argc, &argv);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <mysql.h>
|
||||
|
||||
#define ADMIN_VERSION "8.42"
|
||||
#define MAX_MYSQL_VAR 256
|
||||
#define MAX_MYSQL_VAR 512
|
||||
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
|
||||
#define MAX_TRUNC_LENGTH 3
|
||||
|
||||
|
|
@ -232,6 +232,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
opt_count_iterations= 1;
|
||||
break;
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; // Don't require password
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
|
|
@ -369,7 +371,7 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
while (!interrupted && (!opt_count_iterations || nr_iterations))
|
||||
while (!interrupted)
|
||||
{
|
||||
new_line = 0;
|
||||
if ((error=execute_commands(&mysql,argc,commands)))
|
||||
|
|
@ -393,11 +395,11 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
if (interval)
|
||||
{
|
||||
if (opt_count_iterations && --nr_iterations == 0)
|
||||
break;
|
||||
sleep(interval);
|
||||
if (new_line)
|
||||
puts("");
|
||||
if (opt_count_iterations)
|
||||
nr_iterations--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
|
@ -677,10 +679,16 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
pos=argv[1];
|
||||
for (;;)
|
||||
{
|
||||
if (mysql_kill(mysql,(ulong) atol(pos)))
|
||||
/* We don't use mysql_kill(), since it only handles 32-bit IDs. */
|
||||
char buff[26], *out; /* "KILL " + max 20 digs + NUL */
|
||||
out= strxmov(buff, "KILL ", NullS);
|
||||
ullstr(strtoull(pos, NULL, 0), out);
|
||||
|
||||
if (mysql_query(mysql, buff))
|
||||
{
|
||||
my_printf_error(0, "kill failed on %ld; error: '%s'", error_flags,
|
||||
atol(pos), mysql_error(mysql));
|
||||
/* out still points to just the number */
|
||||
my_printf_error(0, "kill failed on %s; error: '%s'", error_flags,
|
||||
out, mysql_error(mysql));
|
||||
error=1;
|
||||
}
|
||||
if (!(pos=strchr(pos,',')))
|
||||
|
|
@ -735,6 +743,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
mysql_error(mysql));
|
||||
return -1;
|
||||
}
|
||||
|
||||
DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR);
|
||||
|
||||
if (!opt_vertical)
|
||||
print_header(res);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -17,10 +17,8 @@
|
|||
|
||||
TODO: print the catalog (some USE catalog.db ????).
|
||||
|
||||
Standalone program to read a MySQL binary log (or relay log);
|
||||
can read files produced by 3.23, 4.x, 5.0 servers.
|
||||
Standalone program to read a MySQL binary log (or relay log).
|
||||
|
||||
Can read binlogs from 3.23/4.x/5.0 and relay logs from 4.x/5.0.
|
||||
Should be able to read any file of these categories, even with
|
||||
--start-position.
|
||||
An important fact: the Format_desc event of the log is at most the 3rd event
|
||||
|
|
@ -681,6 +679,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||
{
|
||||
char ll_buff[21];
|
||||
Log_event_type ev_type= ev->get_type_code();
|
||||
my_bool destroy_evt= TRUE;
|
||||
DBUG_ENTER("process_event");
|
||||
print_event_info->short_form= short_form;
|
||||
Exit_status retval= OK_CONTINUE;
|
||||
|
|
@ -871,12 +870,63 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||
break;
|
||||
}
|
||||
case TABLE_MAP_EVENT:
|
||||
{
|
||||
Table_map_log_event *map= ((Table_map_log_event *)ev);
|
||||
if (shall_skip_database(map->get_db_name()))
|
||||
{
|
||||
print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map);
|
||||
destroy_evt= FALSE;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
case WRITE_ROWS_EVENT:
|
||||
case DELETE_ROWS_EVENT:
|
||||
case UPDATE_ROWS_EVENT:
|
||||
case PRE_GA_WRITE_ROWS_EVENT:
|
||||
case PRE_GA_DELETE_ROWS_EVENT:
|
||||
case PRE_GA_UPDATE_ROWS_EVENT:
|
||||
{
|
||||
if (ev_type != TABLE_MAP_EVENT)
|
||||
{
|
||||
Rows_log_event *e= (Rows_log_event*) ev;
|
||||
Table_map_log_event *ignored_map=
|
||||
print_event_info->m_table_map_ignored.get_table(e->get_table_id());
|
||||
bool skip_event= (ignored_map != NULL);
|
||||
|
||||
/*
|
||||
end of statement check:
|
||||
i) destroy/free ignored maps
|
||||
ii) if skip event, flush cache now
|
||||
*/
|
||||
if (e->get_flags(Rows_log_event::STMT_END_F))
|
||||
{
|
||||
/*
|
||||
Now is safe to clear ignored map (clear_tables will also
|
||||
delete original table map events stored in the map).
|
||||
*/
|
||||
if (print_event_info->m_table_map_ignored.count() > 0)
|
||||
print_event_info->m_table_map_ignored.clear_tables();
|
||||
|
||||
/*
|
||||
One needs to take into account an event that gets
|
||||
filtered but was last event in the statement. If this is
|
||||
the case, previous rows events that were written into
|
||||
IO_CACHEs still need to be copied from cache to
|
||||
result_file (as it would happen in ev->print(...) if
|
||||
event was not skipped).
|
||||
*/
|
||||
if (skip_event)
|
||||
{
|
||||
if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) ||
|
||||
copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file)))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip the event check */
|
||||
if (skip_event)
|
||||
goto end;
|
||||
}
|
||||
/*
|
||||
These events must be printed in base64 format, if printed.
|
||||
base64 format requires a FD event to be safe, so if no FD
|
||||
|
|
@ -900,6 +950,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
|||
goto err;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
}
|
||||
default:
|
||||
ev->print(result_file, print_event_info);
|
||||
}
|
||||
|
|
@ -919,7 +970,8 @@ end:
|
|||
{
|
||||
if (remote_opt)
|
||||
ev->temp_buf= 0;
|
||||
delete ev;
|
||||
if (destroy_evt) /* destroy it later if not set (ignored table map) */
|
||||
delete ev;
|
||||
}
|
||||
DBUG_RETURN(retval);
|
||||
}
|
||||
|
|
@ -934,10 +986,13 @@ static struct my_option my_long_options[] =
|
|||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"base64-output", OPT_BASE64_OUTPUT_MODE,
|
||||
/* 'unspec' is not mentioned because it is just a placeholder. */
|
||||
"Determine when the output statements should be base64-encoded BINLOG "
|
||||
"statements: 'never' disables it and works only for binlogs without "
|
||||
"row-based events; 'auto' is the default and prints base64 only when "
|
||||
"necessary (i.e., for row-based events and format description events); "
|
||||
"'decode-rows' suppresses BINLOG statements for row events, but does "
|
||||
"not exit as an error if a row event is found, unlike 'never'; "
|
||||
"'always' prints base64 whenever possible. 'always' is for debugging "
|
||||
"only and should not be used in a production system. The default is "
|
||||
"'auto'. --base64-output is a short form for --base64-output=always."
|
||||
|
|
@ -1226,6 +1281,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
one_database = 1;
|
||||
break;
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; // Don't require password
|
||||
if (argument)
|
||||
{
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
|
|
@ -1529,8 +1586,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
|
|||
If reading from a remote host, ensure the temp_buf for the
|
||||
Log_event class is pointing to the incoming stream.
|
||||
*/
|
||||
if (remote_opt)
|
||||
ev->register_temp_buf((char*) net->read_pos + 1);
|
||||
ev->register_temp_buf((char *) net->read_pos + 1);
|
||||
|
||||
Log_event_type type= ev->get_type_code();
|
||||
if (glob_description_event->binlog_version >= 3 ||
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
what_to_do= DO_UPGRADE;
|
||||
break;
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
if (argument)
|
||||
{
|
||||
char *start = argument;
|
||||
|
|
@ -440,7 +442,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
|
|||
{
|
||||
if (use_db(db))
|
||||
return 1;
|
||||
if (opt_all_in_1)
|
||||
if (opt_all_in_1 && what_to_do != DO_UPGRADE)
|
||||
{
|
||||
/*
|
||||
We need table list in form `a`, `b`, `c`
|
||||
|
|
@ -534,7 +536,7 @@ static int process_all_tables_in_db(char *database)
|
|||
|
||||
num_columns= mysql_num_fields(res);
|
||||
|
||||
if (opt_all_in_1)
|
||||
if (opt_all_in_1 && what_to_do != DO_UPGRADE)
|
||||
{
|
||||
/*
|
||||
We need table list in form `a`, `b`, `c`
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ static struct my_option my_long_options[] =
|
|||
(uchar**) &opt_compatible_mode_str, (uchar**) &opt_compatible_mode_str, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"compact", OPT_COMPACT,
|
||||
"Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-add-locks",
|
||||
"Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset",
|
||||
(uchar**) &opt_compact, (uchar**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
||||
0, 0},
|
||||
{"complete-insert", 'c', "Use complete insert statements.",
|
||||
|
|
@ -702,6 +702,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
|
|
@ -1395,18 +1397,19 @@ static char *cover_definer_clause_in_sp(const char *def_str,
|
|||
SYNOPSIS
|
||||
open_sql_file_for_table
|
||||
name name of the table or view
|
||||
flags flags (as per "man 2 open")
|
||||
|
||||
RETURN VALUES
|
||||
0 Failed to open file
|
||||
> 0 Handle of the open file
|
||||
*/
|
||||
static FILE* open_sql_file_for_table(const char* table)
|
||||
static FILE* open_sql_file_for_table(const char* table, int flags)
|
||||
{
|
||||
FILE* res;
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
convert_dirname(tmp_path,path,NullS);
|
||||
res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
||||
O_WRONLY, MYF(MY_WME));
|
||||
flags, MYF(MY_WME));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -2288,7 +2291,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||
|
||||
if (path)
|
||||
{
|
||||
if (!(sql_file= open_sql_file_for_table(table)))
|
||||
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
write_header(sql_file, db);
|
||||
|
|
@ -2499,7 +2502,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||
{
|
||||
if (path)
|
||||
{
|
||||
if (!(sql_file= open_sql_file_for_table(table)))
|
||||
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
|
||||
DBUG_RETURN(0);
|
||||
write_header(sql_file, db);
|
||||
}
|
||||
|
|
@ -2723,12 +2726,10 @@ continue_xml:
|
|||
DBUG_RETURN((uint) num_fields);
|
||||
} /* get_table_structure */
|
||||
|
||||
static void dump_trigger_old(MYSQL_RES *show_triggers_rs,
|
||||
static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
|
||||
MYSQL_ROW *show_trigger_row,
|
||||
const char *table_name)
|
||||
{
|
||||
FILE *sql_file= md_result_file;
|
||||
|
||||
char quoted_table_name_buf[NAME_LEN * 2 + 3];
|
||||
char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1);
|
||||
|
||||
|
|
@ -2794,11 +2795,10 @@ static void dump_trigger_old(MYSQL_RES *show_triggers_rs,
|
|||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
static int dump_trigger(MYSQL_RES *show_create_trigger_rs,
|
||||
static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
|
||||
const char *db_name,
|
||||
const char *db_cl_name)
|
||||
{
|
||||
FILE *sql_file= md_result_file;
|
||||
MYSQL_ROW row;
|
||||
int db_cl_altered= FALSE;
|
||||
|
||||
|
|
@ -2862,22 +2862,28 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
|
|||
uint old_opt_compatible_mode= opt_compatible_mode;
|
||||
MYSQL_RES *show_triggers_rs;
|
||||
MYSQL_ROW row;
|
||||
FILE *sql_file= md_result_file;
|
||||
|
||||
char db_cl_name[MY_CS_NAME_SIZE];
|
||||
int ret= TRUE;
|
||||
|
||||
DBUG_ENTER("dump_triggers_for_table");
|
||||
DBUG_PRINT("enter", ("db: %s, table_name: %s", db_name, table_name));
|
||||
|
||||
if (path && !(sql_file= open_sql_file_for_table(table_name,
|
||||
O_WRONLY | O_APPEND)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
/* Do not use ANSI_QUOTES on triggers in dump */
|
||||
opt_compatible_mode&= ~MASK_ANSI_QUOTES;
|
||||
|
||||
/* Get database collation. */
|
||||
|
||||
if (switch_character_set_results(mysql, "binary"))
|
||||
DBUG_RETURN(TRUE);
|
||||
goto done;
|
||||
|
||||
if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name)))
|
||||
DBUG_RETURN(TRUE);
|
||||
goto done;
|
||||
|
||||
/* Get list of triggers. */
|
||||
|
||||
|
|
@ -2886,7 +2892,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
|
|||
quote_for_like(table_name, name_buff));
|
||||
|
||||
if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff))
|
||||
DBUG_RETURN(TRUE);
|
||||
goto done;
|
||||
|
||||
/* Dump triggers. */
|
||||
|
||||
|
|
@ -2907,17 +2913,15 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
|
|||
provide all the necessary information to restore trigger properly.
|
||||
*/
|
||||
|
||||
dump_trigger_old(show_triggers_rs, &row, table_name);
|
||||
dump_trigger_old(sql_file, show_triggers_rs, &row, table_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql);
|
||||
|
||||
if (!show_create_trigger_rs ||
|
||||
dump_trigger(show_create_trigger_rs, db_name, db_cl_name))
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
dump_trigger(sql_file, show_create_trigger_rs, db_name, db_cl_name))
|
||||
goto done;
|
||||
|
||||
mysql_free_result(show_create_trigger_rs);
|
||||
}
|
||||
|
|
@ -2927,7 +2931,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
|
|||
mysql_free_result(show_triggers_rs);
|
||||
|
||||
if (switch_character_set_results(mysql, default_charset))
|
||||
DBUG_RETURN(TRUE);
|
||||
goto done;
|
||||
|
||||
/*
|
||||
make sure to set back opt_compatible mode to
|
||||
|
|
@ -2935,7 +2939,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
|
|||
*/
|
||||
opt_compatible_mode=old_opt_compatible_mode;
|
||||
|
||||
DBUG_RETURN(FALSE);
|
||||
ret= FALSE;
|
||||
|
||||
done:
|
||||
if (path)
|
||||
my_fclose(sql_file, MYF(0));
|
||||
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
static void add_load_option(DYNAMIC_STRING *str, const char *option,
|
||||
|
|
@ -3127,6 +3137,12 @@ static void dump_table(char *table, char *db)
|
|||
dynstr_append_checked(&query_string, filename);
|
||||
dynstr_append_checked(&query_string, "'");
|
||||
|
||||
dynstr_append_checked(&query_string, " /*!50138 CHARACTER SET ");
|
||||
dynstr_append_checked(&query_string, default_charset == mysql_universal_client_charset ?
|
||||
my_charset_bin.name : /* backward compatibility */
|
||||
default_charset);
|
||||
dynstr_append_checked(&query_string, " */");
|
||||
|
||||
if (fields_terminated || enclosed || opt_enclosed || escaped)
|
||||
dynstr_append_checked(&query_string, " FIELDS");
|
||||
|
||||
|
|
@ -3811,6 +3827,10 @@ static int dump_all_databases()
|
|||
return 1;
|
||||
while ((row= mysql_fetch_row(tableres)))
|
||||
{
|
||||
if (mysql_get_server_version(mysql) >= 50003 &&
|
||||
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
|
||||
continue;
|
||||
|
||||
if (dump_all_tables_in_db(row[0]))
|
||||
result=1;
|
||||
}
|
||||
|
|
@ -3825,6 +3845,10 @@ static int dump_all_databases()
|
|||
}
|
||||
while ((row= mysql_fetch_row(tableres)))
|
||||
{
|
||||
if (mysql_get_server_version(mysql) >= 50003 &&
|
||||
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
|
||||
continue;
|
||||
|
||||
if (dump_all_views_in_db(row[0]))
|
||||
result=1;
|
||||
}
|
||||
|
|
@ -3931,10 +3955,6 @@ int init_dumping_tables(char *qdatabase)
|
|||
|
||||
static int init_dumping(char *database, int init_func(char*))
|
||||
{
|
||||
if (mysql_get_server_version(mysql) >= 50003 &&
|
||||
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
|
||||
return 1;
|
||||
|
||||
if (mysql_select_db(mysql, database))
|
||||
{
|
||||
DB_error(mysql, "when selecting the database");
|
||||
|
|
@ -3993,6 +4013,7 @@ static int dump_all_tables_in_db(char *database)
|
|||
DBUG_RETURN(1);
|
||||
if (opt_xml)
|
||||
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
|
||||
|
||||
if (lock_tables)
|
||||
{
|
||||
DYNAMIC_STRING query;
|
||||
|
|
@ -4226,7 +4247,10 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
|||
}
|
||||
end= pos;
|
||||
|
||||
if (lock_tables)
|
||||
/* Can't LOCK TABLES in INFORMATION_SCHEMA, so don't try. */
|
||||
if (lock_tables &&
|
||||
!(mysql_get_server_version(mysql) >= 50003 &&
|
||||
!my_strcasecmp(&my_charset_latin1, db, "information_schema")))
|
||||
{
|
||||
if (mysql_real_query(mysql, lock_tables_query.str,
|
||||
lock_tables_query.length-1))
|
||||
|
|
@ -4780,7 +4804,7 @@ static my_bool get_view_structure(char *table, char* db)
|
|||
/* If requested, open separate .sql file for this view */
|
||||
if (path)
|
||||
{
|
||||
if (!(sql_file= open_sql_file_for_table(table)))
|
||||
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
write_header(sql_file, db);
|
||||
|
|
@ -4792,7 +4816,8 @@ static my_bool get_view_structure(char *table, char* db)
|
|||
result_table);
|
||||
check_io(sql_file);
|
||||
}
|
||||
fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table);
|
||||
/* Table might not exist if this view was dumped with --tab. */
|
||||
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
|
||||
if (opt_drop)
|
||||
{
|
||||
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
|
||||
|
|
|
|||
|
|
@ -221,6 +221,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
|
|
@ -301,7 +303,8 @@ static int get_options(int *argc, char ***argv)
|
|||
static int write_to_table(char *filename, MYSQL *mysql)
|
||||
{
|
||||
char tablename[FN_REFLEN], hard_path[FN_REFLEN],
|
||||
sql_statement[FN_REFLEN*16+256], *end;
|
||||
escaped_name[FN_REFLEN * 2 + 1],
|
||||
sql_statement[FN_REFLEN*16+256], *end, *pos;
|
||||
DBUG_ENTER("write_to_table");
|
||||
DBUG_PRINT("enter",("filename: %s",filename));
|
||||
|
||||
|
|
@ -336,15 +339,25 @@ static int write_to_table(char *filename, MYSQL *mysql)
|
|||
fprintf(stdout, "Loading data from SERVER file: %s into %s\n",
|
||||
hard_path, tablename);
|
||||
}
|
||||
mysql_real_escape_string(mysql, escaped_name, hard_path,
|
||||
(unsigned long) strlen(hard_path));
|
||||
sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'",
|
||||
opt_low_priority ? "LOW_PRIORITY" : "",
|
||||
opt_local_file ? "LOCAL" : "", hard_path);
|
||||
opt_local_file ? "LOCAL" : "", escaped_name);
|
||||
end= strend(sql_statement);
|
||||
if (replace)
|
||||
end= strmov(end, " REPLACE");
|
||||
if (ignore)
|
||||
end= strmov(end, " IGNORE");
|
||||
end= strmov(strmov(end, " INTO TABLE "), tablename);
|
||||
end= strmov(end, " INTO TABLE `");
|
||||
/* Turn any ` into `` in table name. */
|
||||
for (pos= tablename; *pos; pos++)
|
||||
{
|
||||
if (*pos == '`')
|
||||
*end++= '`';
|
||||
*end++= *pos;
|
||||
}
|
||||
end= strmov(end, "`");
|
||||
|
||||
if (fields_terminated || enclosed || opt_enclosed || escaped)
|
||||
end= strmov(end, " FIELDS");
|
||||
|
|
|
|||
|
|
@ -281,6 +281,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
opt_verbose++;
|
||||
break;
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
|
|
|
|||
|
|
@ -574,8 +574,7 @@ static struct my_option my_long_options[] =
|
|||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"csv", OPT_SLAP_CSV,
|
||||
"Generate CSV output to named file or to stdout if no file is named.",
|
||||
(uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR,
|
||||
OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef DBUG_OFF
|
||||
{"debug", '#', "This is a non-debug version. Catch this and exit.",
|
||||
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
|
|
@ -723,6 +722,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
verbose++;
|
||||
break;
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; /* Don't require password */
|
||||
if (argument)
|
||||
{
|
||||
char *start= argument;
|
||||
|
|
@ -749,6 +750,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
DBUG_PUSH(argument ? argument : default_dbug_option);
|
||||
debug_check_flag= 1;
|
||||
break;
|
||||
case OPT_SLAP_CSV:
|
||||
if (!argument)
|
||||
argument= (char *)"-"; /* use stdout */
|
||||
opt_csv_str= argument;
|
||||
break;
|
||||
#include <sslopt-case.h>
|
||||
case 'V':
|
||||
print_version();
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ enum enum_commands {
|
|||
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
|
||||
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
|
||||
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
|
||||
Q_MOVE_FILE,
|
||||
|
||||
Q_UNKNOWN, /* Unknown command. */
|
||||
Q_COMMENT, /* Comments, ignored. */
|
||||
|
|
@ -385,6 +386,7 @@ const char *command_names[]=
|
|||
"list_files_append_file",
|
||||
"send_shutdown",
|
||||
"shutdown_server",
|
||||
"move_file",
|
||||
|
||||
0
|
||||
};
|
||||
|
|
@ -975,6 +977,7 @@ void check_command_args(struct st_command *command,
|
|||
for (i= 0; i < num_args; i++)
|
||||
{
|
||||
const struct command_arg *arg= &args[i];
|
||||
char delimiter;
|
||||
|
||||
switch (arg->type) {
|
||||
/* A string */
|
||||
|
|
@ -983,8 +986,15 @@ void check_command_args(struct st_command *command,
|
|||
while (*ptr && *ptr == ' ')
|
||||
ptr++;
|
||||
start= ptr;
|
||||
/* Find end of arg, terminated by "delimiter_arg" */
|
||||
while (*ptr && *ptr != delimiter_arg)
|
||||
delimiter = delimiter_arg;
|
||||
/* If start of arg is ' ` or " search to matching quote end instead */
|
||||
if (*ptr && strchr ("'`\"", *ptr))
|
||||
{
|
||||
delimiter= *ptr;
|
||||
start= ++ptr;
|
||||
}
|
||||
/* Find end of arg, terminated by "delimiter" */
|
||||
while (*ptr && *ptr != delimiter)
|
||||
ptr++;
|
||||
if (ptr > start)
|
||||
{
|
||||
|
|
@ -996,6 +1006,11 @@ void check_command_args(struct st_command *command,
|
|||
/* Empty string */
|
||||
init_dynamic_string(arg->ds, "", 0, 0);
|
||||
}
|
||||
/* Find real end of arg, terminated by "delimiter_arg" */
|
||||
/* This will do nothing if arg was not closed by quotes */
|
||||
while (*ptr && *ptr != delimiter_arg)
|
||||
ptr++;
|
||||
|
||||
command->last_argument= (char*)ptr;
|
||||
|
||||
/* Step past the delimiter */
|
||||
|
|
@ -1454,34 +1469,38 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
|
|||
Test if diff is present. This is needed on Windows systems
|
||||
as the OS returns 1 whether diff is successful or if it is
|
||||
not present.
|
||||
Takes name of diff program as argument
|
||||
|
||||
|
||||
We run diff -v and look for output in stdout.
|
||||
We don't redirect stderr to stdout to make for a simplified check
|
||||
Windows will output '"diff"' is not recognized... to stderr if it is
|
||||
not present.
|
||||
*/
|
||||
|
||||
int diff_check (const char *diff_name)
|
||||
#ifdef __WIN__
|
||||
|
||||
static int diff_check(const char *diff_name)
|
||||
{
|
||||
char buf[512]= {0};
|
||||
FILE *res_file;
|
||||
char cmd[128];
|
||||
my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name);
|
||||
int have_diff = 0;
|
||||
FILE *res_file;
|
||||
char buf[128];
|
||||
int have_diff= 0;
|
||||
|
||||
if (!(res_file= popen(cmd, "r")))
|
||||
die("popen(\"%s\", \"r\") failed", cmd);
|
||||
my_snprintf(buf, sizeof(buf), "%s -v", diff_name);
|
||||
|
||||
/* if diff is not present, nothing will be in stdout to increment have_diff */
|
||||
if (fgets(buf, sizeof(buf), res_file))
|
||||
{
|
||||
have_diff += 1;
|
||||
}
|
||||
pclose(res_file);
|
||||
return have_diff;
|
||||
if (!(res_file= popen(buf, "r")))
|
||||
die("popen(\"%s\", \"r\") failed", buf);
|
||||
|
||||
/* if diff is not present, nothing will be in stdout to increment have_diff */
|
||||
if (fgets(buf, sizeof(buf), res_file))
|
||||
have_diff= 1;
|
||||
|
||||
pclose(res_file);
|
||||
|
||||
return have_diff;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Show the diff of two files using the systems builtin diff
|
||||
command. If no such diff command exist, just dump the content
|
||||
|
|
@ -1823,7 +1842,7 @@ void check_result()
|
|||
log_file.file_name(), reject_file, errno);
|
||||
|
||||
show_diff(NULL, result_file_name, reject_file);
|
||||
die(mess);
|
||||
die("%s", mess);
|
||||
break;
|
||||
}
|
||||
default: /* impossible */
|
||||
|
|
@ -2918,6 +2937,42 @@ void do_copy_file(struct st_command *command)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
do_move_file
|
||||
command command handle
|
||||
|
||||
DESCRIPTION
|
||||
move_file <from_file> <to_file>
|
||||
Move <from_file> to <to_file>
|
||||
*/
|
||||
|
||||
void do_move_file(struct st_command *command)
|
||||
{
|
||||
int error;
|
||||
static DYNAMIC_STRING ds_from_file;
|
||||
static DYNAMIC_STRING ds_to_file;
|
||||
const struct command_arg move_file_args[] = {
|
||||
{ "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to move from" },
|
||||
{ "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to move to" }
|
||||
};
|
||||
DBUG_ENTER("do_move_file");
|
||||
|
||||
check_command_args(command, command->first_argument,
|
||||
move_file_args,
|
||||
sizeof(move_file_args)/sizeof(struct command_arg),
|
||||
' ');
|
||||
|
||||
DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str));
|
||||
error= (my_rename(ds_from_file.str, ds_to_file.str,
|
||||
MYF(0)) != 0);
|
||||
handle_command_error(command, error);
|
||||
dynstr_free(&ds_from_file);
|
||||
dynstr_free(&ds_to_file);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
do_chmod_file
|
||||
|
|
@ -4575,7 +4630,7 @@ void select_connection(struct st_command *command)
|
|||
};
|
||||
check_command_args(command, command->first_argument, connection_args,
|
||||
sizeof(connection_args)/sizeof(struct command_arg),
|
||||
',');
|
||||
' ');
|
||||
|
||||
DBUG_PRINT("info", ("changing connection: %s", ds_connection.str));
|
||||
select_connection_name(ds_connection.str);
|
||||
|
|
@ -5702,11 +5757,11 @@ static struct my_option my_long_options[] =
|
|||
{"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select",
|
||||
(uchar**) &sp_protocol, (uchar**) &sp_protocol, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#include "sslopt-longopts.h"
|
||||
{"tail-lines", OPT_TAIL_LINES,
|
||||
"Number of lines of the resul to include in a failure report",
|
||||
(uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0,
|
||||
GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0},
|
||||
#include "sslopt-longopts.h"
|
||||
{"test-file", 'x', "Read test from/in this file (default stdin).",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"connect-timeout", OPT_MY_CONNECT_TIMEOUT, "Client connection timeout",
|
||||
|
|
@ -5843,6 +5898,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
break;
|
||||
}
|
||||
case 'p':
|
||||
if (argument == disabled_my_option)
|
||||
argument= (char*) ""; // Don't require password
|
||||
if (argument)
|
||||
{
|
||||
my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
|
||||
|
|
@ -7727,6 +7784,7 @@ int main(int argc, char **argv)
|
|||
case Q_CHANGE_USER: do_change_user(command); break;
|
||||
case Q_CAT_FILE: do_cat_file(command); break;
|
||||
case Q_COPY_FILE: do_copy_file(command); break;
|
||||
case Q_MOVE_FILE: do_move_file(command); break;
|
||||
case Q_CHMOD_FILE: do_chmod_file(command); break;
|
||||
case Q_PERL: do_perl(command); break;
|
||||
case Q_DELIMITER:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue