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

1.1.7 by Tobias Frost
Import upstream version 7.2.3
1
# This program is free software; you can redistribute it and/or modify
2
# it under the terms of the GNU General Public License as published by
3
# the Free Software Foundation; version 2 of the License.
4
#
5
# This program is distributed in the hope that it will be useful, but
6
# WITHOUT ANY WARRANTY; without even the implied warranty of
7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8
# General Public License for more details.
9
#
10
# You should have received a copy of the GNU General Public License
11
# along with this program; if not, write to the Free Software
12
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
13
# USA
14
15
package GenTest::Transform::ExecuteAsUnion;
16
17
require Exporter;
18
@ISA = qw(GenTest GenTest::Transform);
19
20
use strict;
21
use lib 'lib';
22
23
use GenTest;
24
use GenTest::Transform;
25
use GenTest::Constants;
26
27
sub transform {
28
	my ($class, $original_query, $executor) = @_;
29
	
30
	return STATUS_WONT_HANDLE if $original_query !~ m{\s*SELECT}sio;
31
32
	my $original_query_no_limit = $original_query;
33
	$original_query_no_limit =~ s{LIMIT\s+\d+\s+OFFSET\s+\d+\s*$}{}sio;
34
	$original_query_no_limit =~ s{LIMIT\s+\d+\s*$}{}sio;
35
36
	return [
37
		"( $original_query ) UNION ALL ( $original_query_no_limit LIMIT 0 ) /* TRANSFORM_OUTCOME_UNORDERED_MATCH */",
38
		"( $original_query_no_limit LIMIT 0 ) UNION ALL ( $original_query ) /* TRANSFORM_OUTCOME_UNORDERED_MATCH */",
39
		"( $original_query ) UNION DISTINCT ( $original_query ) /* TRANSFORM_OUTCOME_DISTINCT */",
40
		"( $original_query ) UNION ALL ( $original_query ) /* TRANSFORM_OUTCOME_SUPERSET */"
41
	];
42
}
43
44
1;