Debian Codegraph @

mysql-test/suite/storage_engine/check_errors.inc

raw
1 #
2 # Since we run tests in disable_abort_on_error mode, we cannot use --error command,
3 # and need to check the result manually.
4 # Usage in a test:
5 # --let $error_codes = <comma-separated list> # optional, default ''
6 # --let $mysql_errname = <error name> # optional, default current $mysql_errname (from the last SQL command)
7 # --let $mysql_errno = <error code> # optional, default current $mysql_errno (from the last SQL command)
8 #
9
10 if ($error_codes == '0')
11 {
12 --let $error_codes =
13 }
14 if ($error_codes == '')
15 {
16 if ($mysql_errname)
17 {
18 --echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected to succeed)
19 }
20
21 # If both error_codes and mysql_errname are false, all is good, no logic needed
22 }
23
24 if ($error_codes != '')
25 {
26 # If mysql_errname or mysql_errno is equal to $error_codes, it's good too, nothing to do
27
28 if ($mysql_errname != $error_codes)
29 {
30 if ($mysql_errno != $error_codes)
31 {
32 --let $save_errno = $mysql_errno
33 --let $save_errname = $mysql_errname
34
35 --let $codeline = `SELECT CONCAT('\'',REPLACE('$error_codes',',','\',\''),'\'')`
36 --let $result = `SELECT '$save_errname' IN($codeline) or '$save_errno' IN ($codeline)`
37
38 --let $mysql_errno = $save_errno
39 --let $mysql_errname = $save_errname
40
41 if (!$result)
42 {
43 if ($mysql_errname)
44 {
45 --echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected results: $error_codes)
46 }
47 if (!$mysql_errname)
48 {
49 --echo # ERROR: Statement succeeded (expected results: $error_codes)
50 }
51 }
52 # If a list contained more than one error, it could be on one of two reasons:
53 # first, we do not care which code it is, as long as it is one of the listed errors.
54 # In this case we will suggest to add an rdiff file if the message differs.
55 # Second, check_errors might be called from a generalized include file or test,
56 # which runs with different parameters and thus might produce different results for the same statement.
57 # Then, the message will be stricter, as the difference with the result file is actually a problem
58 # which needs to be checked at least.
59 if ($result)
60 {
61 if (!$strict_check)
62 {
63 --echo # Statement ended with one of expected results ($error_codes).
64 --echo # If you got a difference in error message, just add it to rdiff file
65 }
66 if ($strict_check)
67 {
68 --echo # WARNING: Statement ended with errno $mysql_errno, errname '$mysql_errname'.
69 --echo # If it differs from the result file, it might indicate a problem.
70 }
71
72 }
73 }
74 }
75 }
76
77 # Don't want the variables to be accidentally reused later
78 --let $error_codes =
79 --let $strict_check =
80