2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; version 2 of the License.
6
# This program is distributed in the hope that it will be useful, but
7
# WITHOUT ANY WARRANTY; without even the implied warranty of
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9
# General Public License for more details.
11
# You should have received a copy of the GNU General Public License
12
# along with this program; if not, write to the Free Software
13
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
17
package GenTest::SimPipe::Oracle::FullScan;
20
@ISA = qw(GenTest::SimPipe::Oracle GenTest);
26
use GenTest::SimPipe::Oracle;
27
use GenTest::Constants;
28
use GenTest::Executor;
29
use GenTest::Comparator;
35
my %option_defaults = (
36
'optimizer_use_mrr' => 'disable',
37
'mrr_buffer_size' => 262144,
38
'join_cache_level' => 0,
39
'join_buffer_size' => 131072,
40
'join_buffer_space_limit' => 1048576,
41
'rowid_merge_buff_size' => 8388608,
42
'storage_engine' => 'MyISAM',
43
'optimizer_switch' => 'index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=off,table_elimination=off,in_to_exists=off'
48
my ($oracle, $testcase) = @_;
50
my $executor = GenTest::Executor->newFromDSN($oracle->dsn());
53
my $dbh = $executor->dbh();
55
foreach my $option_name (keys %option_defaults) {
56
if ($option_defaults{$option_name} =~ m{^\d+$}sio) {
57
$dbh->do("SET SESSION $option_name = ".$option_defaults{$option_name});
59
$dbh->do("SET SESSION $option_name = '".$option_defaults{$option_name}."'");
63
my $testcase_string = join("\n", (
64
"DROP DATABASE IF EXISTS fullscan$$;",
65
"CREATE DATABASE IF NOT EXISTS fullscan$$;",
67
$testcase->mysqldOptionsToString(),
68
$testcase->dbObjectsToString()
71
if ($#{$testcase->queries()} > 0) {
72
$testcase_string .= "\n".join(";\n", @{$testcase->queries()}[0..$#{$testcase->queries()}-1]).";\n";
75
open (LD, '>/tmp/last_dump.test');
76
print LD $testcase_string;
79
$dbh->do($testcase_string, { RaiseError => 1 , mysql_multi_statements => 1 });
81
my $original_query = $testcase->queries()->[$#{$testcase->queries()}];
82
my $original_result = $executor->execute($original_query);
84
# print Dumper $original_result;
85
my $original_explain = $executor->execute("EXPLAIN ".$original_query);
86
# print Dumper $original_explain;
88
$testcase_string .= "\n$original_query;\n";
90
my @table_names = @{$dbh->selectcol_arrayref("SHOW TABLES")};
91
foreach my $table_name (@table_names) {
92
$dbh->do("ALTER TABLE $table_name DISABLE KEYS");
95
$dbh->do("SET SESSION join_cache_level = 0");
96
$dbh->do("SET SESSION optimizer_use_mrr = 'disable'");
97
$dbh->do("SET SESSION optimizer_switch='".$option_defaults{'optimizer_switch'}."'");
99
my $no_hints_query = $original_query;
100
$no_hints_query =~ s{(FORCE|IGNORE|USE)\s+KEY\s*\(.*?\)}{}sio;
102
my $fullscan_result = $executor->execute($no_hints_query);
104
# $dbh->do("DROP DATABASE fullscan$$");
106
my $compare_outcome = GenTest::Comparator::compare($original_result, $fullscan_result);
107
print "Compare outcome is: ".$compare_outcome."\n";
110
($original_result->status() != STATUS_OK) ||
111
($fullscan_result->status() != STATUS_OK) ||
112
($compare_outcome == STATUS_OK)
114
open (LR, '>/tmp/last_not_repeatable.test');
115
print LR $testcase_string;
117
return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
119
# print Dumper $original_result;
120
# print Dumper $fullscan_result;
121
open (LR, '>/tmp/last_repeatable.test');
122
print LR $testcase_string;
124
return ORACLE_ISSUE_STILL_REPEATABLE;