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
18
package GenTest::Validator::ExplainMatch;
21
@ISA = qw(GenTest::Validator GenTest);
26
use GenTest::Constants;
28
use GenTest::Validator;
29
use GenTest::Simplifier::Test;
32
my $match_string = 'unique row not found';
37
my ($validator, $executors, $results) = @_;
39
my $executor = $executors->[0];
40
my $query = $results->[0]->query();
42
return STATUS_WONT_HANDLE if $query !~ m{^\s*SELECT}sio;
44
my $explain_output = $executor->dbh()->selectall_arrayref("EXPLAIN $query");
46
my $explain_string = Dumper $explain_output;
48
if ($explain_string =~ m{$match_string}sio) {
49
say("EXPLAIN $query matches $match_string");
50
my $simplifier_test = GenTest::Simplifier::Test->new(
51
executors => [ $executor ],
52
queries => [ $query , "EXPLAIN $query" ]
54
my $simplified_test = $simplifier_test->simplify();
55
say("Simplified test:");
56
print $simplified_test;
57
return STATUS_CUSTOM_OUTCOME;