~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/lib/GenTest/Executor/Dummy.pm

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.
 
2
# Use is subject to license terms.
 
3
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
# USA
 
17
 
 
18
package GenTest::Executor::Dummy;
 
19
 
 
20
require Exporter;
 
21
 
 
22
@ISA = qw(GenTest::Executor);
 
23
 
 
24
use strict;
 
25
use DBI;
 
26
use GenTest;
 
27
use GenTest::Constants;
 
28
use GenTest::Result;
 
29
use GenTest::Executor;
 
30
use GenTest::Translator;
 
31
use GenTest::Translator::MysqlDML2ANSI;
 
32
use GenTest::Translator::Mysqldump2ANSI;
 
33
use GenTest::Translator::MysqlDML2javadb;
 
34
use GenTest::Translator::Mysqldump2javadb;
 
35
use GenTest::Translator::MysqlDML2pgsql;
 
36
use GenTest::Translator::Mysqldump2pgsql;
 
37
 
 
38
 
 
39
use Data::Dumper;
 
40
 
 
41
 
 
42
sub init {
 
43
        my $executor = shift;
 
44
 
 
45
    ## Just to have somthing that is not undefined
 
46
        $executor->setDbh($executor); 
 
47
 
 
48
    $executor->defaultSchema("schema");
 
49
 
 
50
        return STATUS_OK;
 
51
}
 
52
 
 
53
sub execute {
 
54
        my ($self, $query, $silent) = @_;
 
55
 
 
56
    $query = $self->preprocess($query);
 
57
 
 
58
    ## This may be generalized into a translator which is a pipe
 
59
 
 
60
    my @pipe;
 
61
    if ($self->dsn() =~ m/javadb/) {
 
62
        @pipe = (GenTest::Translator::Mysqldump2javadb->new(),
 
63
                 GenTest::Translator::MysqlDML2javadb->new());
 
64
 
 
65
    } elsif ($self->dsn() =~ m/postgres/) {
 
66
 
 
67
        @pipe = (GenTest::Translator::Mysqldump2pgsql->new(),
 
68
                 GenTest::Translator::MysqlDML2pgsql->new());
 
69
 
 
70
    }
 
71
    foreach my $p (@pipe) {
 
72
        $query = $p->translate($query);
 
73
        return GenTest::Result->new( 
 
74
            query => $query, 
 
75
            status => STATUS_WONT_HANDLE ) 
 
76
            if not $query;
 
77
        
 
78
    }
 
79
 
 
80
    if ($ENV{RQG_DEBUG} or $self->dsn() =~ m/print/) {
 
81
        print "Executing $query;\n";
 
82
    }
 
83
 
 
84
        return new GenTest::Result(query => $query,
 
85
                               status => STATUS_OK);
 
86
}
 
87
 
 
88
 
 
89
sub version {
 
90
        my ($self) = @_;
 
91
        return "Version N/A"; # Not implemented in DBD::JDBC
 
92
}
 
93
 
 
94
sub currentSchema {
 
95
    my ($self,$schema) = @_;
 
96
    return $self->defaultSchema();
 
97
}
 
98
 
 
99
sub getSchemaMetaData {
 
100
    return [['schema','tab','table','col1','ordinary'],
 
101
            ['schema','tab','table','col2','primary'],
 
102
            ['schema','tab','table','col3','indexed'],
 
103
            ['test','tab','table','col1','ordinary'],
 
104
            ['test','tab','table','col2','primary'],
 
105
            ['test','tab','table','col3','indexed'],
 
106
            ['mysql','tab','table','col','indexed'],
 
107
            ['performance_schema','tab','table','col','indexed'],
 
108
            ['INFORMATION_SCHEMA','tab','table','col','indexed']];
 
109
            
 
110
}
 
111
 
 
112
sub getCollationMetaData {
 
113
    return [['collation','charset']];
 
114
}
 
115
 
 
116
sub disconnect {
 
117
    my ($self) = @_;
 
118
    $self->setDbh(undef);
 
119
}
 
120
 
 
121
1;