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

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/lib/GenTest/Transform/InlineVirtualColumns.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2012-04-04 15:12:07 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120404151207-xwsgn1xegslle4p0
Tags: 1:7.1.32-rc-1
* New upstream release.
* Plugin-filtered-replicator upstream removed and will no longer be built.
* Updating d/*install files to accommodate upstream changes from drizzle7
  to drizzle
* Added symlink in libdrizzledmessage-dev to library
* libdrizzle: soname-bump
* Rename package drizzle-plugin-performance-dictionary to shorten package name
  (due to linitan warning package-has-long-file-name)
* Debian/control: removed unused substitution variable ${shlibs:Depends} for
  -dbg and -dev packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008, 2011 Oracle and/or its affiliates. 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::Transform::InlineVirtualColumns;
 
19
 
 
20
require Exporter;
 
21
@ISA = qw(GenTest GenTest::Transform);
 
22
 
 
23
use strict;
 
24
use lib 'lib';
 
25
use GenTest;
 
26
use GenTest::Transform;
 
27
use GenTest::Constants;
 
28
 
 
29
my $global_inlines = 0;
 
30
 
 
31
sub transform {
 
32
        my ($class, $query, $executor) = @_;
 
33
 
 
34
        return STATUS_WONT_HANDLE if $query !~ m{\s*SELECT}sio;
 
35
 
 
36
        my %virtual_columns;
 
37
 
 
38
        my $dbh = $executor->dbh();
 
39
        my ($table_name) = $query =~ m{FROM (.*?)[ ^]}sio;
 
40
 
 
41
        my ($foo, $table_create) = $dbh->selectrow_array("SHOW CREATE TABLE $table_name");
 
42
 
 
43
        foreach my $create_row (split("\n", $table_create)) {
 
44
                next if $create_row !~ m{ VIRTUAL}sio;
 
45
                my ($column_name, $column_def) = $create_row =~ m{`(.*)` [^ ]*? AS (.*) VIRTUAL}sio;
 
46
                $virtual_columns{$column_name} = $column_def;
 
47
        }
 
48
 
 
49
        foreach my $virtual_column (keys %virtual_columns) {
 
50
                my $inlines = $query =~ s{$virtual_column}{$virtual_columns{$virtual_column}}sgi;
 
51
                $global_inlines = $global_inlines + $inlines;
 
52
        }
 
53
 
 
54
        return $query." /* TRANSFORM_OUTCOME_UNORDERED_MATCH */";
 
55
}
 
56
 
 
57
DESTROY {
 
58
        say("[Statistics]: InlineVirtualColumns Transformer inlined $global_inlines expressions") if rqg_debug();
 
59
}
 
60
 
 
61
1;