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.
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.
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
16
package GenTest::Transform::ConvertLiteralsToDyncols;
19
@ISA = qw(GenTest GenTest::Transform);
24
use GenTest::Transform;
25
use GenTest::Constants;
30
my ($class, $orig_query, $executor) = @_;
33
# We skip LIMIT queries because LIMIT N can not be converted into LIMIT COLUMN_GET( COLUMN_CREATE () )
34
return STATUS_WONT_HANDLE if $orig_query =~ m{LIMIT}sio;
36
my @transformed_queries;
39
my $new_integer_query_const = $orig_query;
42
$new_integer_query_const =~ s{\s+(\d+)}{
43
push @integer_literals, $1;
44
" COLUMN_GET(COLUMN_CREATE( $1 , $1 AS INTEGER ) , $1 AS INTEGER ) ";
47
if ($new_integer_query_const ne $orig_query) {
48
push @transformed_queries, [
49
$new_integer_query_const." /* TRANSFORM_OUTCOME_UNORDERED_MATCH */ "
55
my $new_string_query_const = $orig_query;
58
$new_string_query_const =~ s{\s+'(.+?)'}{
59
" COLUMN_GET(COLUMN_CREATE( 1 , '$1' AS CHAR), 1 AS CHAR ) ";
62
if ($new_string_query_const ne $orig_query) {
63
push @transformed_queries, [
64
$new_string_query_const." /* TRANSFORM_OUTCOME_UNORDERED_MATCH */ "
69
if ($#transformed_queries > -1) {
70
return \@transformed_queries;
72
return STATUS_WONT_HANDLE;