1
# Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved.
2
# Use is subject to license terms.
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.
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.
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
18
package GenTest::Constants;
32
STATUS_ENVIRONMENT_FAILURE
42
STATUS_TRANSACTION_ERROR
46
STATUS_ERROR_MISMATCH_SELECT
47
STATUS_LENGTH_MISMATCH_SELECT
48
STATUS_CONTENT_MISMATCH_SELECT
49
STATUS_SELECT_REDUCTION
52
STATUS_LENGTH_MISMATCH
53
STATUS_CONTENT_MISMATCH
55
STATUS_CRITICAL_FAILURE
58
STATUS_REPLICATION_FAILURE
60
STATUS_RECOVERY_FAILURE
61
STATUS_DATABASE_CORRUPTION
62
STATUS_SERVER_DEADLOCKED
63
STATUS_VALGRIND_FAILURE
66
ORACLE_ISSUE_STILL_REPEATABLE
67
ORACLE_ISSUE_NO_LONGER_REPEATABLE
68
ORACLE_ISSUE_STATUS_UNKNOWN
77
DEFAULT_MTR_BUILD_THREAD
85
use constant STATUS_OK => 0; ## Suitable for exit code
86
use constant STATUS_UNKNOWN_ERROR => 2;
88
use constant STATUS_ANY_ERROR => 3; # Used in util/simplify* to not differentiate based on error code
90
use constant STATUS_EOF => 4; # A module requested that the test is terminated without failure
92
use constant STATUS_WONT_HANDLE => 5; # A module, e.g. a Validator refuses to handle certain query
93
use constant STATUS_SKIP => 6; # A Filter specifies that the query should not be processed further
95
use constant STATUS_SYNTAX_ERROR => 21;
96
use constant STATUS_SEMANTIC_ERROR => 22; # Errors caused by the randomness of the test, e.g. dropping a non-existing table
97
use constant STATUS_TRANSACTION_ERROR => 23; # Lock wait timeouts, deadlocks, duplicate keys, etc.
99
use constant STATUS_TEST_FAILURE => 24; # Boundary between genuine errors and false positives due to randomness
101
use constant STATUS_SELECT_REDUCTION => 5; # A coefficient to substract from error codes in order to make them non-fatal
103
use constant STATUS_ERROR_MISMATCH_SELECT => 26; # A SELECT query caused those erros, however the test can continue
104
use constant STATUS_LENGTH_MISMATCH_SELECT => 27; # since the database has not been modified
105
use constant STATUS_CONTENT_MISMATCH_SELECT => 28; #
107
use constant STATUS_ERROR_MISMATCH => 31; # A DML statement caused those errors, and the test can not continue
108
use constant STATUS_LENGTH_MISMATCH => 32; # because the databases are in an unknown inconsistent state
109
use constant STATUS_CONTENT_MISMATCH => 33; #
111
# Higher-priority errors
113
use constant STATUS_CRITICAL_FAILURE => 100; # Boundary between critical and non-critical errors
115
use constant STATUS_ENVIRONMENT_FAILURE => 110; # A failure in the environment or the grammar file
116
use constant STATUS_PERL_FAILURE => 255; # Perl died for some reason
118
use constant STATUS_CUSTOM_OUTCOME => 36; # Used for things such as signaling an EXPLAIN hit from the ExplainMatch Validator
120
use constant STATUS_SERVER_CRASHED => 101;
122
use constant STATUS_SERVER_KILLED => 102; # Willfull killing of the server, will not be reported as a crash
124
use constant STATUS_REPLICATION_FAILURE => 103;
125
use constant STATUS_RECOVERY_FAILURE => 104;
126
use constant STATUS_DATABASE_CORRUPTION => 105;
127
use constant STATUS_SERVER_DEADLOCKED => 106;
128
use constant STATUS_BACKUP_FAILURE => 107;
129
use constant STATUS_VALGRIND_FAILURE => 108;
130
use constant STATUS_ALARM => 109; # A module, e.g. a Reporter, raises an alarm with critical severity
132
use constant ORACLE_ISSUE_STILL_REPEATABLE => 2;
133
use constant ORACLE_ISSUE_NO_LONGER_REPEATABLE => 3;
134
use constant ORACLE_ISSUE_STATUS_UNKNOWN => 4;
136
use constant DB_UNKNOWN => 0;
137
use constant DB_DUMMY => 1;
138
use constant DB_MYSQL => 2;
139
use constant DB_POSTGRES => 3;
140
use constant DB_JAVADB => 4;
141
use constant DB_DRIZZLE => 5;
143
use constant DEFAULT_MTR_BUILD_THREAD => 930; ## Legacy...
146
# The part below deals with constant value to constant name conversions
154
# What we do here is open the Constants.pm file and parse the 'use constant' lines from it
155
# The regexp is faily hairy in order to be more permissive.
157
open (CONSTFILE, __FILE__) or croak "Unable to read constants from ".__FILE__;
158
read(CONSTFILE, my $constants_text, -s __FILE__);
159
%text2value = $constants_text =~ m{^\s*use\s+constant\s+([A-Z_0-9]*?)\s*=>\s*(\d+)\s*;}mgio;
163
my ($constant_value, $prefix) = @_;
165
foreach my $constant_text (keys %text2value) {
166
return $constant_text if $text2value{$constant_text} == $constant_value && $constant_text =~ m{^$prefix}si;
168
carp "Unable to obtain constant text for constant_value = $constant_value; prefix = $prefix";
173
return constant2text($_[0], 'STATUS_');