summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/Makefile.am121
-rw-r--r--client/client_priv.h8
-rw-r--r--client/completion_hash.h4
-rw-r--r--client/my_readline.h4
-rw-r--r--client/mysql.cc60
-rw-r--r--client/mysql_upgrade.c18
-rw-r--r--client/mysqladmin.cc37
-rw-r--r--client/mysqlbinlog.cc56
-rw-r--r--client/mysqlcheck.c90
-rw-r--r--client/mysqldump.c47
-rw-r--r--client/mysqlimport.c22
-rw-r--r--client/mysqlshow.c20
-rw-r--r--client/mysqlslap.c57
-rw-r--r--client/mysqltest.cc453
-rw-r--r--client/readline.cc43
-rw-r--r--client/sql_string.h10
16 files changed, 718 insertions, 332 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
deleted file mode 100644
index 97ced5fbfb7..00000000000
--- a/client/Makefile.am
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright (C) 2000-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# This file is public domain and comes with NO WARRANTY of any kind
-
-if THREAD_SAFE_CLIENT
-LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql_r/libmysqlclient_r.la
-else
-LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql/libmysqlclient.la
-endif
-
-INCLUDES = -I$(top_builddir)/include \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/regex \
- $(openssl_includes)
-
-LIBS = @CLIENT_LIBS@
-
-LDADD= @CLIENT_EXTRA_LDFLAGS@ $(CLIENT_THREAD_LIBS) \
- $(top_builddir)/libmysql/libmysqlclient.la
-
-noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \
- client_priv.h
-
-EXTRA_DIST = get_password.c CMakeLists.txt echo.c
-
-BUILT_SOURCES = link_sources
-
-CLEANFILES = $(BUILT_SOURCES)
-
-bin_PROGRAMS = mysql \
- mysqladmin \
- mysqlbinlog \
- mysqlcheck \
- mysqldump \
- mysqlimport \
- mysqlshow \
- mysqlslap \
- mysqltest \
- mysql_upgrade
-
-mysql_SOURCES = mysql.cc readline.cc sql_string.cc \
- completion_hash.cc
-mysql_LDADD = @readline_link@ @TERMCAP_LIB@ \
- $(LDADD) $(CXXLDFLAGS)
-mysqladmin_SOURCES = mysqladmin.cc
-
-mysqlbinlog_SOURCES = mysqlbinlog.cc \
- $(top_srcdir)/mysys/mf_tempdir.c \
- $(top_srcdir)/mysys/my_new.cc \
- $(top_srcdir)/mysys/my_bit.c \
- $(top_srcdir)/mysys/my_bitmap.c \
- $(top_srcdir)/mysys/base64.c
-mysqlbinlog_CXXFLAGS= -I$(top_srcdir)/sql
-mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
-
-mysqldump_SOURCES= mysqldump.c \
- my_user.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) \
- $(top_builddir)/mysys/libmysys.a
-
-mysqlshow_SOURCES= mysqlshow.c
-
-mysqlslap_SOURCES= mysqlslap.c
-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 -UMYSQL_CLIENT_NO_THREADS
-mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
- $(top_builddir)/mysys/libmysys.a \
- $(top_builddir)/regex/libregex.a \
- $(CLIENT_THREAD_LIBS)
-
-mysql_upgrade_SOURCES= mysql_upgrade.c \
- $(top_srcdir)/mysys/my_getpagesize.c
-
-# Fix for mit-threads
-DEFS = -DMYSQL_CLIENT_NO_THREADS \
- -DDEFAULT_MYSQL_HOME='"$(prefix)"' \
- -DMYSQL_DATADIR='"$(localstatedir)"'
-
-sql_src=rpl_tblmap.cc log_event.cc my_decimal.cc log_event_old.cc \
- rpl_record_old.cc rpl_utility.cc sql_list.cc rpl_filter.cc
-strings_src=decimal.c dtoa.c
-
-link_sources:
- for f in $(sql_src) ; do \
- rm -f $$f; \
- @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
- done; \
- for f in $(strings_src) ; do \
- rm -f $(srcdir)/$$f; \
- @LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
- done; \
- rm -f $(srcdir)/my_user.c; \
- @LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
- echo timestamp > link_sources;
diff --git a/client/client_priv.h b/client/client_priv.h
index c543dd4efa2..0eed5262260 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -50,9 +50,6 @@ enum options_client
OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_SERVER_ARG,
OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME,
OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT,
-#ifdef HAVE_NDBCLUSTER_DB
- OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING,
-#endif
OPT_TRIGGERS,
OPT_MYSQL_ONLY_PRINT,
OPT_MYSQL_LOCK_DIRECTORY,
@@ -78,16 +75,17 @@ enum options_client
OPT_SLAP_POST_SYSTEM,
OPT_SLAP_COMMIT,
OPT_SLAP_DETACH,
+ OPT_SLAP_NO_DROP,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_AUTO_VERTICAL_OUTPUT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
OPT_INIT_COMMAND,
+ OPT_PLUGIN_DIR,
+ OPT_DEFAULT_AUTH,
OPT_ABORT_SOURCE_ON_ERROR,
OPT_REWRITE_DB,
- OPT_PLUGIN_DIR,
- OPT_DEFAULT_PLUGIN,
OPT_MAX_CLIENT_OPTION /* should be always the last */
};
diff --git a/client/completion_hash.h b/client/completion_hash.h
index b91d6e4d187..8e1b2d6e453 100644
--- a/client/completion_hash.h
+++ b/client/completion_hash.h
@@ -1,11 +1,11 @@
/* Copyright (C) 2000-2002 MySQL AB
- This library is free software; you can redistribute it and/or
+ This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
- This library is distributed in the hope that it will be useful,
+ 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
Library General Public License for more details.
diff --git a/client/my_readline.h b/client/my_readline.h
index 08cff565819..276e279f43d 100644
--- a/client/my_readline.h
+++ b/client/my_readline.h
@@ -28,11 +28,13 @@ typedef struct st_line_buffer
uint eof;
ulong max_size;
ulong read_length; /* Length of last read string */
+ int error;
+ bool truncated;
} LINE_BUFFER;
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
-extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
+extern char *batch_readline(LINE_BUFFER *buffer);
extern void batch_readline_end(LINE_BUFFER *buffer);
#endif /* CLIENT_MY_READLINE_INCLUDED */
diff --git a/client/mysql.cc b/client/mysql.cc
index d0c35e63536..d87ca257b11 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -15,10 +15,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define COPYRIGHT_NOTICE "\
-This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL v2 license\n"
-
/* mysql command tool
* Commands compatible with mSQL by David J. Hughes
*
@@ -111,6 +107,7 @@ extern "C" {
#endif
#include "completion_hash.h"
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
#define PROMPT_CHAR '\\'
#define DEFAULT_DELIMITER ";"
@@ -169,7 +166,7 @@ static int wait_time = 5;
static STATUS status;
static ulong select_limit,max_join_size,opt_connect_timeout=0;
static char mysql_charsets_dir[FN_REFLEN+1];
-static char *opt_plugin_dir= 0, *opt_default_auth;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static const char *xmlmeta[] = {
"&", "&amp;",
"<", "&lt;",
@@ -1135,6 +1132,8 @@ int main(int argc,char *argv[])
if (status.batch && !status.line_buff &&
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{
+ put_info("Can't initialize batch_readline - may be the input source is "
+ "a directory or a block device.", INFO_ERROR, 0);
free_defaults(defaults_argv);
my_end(0);
exit(1);
@@ -1182,7 +1181,7 @@ int main(int argc,char *argv[])
mysql_thread_id(&mysql), server_version_string(&mysql));
put_info((char*) glob_buffer.ptr(),INFO_INFO);
- put_info(COPYRIGHT_NOTICE, INFO_INFO);
+ put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"), INFO_INFO);
#ifdef HAVE_READLINE
initialize_readline((char*) my_progname);
@@ -1474,8 +1473,8 @@ static struct my_option my_long_options[] =
&opt_sigint_ignore, &opt_sigint_ignore, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"one-database", 'o',
- "Only update the default database. This is useful for skipping updates "
- "to other database in the update log.",
+ "Ignore statements except those that occur while the default "
+ "database is the one named at the command line.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef USE_POPEN
{"pager", OPT_PAGER,
@@ -1580,11 +1579,11 @@ static struct my_option my_long_options[] =
&show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
- (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+ &opt_plugin_dir, &opt_plugin_dir, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"default_auth", OPT_PLUGIN_DIR,
+ {"default_auth", OPT_DEFAULT_AUTH,
"Default authentication client-side plugin to use.",
- (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+ &opt_default_auth, &opt_default_auth, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -1609,7 +1608,7 @@ static void usage(int version)
if (version)
return;
- printf("%s", COPYRIGHT_NOTICE);
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
printf("Usage: %s [OPTIONS] [database]\n", my_progname);
my_print_help(my_long_options);
print_defaults("my", load_default_groups);
@@ -1860,14 +1859,13 @@ static int read_and_execute(bool interactive)
ulong line_number=0;
bool ml_comment= 0;
COMMANDS *com;
- bool truncated= 0;
status.exit_status=1;
while (!aborted)
{
if (!interactive)
{
- line=batch_readline(status.line_buff, &truncated);
+ line=batch_readline(status.line_buff);
/*
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
Editors like "notepad" put this marker in
@@ -1930,9 +1928,13 @@ static int read_and_execute(bool interactive)
if (opt_outfile && line)
fprintf(OUTFILE, "%s\n", line);
}
- if (!line) // End of file
+ // End of file or system error
+ if (!line)
{
- status.exit_status=0;
+ if (status.line_buff && status.line_buff->error)
+ status.exit_status= 1;
+ else
+ status.exit_status= 0;
break;
}
@@ -1953,7 +1955,8 @@ static int read_and_execute(bool interactive)
#endif
continue;
}
- if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
+ if (add_line(glob_buffer, line, &in_string, &ml_comment,
+ status.line_buff ? status.line_buff->truncated : 0))
break;
}
/* if in batch mode, send last query even if it doesn't end with \g or go */
@@ -2718,6 +2721,10 @@ static void get_current_db()
{
MYSQL_RES *res;
+ /* If one_database is set, current_db is not supposed to change. */
+ if (one_database)
+ return;
+
my_free(current_db);
current_db= NULL;
/* In case of error below current_db will be NULL */
@@ -3760,7 +3767,8 @@ print_tab_data(MYSQL_RES *result)
}
static int
-com_tee(String *buffer, char *line __attribute__((unused)))
+com_tee(String *buffer __attribute__((unused)),
+ char *line __attribute__((unused)))
{
char file_name[FN_REFLEN], *end, *param;
@@ -3819,7 +3827,8 @@ com_notee(String *buffer __attribute__((unused)),
#ifdef USE_POPEN
static int
-com_pager(String *buffer, char *line __attribute__((unused)))
+com_pager(String *buffer __attribute__((unused)),
+ char *line __attribute__((unused)))
{
char pager_name[FN_REFLEN], *end, *param;
@@ -3949,7 +3958,8 @@ com_rehash(String *buffer __attribute__((unused)),
#ifdef USE_POPEN
static int
-com_shell(String *buffer, char *line __attribute__((unused)))
+com_shell(String *buffer __attribute__((unused)),
+ char *line __attribute__((unused)))
{
char *shell_cmd;
@@ -4041,7 +4051,8 @@ com_connect(String *buffer, char *line)
}
-static int com_source(String *buffer, char *line)
+static int com_source(String *buffer __attribute__((unused)),
+ char *line)
{
char source_name[FN_REFLEN], *end, *param;
LINE_BUFFER *line_buff;
@@ -4395,8 +4406,8 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
if (!mysql_real_connect(&mysql, host, user, password,
- database, opt_mysql_port, opt_mysql_unix_port,
- connect_flag | CLIENT_MULTI_STATEMENTS))
+ database, opt_mysql_port, opt_mysql_unix_port,
+ connect_flag | CLIENT_MULTI_STATEMENTS))
{
if (!silent ||
(mysql_errno(&mysql) != CR_CONN_HOST_ERROR &&
@@ -5032,7 +5043,8 @@ static void init_username()
}
}
-static int com_prompt(String *buffer, char *line)
+static int com_prompt(String *buffer __attribute__((unused)),
+ char *line)
{
char *ptr=strchr(line, ' ');
prompt_counter = 0;
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 5045ee0f8cb..936968cbcae 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Copyright (C) 2010 Monty Program Ab
This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,8 @@
#include <sslopt-vars.h>
#include "../scripts/mysql_fix_privilege_tables_sql.c"
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
#define VER "1.2"
#ifdef HAVE_SYS_WAIT_H
@@ -45,6 +47,8 @@ static DYNAMIC_STRING ds_args;
static DYNAMIC_STRING conn_args;
static char *opt_password= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
+
static my_bool tty_password= 0;
static char opt_tmpdir[FN_REFLEN] = "";
@@ -92,6 +96,10 @@ static struct my_option my_long_options[]=
{"default-character-set", OPT_DEFAULT_CHARSET,
"Not used by mysql_upgrade. Only for backward compatibility.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 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.",
&opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -105,6 +113,9 @@ static struct my_option my_long_options[]=
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
@@ -238,7 +249,8 @@ get_one_option(int optid, const struct my_option *opt,
case '?':
printf("%s Ver %s Distrib %s, for %s (%s)\n",
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
- puts("MySQL utility for upgrading databases to new MySQL versions.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+ puts("MariaDB utility for upgrading databases to new MariaDB versions.\n");
my_print_help(my_long_options);
exit(0);
break;
@@ -301,6 +313,8 @@ get_one_option(int optid, const struct my_option *opt,
case 'S': /* --socket */
case OPT_MYSQL_PROTOCOL: /* --protocol */
case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */
+ case OPT_PLUGIN_DIR: /* --plugin-dir */
+ case OPT_DEFAULT_AUTH: /* --default-auth */
add_one_option(&conn_args, opt, argument);
break;
}
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 83b034a61b5..b0765f90f5a 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
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
@@ -17,12 +17,11 @@
#include "client_priv.h"
#include <signal.h>
-#ifdef THREAD
#include <my_pthread.h> /* because of signal() */
-#endif
#include <sys/stat.h>
#include <mysql.h>
#include <sql_common.h>
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
#define ADMIN_VERSION "9.0"
#define MAX_MYSQL_VAR 512
@@ -43,6 +42,7 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
static uint opt_count_iterations= 0, my_end_arg;
static ulong opt_connect_timeout, opt_shutdown_timeout;
static char * unix_port=0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@@ -211,6 +211,13 @@ static struct my_option my_long_options[] =
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", &opt_shutdown_timeout,
&opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG,
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -347,6 +354,12 @@ int main(int argc,char *argv[])
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
error_flags= (myf)(opt_nobeep ? 0 : ME_BELL);
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (sql_connect(&mysql, option_wait))
{
/*
@@ -362,7 +375,8 @@ int main(int argc,char *argv[])
/* Return 0 if all commands are PING */
for (; argc > 0; argv++, argc--)
{
- if (find_type(argv[0], &command_typelib, 2) != ADMIN_PING)
+ if (find_type(argv[0], &command_typelib, FIND_TYPE_BASIC) !=
+ ADMIN_PING)
{
error= 1;
break;
@@ -406,6 +420,9 @@ int main(int argc,char *argv[])
if (interval) /* --sleep=interval given */
{
+ if (opt_count_iterations && --nr_iterations == 0)
+ break;
+
/*
If connection was dropped (unintentionally, or due to SHUTDOWN),
re-establish it if --wait ("retry-connect") was given and user
@@ -583,7 +600,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
for (; argc > 0 ; argv++,argc--)
{
int command;
- switch ((command= find_type(argv[0],&command_typelib,2))) {
+ switch ((command= find_type(argv[0],&command_typelib,FIND_TYPE_BASIC))) {
case ADMIN_CREATE:
{
char buff[FN_REFLEN+20];
@@ -681,9 +698,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
case ADMIN_VER:
new_line=1;
print_version();
- puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc,\n"
- "2009 Monty Program Ab");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
printf("Server version\t\t%s\n", mysql_get_server_info(mysql));
printf("Protocol version\t%d\n", mysql_get_proto_info(mysql));
printf("Connection\t\t%s\n",mysql_get_host_info(mysql));
@@ -1001,7 +1016,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
if (typed_password[0])
{
- bool old= (find_type(argv[0], &command_typelib, 2) ==
+ bool old= (find_type(argv[0], &command_typelib, FIND_TYPE_BASIC) ==
ADMIN_OLD_PASSWORD);
#ifdef __WIN__
size_t pw_len= strlen(typed_password);
@@ -1155,9 +1170,7 @@ static void print_version(void)
static void usage(void)
{
print_version();
- puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc,\n"
- "2009 Monty Program Ab");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
puts("Administration program for the mysqld daemon.");
printf("Usage: %s [OPTIONS] command command....\n", my_progname);
my_print_help(my_long_options);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 4b62bd12ceb..0cfb70ed028 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2004 MySQL AB
+/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
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
@@ -35,6 +35,7 @@
#include "sql_priv.h"
#include "log_event.h"
#include "sql_common.h"
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
/* Needed for Rpl_filter */
CHARSET_INFO* system_charset_info= &my_charset_utf8_general_ci;
@@ -88,6 +89,8 @@ static char* host = 0;
static int port= 0;
static uint my_end_arg;
static const char* sock= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
+
#ifdef HAVE_SMEM
static char *shared_memory_base_name= 0;
#endif
@@ -757,10 +760,18 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
*/
start_datetime= 0;
offset= 0; // print everything and protect against cycling rec_count
+ /*
+ Skip events according to the --server-id flag. However, don't
+ skip format_description or rotate events, because they they
+ are really "global" events that are relevant for the entire
+ binlog, even if they have a server_id. Also, we have to read
+ the format_description event so that we can parse subsequent
+ events.
+ */
+ if (ev_type != ROTATE_EVENT &&
+ server_id && (server_id != ev->server_id))
+ goto end;
}
- if (server_id && (server_id != ev->server_id))
- /* skip just this event, continue processing the log. */
- goto end;
if (((my_time_t)(ev->when) >= stop_datetime)
|| (pos >= stop_position_mot))
{
@@ -1012,7 +1023,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
passed --short-form, because --short-form disables printing
row events.
*/
- if (!print_event_info->printed_fd_event && !short_form)
+ if (!print_event_info->printed_fd_event && !short_form &&
+ opt_base64_output_mode != BASE64_OUTPUT_DECODE_ROWS)
{
const char* type_str= ev->get_type_str();
if (opt_base64_output_mode == BASE64_OUTPUT_NEVER)
@@ -1068,10 +1080,11 @@ static struct my_option my_long_options[] =
"row-based events; 'decode-rows' decodes row events into commented SQL "
"statements if the --verbose option is also given; 'auto' prints base64 "
"only when necessary (i.e., for row-based events and format description "
- "events); 'always' prints base64 whenever possible. 'always' is for "
- "debugging only and should not be used in a production system. If this "
- "argument is not given, the default is 'auto'; if it is given with no "
- "argument, 'always' is used.",
+ "events); 'always' prints base64 whenever possible. 'always' is "
+ "deprecated, will be removed in a future version, and should not be used "
+ "in a production system. --base64-output with no 'name' argument is "
+ "equivalent to --base64-output=always and is also deprecated. If no "
+ "--base64-output[=name] option is given at all, the default is 'auto'.",
&opt_base64_output_mode_str, &opt_base64_output_mode_str,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
/*
@@ -1096,6 +1109,10 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
&debug_info_flag, &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"disable-log-bin", 'D', "Disable binary log. This is useful, if you "
"enabled --to-last-log and are sending the output to the same MySQL server. "
"This way you could avoid an endless loop. You would also like to use it "
@@ -1121,6 +1138,9 @@ static struct my_option my_long_options[] =
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to connect to remote server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
@@ -1302,10 +1322,7 @@ static void print_version()
static void usage()
{
print_version();
- puts("By Monty and Sasha, for your professional use\n\
-This software comes with NO WARRANTY: This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL license.\n");
-
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2001, 2010"));
printf("\
Dumps a MySQL binary log in a format usable for viewing or for piping to\n\
the mysql command line client.\n\n");
@@ -1496,6 +1513,12 @@ static Exit_status safe_connect()
return ERROR_STOP;
}
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (opt_protocol)
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
#ifdef HAVE_SMEM
@@ -2150,6 +2173,13 @@ int main(int argc, char** argv)
if (opt_base64_output_mode == BASE64_OUTPUT_UNSPEC)
opt_base64_output_mode= BASE64_OUTPUT_AUTO;
+ if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+ warning("The --base64-output=always flag and the --base64-output flag "
+ "(with '=MODE' omitted), are deprecated. "
+ "The output generated when these flags are used cannot be "
+ "parsed by mysql 5.6.0 and later. "
+ "The flags will be removed in a future version. "
+ "Please use --base64-output=auto instead.");
my_set_max_open_files(open_files_limit);
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index f5a2c4600f8..c4242e1331e 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -1,6 +1,5 @@
-/* Copyright (C) 2000 MySQL AB & Jani Tolonen
- Copyright (C) 2009 Sun Microsystems, Inc
- Copyright (C) 2010 Monty Program Ab
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (C) 2010-2011 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
@@ -24,6 +23,7 @@
#include <mysql_version.h>
#include <mysqld_error.h>
#include <sslopt-vars.h>
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
/* Exit codes */
@@ -43,14 +43,15 @@ static int my_end_arg;
static char * opt_mysql_unix_port = 0;
static char *opt_password = 0, *current_user = 0,
*default_charset= 0, *current_host= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static int first_error = 0;
-DYNAMIC_ARRAY tables4repair;
+DYNAMIC_ARRAY tables4repair, tables4rebuild;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol=0;
-enum operations { DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
+enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
static struct my_option my_long_options[] =
{
@@ -102,6 +103,10 @@ static struct my_option my_long_options[] =
{"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", &default_charset,
&default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"fast",'F', "Check only tables that haven't been closed properly.",
&opt_fast, &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
@@ -139,6 +144,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
@@ -217,9 +225,7 @@ static void print_version(void)
static void usage(void)
{
print_version();
- puts("By Jani Tolonen, 2001-04-20, MySQL Development Team.\n");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
- puts("and you are welcome to modify and redistribute it under the GPL license.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
my_progname);
@@ -248,6 +254,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
+ int orig_what_to_do= what_to_do;
+
switch(optid) {
case 'a':
what_to_do = DO_ANALYZE;
@@ -322,6 +330,13 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt->name);
break;
}
+
+ if (orig_what_to_do && (what_to_do != orig_what_to_do))
+ {
+ fprintf(stderr, "Error: %s doesn't support multiple contradicting commands.\n",
+ my_progname);
+ return 1;
+ }
return 0;
}
@@ -628,6 +643,27 @@ static int fix_database_storage_name(const char *name)
return rc;
}
+static int rebuild_table(char *name)
+{
+ char *query, *ptr;
+ int rc= 0;
+ query= (char*)my_malloc(sizeof(char) * (12 + fixed_name_length(name) + 6 + 1),
+ MYF(MY_WME));
+ if (!query)
+ return 1;
+ ptr= strmov(query, "ALTER TABLE ");
+ ptr= fix_table_name(ptr, name);
+ ptr= strxmov(ptr, " FORCE", NullS);
+ if (mysql_real_query(sock, query, (uint)(ptr - query)))
+ {
+ fprintf(stderr, "Failed to %s\n", query);
+ fprintf(stderr, "Error: %s\n", mysql_error(sock));
+ rc= 1;
+ }
+ my_free(query);
+ return rc;
+}
+
static int process_one_db(char *database)
{
if (verbose)
@@ -744,7 +780,7 @@ static void print_result()
MYSQL_ROW row;
char prev[(NAME_LEN+9)*2+2];
uint i;
- my_bool found_error=0;
+ my_bool found_error=0, table_rebuild=0;
res = mysql_use_result(sock);
@@ -763,8 +799,14 @@ static void print_result()
*/
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
strcmp(row[3],"OK"))
- insert_dynamic(&tables4repair, (uchar*) prev);
+ {
+ if (table_rebuild)
+ insert_dynamic(&tables4rebuild, (uchar*) prev);
+ else
+ insert_dynamic(&tables4repair, (uchar*) prev);
+ }
found_error=0;
+ table_rebuild=0;
if (opt_silent)
continue;
}
@@ -782,7 +824,11 @@ static void print_result()
else
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
if (strcmp(row[2],"note"))
+ {
found_error=1;
+ if (opt_auto_repair && strstr(row[3], "ALTER TABLE") != NULL)
+ table_rebuild=1;
+ }
}
else
printf("%-9s: %s", row[2], row[3]);
@@ -791,7 +837,12 @@ static void print_result()
}
/* add the last table to be repaired to the list */
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
- insert_dynamic(&tables4repair, (uchar*) prev);
+ {
+ if (table_rebuild)
+ insert_dynamic(&tables4rebuild, (uchar*) prev);
+ else
+ insert_dynamic(&tables4repair, (uchar*) prev);
+ }
mysql_free_result(res);
}
@@ -817,6 +868,13 @@ static int dbConnect(char *host, char *user, char *passwd)
if (shared_memory_base_name)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
+
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql_connection, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
@@ -883,7 +941,8 @@ int main(int argc, char **argv)
}
if (opt_auto_repair &&
- my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64))
+ (my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64) ||
+ my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,64)))
{
first_error = 1;
goto end;
@@ -901,7 +960,7 @@ int main(int argc, char **argv)
{
uint i;
- if (!opt_silent && tables4repair.elements)
+ if (!opt_silent && (tables4repair.elements || tables4rebuild.elements))
puts("\nRepairing tables");
what_to_do = DO_REPAIR;
for (i = 0; i < tables4repair.elements ; i++)
@@ -909,11 +968,16 @@ int main(int argc, char **argv)
char *name= (char*) dynamic_array_ptr(&tables4repair, i);
handle_request_for_tables(name, fixed_name_length(name));
}
+ for (i = 0; i < tables4rebuild.elements ; i++)
+ rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
}
end:
dbDisconnect(current_host);
if (opt_auto_repair)
+ {
delete_dynamic(&tables4repair);
+ delete_dynamic(&tables4rebuild);
+ }
my_free(opt_password);
#ifdef HAVE_SMEM
my_free(shared_memory_base_name);
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 34055f3db67..a8b8c0964fe 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
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
@@ -51,6 +51,8 @@
#include "mysql_version.h"
#include "mysqld_error.h"
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
/* Exit codes */
#define EX_USAGE 1
@@ -135,6 +137,7 @@ FILE *stderror_file=0;
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
/*
Dynamic_string wrapper functions. In this file use these
@@ -497,6 +500,13 @@ static struct my_option my_long_options[] =
&where, &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -584,8 +594,7 @@ static void short_usage_sub(void)
static void usage(void)
{
print_version();
- puts("By Igor Romanenko, Monty, Jani & Sinisa.");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
puts("Dumping structure and contents of MySQL databases and tables.");
short_usage_sub();
print_defaults("my",load_default_groups);
@@ -1144,6 +1153,9 @@ static int switch_db_collation(FILE *sql_file,
{
if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
{
+ char quoted_db_buf[NAME_LEN * 2 + 3];
+ char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
if (!db_cl)
@@ -1151,7 +1163,7 @@ static int switch_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
- (const char *) db_name,
+ (const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
@@ -1172,6 +1184,9 @@ static int restore_db_collation(FILE *sql_file,
const char *delimiter,
const char *db_cl_name)
{
+ char quoted_db_buf[NAME_LEN * 2 + 3];
+ char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
if (!db_cl)
@@ -1179,7 +1194,7 @@ static int restore_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
- (const char *) db_name,
+ (const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
@@ -1452,6 +1467,13 @@ static int connect_to_db(char *host, char *user,char *passwd)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
+
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql_connection, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd,
NULL,opt_mysql_port,opt_mysql_unix_port,
0)))
@@ -2222,6 +2244,15 @@ static uint get_table_structure(char *table, char *db, char *table_type,
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
+ const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, "
+ "`COLUMN_TYPE` AS `Type`, "
+ "`IS_NULLABLE` AS `Null`, "
+ "`COLUMN_KEY` AS `Key`, "
+ "`COLUMN_DEFAULT` AS `Default`, "
+ "`EXTRA` AS `Extra`, "
+ "`COLUMN_COMMENT` AS `Comment` "
+ "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
+ "TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
FILE *sql_file= md_result_file;
int len;
MYSQL_RES *result;
@@ -2489,8 +2520,8 @@ static uint get_table_structure(char *table, char *db, char *table_type,
verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname, mysql_error(mysql));
- my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
- result_table);
+ my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
+
if (mysql_query_with_error_report(mysql, &result, query_buff))
DBUG_RETURN(0);
@@ -4620,7 +4651,7 @@ static ulong find_set(TYPELIB *lib, const char *x, uint length,
for (; pos != end && *pos != ','; pos++) ;
var_len= (uint) (pos - start);
strmake(buff, start, min(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
+ find= find_type(buff, lib, FIND_TYPE_BASIC);
if (!find)
{
*err_pos= (char*) start;
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 593d43c0c80..e15bbdddfb9 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
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
@@ -32,6 +32,8 @@
#include <my_pthread.h>
#endif
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
/* Global Thread counter */
uint counter;
@@ -58,6 +60,7 @@ static char *opt_password=0, *current_user=0,
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
static uint opt_mysql_port= 0, opt_protocol= 0;
static char * opt_mysql_unix_port=0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static longlong opt_ignore_lines= -1;
#include <sslopt-vars.h>
@@ -88,6 +91,10 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
&debug_info_flag, &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delete", 'd', "First delete all rows from table.", &opt_delete,
&opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"fields-terminated-by", OPT_FTB,
@@ -137,6 +144,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
@@ -191,8 +201,7 @@ static void print_version(void)
static void usage(void)
{
print_version();
- puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
printf("\
Loads tables from text files in various formats. The base name of the\n\
text file must be the name of the table that should be used.\n\
@@ -428,6 +437,13 @@ static MYSQL *db_connect(char *host, char *database,
if (shared_memory_base_name)
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
+
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(mysql_real_connect(mysql,host,user,passwd,
database,opt_mysql_port,opt_mysql_unix_port,
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 3cc551d2092..255ea3c38bb 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
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
@@ -25,6 +25,7 @@
#include <signal.h>
#include <stdarg.h>
#include <sslopt-vars.h>
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
static char * host=0, *opt_password=0, *user=0;
static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0;
@@ -33,6 +34,7 @@ static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint my_end_arg= 0;
static uint opt_verbose=0;
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@@ -123,6 +125,12 @@ int main(int argc, char **argv)
#endif
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (!(mysql_real_connect(&mysql,host,user,opt_password,
(first_argument_uses_wildcards) ? "" :
argv[0],opt_mysql_port,opt_mysql_unix_port,
@@ -181,6 +189,10 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
&debug_info_flag, &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
@@ -194,6 +206,9 @@ static struct my_option my_long_options[] =
"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},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
@@ -247,8 +262,7 @@ static void print_version(void)
static void usage(void)
{
print_version();
- puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010)"));
puts("Shows the structure of a MySQL database (databases, tables, and columns).\n");
printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname);
puts("\n\
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 6d93bd73efe..00f9420159e 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
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
@@ -11,12 +11,7 @@
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
-
- original idea: Brian Aker via playing with ab for too many years
- coded by: Patrick Galbraith
-*/
-
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
MySQL Slap
@@ -94,6 +89,7 @@ TODO:
#include <sys/wait.h>
#endif
#include <ctype.h>
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
#ifdef __WIN__
#define srandom srand
@@ -126,12 +122,13 @@ static char *host= NULL, *opt_password= NULL, *user= NULL,
*pre_system= NULL,
*post_system= NULL,
*opt_mysql_unix_port= NULL;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
const char *delimiter= "\n";
const char *create_schema_string= "mysqlslap";
-static my_bool opt_preserve= TRUE;
+static my_bool opt_preserve= TRUE, opt_no_drop= FALSE;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool opt_only_print= FALSE;
static my_bool opt_compress= FALSE, tty_password= FALSE,
@@ -348,6 +345,12 @@ int main(int argc, char **argv)
mysql_init(&mysql);
set_mysql_connect_options(&mysql);
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (!opt_only_print)
{
if (!(mysql_real_connect(&mysql, host, user, opt_password,
@@ -599,6 +602,10 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
&debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_DEFAULT_AUTH,
+ "Default authentication client-side plugin to use.",
+ &opt_default_auth, &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", 'F',
"Delimiter to use in SQL statements supplied in file or command line.",
(char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG,
@@ -617,6 +624,8 @@ static struct my_option my_long_options[] =
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times to run the tests.", &iterations,
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
+ {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.",
+ &opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"number-char-cols", 'x',
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
(char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
@@ -641,6 +650,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", &opt_mysql_port,
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
@@ -703,8 +715,7 @@ static void print_version(void)
static void usage(void)
{
print_version();
- puts("Copyright (C) 2005 MySQL AB");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2005, 2010"));
puts("Run a query multiple times against the server.\n");
printf("Usage: %s [OPTIONS]\n",my_progname);
print_defaults("my",load_default_groups);
@@ -1159,8 +1170,11 @@ get_options(int *argc,char ***argv)
if (!user)
user= (char *)"root";
- /* If something is created we clean it up, otherwise we leave schemas alone */
- if (create_string || auto_generate_sql)
+ /*
+ If something is created and --no-drop is not specified, we drop the
+ schema.
+ */
+ if (!opt_no_drop && (create_string || auto_generate_sql))
opt_preserve= FALSE;
if (auto_generate_sql && (create_string || user_supplied_query))
@@ -1533,7 +1547,12 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)
exit(1);
}
- result= mysql_store_result(mysql);
+ if (!(result= mysql_store_result(mysql)))
+ {
+ fprintf(stderr, "%s: Error when storing result: %d %s\n",
+ my_progname, mysql_errno(mysql), mysql_error(mysql));
+ exit(1);
+ }
primary_keys_number_of= mysql_num_rows(result);
/* So why check this? Blackhole :) */
@@ -1907,17 +1926,15 @@ limit_not_met:
{
if (mysql_field_count(mysql))
{
- if ((result= mysql_store_result(mysql)))
+ if (!(result= mysql_store_result(mysql)))
+ fprintf(stderr, "%s: Error when storing result: %d %s\n",
+ my_progname, mysql_errno(mysql), mysql_error(mysql));
+ else
{
- while ((row = mysql_fetch_row(result)))
+ while ((row= mysql_fetch_row(result)))
counter++;
mysql_free_result(result);
}
- else
- {
- fprintf(stderr,"%s: Error in mysql_store_result(): %d %s\n",
- my_progname, mysql_errno(mysql), mysql_error(mysql));
- }
}
} while(mysql_next_result(mysql) == 0);
queries++;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 802e94b8d7c..f6aa3ee8e8b 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
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
@@ -11,7 +11,7 @@
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 */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/*
mysqltest
@@ -52,6 +52,8 @@
#include <signal.h>
#include <my_stacktrace.h>
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
+
#ifdef __WIN__
#include <crtdbg.h>
#define SIGNAL_FMT "exception 0x%x"
@@ -197,6 +199,8 @@ static ulonglong timer_now(void);
static ulong connection_retry_sleep= 100000; /* Microseconds */
+static char *opt_plugin_dir= 0;
+
/* Precompiled re's */
static my_regex_t ps_re; /* the query can be run using PS protocol */
static my_regex_t sp_re; /* the query can be run as a SP */
@@ -238,8 +242,9 @@ typedef struct
int str_val_len;
int int_val;
int alloced_len;
- int int_dirty; /* do not update string if int is updated until first read */
- int alloced;
+ bool int_dirty; /* do not update string if int is updated until first read */
+ bool is_int;
+ bool alloced;
} VAR;
/*Perl/shell-like variable registers */
@@ -465,7 +470,7 @@ struct st_command
char *query, *query_buf,*first_argument,*last_argument,*end;
DYNAMIC_STRING content;
int first_word_len, query_len;
- my_bool abort_on_error;
+ my_bool abort_on_error, used_replace;
struct st_expected_errors expected_errors;
char require_file[FN_REFLEN];
enum enum_commands type;
@@ -475,6 +480,8 @@ TYPELIB command_typelib= {array_elements(command_names),"",
command_names, 0};
DYNAMIC_STRING ds_res;
+/* Points to ds_warning in run_query, so it can be freed */
+DYNAMIC_STRING *ds_warn= 0;
char builtin_echo[FN_REFLEN];
@@ -494,7 +501,8 @@ VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
int val_len);
VAR* var_get(const char *var_name, const char** var_name_end,
my_bool raw, my_bool ignore_not_existing);
-void eval_expr(VAR* v, const char *p, const char** p_end);
+void eval_expr(VAR* v, const char *p, const char** p_end,
+ bool open_end=false, bool do_eval=true);
my_bool match_delimiter(int c, const char *delim, uint length);
void dump_result_to_reject_file(char *buf, int size);
void dump_warning_messages();
@@ -788,7 +796,7 @@ end_thread:
static void wait_query_thread_done(struct st_connection *con)
{
- DBUG_ASSERT(con->tid);
+ DBUG_ASSERT(con->has_thread);
if (!con->query_done)
{
pthread_mutex_lock(&con->result_mutex);
@@ -801,7 +809,7 @@ static void wait_query_thread_done(struct st_connection *con)
static void signal_connection_thd(struct st_connection *cn, int command)
{
- DBUG_ASSERT(cn->tid);
+ DBUG_ASSERT(cn->has_thread);
cn->query_done= 0;
cn->command= command;
pthread_mutex_lock(&cn->query_mutex);
@@ -813,13 +821,13 @@ static void signal_connection_thd(struct st_connection *cn, int command)
/*
Sometimes we try to execute queries when the connection is closed.
It's done to make sure it was closed completely.
- So that if our connection is closed (cn->tid == 0), we just return
+ So that if our connection is closed (cn->has_thread == 0), we just return
the mysql_send_query() result which is an error in this case.
*/
static int do_send_query(struct st_connection *cn, const char *q, int q_len)
{
- if (!cn->tid)
+ if (!cn->has_thread)
return mysql_send_query(&cn->mysql, q, q_len);
cn->cur_query= q;
cn->cur_query_len= q_len;
@@ -829,7 +837,7 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len)
static int do_read_query_result(struct st_connection *cn)
{
- DBUG_ASSERT(cn->tid);
+ DBUG_ASSERT(cn->has_thread);
wait_query_thread_done(cn);
signal_connection_thd(cn, EMB_READ_QUERY_RESULT);
wait_query_thread_done(cn);
@@ -840,12 +848,12 @@ static int do_read_query_result(struct st_connection *cn)
static void emb_close_connection(struct st_connection *cn)
{
- if (!cn->tid)
+ if (!cn->has_thread)
return;
wait_query_thread_done(cn);
signal_connection_thd(cn, EMB_END_CONNECTION);
pthread_join(cn->tid, NULL);
- cn->tid= 0;
+ cn->has_thread= FALSE;
pthread_mutex_destroy(&cn->query_mutex);
pthread_cond_destroy(&cn->query_cond);
pthread_mutex_destroy(&cn->result_mutex);
@@ -863,6 +871,7 @@ static void init_connection_thd(struct st_connection *cn)
pthread_cond_init(&cn->result_cond, NULL) ||
pthread_create(&cn->tid, &cn_thd_attrib, connection_thread, (void*)cn))
die("Error in the thread library");
+ cn->has_thread=TRUE;
}
#else /*EMBEDDED_LIBRARY*/
@@ -1180,8 +1189,8 @@ void handle_command_error(struct st_command *command, uint error,
int i;
if (command->abort_on_error)
- die("command \"%.*s\" failed with error %d",
- command->first_word_len, command->query, error);
+ die("command \"%.*s\" failed with error %d. my_errno=%d",
+ command->first_word_len, command->query, error, my_errno);
i= match_expected_error(command, error, NULL);
@@ -1287,6 +1296,8 @@ void free_used_memory()
my_free(embedded_server_args[--embedded_server_arg_count]);
delete_dynamic(&q_lines);
dynstr_free(&ds_res);
+ if (ds_warn)
+ dynstr_free(ds_warn);
free_all_replace();
my_free(opt_pass);
free_defaults(default_argv);
@@ -1330,6 +1341,17 @@ static void cleanup_and_exit(int exit_code)
exit(exit_code);
}
+void print_file_stack()
+{
+ for (struct st_test_file* err_file= cur_file;
+ err_file != file_stack;
+ err_file--)
+ {
+ fprintf(stderr, "included from %s at line %d:\n",
+ err_file->file_name, err_file->lineno);
+ }
+}
+
void die(const char *fmt, ...)
{
static int dying= 0;
@@ -1340,8 +1362,12 @@ void die(const char *fmt, ...)
/* Print the error message */
fprintf(stderr, "mysqltest: ");
if (cur_file && cur_file != file_stack)
- fprintf(stderr, "In included file \"%s\": ",
+ {
+ fprintf(stderr, "In included file \"%s\": \n",
cur_file->file_name);
+ print_file_stack();
+ }
+
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
if (fmt)
@@ -1380,7 +1406,6 @@ void die(const char *fmt, ...)
void abort_not_supported_test(const char *fmt, ...)
{
va_list args;
- struct st_test_file* err_file= cur_file;
DBUG_ENTER("abort_not_supported_test");
/* Print include filestack */
@@ -1388,13 +1413,8 @@ void abort_not_supported_test(const char *fmt, ...)
fprintf(stderr, "The test '%s' is not supported by this installation\n",
file_stack->file_name);
fprintf(stderr, "Detected in file %s at line %d\n",
- err_file->file_name, err_file->lineno);
- while (err_file != file_stack)
- {
- err_file--;
- fprintf(stderr, "included from %s at line %d\n",
- err_file->file_name, err_file->lineno);
- }
+ cur_file->file_name, cur_file->lineno);
+ print_file_stack();
/* Print error message */
va_start(args, fmt);
@@ -2079,6 +2099,23 @@ static void var_free(void *v)
C_MODE_END
+void var_check_int(VAR *v)
+{
+ char *endptr;
+ char *str= v->str_val;
+
+ /* Initially assume not a number */
+ v->int_val= 0;
+ v->is_int= false;
+ v->int_dirty= false;
+ if (!str) return;
+
+ v->int_val = (int) strtol(str, &endptr, 10);
+ /* It is an int if strtol consumed something up to end/space/tab */
+ if (endptr > str && (!*endptr || *endptr == ' ' || *endptr == '\t'))
+ v->is_int= true;
+}
+
VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
int val_len)
@@ -2089,9 +2126,11 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
name_len = strlen(name);
if (!val_len && val)
val_len = strlen(val) ;
+ if (!val)
+ val_len= 0;
val_alloc_len = val_len + 16; /* room to grow */
if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var)
- + name_len+1, MYF(MY_WME))))
+ + name_len+2, MYF(MY_WME))))
die("Out of memory");
if (name != NULL)
@@ -2109,15 +2148,13 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
die("Out of memory");
if (val)
- {
memcpy(tmp_var->str_val, val, val_len);
- tmp_var->str_val[val_len]= 0;
- }
+ tmp_var->str_val[val_len]= 0;
+
+ var_check_int(tmp_var);
tmp_var->name_len = name_len;
tmp_var->str_val_len = val_len;
tmp_var->alloced_len = val_alloc_len;
- tmp_var->int_val = (val) ? atoi(val) : 0;
- tmp_var->int_dirty = 0;
return tmp_var;
}
@@ -2178,7 +2215,7 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
if (!raw && v->int_dirty)
{
sprintf(v->str_val, "%d", v->int_val);
- v->int_dirty = 0;
+ v->int_dirty= false;
v->str_val_len = strlen(v->str_val);
}
if (var_name_end)
@@ -2240,7 +2277,7 @@ void var_set(const char *var_name, const char *var_name_end,
if (v->int_dirty)
{
sprintf(v->str_val, "%d", v->int_val);
- v->int_dirty= 0;
+ v->int_dirty=false;
v->str_val_len= strlen(v->str_val);
}
/* setenv() expects \0-terminated strings */
@@ -2355,7 +2392,8 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
dynstr_append_mem(&result, "\t", 1);
}
end= result.str + result.length-1;
- eval_expr(var, result.str, (const char**) &end);
+ /* Evaluation should not recurse via backtick */
+ eval_expr(var, result.str, (const char**) &end, false, false);
dynstr_free(&result);
}
else
@@ -2534,7 +2572,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
break;
}
}
- eval_expr(var, value, 0);
+ eval_expr(var, value, 0, false, false);
}
dynstr_free(&ds_query);
mysql_free_result(res);
@@ -2546,6 +2584,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
void var_copy(VAR *dest, VAR *src)
{
dest->int_val= src->int_val;
+ dest->is_int= src->is_int;
dest->int_dirty= src->int_dirty;
/* Alloc/realloc data for str_val in dest */
@@ -2564,12 +2603,17 @@ void var_copy(VAR *dest, VAR *src)
}
-void eval_expr(VAR *v, const char *p, const char **p_end)
+void eval_expr(VAR *v, const char *p, const char **p_end,
+ bool open_end, bool do_eval)
{
DBUG_ENTER("eval_expr");
DBUG_PRINT("enter", ("p: '%s'", p));
+ /* Skip to treat as pure string if no evaluation */
+ if (! do_eval)
+ goto NO_EVAL;
+
if (*p == '$')
{
VAR *vp;
@@ -2582,7 +2626,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
/* Make sure there was just a $variable and nothing else */
const char* end= *p_end + 1;
- if (end < expected_end)
+ if (end < expected_end && !open_end)
die("Found junk '%.*s' after $variable in expression",
(int)(expected_end - end - 1), end);
@@ -2612,6 +2656,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
}
}
+ NO_EVAL:
{
int new_val_len = (p_end && *p_end) ?
(int) (*p_end - p) : (int) strlen(p);
@@ -2629,9 +2674,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
v->str_val_len = new_val_len;
memcpy(v->str_val, p, new_val_len);
v->str_val[new_val_len] = 0;
- v->int_val=atoi(p);
- DBUG_PRINT("info", ("atoi on '%s', returns: %d", p, v->int_val));
- v->int_dirty=0;
+ var_check_int(v);
}
DBUG_VOID_RETURN;
}
@@ -2978,6 +3021,8 @@ int do_modify_var(struct st_command *command,
die("The argument to %.*s must be a variable (start with $)",
command->first_word_len, command->query);
v= var_get(p, &p, 1, 0);
+ if (! v->is_int)
+ die("Cannot perform inc/dec on a non-numeric value");
switch (op) {
case DO_DEC:
v->int_val--;
@@ -2989,7 +3034,7 @@ int do_modify_var(struct st_command *command,
die("Invalid operator to do_modify_var");
break;
}
- v->int_dirty= 1;
+ v->int_dirty= true;
command->last_argument= (char*)++p;
return 0;
}
@@ -3465,7 +3510,7 @@ static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname,
if (ds_wild && ds_wild->length &&
wild_compare(file->name, ds_wild->str, 0))
continue;
- dynstr_append(ds, file->name);
+ replace_dynstr_append(ds, file->name);
dynstr_append(ds, "\n");
}
set_wild_chars(0);
@@ -3495,6 +3540,7 @@ static void do_list_files(struct st_command *command)
{"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"}
};
DBUG_ENTER("do_list_files");
+ command->used_replace= 1;
check_command_args(command, command->first_argument,
list_files_args,
@@ -3536,6 +3582,7 @@ static void do_list_files_write_file_command(struct st_command *command,
{"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"}
};
DBUG_ENTER("do_list_files_write_file");
+ command->used_replace= 1;
check_command_args(command, command->first_argument,
list_files_args,
@@ -4260,7 +4307,7 @@ int do_save_master_pos()
const char latest_applied_binlog_epoch_str[]=
"latest_applied_binlog_epoch=";
if (count)
- sleep(1);
+ my_sleep(100*1000); /* 100ms */
if (mysql_query(mysql, query= "show engine ndb status"))
die("failed in '%s': %d %s", query,
mysql_errno(mysql), mysql_error(mysql));
@@ -4349,7 +4396,7 @@ int do_save_master_pos()
count++;
if (latest_handled_binlog_epoch >= start_epoch)
do_continue= 0;
- else if (count > 30)
+ else if (count > 300) /* 30s */
{
break;
}
@@ -4594,13 +4641,14 @@ static int my_kill(int pid, int sig)
command called command
DESCRIPTION
- shutdown [<timeout>]
+ shutdown_server [<timeout>]
*/
void do_shutdown_server(struct st_command *command)
{
- int timeout=60, pid;
+ long timeout=60;
+ int pid;
DYNAMIC_STRING ds_pidfile_name;
MYSQL* mysql = &cur_con->mysql;
static DYNAMIC_STRING ds_timeout;
@@ -4615,8 +4663,9 @@ void do_shutdown_server(struct st_command *command)
if (ds_timeout.length)
{
- timeout= atoi(ds_timeout.str);
- if (timeout == 0)
+ char* endptr;
+ timeout= strtol(ds_timeout.str, &endptr, 10);
+ if (*endptr != '\0')
die("Illegal argument for timeout: '%s'", ds_timeout.str);
}
dynstr_free(&ds_timeout);
@@ -4658,7 +4707,7 @@ void do_shutdown_server(struct st_command *command)
DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
DBUG_VOID_RETURN;
}
- DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
+ DBUG_PRINT("info", ("Sleeping, timeout: %ld", timeout));
my_sleep(1000000L);
}
@@ -5300,6 +5349,7 @@ void do_connect(struct st_command *command)
static DYNAMIC_STRING ds_port;
static DYNAMIC_STRING ds_sock;
static DYNAMIC_STRING ds_options;
+ static DYNAMIC_STRING ds_default_auth;
#ifdef HAVE_SMEM
static DYNAMIC_STRING ds_shm;
#endif
@@ -5311,7 +5361,8 @@ void do_connect(struct st_command *command)
{ "database", ARG_STRING, FALSE, &ds_database, "Database to select after connect" },
{ "port", ARG_STRING, FALSE, &ds_port, "Port to connect to" },
{ "socket", ARG_STRING, FALSE, &ds_sock, "Socket to connect with" },
- { "options", ARG_STRING, FALSE, &ds_options, "Options to use while connecting" }
+ { "options", ARG_STRING, FALSE, &ds_options, "Options to use while connecting" },
+ { "default_auth", ARG_STRING, FALSE, &ds_default_auth, "Default authentication to use" }
};
DBUG_ENTER("do_connect");
@@ -5419,8 +5470,13 @@ void do_connect(struct st_command *command)
opt_charsets_dir);
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
- if (opt_use_ssl || con_ssl)
+ if (opt_use_ssl)
+ con_ssl= 1;
+#endif
+
+ if (con_ssl)
{
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
mysql_ssl_set(&con_slot->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher);
#if MYSQL_VERSION_ID >= 50000
@@ -5429,15 +5485,15 @@ void do_connect(struct st_command *command)
mysql_options(&con_slot->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
&opt_ssl_verify_server_cert);
#endif
- }
#endif
+ }
-#ifdef __WIN__
if (con_pipe)
{
+#ifdef __WIN__
opt_protocol= MYSQL_PROTOCOL_PIPE;
- }
#endif
+ }
if (opt_protocol)
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
@@ -5462,6 +5518,12 @@ void do_connect(struct st_command *command)
if (ds_database.length == 0)
dynstr_set(&ds_database, opt_db);
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&con_slot->mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (ds_default_auth.length)
+ mysql_options(&con_slot->mysql, MYSQL_DEFAULT_AUTH, ds_default_auth.str);
+
/* Special database to allow one to connect without a database name */
if (ds_database.length && !strcmp(ds_database.str,"*NO-ONE*"))
dynstr_set(&ds_database, "");
@@ -5490,6 +5552,7 @@ void do_connect(struct st_command *command)
dynstr_free(&ds_port);
dynstr_free(&ds_sock);
dynstr_free(&ds_options);
+ dynstr_free(&ds_default_auth);
#ifdef HAVE_SMEM
dynstr_free(&ds_shm);
#endif
@@ -5529,6 +5592,40 @@ int do_done(struct st_command *command)
return 0;
}
+/* Operands available in if or while conditions */
+
+enum block_op {
+ EQ_OP,
+ NE_OP,
+ GT_OP,
+ GE_OP,
+ LT_OP,
+ LE_OP,
+ ILLEG_OP
+};
+
+
+enum block_op find_operand(const char *start)
+{
+ char first= *start;
+ char next= *(start+1);
+
+ if (first == '=' && next == '=')
+ return EQ_OP;
+ if (first == '!' && next == '=')
+ return NE_OP;
+ if (first == '>' && next == '=')
+ return GE_OP;
+ if (first == '>')
+ return GT_OP;
+ if (first == '<' && next == '=')
+ return LE_OP;
+ if (first == '<')
+ return LT_OP;
+
+ return ILLEG_OP;
+}
+
/*
Process start of a "if" or "while" statement
@@ -5554,6 +5651,13 @@ int do_done(struct st_command *command)
A '!' can be used before the <expr> to indicate it should
be executed if it evaluates to zero.
+ <expr> can also be a simple comparison condition:
+
+ <variable> <op> <expr>
+
+ The left hand side must be a variable, the right hand side can be a
+ variable, number, string or `query`. Operands are ==, !=, <, <=, >, >=.
+ == and != can be used for strings, all can be used for numerical values.
*/
void do_block(enum block_cmd cmd, struct st_command* command)
@@ -5589,11 +5693,16 @@ void do_block(enum block_cmd cmd, struct st_command* command)
if (!expr_start++)
die("missing '(' in %s", cmd_name);
+ while (my_isspace(charset_info, *expr_start))
+ expr_start++;
+
/* Check for !<expr> */
if (*expr_start == '!')
{
not_expr= TRUE;
- expr_start++; /* Step past the '!' */
+ expr_start++; /* Step past the '!', then any whitespace */
+ while (*expr_start && my_isspace(charset_info, *expr_start))
+ expr_start++;
}
/* Find ending ')' */
expr_end= strrchr(expr_start, ')');
@@ -5607,14 +5716,110 @@ void do_block(enum block_cmd cmd, struct st_command* command)
die("Missing '{' after %s. Found \"%s\"", cmd_name, p);
var_init(&v,0,0,0,0);
- eval_expr(&v, expr_start, &expr_end);
+ /* If expression starts with a variable, it may be a compare condition */
+
+ if (*expr_start == '$')
+ {
+ const char *curr_ptr= expr_end;
+ eval_expr(&v, expr_start, &curr_ptr, true);
+ while (my_isspace(charset_info, *++curr_ptr))
+ {}
+ /* If there was nothing past the variable, skip condition part */
+ if (curr_ptr == expr_end)
+ goto NO_COMPARE;
+
+ enum block_op operand= find_operand(curr_ptr);
+ if (operand == ILLEG_OP)
+ die("Found junk '%.*s' after $variable in condition",
+ (int)(expr_end - curr_ptr), curr_ptr);
+
+ /* We could silently allow this, but may be confusing */
+ if (not_expr)
+ die("Negation and comparison should not be combined, please rewrite");
+
+ /* Skip the 1 or 2 chars of the operand, then white space */
+ if (operand == LT_OP || operand == GT_OP)
+ {
+ curr_ptr++;
+ }
+ else
+ {
+ curr_ptr+= 2;
+ }
+ while (my_isspace(charset_info, *curr_ptr))
+ curr_ptr++;
+ if (curr_ptr == expr_end)
+ die("Missing right operand in comparison");
+
+ /* Strip off trailing white space */
+ while (my_isspace(charset_info, expr_end[-1]))
+ expr_end--;
+ /* strip off ' or " around the string */
+ if (*curr_ptr == '\'' || *curr_ptr == '"')
+ {
+ if (expr_end[-1] != *curr_ptr)
+ die("Unterminated string value");
+ curr_ptr++;
+ expr_end--;
+ }
+ VAR v2;
+ var_init(&v2,0,0,0,0);
+ eval_expr(&v2, curr_ptr, &expr_end);
+
+ if ((operand!=EQ_OP && operand!=NE_OP) && ! (v.is_int && v2.is_int))
+ die ("Only == and != are supported for string values");
+
+ /* Now we overwrite the first variable with 0 or 1 (for false or true) */
+
+ switch (operand)
+ {
+ case EQ_OP:
+ if (v.is_int)
+ v.int_val= (v2.is_int && v2.int_val == v.int_val);
+ else
+ v.int_val= !strcmp (v.str_val, v2.str_val);
+ break;
+
+ case NE_OP:
+ if (v.is_int)
+ v.int_val= ! (v2.is_int && v2.int_val == v.int_val);
+ else
+ v.int_val= (strcmp (v.str_val, v2.str_val) != 0);
+ break;
+
+ case LT_OP:
+ v.int_val= (v.int_val < v2.int_val);
+ break;
+ case LE_OP:
+ v.int_val= (v.int_val <= v2.int_val);
+ break;
+ case GT_OP:
+ v.int_val= (v.int_val > v2.int_val);
+ break;
+ case GE_OP:
+ v.int_val= (v.int_val >= v2.int_val);
+ break;
+ case ILLEG_OP:
+ die("Impossible operator, this cannot happen");
+ }
+
+ v.is_int= TRUE;
+ var_free(&v2);
+ } else
+ {
+ if (*expr_start != '`' && ! my_isdigit(charset_info, *expr_start))
+ die("Expression in if/while must beging with $, ` or a number");
+ eval_expr(&v, expr_start, &expr_end);
+ }
+
+ NO_COMPARE:
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
- if (v.int_val)
+ if (v.is_int)
{
- cur_block->ok= TRUE;
+ cur_block->ok= (v.int_val != 0);
} else
/* Any non-empty string which does not begin with 0 is also TRUE */
{
@@ -5891,7 +6096,7 @@ int read_line(char *buf, int size)
/* Could be a multibyte character */
/* This code is based on the code in "sql_load.cc" */
#ifdef USE_MB
- int charlen = my_mbcharlen(charset_info, c);
+ int charlen = my_mbcharlen(charset_info, (unsigned char) c);
/* We give up if multibyte character is started but not */
/* completed before we pass buf_end */
if ((charlen > 1) && (p + charlen) <= buf_end)
@@ -5903,16 +6108,16 @@ int read_line(char *buf, int size)
for (i= 1; i < charlen; i++)
{
+ c= my_getc(cur_file->file);
if (feof(cur_file->file))
goto found_eof;
- c= my_getc(cur_file->file);
*p++ = c;
}
if (! my_ismbchar(charset_info, mb_start, p))
{
/* It was not a multiline char, push back the characters */
/* We leave first 'c', i.e. pretend it was a normal char */
- while (p > mb_start)
+ while (p-1 > mb_start)
my_ungetc(*--p);
}
}
@@ -6260,6 +6465,9 @@ static struct my_option my_long_options[] =
"Number of seconds before connection timeout.",
&opt_connect_timeout, &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG,
120, 0, 3600 * 12, 0, 0, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ &opt_plugin_dir, &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -6273,8 +6481,7 @@ void print_version(void)
void usage()
{
print_version();
- printf("MySQL AB, by Sasha, Matt, Monty & Jani\n");
- printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
+ puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
printf("Runs a test against the mysql server and compares output with a results file.\n\n");
printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
my_print_help(my_long_options);
@@ -7551,6 +7758,8 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
die ("Cannot reap on a connection without pending send");
init_dynamic_string(&ds_warnings, NULL, 0, 256);
+ ds_warn= &ds_warnings;
+
/*
Evaluate query if this is an eval command
*/
@@ -7707,7 +7916,8 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
ds, &ds_warnings);
dynstr_free(&ds_warnings);
- if (command->type == Q_EVAL)
+ ds_warn= 0;
+ if (command->type == Q_EVAL || command->type == Q_SEND_EVAL)
dynstr_free(&eval_query);
if (display_result_sorted)
@@ -7813,6 +8023,16 @@ void init_re(void)
int match_re(my_regex_t *re, char *str)
{
+ while (my_isspace(charset_info, *str))
+ str++;
+ if (str[0] == '/' && str[1] == '*')
+ {
+ char *comm_end= strstr (str, "*/");
+ if (! comm_end)
+ die("Statement is unterminated comment");
+ str= comm_end + 2;
+ }
+
int err= my_regexec(re, str, (size_t)0, NULL, 0);
if (err == 0)
@@ -7853,7 +8073,7 @@ void get_command_type(struct st_command* command)
save= command->query[command->first_word_len];
command->query[command->first_word_len]= 0;
- type= find_type(command->query, &command_typelib, 1+2);
+ type= find_type(command->query, &command_typelib, FIND_TYPE_NO_PREFIX);
command->query[command->first_word_len]= save;
if (type > 0)
{
@@ -7951,13 +8171,16 @@ static void dump_backtrace(void)
{
struct st_connection *conn= cur_con;
- my_safe_print_str("read_command_buf", read_command_buf,
- sizeof(read_command_buf));
+ fprintf(stderr, "read_command_buf (%p): ", read_command_buf);
+ my_safe_print_str(read_command_buf, sizeof(read_command_buf));
+
if (conn)
{
- my_safe_print_str("conn->name", conn->name, conn->name_len);
+ fprintf(stderr, "conn->name (%p): ", conn->name);
+ my_safe_print_str(conn->name, conn->name_len);
#ifdef EMBEDDED_LIBRARY
- my_safe_print_str("conn->cur_query", conn->cur_query, conn->cur_query_len);
+ fprintf(stderr, "conn->cur_query (%p): ", conn->cur_query);
+ my_safe_print_str(conn->cur_query, conn->cur_query_len);
#endif
}
fputs("Attempting backtrace...\n", stderr);
@@ -8142,6 +8365,14 @@ int main(int argc, char **argv)
var_set_int("$VIEW_PROTOCOL", view_protocol);
var_set_int("$CURSOR_PROTOCOL", cursor_protocol);
+ var_set_int("$ENABLED_QUERY_LOG", 1);
+ var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
+ var_set_int("$ENABLED_RESULT_LOG", 1);
+ var_set_int("$ENABLED_CONNECT_LOG", 0);
+ var_set_int("$ENABLED_WARNINGS", 1);
+ var_set_int("$ENABLED_INFO", 0);
+ var_set_int("$ENABLED_METADATA", 0);
+
DBUG_PRINT("info",("result_file: '%s'",
result_file_name ? result_file_name : ""));
verbose_msg("Results saved in '%s'.",
@@ -8159,13 +8390,15 @@ int main(int argc, char **argv)
}
var_set_string("MYSQLTEST_FILE", cur_file->file_name);
init_re();
+
+ /* Cursor protcol implies ps protocol */
+ if (cursor_protocol)
+ ps_protocol= 1;
+
ps_protocol_enabled= ps_protocol;
sp_protocol_enabled= sp_protocol;
view_protocol_enabled= view_protocol;
cursor_protocol_enabled= cursor_protocol;
- /* Cursor protcol implies ps protocol */
- if (cursor_protocol_enabled)
- ps_protocol_enabled= 1;
st_connection *con= connections;
#ifdef EMBEDDED_LIBRARY
@@ -8289,22 +8522,64 @@ int main(int argc, char **argv)
case Q_DISCONNECT:
case Q_DIRTY_CLOSE:
do_close_connection(command); break;
- case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
- case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
- case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
- case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
- case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
- case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
- case Q_ENABLE_CONNECT_LOG: disable_connect_log=0; break;
- case Q_DISABLE_CONNECT_LOG: disable_connect_log=1; break;
- case Q_ENABLE_WARNINGS: disable_warnings=0; break;
- case Q_DISABLE_WARNINGS: disable_warnings=1; break;
case Q_ENABLE_PREPARE_WARNINGS: prepare_warnings_enabled=1; break;
case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break;
- case Q_ENABLE_INFO: disable_info=0; break;
- case Q_DISABLE_INFO: disable_info=1; break;
- case Q_ENABLE_METADATA: display_metadata=1; break;
- case Q_DISABLE_METADATA: display_metadata=0; break;
+ case Q_ENABLE_QUERY_LOG:
+ disable_query_log= 0;
+ var_set_int("$ENABLED_QUERY_LOG", 1);
+ break;
+ case Q_DISABLE_QUERY_LOG:
+ disable_query_log= 1;
+ var_set_int("$ENABLED_QUERY_LOG", 0);
+ break;
+ case Q_ENABLE_ABORT_ON_ERROR:
+ abort_on_error= 1;
+ var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
+ break;
+ case Q_DISABLE_ABORT_ON_ERROR:
+ abort_on_error= 0;
+ var_set_int("$ENABLED_ABORT_ON_ERROR", 0);
+ break;
+ case Q_ENABLE_RESULT_LOG:
+ disable_result_log= 0;
+ var_set_int("$ENABLED_RESULT_LOG", 1);
+ break;
+ case Q_DISABLE_RESULT_LOG:
+ disable_result_log=1;
+ var_set_int("$ENABLED_RESULT_LOG", 0);
+ break;
+ case Q_ENABLE_CONNECT_LOG:
+ disable_connect_log=0;
+ var_set_int("$ENABLED_CONNECT_LOG", 1);
+ break;
+ case Q_DISABLE_CONNECT_LOG:
+ disable_connect_log=1;
+ var_set_int("$ENABLED_CONNECT_LOG", 0);
+ break;
+ case Q_ENABLE_WARNINGS:
+ disable_warnings= 0;
+ var_set_int("$ENABLED_WARNINGS", 1);
+ break;
+ case Q_DISABLE_WARNINGS:
+ disable_warnings= 1;
+ var_set_int("$ENABLED_WARNINGS", 0);
+ break;
+ case Q_ENABLE_INFO:
+ disable_info= 0;
+ var_set_int("$ENABLED_INFO", 1);
+ break;
+ case Q_DISABLE_INFO:
+ disable_info= 1;
+ var_set_int("$ENABLED_INFO", 0);
+ break;
+ case Q_ENABLE_METADATA:
+ display_metadata= 1;
+ var_set_int("$ENABLED_METADATA", 1);
+ break;
+ case Q_DISABLE_METADATA:
+ display_metadata= 0;
+ var_set_int("$ENABLED_METADATA", 0);
+ break;
case Q_SOURCE: do_source(command); break;
case Q_SLEEP: do_sleep(command, 0); break;
case Q_REAL_SLEEP: do_sleep(command, 1); break;
@@ -8598,7 +8873,7 @@ int main(int argc, char **argv)
memset(&saved_expected_errors, 0, sizeof(saved_expected_errors));
}
- if (command_executed != last_command_executed)
+ if (command_executed != last_command_executed || command->used_replace)
{
/*
As soon as any command has been executed,
@@ -9854,7 +10129,7 @@ int find_set(REP_SETS *sets,REP_SET *find)
return i;
}
}
- return i; /* return new postion */
+ return i; /* return new position */
}
/* find if there is a found_set with same table_offset & found_offset
@@ -9874,7 +10149,7 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
found_set[i].table_offset=table_offset;
found_set[i].found_offset=found_offset;
found_sets++;
- return -i-2; /* return new postion */
+ return -i-2; /* return new position */
}
/* Return 1 if regexp starts with \b or ends with \b*/
@@ -9990,6 +10265,7 @@ void free_pointer_array(POINTER_ARRAY *pa)
void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
const char *val, int len)
{
+ char lower[512];
#ifdef __WIN__
fix_win_paths(val, len);
#endif
@@ -9997,7 +10273,6 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
if (display_result_lower)
{
/* Convert to lower case, and do this first */
- char lower[512];
char *c= lower;
for (const char *v= val; *v; v++)
*c++= my_tolower(charset_info, *v);
diff --git a/client/readline.cc b/client/readline.cc
index 5c1a9951d9b..f6d3d1295f1 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -18,18 +18,28 @@
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
+#include <my_dir.h>
#include "my_readline.h"
static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
ulong max_size);
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
static size_t fill_buffer(LINE_BUFFER *buffer);
-static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
+static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length);
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
{
LINE_BUFFER *line_buff;
+ MY_STAT input_file_stat;
+
+#ifndef __WIN__
+ if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) ||
+ MY_S_ISDIR(input_file_stat.st_mode) ||
+ MY_S_ISBLK(input_file_stat.st_mode))
+ return 0;
+#endif
+
if (!(line_buff=(LINE_BUFFER*)
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
return 0;
@@ -42,13 +52,12 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
}
-char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
+char *batch_readline(LINE_BUFFER *line_buff)
{
char *pos;
ulong out_length;
- DBUG_ASSERT(truncated != NULL);
- if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
+ if (!(pos=intern_read_line(line_buff, &out_length)))
return 0;
if (out_length && pos[out_length-1] == '\n')
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
@@ -162,7 +171,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
buffer->bufread+1,
MYF(MY_WME | MY_FAE))))
- return (uint) -1;
+ {
+ buffer->error= my_errno;
+ return (size_t) -1;
+ }
buffer->start_of_line=buffer->buffer+start_offset;
buffer->end=buffer->buffer+bufbytes;
}
@@ -177,7 +189,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
/* Read in new stuff. */
if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count,
MYF(MY_WME))) == MY_FILE_ERROR)
+ {
+ buffer->error= my_errno;
return (size_t) -1;
+ }
DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
@@ -198,8 +213,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
}
-
-char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
+char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length)
{
char *pos;
size_t length;
@@ -214,22 +228,25 @@ char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
if (pos == buffer->end)
{
/*
- fill_buffer() can return 0 either on EOF in which case we abort
- or when the internal buffer has hit the size limit. In the latter case
- return what we have read so far and signal string truncation.
+ fill_buffer() can return NULL on EOF (in which case we abort),
+ on error, or when the internal buffer has hit the size limit.
+ In the latter case return what we have read so far and signal
+ string truncation.
*/
- if (!(length=fill_buffer(buffer)) || length == (uint) -1)
+ if (!(length= fill_buffer(buffer)))
{
if (buffer->eof)
DBUG_RETURN(0);
}
+ else if (length == (size_t) -1)
+ DBUG_RETURN(NULL);
else
continue;
pos--; /* break line here */
- *truncated= 1;
+ buffer->truncated= 1;
}
else
- *truncated= 0;
+ buffer->truncated= 0;
buffer->end_of_line=pos+1;
*out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
DBUG_RETURN(buffer->start_of_line);
diff --git a/client/sql_string.h b/client/sql_string.h
index bafc287c73e..f406da28995 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -69,9 +69,13 @@ public:
}
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
- static void operator delete(void *ptr_arg,size_t size)
- { TRASH(ptr_arg, size); }
- static void operator delete(void *ptr_arg, MEM_ROOT *mem_root)
+ static void operator delete(void *ptr_arg, size_t size)
+ {
+ (void) ptr_arg;
+ (void) size;
+ TRASH(ptr_arg, size);
+ }
+ static void operator delete(void *, MEM_ROOT *)
{ /* never called */ }
~String() { free(); }