~tsarev/dbqp/dbqp_out_of_source

« back to all changes in this revision

Viewing changes to randgen/lib/GenTest/Validator/MarkErrorLog.pm

  • Committer: patrick crews
  • Date: 2011-10-05 20:26:34 UTC
  • Revision ID: gleebix@gmail.com-20111005202634-2q6baxxvbfuhmdzy
Initial branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008, 2010 Oracle and/or its affiliates, Inc. All
 
2
# rights reserved.  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::Validator::MarkErrorLog;
 
19
 
 
20
require Exporter;
 
21
@ISA = qw(GenTest::Validator);
 
22
 
 
23
use strict;
 
24
use GenTest;
 
25
use GenTest::Validator;
 
26
use GenTest::Constants;
 
27
 
 
28
my $error_log;
 
29
 
 
30
sub validate {
 
31
    my ($validator, $executors, $results) = @_;
 
32
        my $dbh = $executors->[0]->dbh();
 
33
 
 
34
        if (not defined $error_log) {
 
35
                my ($foo, $error_log_mysql) = $dbh->selectrow_array("SHOW VARIABLES LIKE 'log_error'");
 
36
 
 
37
                if ($error_log_mysql ne '') {
 
38
                        $error_log = $error_log_mysql;
 
39
                } else {
 
40
                        my ($bar, $datadir_mysql) = $dbh->selectrow_array("SHOW VARIABLES LIKE 'datadir'");
 
41
            foreach my $errlog ('../log/master.err', '../mysql.err') {
 
42
                if (-f $datadir_mysql.'/'.$errlog) {
 
43
                    $error_log = $datadir_mysql.'/'.$errlog;
 
44
                    last;
 
45
                }
 
46
            }
 
47
            
 
48
                }
 
49
        say ("MarkErrorLog found errorlog at " . $error_log);
 
50
        }
 
51
        
 
52
 
 
53
    
 
54
        my $query = $results->[0]->query();
 
55
 
 
56
        open(LOG, ">>$error_log") or die "unable to open $error_log: $!";
 
57
        print LOG isoTimestamp()." [$$] Query: $query\n";
 
58
        close LOG;
 
59
 
 
60
        return STATUS_OK;
 
61
}
 
62
 
 
63
1;