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

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/lib/GenTest/Validator/DML.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::Validator::DML;
18
 
 
19
 
require Exporter;
20
 
@ISA = qw(GenTest::Validator GenTest);
21
 
 
22
 
use strict;
23
 
 
24
 
use GenTest;
25
 
use GenTest::Comparator;
26
 
use GenTest::Constants;
27
 
use GenTest::Result;
28
 
use GenTest::Validator;
29
 
use Time::HiRes;
30
 
 
31
 
my $matched_rows_count = 0;
32
 
 
33
 
sub validate {
34
 
        my ($validator, $executors, $results) = @_;
35
 
        my $executor = $executors->[0];
36
 
        my $dbh = $executor->dbh();
37
 
        my $orig_result = $results->[0];
38
 
        my $orig_query = $orig_result->query();
39
 
 
40
 
        return STATUS_WONT_HANDLE if $orig_query !~ m{INSERT|UPDATE|DELETE}sio;
41
 
        return STATUS_WONT_HANDLE if $orig_result->status() != STATUS_OK;
42
 
 
43
 
        $dbh->do("ROLLBACK");
44
 
        my $join_cache_level = $dbh->selectrow_array('SELECT @@join_cache_level');
45
 
        my $optimizer_switch = $dbh->selectrow_array('SELECT @@optimizer_switch');
46
 
        my $optimizer_use_mrr = $dbh->selectrow_array('SELECT @@optimizer_use_mrr');
47
 
 
48
 
        $dbh->do("SET SESSION join_cache_level = 0");
49
 
        $dbh->do("SET SESSION optimizer_switch = 'index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=off,index_condition_pushdown=off,firstmatch=off,loosescan=off,materialization=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr_sort_keys=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,table_elimination=off'");
50
 
        $dbh->do("SET SESSION optimizer_use_mrr = 'disable'");
51
 
 
52
 
        $dbh->do("START TRANSACTION");
53
 
        my $oracle_result = $executor->execute($orig_query);
54
 
        $dbh->do("ROLLBACK");
55
 
 
56
 
        $dbh->do("SET SESSION join_cache_level = $join_cache_level");
57
 
        $dbh->do("SET SESSION optimizer_switch = '$optimizer_switch'");
58
 
        $dbh->do("SET SESSION optimizer_use_mrr = '$optimizer_use_mrr'");
59
 
 
60
 
        $matched_rows_count = $matched_rows_count + $oracle_result->matchedRows();
61
 
 
62
 
        if ($orig_result->status() != $oracle_result->status()) {
63
 
                say("Query: $orig_query; had a different STATUS when executed without optimizations ('".$orig_result->errstr()."' vs. '".$oracle_result->errstr()."').");
64
 
                return STATUS_ERROR_MISMATCH;
65
 
        } elsif (int($orig_result->affectedRows()) != int($oracle_result->affectedRows())) {
66
 
                say("Query: $orig_query; affected a different number of rows when run with no optimizations (".$orig_result->affectedRows()." vs. ".$oracle_result->affectedRows().").");
67
 
                return STATUS_LENGTH_MISMATCH;
68
 
        } elsif ($orig_result->matchedRows() != $oracle_result->matchedRows()) {
69
 
                say("Query: $orig_query; matched a different number of rows when run with no optimizations (".$orig_result->matchedRows()." vs. ".$oracle_result->matchedRows().").");
70
 
                return STATUS_LENGTH_MISMATCH;
71
 
        } elsif ($orig_result->changedRows() != $oracle_result->changedRows()) {
72
 
                say("Query: $orig_query; changed a different number of rows when run with no optimizations (".$orig_result->changedRows()." vs. ".$oracle_result->changedRows().").");
73
 
                return STATUS_LENGTH_MISMATCH;
74
 
        } else {
75
 
                return STATUS_OK;
76
 
        }
77
 
}
78
 
 
79
 
sub DESTROY {
80
 
        say("Total matched_rows reported by the DML statements: $matched_rows_count.");
81
 
}
82
 
 
83
 
1;