~drizzle-trunk/drizzle/development

0.67.305 by Bernt M. Johnsen
Copyright headres and license added
1
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
3
#
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.
7
#
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.
12
#
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
16
# USA
17
0.67.9 by Philip Stoev
merge from internal tree
18
use strict;
19
use lib 'lib';
20
use lib '../lib';
21
use DBI;
22
23
use GenTest::Constants;
24
use GenTest::Executor::MySQL;
25
use GenTest::Simplifier::SQL;
26
use GenTest::Simplifier::Test;
27
28
#
29
# Please modify those settings to fit your environment before you run this script
30
#
31
0.67.439 by Philip Stoev
some cleanup in util/simplify-crash.pl
32
my $basedir = '/build/bzr/mysql-6.0-codebase-bugfixing';
33
my $vardir = $basedir.'/mysql-test/var';
0.67.9 by Philip Stoev
merge from internal tree
34
my $dsn = 'dbi:mysql:host=127.0.0.1:port=19306:user=root:database=test';
0.67.439 by Philip Stoev
some cleanup in util/simplify-crash.pl
35
36
my $original_query = ' 
37
	SELECT 1 FROM DUAL
38
';
39
0.67.154 by Philip Stoev
timeouts for util/simplify-crash.pl
40
# Maximum number of seconds a query will be allowed to proceed. It is assumed that most crashes will happen immediately after takeoff
0.67.496 by eve
improvements and speedups to the simplify-crash script
41
my $timeout = 10;
0.67.9 by Philip Stoev
merge from internal tree
42
43
my @mtr_options = (
0.67.439 by Philip Stoev
some cleanup in util/simplify-crash.pl
44
#	'--mysqld=--innodb',
0.67.496 by eve
improvements and speedups to the simplify-crash script
45
	'--mysqld=--log-output=file',	# Prevents excessively long CSV recovery on each startup
0.67.9 by Philip Stoev
merge from internal tree
46
	'--start-and-exit',
47
	'--start-dirty',
48
	"--vardir=$vardir",
49
	"--master_port=19306",
50
	'--skip-ndbcluster',
0.67.514 by eve
better defaults for the simplify-crash.pl script
51
	'--mysqld=--loose-core-file-size=1',
0.67.466 by eve
speed up util/simplify-crash.pl by not dumping intermediate cores and using MTR --fast
52
	'--fast',
0.67.9 by Philip Stoev
merge from internal tree
53
	'1st'	# Required for proper operation of MTR --start-and-exit
54
);
55
56
my $orig_database = 'test';
57
my $new_database = 'crash';
58
59
my $executor;
0.67.466 by eve
speed up util/simplify-crash.pl by not dumping intermediate cores and using MTR --fast
60
0.67.9 by Philip Stoev
merge from internal tree
61
start_server();
62
63
my $simplifier = GenTest::Simplifier::SQL->new(
64
	oracle => sub {
65
		my $oracle_query = shift;
0.67.154 by Philip Stoev
timeouts for util/simplify-crash.pl
66
		my $dbh = $executor->dbh();
67
	
68
		my $connection_id = $dbh->selectrow_array("SELECT CONNECTION_ID()");
69
		$dbh->do("CREATE EVENT timeout ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL $timeout SECOND DO KILL QUERY $connection_id");
70
0.67.496 by eve
improvements and speedups to the simplify-crash script
71
		$executor->execute($oracle_query);
72
73
		# Or, alternatively, execute as a prepared statement
0.67.514 by eve
better defaults for the simplify-crash.pl script
74
		# $executor->execute("PREPARE prep_stmt FROM \"$oracle_query\"");
75
		# $executor->execute("EXECUTE prep_stmt");
76
		# $executor->execute("EXECUTE prep_stmt");
77
		# $executor->execute("DEALLOCATE PREPARE prep_stmt");
0.67.154 by Philip Stoev
timeouts for util/simplify-crash.pl
78
79
		$dbh->do("DROP EVENT IF EXISTS timeout");
80
81
		if (!$executor->dbh()->ping()) {
0.67.9 by Philip Stoev
merge from internal tree
82
			start_server();
83
			return ORACLE_ISSUE_STILL_REPEATABLE;
84
		} else {
85
			return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
86
		}
87
	}
88
);
89
90
my $simplified_query = $simplifier->simplify($original_query);
91
print "Simplified query:\n$simplified_query;\n\n";
92
93
my $simplifier_test = GenTest::Simplifier::Test->new(
94
	executors => [ $executor ],
95
	queries => [ $simplified_query , $original_query ]
96
);
97
98
my $simplified_test = $simplifier_test->simplify();
99
100
print "Simplified test\n\n";
101
print $simplified_test;
102
103
sub start_server {
104
	chdir($basedir.'/mysql-test') or die $!;
105
	system("MTR_VERSION=1 perl mysql-test-run.pl ".join(" ", @mtr_options));
106
107
	$executor = GenTest::Executor::MySQL->new( dsn => $dsn );
108
109
	$executor->init();
0.67.154 by Philip Stoev
timeouts for util/simplify-crash.pl
110
111
	my $dbh = $executor->dbh();
112
113
	$dbh->do("SET GLOBAL EVENT_SCHEDULER = ON");
0.67.9 by Philip Stoev
merge from internal tree
114
}