~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/lib/GenTest/SimPipe/Oracle/FullScan.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
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.
5
 
#
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.
10
 
#
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
14
 
# USA
15
 
#
16
 
 
17
 
package GenTest::SimPipe::Oracle::FullScan;
18
 
 
19
 
require Exporter;
20
 
@ISA = qw(GenTest::SimPipe::Oracle GenTest);
21
 
@EXPORT = qw();
22
 
 
23
 
use strict;
24
 
use DBI;
25
 
use GenTest;
26
 
use GenTest::SimPipe::Oracle;
27
 
use GenTest::Constants;
28
 
use GenTest::Executor;
29
 
use GenTest::Comparator;
30
 
 
31
 
use Data::Dumper;
32
 
 
33
 
1;
34
 
 
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'
44
 
);
45
 
 
46
 
 
47
 
sub oracle {
48
 
        my ($oracle, $testcase) = @_;
49
 
 
50
 
        my $executor = GenTest::Executor->newFromDSN($oracle->dsn());
51
 
        $executor->init();
52
 
        
53
 
        my $dbh = $executor->dbh();
54
 
 
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});
58
 
                } else {
59
 
                        $dbh->do("SET SESSION $option_name = '".$option_defaults{$option_name}."'");
60
 
                }
61
 
        }
62
 
 
63
 
        my $testcase_string = join("\n", (
64
 
                "DROP DATABASE IF EXISTS fullscan$$;",
65
 
                "CREATE DATABASE IF NOT EXISTS fullscan$$;",
66
 
                "USE fullscan$$;",
67
 
                $testcase->mysqldOptionsToString(),
68
 
                $testcase->dbObjectsToString()
69
 
        ));
70
 
 
71
 
        if ($#{$testcase->queries()} > 0) {
72
 
                $testcase_string .= "\n".join(";\n", @{$testcase->queries()}[0..$#{$testcase->queries()}-1]).";\n";
73
 
        }
74
 
 
75
 
        open (LD, '>/tmp/last_dump.test');
76
 
        print LD $testcase_string;
77
 
        close LD;
78
 
 
79
 
        $dbh->do($testcase_string, { RaiseError => 1 , mysql_multi_statements => 1 });
80
 
 
81
 
        my $original_query = $testcase->queries()->[$#{$testcase->queries()}];
82
 
        my $original_result = $executor->execute($original_query);
83
 
 
84
 
#       print Dumper $original_result;
85
 
        my $original_explain = $executor->execute("EXPLAIN ".$original_query);
86
 
#       print Dumper $original_explain;
87
 
 
88
 
        $testcase_string .= "\n$original_query;\n";
89
 
 
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");
93
 
        }
94
 
 
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'}."'");
98
 
 
99
 
        my $no_hints_query = $original_query;
100
 
        $no_hints_query =~ s{(FORCE|IGNORE|USE)\s+KEY\s*\(.*?\)}{}sio;
101
 
 
102
 
        my $fullscan_result = $executor->execute($no_hints_query);
103
 
 
104
 
#       $dbh->do("DROP DATABASE fullscan$$");
105
 
 
106
 
        my $compare_outcome = GenTest::Comparator::compare($original_result, $fullscan_result);
107
 
        print "Compare outcome is: ".$compare_outcome."\n";
108
 
 
109
 
        if (
110
 
                ($original_result->status() != STATUS_OK) ||
111
 
                ($fullscan_result->status() != STATUS_OK) ||
112
 
                ($compare_outcome == STATUS_OK)
113
 
        ) {
114
 
                open (LR, '>/tmp/last_not_repeatable.test');
115
 
                print LR $testcase_string;
116
 
                close LR;
117
 
                return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
118
 
        } else {
119
 
#               print Dumper $original_result;
120
 
#               print Dumper $fullscan_result;
121
 
                open (LR, '>/tmp/last_repeatable.test');
122
 
                print LR $testcase_string;
123
 
                close LR;
124
 
                return ORACLE_ISSUE_STILL_REPEATABLE;
125
 
        }       
126
 
}
127
 
 
128
 
1;