Debian Codegraph @

mysql-test/suite/sys_vars/inc/assertions_for_sysvar_warnings.inc

raw
1 # ==== Purpose ====
2 #
3 # Assert that SHOW WARNINGS contains the expected warnings and nothing else.
4 #
5 # ==== Usage ====
6 #
7 # [--let $expect_deprecation_warning = 1]
8 # [--let $expect_truncation_warning = 1]
9 # --source ../inc/assertions_for_sysvar_warnings.inc
10 #
11 # Parameters:
12 # $expect_deprecation_warning
13 # Expect ER_WARN_DEPRECATED_SYNTAX.
14 #
15 # $expect_truncation_warning
16 # Expect ER_TRUNCATED_WRONG_VALUE.
17 #
18 # ==== Implementation notes ====
19 #
20 # Since statements other than SHOW WARNINGS resets the warnings, we
21 # can't use SQL to check the warnings. So we are limited to mtr
22 # language, which makes it impossible to use assert.inc, and have to
23 # use a bit of copy-paste coding.
24
25 --let $_csw_expected_warning_count = 0
26 --let $_csw_expected_warning_desc =
27 if ($expect_deprecation_warning) {
28 --inc $_csw_expected_warning_count
29 --let $_csw_expected_warning_desc = $_csw_expected_warning_desc deprecation
30 --let $_csw_deprecation_warning_number = convert_error(ER_WARN_DEPRECATED_SYNTAX)
31 }
32 if ($expect_truncation_warning) {
33 --inc $_csw_expected_warning_count
34 --let $_csw_expected_warning_desc = $_csw_expected_warning_desc truncation
35 --let $_csw_truncation_warning_number = convert_error(ER_TRUNCATED_WRONG_VALUE)
36 }
37
38 --let $_csw_found_error = 0
39
40 --let $_csw_warning_count = `SHOW COUNT(*) WARNINGS`
41 if ($_csw_warning_count != $_csw_expected_warning_count) {
42 --let $_csw_found_error = 1
43 }
44
45 --let $_csw_warning_counter = 1
46 while ($_csw_warning_counter <= $_csw_warning_count) {
47 --let $_csw_warning_error_code = query_get_value("SHOW WARNINGS", Code, $_csw_warning_counter)
48
49 --let $_csw_is_expected_warning = 0
50 if ($expect_deprecation_warning) {
51 if ($_csw_warning_error_code == $_csw_deprecation_warning_number) {
52 --let $_csw_is_expected_warning = 1
53 }
54 }
55 if ($expect_truncation_warning) {
56 if ($_csw_warning_error_code == $_csw_truncation_warning_number) {
57 --let $_csw_is_expected_warning = 1
58 }
59 }
60 if (!$_csw_is_expected_warning) {
61 --let $_csw_found_error = 1
62 }
63
64 --inc $_csw_warning_counter
65 }
66
67 if ($_csw_found_error) {
68 # Print debug info and fail
69 --disable_abort_on_error
70 SELECT @@$scope.$variable;
71 SELECT @@$scope.$name;
72 SELECT @@$scope.$alias;
73 SELECT * FROM performance_schema.session_variables WHERE VARIABLE_NAME IN ('$variable', '$name', '$alias');
74 SHOW WARNINGS;
75 --echo Error: got the $_csw_warning_count warnings above, but expected $_csw_expected_warning_count warnings of types: $_csw_expected_warning_desc
76 --die Error: Did not get the expected warnings
77 }