~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to lib/GenTest/Validator/FalconErrors.pm

initial import from internal tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package GenTest::Validator::FalconErrors;
 
2
 
 
3
require Exporter;
 
4
@ISA = qw(GenTest::Validator GenTest);
 
5
 
 
6
use strict;
 
7
 
 
8
use GenTest;
 
9
use GenTest::Constants;
 
10
use GenTest::Result;
 
11
use GenTest::Validator;
 
12
 
 
13
1;
 
14
 
 
15
#
 
16
# This test examines error messages returned from Falcon in order to detect situations
 
17
# where the error message mentiones tables that were not used in the original query
 
18
#
 
19
 
 
20
sub validate {
 
21
        my ($comparator, $executors, $results) = @_;
 
22
 
 
23
        foreach my $result (@$results) {
 
24
                my $query = $result->query();
 
25
                my $error = $result->errstr();
 
26
 
 
27
                # This test only pertains to SELECT/INSERT/UPDATE/DELETE queries
 
28
                # It does not pertain to ALTERs because of unpredictable temporary table names
 
29
                return STATUS_OK if $query !~ m{insert|update|select|delete}sgio;
 
30
 
 
31
                if (
 
32
                        ($query =~ m{^select}sio) &&
 
33
                        ($error =~ m{table has uncommitted updates})
 
34
                ) {
 
35
                        say("Error: '".$error."' returned on a SELECT query.");
 
36
                        return STATUS_DATABASE_CORRUPTION;
 
37
                }
 
38
                
 
39
        
 
40
                my $falcon_table;
 
41
 
 
42
                if ($error =~ m{update conflict in table .*?\.([A-Z.]*)}sio) {
 
43
                        $falcon_table = $1;
 
44
                } elsif ($error =~ m{'duplicate values for key .*? in table .*?\.([A-Z.]*)}sio) {
 
45
                        $falcon_table = $1;
 
46
                }
 
47
 
 
48
                if (
 
49
                        (defined $falcon_table) &&
 
50
                        ($query !~ m{$falcon_table}sio)
 
51
                ) {
 
52
                        say("Error: '".$error."' indicates Falcon internal table mix-up.");
 
53
                        return STATUS_DATABASE_CORRUPTION;
 
54
                }
 
55
        }
 
56
 
 
57
        return STATUS_OK;
 
58
}
 
59
 
 
60
1;