9
use GenTest::Constants;
10
use GenTest::Executor::MySQL;
11
use GenTest::Simplifier::Test;
12
use GenTest::Simplifier::SQL;
13
use GenTest::Comparator;
16
# This script demonstrates the simplification of queries. More information is available at
18
# http://forge.mysql.com/wiki/RandomQueryGeneratorSimplification
21
my $query = "SELECT 1 FROM DUAL";
23
my @desired_outcomes = (
24
STATUS_CONTENT_MISMATCH,
25
STATUS_LENGTH_MISMATCH
29
'dbi:mysql:host=127.0.0.1:port=19306:user=root:database=test',
30
'dbi:mysql:host=127.0.0.1:port=19308:user=root:database=test'
33
# End of user-editable part
37
foreach my $dsn (@dsns) {
38
my $executor = GenTest::Executor::MySQL->new( dsn => $dsn );
39
my $init_status = $executor->init();
40
exit ($init_status) if $init_status != STATUS_OK;
41
push @executors, $executor;
44
my $simplifier = GenTest::Simplifier::SQL->new(
46
my $oracle_query = shift;
52
foreach my $executor (@executors) {
53
my $oracle_result = $executor->execute($oracle_query, 1);
54
push @oracle_results, $oracle_result;
57
if ($#executors == 0) {
58
$outcome = $oracle_results[0]->status();
60
$outcome = GenTest::Comparator::compare($oracle_results[0], $oracle_results[1]);
63
foreach my $desired_outcome (@desired_outcomes) {
64
return ORACLE_ISSUE_STILL_REPEATABLE if $outcome == $desired_outcome;
67
return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
71
my $simplified_query = $simplifier->simplify($query);
73
print "\nSimplified query:\n$simplified_query ;\n\n";
75
my @simplified_results;
77
foreach my $executor (@executors) {
78
my $simplified_result = $executor->execute($simplified_query);
79
push @simplified_results, $simplified_result;
83
my $simplifier_test = GenTest::Simplifier::Test->new(
84
executors => \@executors,
85
queries => [ $simplified_query, $query ],
86
results => [ \@simplified_results ]
89
my $test = $simplifier_test->simplify();
91
print "Simplified test:\n\n";