~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to lib/GenTest/Transform/Distinct.pm

initial import from internal tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package GenTest::Transform::Distinct;
 
2
 
 
3
use strict;
 
4
use lib 'lib';
 
5
use GenTest::Constants;
 
6
 
 
7
sub transform {
 
8
        my ($class, $orig_query) = @_;
 
9
 
 
10
        # At this time we do not handle LIMIT because it may cause
 
11
        # both duplicate elimination AND extra rows to appear
 
12
 
 
13
        return STATUS_WONT_HANDLE if $orig_query =~ m{LIMIT}io;
 
14
 
 
15
        if ($orig_query =~ m{SELECT\s+DISTINCT}io) {
 
16
                $orig_query =~ s{SELECT\s+DISTINCT}{SELECT }io;
 
17
                return $orig_query." /* TRANSFORM_OUTCOME_SUPERSET */ ";
 
18
        } else {
 
19
                $orig_query =~ s{SELECT}{SELECT DISTINCT}io;
 
20
                return $orig_query." /* TRANSFORM_OUTCOME_DISTINCT */ ";
 
21
        }
 
22
}
 
23
 
 
24
1;