Commit e32d7bce authored by jonas@perch.ndb.mysql.com's avatar jonas@perch.ndb.mysql.com

Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new

into  perch.ndb.mysql.com:/home/jonas/src/51-work
parents ef01ad4d 50440fb3
......@@ -2910,7 +2910,7 @@ static int init_dumping(char *database)
/*
length of table name * 2 (if name contains quotes), 2 quotes and 0
*/
char quoted_database_buf[64*2+3];
char quoted_database_buf[NAME_LEN*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
if (opt_comments)
{
......@@ -3067,7 +3067,18 @@ static my_bool dump_all_views_in_db(char *database)
DB_error(sock, "when selecting the database");
return 1;
}
if (opt_databases || opt_alldbs)
{
char quoted_database_buf[NAME_LEN*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
if (opt_comments)
{
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
check_io(md_result_file);
}
fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
check_io(md_result_file);
}
if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", database, "\n");
if (lock_tables)
......@@ -3526,7 +3537,7 @@ static char *primary_key_fields(const char *table_name)
MYSQL_RES *res = NULL;
MYSQL_ROW row;
/* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
char show_keys_buff[15 + 64 * 2 + 3];
char show_keys_buff[15 + NAME_LEN * 2 + 3];
uint result_length = 0;
char *result = 0;
......
......@@ -82,9 +82,6 @@
#define MAX_EXPECTED_ERRORS 10
#define QUERY_SEND 1
#define QUERY_REAP 2
#ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546
#endif
#define MAX_SERVER_ARGS 64
......@@ -96,11 +93,10 @@
#define RESULT_CONTENT_MISMATCH 1
#define RESULT_LENGTH_MISMATCH 2
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC,
OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER,OPT_PS_PROTOCOL,OPT_SP_PROTOCOL,OPT_CURSOR_PROTOCOL,
OPT_VIEW_PROTOCOL, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES,
enum {OPT_SKIP_SAFEMALLOC=256, OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT,
OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL,
OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES,
OPT_MARK_PROGRESS};
/* ************************************************************************ */
......@@ -160,11 +156,6 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0;
static my_bool view_protocol= 0, view_protocol_enabled= 0;
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
static int parsing_disabled= 0;
const char *manager_user="root",*manager_host=0;
char *manager_pass=0;
int manager_port=MYSQL_MANAGER_PORT;
int manager_wait_timeout=3;
MYSQL_MANAGER* manager=0;
static char **default_argv;
static const char *load_default_groups[]= { "mysqltest","client",0 };
......@@ -180,7 +171,7 @@ typedef struct
static test_file file_stack[MAX_INCLUDE_DEPTH];
static test_file* cur_file;
static test_file* file_stack_end;
uint start_lineno; /* Start line of query */
uint start_lineno= 0; /* Start line of query */
/* Stores regex substitutions */
......@@ -335,7 +326,6 @@ Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_WAIT_FOR_SLAVE_TO_STOP,
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS,
......@@ -347,11 +337,10 @@ Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL,
Q_START_TIMER, Q_END_TIMER,
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
Q_EXIT,
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
Q_IF,
Q_DISABLE_PARSING, Q_ENABLE_PARSING,
Q_REPLACE_REGEX,
Q_REPLACE_REGEX, Q_DIE,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
......@@ -409,9 +398,6 @@ const char *command_names[]=
/* Enable/disable that the _result_ from a query is logged to result file */
"enable_result_log",
"disable_result_log",
"server_start",
"server_stop",
"require_manager",
"wait_for_slave_to_stop",
"enable_warnings",
"disable_warnings",
......@@ -434,13 +420,13 @@ const char *command_names[]=
"character_set",
"disable_ps_protocol",
"enable_ps_protocol",
"exit",
"disable_reconnect",
"enable_reconnect",
"if",
"disable_parsing",
"enable_parsing",
"replace_regex",
"die",
0
};
......@@ -610,10 +596,7 @@ static void free_used_memory()
{
uint i;
DBUG_ENTER("free_used_memory");
#ifndef EMBEDDED_LIBRARY
if (manager)
mysql_manager_close(manager);
#endif
close_cons();
close_files();
hash_free(&var_hash);
......@@ -660,7 +643,7 @@ static void die(const char *fmt, ...)
if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name);
if (start_lineno != 0)
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
......@@ -682,17 +665,43 @@ static void die(const char *fmt, ...)
exit(1);
}
/* Note that we will get some memory leaks when calling this! */
static void abort_not_supported_test(const char *fname)
static void abort_not_supported_test(const char *fmt, ...)
{
va_list args;
test_file* err_file= cur_file;
DBUG_ENTER("abort_not_supported_test");
/* Print include filestack */
fprintf(stderr, "The test '%s' is not supported by this installation\n",
fname);
if (!silent)
printf("skipped\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);
}
/* Print error message */
va_start(args, fmt);
if (fmt)
{
fprintf(stderr, "reason: ");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
fflush(stderr);
}
va_end(args);
/* Clean up and exit */
free_used_memory();
my_end(MY_CHECK_ERROR);
if (!silent)
printf("skipped\n");
exit(62);
}
......@@ -704,13 +713,13 @@ static void verbose_msg(const char *fmt, ...)
DBUG_VOID_RETURN;
va_start(args, fmt);
fprintf(stderr, "mysqltest: ");
if (start_lineno != 0)
fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
DBUG_VOID_RETURN;
}
......@@ -736,10 +745,10 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
if (!test_if_hard_path(fname))
{
strxmov(eval_file, opt_basedir, fname, NullS);
fn_format(eval_file, eval_file,"","",4);
fn_format(eval_file, eval_file, "", "", MY_UNPACK_FILENAME);
}
else
fn_format(eval_file, fname,"","",4);
fn_format(eval_file, fname, "", "", MY_UNPACK_FILENAME);
if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
die(NullS);
......@@ -780,8 +789,9 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
err:
if (res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
res_len);
str_to_file(fn_format(eval_file, fname, "", ".eval",
MY_REPLACE_EXT),
res_ptr, res_len);
my_free((gptr) tmp, MYF(0));
my_close(fd, MYF(MY_WME));
......@@ -811,7 +821,11 @@ static void check_result(DYNAMIC_STRING* ds, const char *fname,
DBUG_ENTER("check_result");
if (res && require_option)
abort_not_supported_test(fname);
{
char reason[FN_REFLEN];
fn_format(reason, fname, "", "", MY_REPLACE_EXT | MY_REPLACE_DIR);
abort_not_supported_test("Test requires: '%s'", reason);
}
switch (res) {
case RESULT_OK:
break; /* ok */
......@@ -956,7 +970,7 @@ int open_file(const char *name)
strxmov(buff, opt_basedir, name, NullS);
name=buff;
}
fn_format(buff,name,"","",4);
fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
if (cur_file == file_stack_end)
die("Source directives are nesting too deep");
......@@ -1030,57 +1044,6 @@ int do_wait_for_slave_to_stop(struct st_query *q __attribute__((unused)))
return 0;
}
int do_require_manager(struct st_query *query __attribute__((unused)) )
{
if (!manager)
abort_not_supported_test("manager");
return 0;
}
#ifndef EMBEDDED_LIBRARY
static int do_server_op(struct st_query *q, const char *op)
{
char *p= q->first_argument;
char com_buf[256], *com_p;
if (!manager)
{
die("Manager is not initialized, manager commands are not possible");
}
com_p= strmov(com_buf,op);
com_p= strmov(com_p,"_exec ");
if (!*p)
die("Missing server name in server_%s", op);
while (*p && !my_isspace(charset_info, *p))
*com_p++= *p++;
*com_p++= ' ';
com_p= int10_to_str(manager_wait_timeout, com_p, 10);
*com_p++= '\n';
*com_p= 0;
if (mysql_manager_command(manager, com_buf, (int)(com_p-com_buf)))
die("Error in command: %s(%d)", manager->last_error, manager->last_errno);
while (!manager->eof)
{
if (mysql_manager_fetch_line(manager, com_buf, sizeof(com_buf)))
die("Error fetching result line: %s(%d)", manager->last_error,
manager->last_errno);
}
q->last_argument= p;
return 0;
}
int do_server_start(struct st_query *q)
{
return do_server_op(q, "start");
}
int do_server_stop(struct st_query *q)
{
return do_server_op(q, "stop");
}
#endif
/*
Source and execute the given file
......@@ -1919,7 +1882,7 @@ static void set_charset(struct st_query *q)
q->last_argument= p;
charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME));
if (!charset_info)
abort_not_supported_test(charset_name);
abort_not_supported_test("Test requires charset '%s'", charset_name);
}
static uint get_errcodes(match_err *to,struct st_query *q)
......@@ -2473,19 +2436,6 @@ char* safe_get_param(char *str, char** arg, const char *msg)
DBUG_RETURN(str);
}
#ifndef EMBEDDED_LIBRARY
void init_manager()
{
if (!(manager=mysql_manager_init(0)))
die("Failed in mysql_manager_init()");
if (!mysql_manager_connect(manager,manager_host,manager_user,
manager_pass,manager_port))
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
manager->last_errno);
}
#endif
/*
Connect to a server doing several retries if needed.
......@@ -2770,7 +2720,7 @@ int do_connect(struct st_query *q)
}
#endif
if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR)
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
con_sock=fn_format(buff, con_sock, TMPDIR, "", 0);
if (!con_db[0])
con_db= db;
/* Special database to allow one to connect without a database name */
......@@ -3287,20 +3237,6 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include,
(gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"manager-host", OPT_MANAGER_HOST, "Undocumented: Used for debugging.",
(gptr*) &manager_host, (gptr*) &manager_host, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"manager-password", OPT_MANAGER_PASSWD, "Undocumented: Used for debugging.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"manager-port", OPT_MANAGER_PORT, "Undocumented: Used for debugging.",
(gptr*) &manager_port, (gptr*) &manager_port, 0, GET_INT, REQUIRED_ARG,
MYSQL_MANAGER_PORT, 0, 0, 0, 0, 0},
{"manager-user", OPT_MANAGER_USER, "Undocumented: Used for debugging.",
(gptr*) &manager_user, (gptr*) &manager_user, 0, GET_STR, REQUIRED_ARG, 0,
0, 0, 0, 0, 0},
{"manager-wait-timeout", OPT_MANAGER_WAIT_TIMEOUT,
"Undocumented: Used for debugging.", (gptr*) &manager_wait_timeout,
(gptr*) &manager_wait_timeout, 0, GET_INT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0},
{"mark-progress", OPT_MARK_PROGRESS,
"Write linenumber and elapsed time to <testname>.progress ",
(gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0,
......@@ -3397,11 +3333,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'r':
record = 1;
break;
case (int)OPT_MANAGER_PASSWD:
my_free(manager_pass,MYF(MY_ALLOW_ZERO_PTR));
manager_pass=my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
break;
case 'x':
{
char buff[FN_REFLEN];
......@@ -3410,7 +3341,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strxmov(buff, opt_basedir, argument, NullS);
argument= buff;
}
fn_format(buff, argument, "", "", 4);
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file=
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
......@@ -3427,7 +3358,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strxmov(buff, opt_basedir, argument, NullS);
argument= buff;
}
fn_format(buff, argument, "", "", 4);
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
timer_file= buff;
unlink(timer_file); /* Ignore error, may not exist */
break;
......@@ -3521,7 +3452,7 @@ static void str_to_file(const char *fname, char *str, int size)
strxmov(buff, opt_basedir, fname, NullS);
fname= buff;
}
fn_format(buff,fname,"","",4);
fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);
if ((fd= my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
MYF(MY_WME | MY_FFNF))) < 0)
......@@ -3535,19 +3466,24 @@ static void str_to_file(const char *fname, char *str, int size)
void dump_result_to_reject_file(const char *record_file, char *buf, int size)
{
char reject_file[FN_REFLEN];
str_to_file(fn_format(reject_file, record_file,"",".reject",2), buf, size);
str_to_file(fn_format(reject_file, record_file, "", ".reject",
MY_REPLACE_EXT),
buf, size);
}
void dump_result_to_log_file(const char *record_file, char *buf, int size)
{
char log_file[FN_REFLEN];
str_to_file(fn_format(log_file, record_file,"",".log",2), buf, size);
str_to_file(fn_format(log_file, record_file, "", ".log",
MY_REPLACE_EXT),
buf, size);
}
void dump_progress(const char *record_file)
{
char log_file[FN_REFLEN];
str_to_file(fn_format(log_file, record_file,"",".progress",2),
str_to_file(fn_format(log_file, record_file, "", ".progress",
MY_REPLACE_EXT),
ds_progress.str, ds_progress.length);
}
......@@ -4358,7 +4294,9 @@ static void handle_error(const char *query, struct st_query *q,
if (err_errno == CR_SERVER_LOST ||
err_errno == CR_SERVER_GONE_ERROR)
die("require query '%s' failed: %d: %s", query, err_errno, err_error);
abort_not_supported_test("failed_query");
/* Abort the run of this test, pass the failed query as reason */
abort_not_supported_test("Query '%s' failed, required functionality not supported", query);
}
if (q->abort_on_error)
......@@ -5139,7 +5077,7 @@ static void init_var_hash(MYSQL *mysql)
test run completes
*/
static void mark_progress(struct st_query* q, int line)
static void mark_progress(struct st_query* q __attribute__((unused)), int line)
{
char buf[32], *end;
ulonglong timer= timer_now();
......@@ -5174,7 +5112,7 @@ static void mark_progress(struct st_query* q, int line)
int main(int argc, char **argv)
{
struct st_query *q;
my_bool require_file=0, q_send_flag=0, abort_flag= 0,
my_bool require_file=0, q_send_flag=0,
query_executed= 0;
char save_file[FN_REFLEN];
MY_STAT res_info;
......@@ -5224,10 +5162,6 @@ int main(int argc, char **argv)
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
cur_file->lineno= 1;
}
#ifndef EMBEDDED_LIBRARY
if (manager_host)
init_manager();
#endif
init_re();
ps_protocol_enabled= ps_protocol;
sp_protocol_enabled= sp_protocol;
......@@ -5281,7 +5215,7 @@ int main(int argc, char **argv)
open_file(opt_include);
}
while (!abort_flag && !read_query(&q))
while (!read_query(&q))
{
int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
......@@ -5319,11 +5253,6 @@ int main(int argc, char **argv)
case Q_SLEEP: do_sleep(q, 0); break;
case Q_REAL_SLEEP: do_sleep(q, 1); break;
case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break;
case Q_REQUIRE_MANAGER: do_require_manager(q); break;
#ifndef EMBEDDED_LIBRARY
case Q_SERVER_START: do_server_start(q); break;
case Q_SERVER_STOP: do_server_stop(q); break;
#endif
case Q_INC: do_modify_var(q, DO_INC); break;
case Q_DEC: do_modify_var(q, DO_DEC); break;
case Q_ECHO: do_echo(q); query_executed= 1; break;
......@@ -5501,8 +5430,8 @@ int main(int argc, char **argv)
parsing_disabled--;
break;
case Q_EXIT:
abort_flag= 1;
case Q_DIE:
die("%s", q->first_argument);
break;
default:
......@@ -5622,7 +5551,7 @@ static int read_server_arguments(const char *name)
strxmov(buff, opt_basedir, name, NullS);
name=buff;
}
fn_format(buff,name,"","",4);
fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
if (!embedded_server_arg_count)
{
......
--require r/true.require
--require r/not_ndb_default.require
disable_query_log;
select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE";
enable_query_log;
--require r/true.require
--require r/not_windows.require
disable_query_log;
select convert(@@version_compile_os using latin1) NOT IN ("Win32","Win64","Windows") as "TRUE";
enable_query_log;
#
# Include this script to wait until the connection to the
# server has been restored or timeout occurs
--disable_result_log
--disable_query_log
let $counter= 100;
while ($mysql_errno)
{
--error 0,2002,2006
show status;
dec $counter;
if (!$counter)
{
--die Server failed to restart
}
--sleep 0.1
}
--enable_query_log
--enable_result_log
--require r/true.require
--require r/windows.require
disable_query_log;
select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") as "TRUE";
enable_query_log;
......@@ -11,6 +11,7 @@ sub mtr_get_opts_from_file ($);
sub mtr_fromfile ($);
sub mtr_tofile ($@);
sub mtr_tonewfile($@);
sub mtr_lastlinefromfile($);
##############################################################################
#
......@@ -113,6 +114,20 @@ sub mtr_fromfile ($) {
return $text;
}
sub mtr_lastlinefromfile ($) {
my $file= shift;
my $text;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
while (my $line= <FILE>)
{
$text= $line;
}
close FILE;
return $text;
}
sub mtr_tofile ($@) {
my $file= shift;
......@@ -129,5 +144,4 @@ sub mtr_tonewfile ($@) {
close FILE;
}
1;
......@@ -272,10 +272,10 @@ sub spawn_parent_impl {
last;
}
# If one of the processes died, we want to
# mark this, and kill the mysqltest process.
# One of the child processes died, unless this was expected
# mysqltest should be killed and test aborted
mark_process_dead($ret_pid);
check_expected_crash_and_restart($ret_pid);
}
if ( $ret_pid != $pid )
......@@ -811,6 +811,81 @@ sub mark_process_dead($)
}
#
# Loop through our list of processes and look for and entry
# with the provided pid, if found check for the file indicating
# expected crash and restart it.
#
sub check_expected_crash_and_restart($)
{
my $ret_pid= shift;
foreach my $mysqld (@{$::master}, @{$::slave})
{
if ( $mysqld->{'pid'} eq $ret_pid )
{
mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
$mysqld->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
"$mysqld->{'idx'}" . ".expect";
if ( -f $expect_file )
{
mtr_verbose("Crash was expected, file $expect_file exists");
mysqld_start($mysqld, $mysqld->{'start_opts'},
$mysqld->{'start_slave_master_info'});
unlink($expect_file);
}
return;
}
}
foreach my $cluster (@{$::clusters})
{
if ( $cluster->{'pid'} eq $ret_pid )
{
mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
$cluster->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
".expect";
if ( -f $expect_file )
{
mtr_verbose("Crash was expected, file $expect_file exists");
ndbmgmd_start($cluster);
unlink($expect_file);
}
return;
}
foreach my $ndbd (@{$cluster->{'ndbds'}})
{
if ( $ndbd->{'pid'} eq $ret_pid )
{
mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
$ndbd->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
"$ndbd->{'idx'}" . ".expect";
if ( -f $expect_file )
{
mtr_verbose("Crash was expected, file $expect_file exists");
ndbd_start($cluster, $ndbd->{'idx'},
$ndbd->{'start_extra_args'});
unlink($expect_file);
}
return;
}
}
}
mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
}
##############################################################################
#
# The operating system will keep information about dead children,
......
......@@ -1806,6 +1806,10 @@ sub ndbd_start ($$$) {
# Add pid to list of pids for this cluster
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
# Rememeber options used when starting
$cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
$cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
mtr_verbose("ndbd_start, pid: $pid");
return $pid;
......@@ -2343,8 +2347,11 @@ sub run_testcase ($) {
elsif ( $res == 62 )
{
# Testcase itself tell us to skip this one
# FIXME get reason to skip from mysqltest
$tinfo->{'comment'}= "Detected by testcase";
# Try to get reason from mysqltest.log
my $last_line= mtr_lastlinefromfile($path_timefile) if -f $path_timefile;
my $reason= mtr_match_prefix($last_line, "reason: ");
$tinfo->{'comment'}= defined $reason ? $reason : "Detected by testcase(reason unknown) ";
mtr_report_test_skipped($tinfo);
}
elsif ( $res == 63 )
......@@ -2904,6 +2911,7 @@ sub mysqld_start ($$$) {
# Remember options used when starting
$mysqld->{'start_opts'}= $extra_opt;
$mysqld->{'start_slave_master_info'}= $slave_master_info;
mtr_verbose("mysqld pid: $pid");
return $pid;
......
CREATE TABLE t1(a int) engine=innodb;
START TRANSACTION;
insert into t1 values(9);
SET SESSION debug="d,crash_commit_before";
COMMIT;
ERROR HY000: Lost connection to MySQL server during query
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM t1;
a
......@@ -695,3 +695,103 @@ CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
CREATE DATABASE meow;
CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE VIEW view_target2 AS SELECT mexs_id,messzeit FROM table_target2;
CREATE SQL SECURITY INVOKER VIEW view_target3 AS SELECT mexs_id,messzeit FROM table_target3;
CREATE TABLE table_stations ( mexs_id VARCHAR(8), icao VARCHAR(4), country CHAR(2), PRIMARY KEY (mexs_id), UNIQUE KEY icao (icao), KEY country (country), CONSTRAINT stations_ibfk_8 FOREIGN KEY (country) REFERENCES countries (country) ON UPDATE CASCADE);
INSERT INTO table_stations VALUES ('87654321','XXXX','YY');
CREATE TABLE table_countries ( country CHAR(2), iso_short_en VARCHAR(64), PRIMARY KEY (country));
INSERT INTO table_countries VALUES ('YY','Entenhausen');
CREATE ALGORITHM=MERGE SQL SECURITY INVOKER VIEW view_stations AS select table_stations.mexs_id AS mexs_id, table_stations.icao AS icao, table_stations.country AS landescode from (table_stations join table_countries on((table_stations.country = table_countries.country)));
CREATE TABLE table_source ( id varchar(4), datetime TIMESTAMP, PRIMARY KEY (id));
INSERT INTO table_source VALUES ('XXXX','2006-07-12 07:50:00');
GRANT SELECT ON table_source TO user20989@localhost;
GRANT SELECT ON table_countries TO user20989@localhost;
GRANT SELECT ON table_stations TO user20989@localhost;
GRANT SELECT ON view_stations TO user20989@localhost;
GRANT SELECT ON table_target TO user20989@localhost;
GRANT SELECT ON table_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN table_target AS old
USING (mexs_id);
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target'
REPLACE INTO view_target2
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'view_target2'
REPLACE INTO view_target3
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
ERROR HY000: View 'meow.view_target3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
GRANT INSERT,DELETE ON table_target TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN table_target AS old
USING (mexs_id);
REPLACE INTO table_target2 VALUES ('00X45Y78','2006-07-12 07:50:00');
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target2'
REPLACE INTO view_target2 VALUES ('12X45Y78','2006-07-12 07:50:00');
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
mexs_id messzeit
87654321 2006-07-12 07:50:00
REPLACE INTO view_target2
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
REPLACE INTO view_target3
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
SELECT * FROM table_target;
mexs_id messzeit
87654321 2006-07-12 07:50:00
SELECT * FROM view_target2;
mexs_id messzeit
12X45Y78 2006-07-12 07:50:00
87654321 2006-07-12 07:50:00
SELECT * FROM view_target3;
mexs_id messzeit
87654321 2006-07-12 07:50:00
DROP VIEW view_stations;
DROP TABLE table_source;
DROP TABLE table_countries;
DROP TABLE table_stations;
DROP TABLE table_target;
DROP TABLE table_target2;
DROP TABLE table_target3;
DROP VIEW view_target2;
DROP VIEW view_target3;
DROP USER user20989@localhost;
DROP DATABASE meow;
......@@ -2574,6 +2574,8 @@ DROP TABLE IF EXISTS `v2`;
`b` varchar(32),
`c` varchar(32)
) */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
......@@ -2827,6 +2829,8 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
......@@ -2852,59 +2856,63 @@ create database mysqldump_views;
use mysqldump_views;
create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_tables`;
DROP TABLE IF EXISTS `basetable`;
CREATE TABLE `basetable` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`tag` varchar(64) DEFAULT NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `basetable` WRITE;
/*!40000 ALTER TABLE `basetable` DISABLE KEYS */;
/*!40000 ALTER TABLE `basetable` ENABLE KEYS */;
UNLOCK TABLES;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_views`;
DROP TABLE IF EXISTS `nasishnasifu`;
/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
/*!50001 CREATE TABLE `nasishnasifu` (
`id` bigint(20) unsigned
) */;
/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
USE `mysqldump_tables`;
USE `mysqldump_views`;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
create database mysqldump_dba;
use mysqldump_dba;
create table t1 (f1 int, f2 int);
insert into t1 values (1,1);
create view v1 as select f1, f2 from t1;
create database mysqldump_dbb;
use mysqldump_dbb;
create table t1 (f1 int, f2 int);
insert into t1 values (2,2);
create view v1 as select f1, f2 from t1;
drop view v1;
drop table t1;
drop database mysqldump_dbb;
use mysqldump_dba;
drop view v1;
drop table t1;
drop database mysqldump_dba;
select * from mysqldump_dba.v1;
f1 f2
1 1
select * from mysqldump_dbb.v1;
f1 f2
2 2
use mysqldump_dba;
drop view v1;
drop table t1;
drop database mysqldump_dba;
use mysqldump_dbb;
drop view v1;
drop table t1;
drop database mysqldump_dbb;
use test;
End of 5.0 tests
create table t1 (a text , b text);
......@@ -3159,6 +3167,8 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
......
reset master;
reset slave;
start slave;
show binary logs;
Log_name
master-bin.000001
master-bin.000002
drop table if exists t1;
create table t1(n int);
insert into t1 values (3351);
select * from t1;
n
3351
drop table t1;
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
reset master;
change master to master_host='127.0.0.1',master_port=9307, master_user='root';
start slave;
create temporary table t1 (a int);
create temporary table t1 (a int);
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 2
create temporary table t1 (a int);
create temporary table t1 (a int);
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 4
stop slave;
insert into t1 values(1);
create table t2 as select * from t1;
start slave;
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 4
select * from t2;
a
1
drop table t2;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 1
show status like 'Rpl_status';
Variable_name Value
Rpl_status AUTH_MASTER
create table t1(n int);
drop table t1;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 2
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 3
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 4
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
reset master;
drop table if exists t1;
create table t1 ENGINE=HEAP select 10 as a;
insert into t1 values(11);
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use `test`; create table t1 ENGINE=HEAP select 10 as a
master-bin.001 154 Query 1 154 use `test`; insert into t1 values(11)
reset slave;
start slave;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(2) NOT NULL default '0'
) ENGINE=HEAP
select * from t1;
a
10
11
select * from t1;
a
select * from t1 limit 10;
a
show binlog events in 'master-bin.002' from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.002 79 Query 1 79 use `test`; DELETE FROM `test`.`t1`
select * from t1;
a
drop table t1;
......@@ -166,6 +166,13 @@ show variables like 'max_error_count';
Variable_name Value
max_error_count 10
drop table t1;
create table t1 (id int) engine=merge;
Warnings:
Warning 1266 Using storage engine MyISAM for table 't1'
alter table t1 engine=merge;
Warnings:
Warning 1266 Using storage engine MyISAM for table 't1'
drop table t1;
set table_type=MYISAM;
Warnings:
Warning 1541 The syntax 'table_type' is deprecated and will be removed in MySQL 5.2. Please use 'storage_engine' instead.
......
--source include/have_debug.inc
CREATE TABLE t1(a int) engine=innodb;
START TRANSACTION;
insert into t1 values(9);
# Setup the mysqld to crash at certain point
SET SESSION debug="d,crash_commit_before";
# Write file to make mysql-test-run.pl expect crash and restart
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/master0.expect
# Run the crashing query
--error 2013
COMMIT;
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
SHOW CREATE TABLE t1;
SELECT * FROM t1;
......@@ -41,5 +41,5 @@ rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
rpl_ndb_idempotent : BUG#21298 2006-07-27 msvensson
rpl_row_basic_7ndb : BUG#21298 2006-07-27 msvensson
rpl_truncate_7ndb : BUG#21298 2006-07-27 msvensson
crash_commit_before : 2006-08-02 msvensson
rpl_ndb_dd_advance : BUG#18679 2006-07-28 jimw (Test fails randomly)
......@@ -247,3 +247,141 @@ CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
#
# Bug #20989: View '(null).(null)' references invalid table(s)... on
# SQL SECURITY INVOKER
#
# this is really the fact that REPLACE ... SELECT required additional
# INSERT privs (on tables that are part of a view) over the related
# REPLACE, SELECT
#
CREATE DATABASE meow;
connect (root,localhost,root,,meow);
connection root;
CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE VIEW view_target2 AS SELECT mexs_id,messzeit FROM table_target2;
CREATE SQL SECURITY INVOKER VIEW view_target3 AS SELECT mexs_id,messzeit FROM table_target3;
CREATE TABLE table_stations ( mexs_id VARCHAR(8), icao VARCHAR(4), country CHAR(2), PRIMARY KEY (mexs_id), UNIQUE KEY icao (icao), KEY country (country), CONSTRAINT stations_ibfk_8 FOREIGN KEY (country) REFERENCES countries (country) ON UPDATE CASCADE);
INSERT INTO table_stations VALUES ('87654321','XXXX','YY');
CREATE TABLE table_countries ( country CHAR(2), iso_short_en VARCHAR(64), PRIMARY KEY (country));
INSERT INTO table_countries VALUES ('YY','Entenhausen');
CREATE ALGORITHM=MERGE SQL SECURITY INVOKER VIEW view_stations AS select table_stations.mexs_id AS mexs_id, table_stations.icao AS icao, table_stations.country AS landescode from (table_stations join table_countries on((table_stations.country = table_countries.country)));
CREATE TABLE table_source ( id varchar(4), datetime TIMESTAMP, PRIMARY KEY (id));
INSERT INTO table_source VALUES ('XXXX','2006-07-12 07:50:00');
GRANT SELECT ON table_source TO user20989@localhost;
GRANT SELECT ON table_countries TO user20989@localhost;
GRANT SELECT ON table_stations TO user20989@localhost;
GRANT SELECT ON view_stations TO user20989@localhost;
GRANT SELECT ON table_target TO user20989@localhost;
GRANT SELECT ON table_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
connect (user20989,localhost,user20989,,meow);
connection user20989;
--error 1142
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN table_target AS old
USING (mexs_id);
--error 1142
REPLACE INTO view_target2
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
--error 1356
REPLACE INTO view_target3
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
connection root;
disconnect user20989;
GRANT INSERT,DELETE ON table_target TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
connect (user20989,localhost,user20989,,meow);
connection user20989;
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN table_target AS old
USING (mexs_id);
--error 1142
REPLACE INTO table_target2 VALUES ('00X45Y78','2006-07-12 07:50:00');
REPLACE INTO view_target2 VALUES ('12X45Y78','2006-07-12 07:50:00');
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
REPLACE INTO view_target2
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target2 AS old
USING (mexs_id);
REPLACE INTO view_target3
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
connection root;
disconnect user20989;
SELECT * FROM table_target;
SELECT * FROM view_target2;
SELECT * FROM view_target3;
DROP VIEW view_stations;
DROP TABLE table_source;
DROP TABLE table_countries;
DROP TABLE table_stations;
DROP TABLE table_target;
DROP TABLE table_target2;
DROP TABLE table_target3;
DROP VIEW view_target2;
DROP VIEW view_target3;
DROP USER user20989@localhost;
disconnect root;
connection default;
DROP DATABASE meow;
......@@ -1225,8 +1225,9 @@ drop view v1;
drop table t1;
drop database mysqldump_test_db;
#
# Bug21014 Segmentation fault of mysqldump on view
#
create database mysqldump_tables;
use mysqldump_tables;
create table basetable ( id serial, tag varchar(64) );
......@@ -1235,12 +1236,51 @@ create database mysqldump_views;
use mysqldump_views;
create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
--exec $MYSQL_DUMP --skip-comments --databases mysqldump_tables mysqldump_views;
--exec $MYSQL_DUMP --skip-comments --compact --databases mysqldump_tables mysqldump_views;
drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
#
# Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
#
create database mysqldump_dba;
use mysqldump_dba;
create table t1 (f1 int, f2 int);
insert into t1 values (1,1);
create view v1 as select f1, f2 from t1;
create database mysqldump_dbb;
use mysqldump_dbb;
create table t1 (f1 int, f2 int);
insert into t1 values (2,2);
create view v1 as select f1, f2 from t1;
--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_dba mysqldump_dbb > $MYSQLTEST_VARDIR/tmp/bug20221_backup;
drop view v1;
drop table t1;
drop database mysqldump_dbb;
use mysqldump_dba;
drop view v1;
drop table t1;
drop database mysqldump_dba;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20221_backup;
select * from mysqldump_dba.v1;
select * from mysqldump_dbb.v1;
use mysqldump_dba;
drop view v1;
drop table t1;
drop database mysqldump_dba;
use mysqldump_dbb;
drop view v1;
drop table t1;
drop database mysqldump_dbb;
use test;
--echo End of 5.0 tests
......
#
# Running test with abort-slave-event-count=1
# This will force slave to reconnect after every event
#
require_manager;
connect (master,localhost,root,,test,0,$MASTER_MYPORT);
connect (slave,localhost,root,,test,0,slave.sock);
connection master;
reset master;
server_stop master;
server_start master;
connection slave;
reset slave;
start slave;
connection master;
show binary logs;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(n int);
insert into t1 values (3351);
sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
# End of 4.1 tests
# This test makes some assumptions about values of thread ids, which should be
# true if the servers have been restarted for this test. So we want to
# stop/restart servers. Note that if assumptions are wrong, the test will not
# fail; it will just fail to test the error-prone scenario.
# Using the manager is the only way to have more than one slave server.
# So you must run this test with --manager.
require_manager;
server_stop master;
server_start master;
server_stop slave;
server_start slave;
# no need for slave_sec (no assumptions on thread ids for this server).
source include/master-slave.inc;
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
connection master;
save_master_pos;
connection slave;
sync_with_master;
reset master;
save_master_pos;
connection slave_sec;
eval change master to master_host='127.0.0.1',master_port=$SLAVE_MYPORT, master_user='root';
start slave;
sync_with_master;
# :P now we have a chain ready-to-test.
connection master;
create temporary table t1 (a int);
save_master_pos;
connection slave;
sync_with_master;
connection master1;
create temporary table t1 (a int);
save_master_pos;
connection slave;
sync_with_master;
save_master_pos;
# First test:
connection slave_sec;
# Before BUG#1686 ("If 2 master threads with same-name temp table, slave makes
# bad binlog") was fixed, sync_with_master failed
sync_with_master;
show status like 'slave_open_temp_tables';
# 'master' and 'master1' usually have thread id 2-3 or 3-4.
# 'slave' and 'slave1' usually have thread id 2-3.
connection slave;
create temporary table t1 (a int);
connection slave1;
create temporary table t1 (a int);
# So it's likely that in the binlog of slave we get
# server_id=of_master thread_id=3 create temp...
# server_id=of_slave thread_id=3 create temp...
# which would confuse slave-sec unless slave-sec uses server id to distinguish
# between temp tables (here thread id is obviously not enough to distinguish).
save_master_pos;
# Second test:
connection slave_sec;
# If we did not use the server id to distinguish between temp tables,
# sync_with_master would fail
sync_with_master;
show status like 'slave_open_temp_tables';
# Third test (BUG#1240 "slave of slave breaks when STOP SLAVE was issud on
# parent slave and temp tables").
stop slave;
connection slave;
insert into t1 values(1);
create table t2 as select * from t1;
save_master_pos;
connection slave_sec;
start slave;
sync_with_master;
show status like 'slave_open_temp_tables';
select * from t2;
# clean up
connection slave;
drop table t2;
save_master_pos;
connection slave_sec;
sync_with_master;
# On purpose, we don't delete the temporary tables explicitely.
# So temp tables remain on slave (remember they are not deleted when the slave
# SQL thread terminates). If you run this test with
# --valgrind --valgrind-options=--show-reachable=yes
# you will see if they get cleaned up at slave's shutdown (that is, if the
# memory they use is freed (it should) by mysqld before it terminates).
# If they wouldn't be cleaned up, you would see some "still reachable" blocks in
# Valgrind.
# End of 4.1 tests
require_manager;
source include/master-slave.inc;
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
connect (slave_ter,localhost,root,,test,0,slave.sock-2);
connection master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
create table t1(n int);
drop table t1;
sync_slave_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_sec;
start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_ter;
start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
# End of 4.1 tests
# Requires statement logging
-- source include/have_binlog_format_statement.inc
# You must run this test with --manager.
require_manager;
# Don't know why, but using TCP/IP connections makes this test fail
# with "Lost connection to MySQL server during query" when we
# issue a query after the server restart.
# Maybe this is something awkward in mysqltest or in the manager?
# So we use sockets.
connect (master,localhost,root,,test,0,$MASTER_MYPORT);
connect (slave,localhost,root,,test,0,slave.sock);
connection master;
reset master;
drop table if exists t1;
# we use CREATE SELECT to verify that DELETE does not get into binlog
# before CREATE SELECT
create table t1 engine=HEAP select 10 as a;
insert into t1 values(11);
save_master_pos;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 79;
connection slave;
reset slave;
start slave;
sync_with_master;
show create table t1;
select * from t1; # should be one row
server_stop master;
server_start master;
connection master;
select * from t1;
# to check that DELETE is not written twice
# (the LIMIT is to not use the query cache)
select * from t1 limit 10;
save_master_pos;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.002' from 79;
connection slave;
sync_with_master;
select * from t1; # should be empty
# clean up
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
# End of 4.1 tests
......@@ -4,8 +4,8 @@
# forget to close its tables.
# Can be run with statement-based but no interest (and long test)
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
connection master;
create table t1 (a int not null auto_increment primary key, b int, key(b));
......
--skip-isam
--skip-isam --skip-merge
......@@ -116,6 +116,9 @@ drop table t1;
#create table t1 (id int) engine=isam;
#alter table t1 engine=isam;
#drop table t1;
create table t1 (id int) engine=merge;
alter table t1 engine=merge;
drop table t1;
#
# Test for deprecated table_type variable
......
......@@ -364,6 +364,12 @@ static HASH federated_open_tables; // To track open tables
pthread_mutex_t federated_mutex; // To init the hash
static int federated_init= FALSE; // Checking the state of hash
/* Variables used when chopping off trailing characters */
static const uint sizeof_trailing_comma= sizeof(", ") - 1;
static const uint sizeof_trailing_closeparen= sizeof(") ") - 1;
static const uint sizeof_trailing_and= sizeof(" AND ") - 1;
static const uint sizeof_trailing_where= sizeof(" WHERE ") - 1;
/* Static declaration for handerton */
static handler *federated_create_handler(TABLE_SHARE *table,
MEM_ROOT *mem_root);
......@@ -526,19 +532,14 @@ static int check_foreign_data_source(FEDERATED_SHARE *share,
the query will be: SELECT * FROM `tablename` WHERE 1=0
*/
query.append(FEDERATED_SELECT);
query.append(FEDERATED_STAR);
query.append(FEDERATED_FROM);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("SELECT * FROM `"));
escaped_table_name_length=
escape_string_for_mysql(&my_charset_bin, (char*)escaped_table_name,
sizeof(escaped_table_name),
share->table_name,
share->table_name_length);
query.append(escaped_table_name, escaped_table_name_length);
query.append(FEDERATED_BTICK);
query.append(FEDERATED_WHERE);
query.append(FEDERATED_FALSE);
query.append(STRING_WITH_LEN("` WHERE 1=0"));
if (mysql_real_query(mysql, query.ptr(), query.length()))
{
......@@ -801,9 +802,9 @@ uint ha_federated::convert_row_to_internal_format(byte *record,
static bool emit_key_part_name(String *to, KEY_PART_INFO *part)
{
DBUG_ENTER("emit_key_part_name");
if (to->append(FEDERATED_BTICK) ||
if (to->append(STRING_WITH_LEN("`")) ||
to->append(part->field->field_name) ||
to->append(FEDERATED_BTICK))
to->append(STRING_WITH_LEN("`")))
DBUG_RETURN(1); // Out of memory
DBUG_RETURN(0);
}
......@@ -815,7 +816,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
Field *field= part->field;
DBUG_ENTER("emit_key_part_element");
if (needs_quotes && to->append(FEDERATED_SQUOTE))
if (needs_quotes && to->append(STRING_WITH_LEN("'")))
DBUG_RETURN(1);
if (part->type == HA_KEYTYPE_BIT)
......@@ -862,10 +863,10 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
DBUG_RETURN(1);
}
if (is_like && to->append(FEDERATED_PERCENT))
if (is_like && to->append(STRING_WITH_LEN("%")))
DBUG_RETURN(1);
if (needs_quotes && to->append(FEDERATED_SQUOTE))
if (needs_quotes && to->append(STRING_WITH_LEN("'")))
DBUG_RETURN(1);
DBUG_RETURN(0);
......@@ -1141,9 +1142,9 @@ bool ha_federated::create_where_from_key(String *to,
if (both_not_null)
{
if (i > 0)
tmp.append(FEDERATED_CONJUNCTION);
tmp.append(STRING_WITH_LEN(") AND ("));
else
tmp.append(FEDERATED_OPENPAREN);
tmp.append(STRING_WITH_LEN(" ("));
}
for (key_part= key_info->key_part,
......@@ -1164,13 +1165,13 @@ bool ha_federated::create_where_from_key(String *to,
if (*ptr++)
{
if (emit_key_part_name(&tmp, key_part) ||
tmp.append(FEDERATED_ISNULL))
tmp.append(STRING_WITH_LEN(" IS NULL ")))
goto err;
continue;
}
}
if (tmp.append(FEDERATED_OPENPAREN))
if (tmp.append(STRING_WITH_LEN(" (")))
goto err;
switch (ranges[i]->flag) {
......@@ -1186,12 +1187,12 @@ bool ha_federated::create_where_from_key(String *to,
if (records_in_range)
{
if (tmp.append(FEDERATED_GE))
if (tmp.append(STRING_WITH_LEN(" >= ")))
goto err;
}
else
{
if (tmp.append(FEDERATED_EQ))
if (tmp.append(STRING_WITH_LEN(" = ")))
goto err;
}
......@@ -1203,7 +1204,7 @@ bool ha_federated::create_where_from_key(String *to,
{
/* LIKE */
if (emit_key_part_name(&tmp, key_part) ||
tmp.append(FEDERATED_LIKE) ||
tmp.append(STRING_WITH_LEN(" LIKE ")) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 1, ptr,
part_length))
goto err;
......@@ -1224,12 +1225,12 @@ bool ha_federated::create_where_from_key(String *to,
if (i > 0) /* end key */
{
if (tmp.append(FEDERATED_LE))
if (tmp.append(STRING_WITH_LEN(" <= ")))
goto err;
}
else /* start key */
{
if (tmp.append(FEDERATED_GT))
if (tmp.append(STRING_WITH_LEN(" > ")))
goto err;
}
......@@ -1243,7 +1244,7 @@ bool ha_federated::create_where_from_key(String *to,
case HA_READ_KEY_OR_NEXT:
DBUG_PRINT("info", ("federated HA_READ_KEY_OR_NEXT %d", i));
if (emit_key_part_name(&tmp, key_part) ||
tmp.append(FEDERATED_GE) ||
tmp.append(STRING_WITH_LEN(" >= ")) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
......@@ -1253,7 +1254,7 @@ bool ha_federated::create_where_from_key(String *to,
if (store_length >= length)
{
if (emit_key_part_name(&tmp, key_part) ||
tmp.append(FEDERATED_LT) ||
tmp.append(STRING_WITH_LEN(" < ")) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
......@@ -1262,7 +1263,7 @@ bool ha_federated::create_where_from_key(String *to,
case HA_READ_KEY_OR_PREV:
DBUG_PRINT("info", ("federated HA_READ_KEY_OR_PREV %d", i));
if (emit_key_part_name(&tmp, key_part) ||
tmp.append(FEDERATED_LE) ||
tmp.append(STRING_WITH_LEN(" <= ")) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
......@@ -1271,7 +1272,7 @@ bool ha_federated::create_where_from_key(String *to,
DBUG_PRINT("info",("cannot handle flag %d", ranges[i]->flag));
goto err;
}
if (tmp.append(FEDERATED_CLOSEPAREN))
if (tmp.append(STRING_WITH_LEN(") ")))
goto err;
next_loop:
......@@ -1281,7 +1282,7 @@ bool ha_federated::create_where_from_key(String *to,
DBUG_ASSERT(remainder > 1);
length-= store_length;
ptr+= store_length;
if (tmp.append(FEDERATED_AND))
if (tmp.append(STRING_WITH_LEN(" AND ")))
goto err;
DBUG_PRINT("info",
......@@ -1292,10 +1293,10 @@ bool ha_federated::create_where_from_key(String *to,
dbug_tmp_restore_column_map(table->write_set, old_map);
if (both_not_null)
if (tmp.append(FEDERATED_CLOSEPAREN))
if (tmp.append(STRING_WITH_LEN(") ")))
DBUG_RETURN(1);
if (to->append(FEDERATED_WHERE))
if (to->append(STRING_WITH_LEN(" WHERE ")))
DBUG_RETURN(1);
if (to->append(tmp))
......@@ -1339,17 +1340,17 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
connect_string_length)))
{
query.set_charset(system_charset_info);
query.append(FEDERATED_SELECT);
query.append(STRING_WITH_LEN("SELECT "));
for (field= table->field; *field; field++)
{
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("`"));
query.append((*field)->field_name);
query.append(FEDERATED_BTICK);
query.append(FEDERATED_COMMA);
query.append(STRING_WITH_LEN("`, "));
}
query.length(query.length()- FEDERATED_COMMA_LEN);
query.append(FEDERATED_FROM);
query.append(FEDERATED_BTICK);
/* chops off trailing comma */
query.length(query.length() - sizeof_trailing_comma);
query.append(STRING_WITH_LEN(" FROM `"));
if (!(share= (FEDERATED_SHARE *)
my_multi_malloc(MYF(MY_WME),
......@@ -1364,7 +1365,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
share->table_name_length= strlen(share->table_name);
/* TODO: share->table_name to LEX_STRING object */
query.append(share->table_name, share->table_name_length);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("`"));
share->select_query= select_query;
strmov(share->select_query, query.ptr());
share->use_count= 0;
......@@ -1608,14 +1609,11 @@ int ha_federated::write_row(byte *buf)
/*
start both our field and field values strings
*/
insert_string.append(FEDERATED_INSERT);
insert_string.append(FEDERATED_BTICK);
insert_string.append(STRING_WITH_LEN("INSERT `"));
insert_string.append(share->table_name, share->table_name_length);
insert_string.append(FEDERATED_BTICK);
insert_string.append(FEDERATED_OPENPAREN);
insert_string.append(STRING_WITH_LEN("` ("));
values_string.append(FEDERATED_VALUES);
values_string.append(FEDERATED_OPENPAREN);
values_string.append(STRING_WITH_LEN(" VALUES ("));
/*
loop through the field pointer array, add any fields to both the values
......@@ -1636,7 +1634,7 @@ int ha_federated::write_row(byte *buf)
has_fields= TRUE;
if ((*field)->is_null())
insert_field_value_string.append(FEDERATED_NULL);
insert_field_value_string.append(STRING_WITH_LEN(" NULL "));
else
{
(*field)->val_str(&insert_field_value_string);
......@@ -1656,8 +1654,8 @@ int ha_federated::write_row(byte *buf)
make the following appends conditional as we don't know if the
next field is in the write set
*/
insert_string.append(FEDERATED_COMMA);
values_string.append(FEDERATED_COMMA);
insert_string.append(STRING_WITH_LEN(", "));
values_string.append(STRING_WITH_LEN(", "));
}
}
dbug_tmp_restore_column_map(table->read_set, old_map);
......@@ -1669,16 +1667,18 @@ int ha_federated::write_row(byte *buf)
*/
if (has_fields)
{
/* chops off leading commas */
insert_string.length(insert_string.length() - FEDERATED_COMMA_LEN);
values_string.length(values_string.length() - FEDERATED_COMMA_LEN);
insert_string.append(FEDERATED_CLOSEPAREN);
/* chops off trailing commas */
insert_string.length(insert_string.length() - sizeof_trailing_comma);
values_string.length(values_string.length() - sizeof_trailing_comma);
insert_string.append(STRING_WITH_LEN(") "));
}
else
insert_string.length(insert_string.length() - FEDERATED_CLOSEPAREN_LEN);
{
/* chops off trailing ) */
insert_string.length(insert_string.length() - sizeof_trailing_closeparen);
}
/* we always want to append this, even if there aren't any fields */
values_string.append(FEDERATED_CLOSEPAREN);
values_string.append(STRING_WITH_LEN(") "));
/* add the values */
insert_string.append(values_string);
......@@ -1726,10 +1726,9 @@ int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt)
query.length(0);
query.set_charset(system_charset_info);
query.append(FEDERATED_OPTIMIZE);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("OPTIMIZE TABLE `"));
query.append(share->table_name, share->table_name_length);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("`"));
if (mysql_real_query(mysql, query.ptr(), query.length()))
{
......@@ -1749,16 +1748,15 @@ int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt)
query.length(0);
query.set_charset(system_charset_info);
query.append(FEDERATED_REPAIR);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("REPAIR TABLE `"));
query.append(share->table_name, share->table_name_length);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("`"));
if (check_opt->flags & T_QUICK)
query.append(FEDERATED_QUICK);
query.append(STRING_WITH_LEN(" QUICK"));
if (check_opt->flags & T_EXTEND)
query.append(FEDERATED_EXTENDED);
query.append(STRING_WITH_LEN(" EXTENDED"));
if (check_opt->sql_flags & TT_USEFRM)
query.append(FEDERATED_USE_FRM);
query.append(STRING_WITH_LEN(" USE_FRM"));
if (mysql_real_query(mysql, query.ptr(), query.length()))
{
......@@ -1827,11 +1825,9 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
update_string.length(0);
where_string.length(0);
update_string.append(FEDERATED_UPDATE);
update_string.append(FEDERATED_BTICK);
update_string.append(STRING_WITH_LEN("UPDATE `"));
update_string.append(share->table_name);
update_string.append(FEDERATED_BTICK);
update_string.append(FEDERATED_SET);
update_string.append(STRING_WITH_LEN("` SET "));
/*
In this loop, we want to match column names to values being inserted
......@@ -1848,10 +1844,10 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
update_string.append((*field)->field_name);
update_string.append(FEDERATED_EQ);
update_string.append(STRING_WITH_LEN("="));
if ((*field)->is_null())
update_string.append(FEDERATED_NULL);
update_string.append(STRING_WITH_LEN(" NULL "));
else
{
my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
......@@ -1862,33 +1858,34 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
field_value.length(0);
tmp_restore_column_map(table->read_set, old_map);
}
update_string.append(FEDERATED_COMMA);
update_string.append(STRING_WITH_LEN(", "));
}
if (bitmap_is_set(table->read_set, (*field)->field_index))
{
where_string.append((*field)->field_name);
if (field_in_record_is_null(table, *field, (char*) old_data))
where_string.append(FEDERATED_ISNULL);
where_string.append(STRING_WITH_LEN(" IS NULL "));
else
{
where_string.append(FEDERATED_EQ);
where_string.append(STRING_WITH_LEN(" = "));
(*field)->val_str(&field_value,
(char*) (old_data + (*field)->offset()));
(*field)->quote_data(&field_value);
where_string.append(field_value);
field_value.length(0);
}
where_string.append(FEDERATED_AND);
where_string.append(STRING_WITH_LEN(" AND "));
}
}
/* Remove last ', '. This works as there must be at least on updated field */
update_string.length(update_string.length() - FEDERATED_COMMA_LEN);
update_string.length(update_string.length() - sizeof_trailing_comma);
if (where_string.length())
{
where_string.length(where_string.length() - FEDERATED_AND_LEN);
update_string.append(FEDERATED_WHERE);
/* chop off trailing AND */
where_string.length(where_string.length() - sizeof_trailing_and);
update_string.append(STRING_WITH_LEN(" WHERE "));
update_string.append(where_string);
}
......@@ -1897,7 +1894,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
update multiple rows. We want to make sure to only update one!
*/
if (!has_a_primary_key)
update_string.append(FEDERATED_LIMIT1);
update_string.append(STRING_WITH_LEN(" LIMIT 1"));
if (mysql_real_query(mysql, update_string.ptr(), update_string.length()))
{
......@@ -1931,12 +1928,9 @@ int ha_federated::delete_row(const byte *buf)
DBUG_ENTER("ha_federated::delete_row");
delete_string.length(0);
delete_string.append(FEDERATED_DELETE);
delete_string.append(FEDERATED_FROM);
delete_string.append(FEDERATED_BTICK);
delete_string.append(STRING_WITH_LEN("DELETE FROM `"));
delete_string.append(share->table_name);
delete_string.append(FEDERATED_BTICK);
delete_string.append(FEDERATED_WHERE);
delete_string.append(STRING_WITH_LEN("` WHERE "));
for (Field **field= table->field; *field; field++)
{
......@@ -1948,26 +1942,25 @@ int ha_federated::delete_row(const byte *buf)
delete_string.append(cur_field->field_name);
if (cur_field->is_null())
{
delete_string.append(FEDERATED_IS);
delete_string.append(FEDERATED_NULL);
delete_string.append(STRING_WITH_LEN(" IS NULL "));
}
else
{
delete_string.append(FEDERATED_EQ);
delete_string.append(STRING_WITH_LEN(" = "));
cur_field->val_str(&data_string);
cur_field->quote_data(&data_string);
delete_string.append(data_string);
}
delete_string.append(FEDERATED_AND);
delete_string.append(STRING_WITH_LEN(" AND "));
}
}
// Remove trailing AND
delete_string.length(delete_string.length() - FEDERATED_AND_LEN);
// Remove trailing AND
delete_string.length(delete_string.length() - sizeof_trailing_and);
if (!found)
delete_string.length(delete_string.length() - FEDERATED_WHERE_LEN);
delete_string.length(delete_string.length() - sizeof_trailing_where);
delete_string.append(FEDERATED_LIMIT1);
delete_string.append(STRING_WITH_LEN(" LIMIT 1"));
DBUG_PRINT("info",
("Delete sql: %s", delete_string.c_ptr_quick()));
if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length()))
......@@ -2463,15 +2456,13 @@ void ha_federated::info(uint flag)
if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST))
{
status_query_string.length(0);
status_query_string.append(FEDERATED_INFO);
status_query_string.append(FEDERATED_SQUOTE);
status_query_string.append(STRING_WITH_LEN("SHOW TABLE STATUS LIKE '"));
escape_string_for_mysql(&my_charset_bin, (char *)escaped_table_name,
sizeof(escaped_table_name),
share->table_name,
share->table_name_length);
status_query_string.append(escaped_table_name);
status_query_string.append(FEDERATED_SQUOTE);
status_query_string.append(STRING_WITH_LEN("'"));
if (mysql_real_query(mysql, status_query_string.ptr(),
status_query_string.length()))
......@@ -2563,10 +2554,9 @@ int ha_federated::delete_all_rows()
query.length(0);
query.set_charset(system_charset_info);
query.append(FEDERATED_TRUNCATE);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("TRUNCATE `"));
query.append(share->table_name);
query.append(FEDERATED_BTICK);
query.append(STRING_WITH_LEN("`"));
/*
TRUNCATE won't return anything in mysql_affected_rows
......
......@@ -38,85 +38,6 @@
#define FEDERATED_QUERY_BUFFER_SIZE STRING_BUFFER_USUAL_SIZE * 5
#define FEDERATED_RECORDS_IN_RANGE 2
#define FEDERATED_INFO " SHOW TABLE STATUS LIKE "
#define FEDERATED_INFO_LEN (sizeof(FEDERATED_INFO) -1)
#define FEDERATED_SELECT "SELECT "
#define FEDERATED_SELECT_LEN (sizeof(FEDERATED_SELECT) -1)
#define FEDERATED_WHERE " WHERE "
#define FEDERATED_WHERE_LEN (sizeof(FEDERATED_WHERE) -1)
#define FEDERATED_FROM " FROM "
#define FEDERATED_FROM_LEN (sizeof(FEDERATED_FROM) -1)
#define FEDERATED_PERCENT "%"
#define FEDERATED_PERCENT_LEN (sizeof(FEDERATED_PERCENT) -1)
#define FEDERATED_IS " IS "
#define FEDERATED_IS_LEN (sizeof(FEDERATED_IS) -1)
#define FEDERATED_NULL " NULL "
#define FEDERATED_NULL_LEN (sizeof(FEDERATED_NULL) -1)
#define FEDERATED_ISNULL " IS NULL "
#define FEDERATED_ISNULL_LEN (sizeof(FEDERATED_ISNULL) -1)
#define FEDERATED_LIKE " LIKE "
#define FEDERATED_LIKE_LEN (sizeof(FEDERATED_LIKE) -1)
#define FEDERATED_TRUNCATE "TRUNCATE "
#define FEDERATED_TRUNCATE_LEN (sizeof(FEDERATED_TRUNCATE) -1)
#define FEDERATED_DELETE "DELETE "
#define FEDERATED_DELETE_LEN (sizeof(FEDERATED_DELETE) -1)
#define FEDERATED_INSERT "INSERT INTO "
#define FEDERATED_INSERT_LEN (sizeof(FEDERATED_INSERT) -1)
#define FEDERATED_OPTIMIZE "OPTIMIZE TABLE "
#define FEDERATED_OPTIMIZE_LEN (sizeof(FEDERATED_OPTIMIZE) -1)
#define FEDERATED_REPAIR "REPAIR TABLE "
#define FEDERATED_REPAIR_LEN (sizeof(FEDERATED_REPAIR) -1)
#define FEDERATED_QUICK " QUICK"
#define FEDERATED_QUICK_LEN (sizeof(FEDERATED_QUICK) -1)
#define FEDERATED_EXTENDED " EXTENDED"
#define FEDERATED_EXTENDED_LEN (sizeof(FEDERATED_EXTENDED) -1)
#define FEDERATED_USE_FRM " USE_FRM"
#define FEDERATED_USE_FRM_LEN (sizeof(FEDERATED_USE_FRM) -1)
#define FEDERATED_LIMIT1 " LIMIT 1"
#define FEDERATED_LIMIT1_LEN (sizeof(FEDERATED_LIMIT1) -1)
#define FEDERATED_VALUES "VALUES "
#define FEDERATED_VALUES_LEN (sizeof(FEDERATED_VALUES) -1)
#define FEDERATED_UPDATE "UPDATE "
#define FEDERATED_UPDATE_LEN (sizeof(FEDERATED_UPDATE) -1)
#define FEDERATED_SET " SET "
#define FEDERATED_SET_LEN (sizeof(FEDERATED_SET) -1)
#define FEDERATED_AND " AND "
#define FEDERATED_AND_LEN (sizeof(FEDERATED_AND) -1)
#define FEDERATED_CONJUNCTION ") AND ("
#define FEDERATED_CONJUNCTION_LEN (sizeof(FEDERATED_CONJUNCTION) -1)
#define FEDERATED_OR " OR "
#define FEDERATED_OR_LEN (sizeof(FEDERATED_OR) -1)
#define FEDERATED_NOT " NOT "
#define FEDERATED_NOT_LEN (sizeof(FEDERATED_NOT) -1)
#define FEDERATED_STAR "* "
#define FEDERATED_STAR_LEN (sizeof(FEDERATED_STAR) -1)
#define FEDERATED_SPACE " "
#define FEDERATED_SPACE_LEN (sizeof(FEDERATED_SPACE) -1)
#define FEDERATED_SQUOTE "'"
#define FEDERATED_SQUOTE_LEN (sizeof(FEDERATED_SQUOTE) -1)
#define FEDERATED_COMMA ", "
#define FEDERATED_COMMA_LEN (sizeof(FEDERATED_COMMA) -1)
#define FEDERATED_BTICK "`"
#define FEDERATED_BTICK_LEN (sizeof(FEDERATED_BTICK) -1)
#define FEDERATED_OPENPAREN " ("
#define FEDERATED_OPENPAREN_LEN (sizeof(FEDERATED_OPENPAREN) -1)
#define FEDERATED_CLOSEPAREN ") "
#define FEDERATED_CLOSEPAREN_LEN (sizeof(FEDERATED_CLOSEPAREN) -1)
#define FEDERATED_NE " != "
#define FEDERATED_NE_LEN (sizeof(FEDERATED_NE) -1)
#define FEDERATED_GT " > "
#define FEDERATED_GT_LEN (sizeof(FEDERATED_GT) -1)
#define FEDERATED_LT " < "
#define FEDERATED_LT_LEN (sizeof(FEDERATED_LT) -1)
#define FEDERATED_LE " <= "
#define FEDERATED_LE_LEN (sizeof(FEDERATED_LE) -1)
#define FEDERATED_GE " >= "
#define FEDERATED_GE_LEN (sizeof(FEDERATED_GE) -1)
#define FEDERATED_EQ " = "
#define FEDERATED_EQ_LEN (sizeof(FEDERATED_EQ) -1)
#define FEDERATED_FALSE " 1=0"
#define FEDERATED_FALSE_LEN (sizeof(FEDERATED_FALSE) -1)
/*
FEDERATED_SHARE is a structure that will be shared amoung all open handlers
The example implements the minimum of what you will probably need.
......
......@@ -551,7 +551,7 @@ bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
static int myisammrg_init()
{
myisammrg_hton.state=SHOW_OPTION_YES;
myisammrg_hton.state=have_merge_db;
myisammrg_hton.db_type=DB_TYPE_MRG_MYISAM;
myisammrg_hton.create=myisammrg_create_handler;
myisammrg_hton.panic=myrg_panic;
......
......@@ -1669,6 +1669,10 @@ extern handlerton partition_hton;
extern SHOW_COMP_OPTION have_partition_db;
#endif
extern handlerton myisammrg_hton;
/* MRG_MYISAM handler is always built, but may be skipped */
#define have_merge_db myisammrg_hton.state
extern handlerton myisam_hton;
extern handlerton myisammrg_hton;
extern handlerton heap_hton;
......
......@@ -310,7 +310,7 @@ static bool lower_case_table_names_used= 0;
static bool volatile select_thread_in_use, signal_thread_in_use;
static bool volatile ready_to_exit;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_bdb, opt_isam, opt_ndbcluster;
static my_bool opt_bdb, opt_isam, opt_ndbcluster, opt_merge;
static my_bool opt_short_log_format= 0;
static uint kill_cached_threads, wake_thread;
static ulong killed_threads, thread_created;
......@@ -4838,7 +4838,8 @@ enum options_mysqld
OPT_LOG_OUTPUT,
OPT_PORT_OPEN_TIMEOUT,
OPT_GENERAL_LOG,
OPT_SLOW_LOG
OPT_SLOW_LOG,
OPT_MERGE
};
......@@ -5346,6 +5347,9 @@ master-ssl",
#endif /* HAVE_REPLICATION */
{"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory,
(gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"merge", OPT_MERGE, "Enable Merge storage engine. Disable with \
--skip-merge.",
(gptr*) &opt_merge, (gptr*) &opt_merge, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0},
{"myisam-recover", OPT_MYISAM_RECOVER,
"Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.",
(gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
......@@ -7556,6 +7560,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
global_system_variables.tx_isolation= (type-1);
break;
}
case OPT_MERGE:
if (opt_merge)
have_merge_db= SHOW_OPTION_YES;
else
have_merge_db= SHOW_OPTION_DISABLED;
#ifdef WITH_BERKELEY_STORAGE_ENGINE
case OPT_BDB_NOSYNC:
/* Deprecated option */
......
......@@ -681,6 +681,7 @@ sys_var_have_variable sys_have_federated_db("have_federated_engine",
&have_federated_db);
sys_var_have_variable sys_have_geometry("have_geometry", &have_geometry);
sys_var_have_variable sys_have_innodb("have_innodb", &have_innodb);
sys_var_have_variable sys_have_merge_db("have_merge", &have_merge_db);
sys_var_have_variable sys_have_ndbcluster("have_ndbcluster", &have_ndbcluster);
sys_var_have_variable sys_have_openssl("have_openssl", &have_openssl);
sys_var_have_variable sys_have_partition_db("have_partitioning",
......@@ -821,6 +822,7 @@ SHOW_VAR init_vars[]= {
{sys_have_federated_db.name,(char*) &have_federated_db, SHOW_HAVE},
{sys_have_geometry.name, (char*) &have_geometry, SHOW_HAVE},
{sys_have_innodb.name, (char*) &have_innodb, SHOW_HAVE},
{sys_have_merge_db.name, (char*) &have_merge_db, SHOW_HAVE},
{sys_have_ndbcluster.name, (char*) &have_ndbcluster, SHOW_HAVE},
{sys_have_openssl.name, (char*) &have_openssl, SHOW_HAVE},
{sys_have_partition_db.name,(char*) &have_partition_db, SHOW_HAVE},
......
......@@ -810,11 +810,18 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
bool insert_into_view= (table_list->view != 0);
DBUG_ENTER("mysql_prepare_insert_check_table");
/*
first table in list is the one we'll INSERT into, requires INSERT_ACL.
all others require SELECT_ACL only. the ACL requirement below is for
new leaves only anyway (view-constituents), so check for SELECT rather
than INSERT.
*/
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list,
&thd->lex->select_lex.leaf_tables,
select_insert, INSERT_ACL))
select_insert, SELECT_ACL))
DBUG_RETURN(TRUE);
if (insert_into_view && !fields.elements)
......
......@@ -86,7 +86,8 @@ int main(int argc,char *argv[])
init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0);
if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED|HA_OPEN_FROM_SQL_LAYER)))
if (!(info=mi_open(argv[0], O_RDONLY,
HA_OPEN_ABORT_IF_LOCKED|HA_OPEN_FROM_SQL_LAYER)))
{
error=my_errno;
goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment