~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/randgen/translateMysql.pl

  • Committer: patrick crews
  • Date: 2011-10-05 20:40:33 UTC
  • mfrom: (2337.1.24 dbqp_revamp2)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: gleebix@gmail.com-20111005204033-5m6kvcii1q87yur6
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.  Use
 
2
# 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
#!/usr/bin/perl
 
19
 
 
20
use lib 'lib';
 
21
use lib "$ENV{RQG_HOME}/lib";
 
22
use strict;
 
23
use GenTest;
 
24
use GenTest::Translator;
 
25
use GenTest::Translator::MysqlDML2ANSI;
 
26
use GenTest::Translator::MysqlDML2pgsql;
 
27
use GenTest::Translator::MysqlDML2javadb;
 
28
use GenTest::Translator::Mysqldump2ANSI;
 
29
use GenTest::Translator::Mysqldump2pgsql;
 
30
use GenTest::Translator::Mysqldump2javadb;
 
31
 
 
32
use Getopt::Long;
 
33
 
 
34
my $from = "unspecified";
 
35
my $to = "ansi";
 
36
 
 
37
my $opt_result = GetOptions(
 
38
    'from=s' => $from,
 
39
    'to=s' => \$to
 
40
    );
 
41
 
 
42
$from =~ tr/A-Z/a-z/;
 
43
$to =~ tr/A-Z/a-z/;
 
44
 
 
45
my $translator1;
 
46
my $translator2;
 
47
if ($to eq "ansi") {
 
48
    $translator1 = GenTest::Translator::Mysqldump2ANSI->new();
 
49
    $translator2 = GenTest::Translator::MysqlDML2ANSI->new();
 
50
} elsif ($to eq "javadb" || $to eq "derby") {
 
51
    $translator1 = GenTest::Translator::Mysqldump2javadb->new();
 
52
    $translator2 = GenTest::Translator::MysqlDML2javadb->new();
 
53
} elsif ($to eq "postgres" || $to eq "pg" || $to eq "postgresql" || $to eq "pgsql") {
 
54
    $translator1 = GenTest::Translator::Mysqldump2pgsql->new();
 
55
    $translator2 = GenTest::Translator::MysqlDML2pgsql->new();
 
56
} else {
 
57
    die "Unknown target \"$to\", use \"ansi\", \"javadb\" or \"postgresql\"";
 
58
}
 
59
 
 
60
my $file;
 
61
while(<>) {
 
62
    $file .= $_;
 
63
}
 
64
 
 
65
my $result;
 
66
 
 
67
if ($from eq "unspecified") {
 
68
    $result = $translator1->translate($file);
 
69
    $result = $translator2->translate($result);
 
70
} elsif ($from eq "mysqldump") {
 
71
    $result = $translator1->translate($file);
 
72
} elsif ($from eq "dml") {
 
73
    $result = $translator2->translate($file);
 
74
} else {
 
75
    die "Unknown source \"$from\", if specified, use \"mysqldump\" or \"dml\"";
 
76
}
 
77
 
 
78
print $result;
 
79
 
 
80