1
package GenTest::Validator::ExplainMatch;
4
@ISA = qw(GenTest::Validator GenTest);
9
use GenTest::Constants;
11
use GenTest::Validator;
12
use GenTest::Simplifier::Test;
15
my $match_string = 'unique row not found';
20
my ($validator, $executors, $results) = @_;
22
my $executor = $executors->[0];
23
my $query = $results->[0]->query();
25
return STATUS_WONT_HANDLE if $query !~ m{^\s*SELECT}sio;
27
my $explain_output = $executor->dbh()->selectall_arrayref("EXPLAIN $query");
29
my $explain_string = Dumper $explain_output;
31
if ($explain_string =~ m{$match_string}sio) {
32
say("EXPLAIN $query matches $match_string");
33
my $simplifier_test = GenTest::Simplifier::Test->new(
34
executors => [ $executor ],
35
queries => [ $query , "EXPLAIN $query" ]
37
my $simplified_test = $simplifier_test->simplify();
38
say("Simplified test:");
39
print $simplified_test;
40
return STATUS_CUSTOM_OUTCOME;