1
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23
use GenTest::Constants;
24
use GenTest::Executor::MySQL;
25
use GenTest::Simplifier::SQL;
26
use GenTest::Simplifier::Test;
29
# Please modify those settings to fit your environment before you run this script
32
my $basedir = '/home/philips/bzr/maria-5.3-mwl128/';
33
my $vardir = $basedir.'/mysql-test/var';
34
my $dsn = 'dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test';
36
my $original_query = "
40
# Maximum number of seconds a query will be allowed to proceed. It is assumed that most crashes will happen immediately after takeoff
44
# '--mysqld=--innodb',
45
'--mysqld=--log-output=file', # Prevents excessively long CSV recovery on each startup
49
"--master_port=19300",
51
'--mysqld=--loose-core-file-size=1',
53
'--mysqld=--key_buffer_size=16K',
54
'--mysqld=--table_open_cache=4',
55
'--mysqld=--sort_buffer_size=64K',
56
'--mysqld=--read_buffer_size=256K',
57
'--mysqld=--read_rnd_buffer_size=256K',
58
'--mysqld=--thread_stack=240K',
59
'--mysqld=--loose-innodb_buffer_pool_size=16M',
60
'--mysqld=--loose-innodb_additional_mem_pool_size=2M',
61
'--mysqld=--innodb_log_file_size=5M',
62
'--mysqld=--innodb_log_buffer_size=8M',
63
'--mysqld=--innodb_flush_log_at_trx_commit=2',
64
'1st' # Required for proper operation of MTR --start-and-exit
67
my $orig_database = 'test';
68
my $new_database = 'crash';
74
my $simplifier = GenTest::Simplifier::SQL->new(
76
my $oracle_query = shift;
77
my $dbh = $executor->dbh();
79
my $connection_id = $dbh->selectrow_array("SELECT CONNECTION_ID()");
80
$dbh->do("CREATE EVENT timeout ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL $timeout SECOND DO KILL QUERY $connection_id");
82
$executor->execute($oracle_query);
84
# Or, alternatively, execute as a prepared statement
85
# $executor->execute("PREPARE prep_stmt FROM \"$oracle_query\"");
86
# $executor->execute("EXECUTE prep_stmt");
87
# $executor->execute("EXECUTE prep_stmt");
88
# $executor->execute("DEALLOCATE PREPARE prep_stmt");
90
$dbh->do("DROP EVENT IF EXISTS timeout");
92
if (!$executor->dbh()->ping()) {
94
return ORACLE_ISSUE_STILL_REPEATABLE;
96
return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
101
my $simplified_query = $simplifier->simplify($original_query);
102
print "Simplified query:\n$simplified_query;\n\n";
104
my $simplifier_test = GenTest::Simplifier::Test->new(
105
executors => [ $executor ],
106
queries => [ $simplified_query , $original_query ]
109
my $simplified_test = $simplifier_test->simplify();
111
print "Simplified test\n\n";
112
print $simplified_test;
115
chdir($basedir.'/mysql-test') or die "Unable to chdir() to $basedir/mysql-test: $!";
117
$executor = GenTest::Executor::MySQL->new( dsn => $dsn );
118
$executor->init() if defined $executor;
120
if ((not defined $executor) || (not defined $executor->dbh()) || (!$executor->dbh()->ping())) {
121
system("MTR_VERSION=1 perl mysql-test-run.pl ".join(" ", @mtr_options));
122
$executor = GenTest::Executor::MySQL->new( dsn => $dsn );
126
$executor->dbh()->do("SET GLOBAL EVENT_SCHEDULER = ON");