mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
merge from 5.1-mtr
This commit is contained in:
commit
64e189c37c
8 changed files with 149 additions and 36 deletions
|
@ -103,6 +103,7 @@ static my_bool parsing_disabled= 0;
|
|||
static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
|
||||
display_metadata= FALSE, display_result_sorted= FALSE;
|
||||
static my_bool disable_query_log= 0, disable_result_log= 0;
|
||||
static my_bool disable_connect_log= 1;
|
||||
static my_bool disable_warnings= 0;
|
||||
static my_bool disable_info= 1;
|
||||
static my_bool abort_on_error= 1;
|
||||
|
@ -242,7 +243,9 @@ struct st_connection
|
|||
int cur_query_len;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
pthread_t tid;
|
||||
int query_done;
|
||||
my_bool has_thread;
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
};
|
||||
|
||||
|
@ -273,6 +276,7 @@ enum enum_commands {
|
|||
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
|
||||
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
|
||||
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
|
||||
Q_ENABLE_CONNECT_LOG, Q_DISABLE_CONNECT_LOG,
|
||||
Q_WAIT_FOR_SLAVE_TO_STOP,
|
||||
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
|
||||
Q_ENABLE_INFO, Q_DISABLE_INFO,
|
||||
|
@ -340,6 +344,8 @@ const char *command_names[]=
|
|||
/* Enable/disable that the _result_ from a query is logged to result file */
|
||||
"enable_result_log",
|
||||
"disable_result_log",
|
||||
"enable_connect_log",
|
||||
"disable_connect_log",
|
||||
"wait_for_slave_to_stop",
|
||||
"enable_warnings",
|
||||
"disable_warnings",
|
||||
|
@ -733,8 +739,6 @@ pthread_handler_t send_one_query(void *arg)
|
|||
static int do_send_query(struct st_connection *cn, const char *q, int q_len,
|
||||
int flags)
|
||||
{
|
||||
pthread_t tid;
|
||||
|
||||
if (flags & QUERY_REAP_FLAG)
|
||||
return mysql_send_query(&cn->mysql, q, q_len);
|
||||
|
||||
|
@ -745,9 +749,10 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
|
|||
cn->cur_query= q;
|
||||
cn->cur_query_len= q_len;
|
||||
cn->query_done= 0;
|
||||
if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
|
||||
if (pthread_create(&cn->tid, &cn_thd_attrib, send_one_query, (void*)cn))
|
||||
die("Cannot start new thread for query");
|
||||
|
||||
cn->has_thread= TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -760,6 +765,14 @@ static void wait_query_thread_end(struct st_connection *con)
|
|||
pthread_cond_wait(&con->cond, &con->mutex);
|
||||
pthread_mutex_unlock(&con->mutex);
|
||||
}
|
||||
if (con->has_thread)
|
||||
{
|
||||
#ifndef __WIN__
|
||||
/* May hang on Windows, but the problem it solves is not seen there */
|
||||
pthread_join(con->tid, NULL);
|
||||
#endif
|
||||
con->has_thread= FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#else /*EMBEDDED_LIBRARY*/
|
||||
|
@ -2175,8 +2188,14 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
|
|||
DBUG_ENTER("var_query_set");
|
||||
LINT_INIT(res);
|
||||
|
||||
/* Only white space or ) allowed past ending ` */
|
||||
while (end > query && *end != '`')
|
||||
{
|
||||
if (*end && (*end != ' ' && *end != '\t' && *end != '\n' && *end != ')'))
|
||||
die("Spurious text after `query` expression");
|
||||
--end;
|
||||
}
|
||||
|
||||
if (query == end)
|
||||
die("Syntax error in query, missing '`'");
|
||||
++query;
|
||||
|
@ -3834,7 +3853,18 @@ void do_perl(struct st_command *command)
|
|||
if (!error)
|
||||
my_delete(temp_file_path, MYF(0));
|
||||
|
||||
handle_command_error(command, WEXITSTATUS(error));
|
||||
/* Check for error code that indicates perl could not be started */
|
||||
int exstat= WEXITSTATUS(error);
|
||||
#ifdef __WIN__
|
||||
if (exstat == 1)
|
||||
/* Text must begin 'perl not found' as mtr looks for it */
|
||||
abort_not_supported_test("perl not found in path or did not start");
|
||||
#else
|
||||
if (exstat == 127)
|
||||
abort_not_supported_test("perl not found in path");
|
||||
#endif
|
||||
else
|
||||
handle_command_error(command, exstat);
|
||||
}
|
||||
dynstr_free(&ds_delimiter);
|
||||
DBUG_VOID_RETURN;
|
||||
|
@ -4778,6 +4808,16 @@ void select_connection_name(const char *name)
|
|||
|
||||
set_current_connection(con);
|
||||
|
||||
/* Connection logging if enabled */
|
||||
if (!disable_connect_log && !disable_query_log)
|
||||
{
|
||||
DYNAMIC_STRING *ds= &ds_res;
|
||||
|
||||
dynstr_append_mem(ds, "connection ", 11);
|
||||
replace_dynstr_append(ds, name);
|
||||
dynstr_append_mem(ds, ";\n", 2);
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -4865,6 +4905,16 @@ void do_close_connection(struct st_command *command)
|
|||
var_set_string("$CURRENT_CONNECTION", con->name);
|
||||
}
|
||||
|
||||
/* Connection logging if enabled */
|
||||
if (!disable_connect_log && !disable_query_log)
|
||||
{
|
||||
DYNAMIC_STRING *ds= &ds_res;
|
||||
|
||||
dynstr_append_mem(ds, "disconnect ", 11);
|
||||
replace_dynstr_append(ds, ds_connection.str);
|
||||
dynstr_append_mem(ds, ";\n", 2);
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -4999,6 +5049,13 @@ int connect_n_handle_errors(struct st_command *command,
|
|||
dynstr_append_mem(ds, delimiter, delimiter_length);
|
||||
dynstr_append_mem(ds, "\n", 1);
|
||||
}
|
||||
/* Simlified logging if enabled */
|
||||
if (!disable_connect_log && !disable_query_log)
|
||||
{
|
||||
replace_dynstr_append(ds, command->query);
|
||||
dynstr_append_mem(ds, ";\n", 2);
|
||||
}
|
||||
|
||||
while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
|
||||
CLIENT_MULTI_STATEMENTS))
|
||||
{
|
||||
|
@ -5187,6 +5244,7 @@ void do_connect(struct st_command *command)
|
|||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
con_slot->query_done= 1;
|
||||
con_slot->has_thread= FALSE;
|
||||
#endif
|
||||
if (!mysql_init(&con_slot->mysql))
|
||||
die("Failed on mysql_init()");
|
||||
|
@ -7307,11 +7365,13 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
|||
(flags & QUERY_REAP_FLAG));
|
||||
DBUG_ENTER("run_query");
|
||||
|
||||
init_dynamic_string(&ds_warnings, NULL, 0, 256);
|
||||
|
||||
if (cn->pending && (flags & QUERY_SEND_FLAG))
|
||||
die ("Cannot run query on connection between send and reap");
|
||||
|
||||
if (!(flags & QUERY_SEND_FLAG) && !cn->pending)
|
||||
die ("Cannot reap on a connection without pending send");
|
||||
|
||||
init_dynamic_string(&ds_warnings, NULL, 0, 256);
|
||||
/*
|
||||
Evaluate query if this is an eval command
|
||||
*/
|
||||
|
@ -8052,6 +8112,8 @@ int main(int argc, char **argv)
|
|||
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_INFO: disable_info=0; break;
|
||||
|
|
|
@ -72,7 +72,7 @@ copy_file $fake_relay_log $_fake_relay_log;
|
|||
|
||||
if (`SELECT LENGTH(@@secure_file_priv) > 0`)
|
||||
{
|
||||
-- let $_file_priv_dir= `SELECT @@secure_file_priv`;
|
||||
-- let $_file_priv_dir= `SELECT @@secure_file_priv`
|
||||
-- let $_suffix= `SELECT UUID()`
|
||||
-- let $_tmp_file= $_file_priv_dir/fake-index.$_suffix
|
||||
|
||||
|
|
|
@ -110,12 +110,24 @@ my $path_vardir_trace; # unix formatted opt_vardir for trace files
|
|||
my $opt_tmpdir; # Path to use for tmp/ dir
|
||||
my $opt_tmpdir_pid;
|
||||
|
||||
my $opt_start;
|
||||
my $opt_start_dirty;
|
||||
my $opt_start_exit;
|
||||
my $start_only;
|
||||
|
||||
END {
|
||||
if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
|
||||
{
|
||||
# Remove the tempdir this process has created
|
||||
mtr_verbose("Removing tmpdir '$opt_tmpdir");
|
||||
rmtree($opt_tmpdir);
|
||||
if (!$opt_start_exit)
|
||||
{
|
||||
# Remove the tempdir this process has created
|
||||
mtr_verbose("Removing tmpdir $opt_tmpdir");
|
||||
rmtree($opt_tmpdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
mtr_warning("tmpdir $opt_tmpdir should be removed after the server has finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,10 +227,6 @@ my $opt_start_timeout = $ENV{MTR_START_TIMEOUT} || 180; # seconds
|
|||
sub suite_timeout { return $opt_suite_timeout * 60; };
|
||||
sub check_timeout { return $opt_testcase_timeout * 6; };
|
||||
|
||||
my $opt_start;
|
||||
my $opt_start_dirty;
|
||||
my $opt_start_exit;
|
||||
my $start_only;
|
||||
my $opt_wait_all;
|
||||
my $opt_user_args;
|
||||
my $opt_repeat= 1;
|
||||
|
@ -2099,6 +2107,11 @@ sub environment_setup {
|
|||
# to detect that valgrind is being used from test cases
|
||||
$ENV{'VALGRIND_TEST'}= $opt_valgrind;
|
||||
|
||||
# Add dir of this perl to aid mysqltest in finding perl
|
||||
my $perldir= dirname($^X);
|
||||
my $pathsep= ":";
|
||||
$pathsep= ";" if IS_WINDOWS && ! IS_CYGWIN;
|
||||
$ENV{'PATH'}= "$ENV{'PATH'}".$pathsep.$perldir;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3575,6 +3588,9 @@ sub run_testcase ($) {
|
|||
# Try to get reason from test log file
|
||||
find_testcase_skipped_reason($tinfo);
|
||||
mtr_report_test_skipped($tinfo);
|
||||
# Restart if skipped due to missing perl, it may have had side effects
|
||||
stop_all_servers($opt_shutdown_timeout)
|
||||
if ($tinfo->{'comment'} =~ /^perl not found/);
|
||||
}
|
||||
elsif ( $res == 65 )
|
||||
{
|
||||
|
|
|
@ -177,6 +177,9 @@ mysqltest: At line 1: End of line junk detected: "disconnect default # comment
|
|||
"
|
||||
mysqltest: At line 1: Extra delimiter ";" found
|
||||
mysqltest: At line 1: Extra delimiter ";" found
|
||||
mysqltest: At line 1: Spurious text after `query` expression
|
||||
mysqltest: At line 1: Spurious text after `query` expression
|
||||
mysqltest: At line 2: Spurious text after `query` expression
|
||||
mysqltest: At line 1: Missing argument(s) to 'error'
|
||||
mysqltest: At line 1: Missing argument(s) to 'error'
|
||||
mysqltest: At line 1: The sqlstate definition must start with an uppercase S
|
||||
|
@ -449,12 +452,16 @@ mysqltest: At line 1: Missing required argument 'host' to command 'connect'
|
|||
mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: 1049: Unknown database 'illegal_db'
|
||||
mysqltest: At line 1: Illegal argument for port: 'illegal_port'
|
||||
mysqltest: At line 1: Illegal option to connect: SMTP
|
||||
OK
|
||||
mysqltest: The test didn't produce any output
|
||||
200 connects succeeded
|
||||
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
|
||||
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
|
||||
show tables;
|
||||
ERROR 3D000: No database selected
|
||||
connect con1,localhost,root,,;
|
||||
connection default;
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
Output from mysqltest-x.inc
|
||||
Output from mysqltest-x.inc
|
||||
Output from mysqltest-x.inc
|
||||
|
|
|
@ -34,8 +34,8 @@ INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
|
|||
--echo
|
||||
--echo # Select a less restrictive isolation level.
|
||||
# Don't use user variables. They won't survive server crash.
|
||||
--let $global_isolation= `SELECT @@global.tx_isolation`;
|
||||
--let $session_isolation= `SELECT @@session.tx_isolation`;
|
||||
--let $global_isolation= `SELECT @@global.tx_isolation`
|
||||
--let $session_isolation= `SELECT @@session.tx_isolation`
|
||||
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
COMMIT;
|
||||
|
|
|
@ -205,7 +205,7 @@ DROP TABLE `t1`;
|
|||
|
||||
-- echo === Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail.
|
||||
|
||||
-- let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
||||
-- let $MYSQLD_DATADIR= `SELECT @@datadir`
|
||||
-- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
|
||||
-- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
|
||||
|
||||
|
@ -330,7 +330,7 @@ while($ntables)
|
|||
-- echo ### assertion: check that binlog is not corrupt. Using mysqlbinlog to
|
||||
-- echo ### detect failure. Before the patch mysqlbinlog would find
|
||||
-- echo ### a corrupted event, thence would fail.
|
||||
-- let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
||||
-- let $MYSQLD_DATADIR= `SELECT @@datadir`
|
||||
-- exec $MYSQL_BINLOG -v --hex $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog
|
||||
|
||||
## clean up
|
||||
|
|
|
@ -9,7 +9,7 @@ SHOW VARIABLES LIKE 'secure_file_priv';
|
|||
# Doing this in a portable manner is difficult but we should be able to
|
||||
# count on the depth of the directory hierarchy used. Three steps up from
|
||||
# the datadir is the 'mysql_test' directory.
|
||||
--let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`;
|
||||
--let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`
|
||||
--eval SELECT * FROM t1 INTO OUTFILE '$PROTECTED_FILE';
|
||||
DELETE FROM t1;
|
||||
--eval LOAD DATA INFILE '$PROTECTED_FILE' INTO TABLE t1;
|
||||
|
|
|
@ -494,6 +494,32 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|||
--error 1
|
||||
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
|
||||
|
||||
#
|
||||
# Extra text after ``
|
||||
#
|
||||
# Cannot use exec echo here as ` may or may not need to be escaped
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
||||
let $x= `select 1` BOO ;
|
||||
EOF
|
||||
--error 1
|
||||
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
||||
--let $x= `select 1`;
|
||||
EOF
|
||||
--error 1
|
||||
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
||||
# Missing ; in next line should be detected and cause failure
|
||||
let $x= `select 1`
|
||||
let $x= 2;
|
||||
echo $x;
|
||||
EOF
|
||||
--error 1
|
||||
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
||||
|
||||
|
||||
# Allow trailing # comment
|
||||
--sleep 1 # Wait for insert delayed to be executed.
|
||||
|
@ -1439,19 +1465,6 @@ eval select "$long_rep" as x;
|
|||
--error 1
|
||||
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1
|
||||
|
||||
# Repeat connect/disconnect
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
||||
let $i=100;
|
||||
while ($i)
|
||||
{
|
||||
connect (test_con1,localhost,root,,);
|
||||
disconnect test_con1;
|
||||
dec $i;
|
||||
}
|
||||
EOF
|
||||
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
||||
|
||||
# Repeat connect/disconnect
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
||||
let $i=200;
|
||||
|
@ -1461,9 +1474,8 @@ while ($i)
|
|||
disconnect test_con1;
|
||||
dec $i;
|
||||
}
|
||||
echo 200 connects succeeded;
|
||||
EOF
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--error 1
|
||||
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
||||
|
||||
|
@ -1504,6 +1516,22 @@ show tables;
|
|||
disconnect con2;
|
||||
connection default;
|
||||
|
||||
# Test enable_connect_log
|
||||
--enable_connect_log
|
||||
connect (con1,localhost,root,,);
|
||||
connection default;
|
||||
connection con1;
|
||||
--disable_query_log
|
||||
# These should not be logged
|
||||
connect (con2,localhost,root,,*NO-ONE*);
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
connection con1;
|
||||
--enable_query_log
|
||||
disconnect con1;
|
||||
connection default;
|
||||
--disable_connect_log
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Test mysqltest arguments
|
||||
# ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue