File: assertions_for_sysvar_warnings.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (77 lines) | stat: -rw-r--r-- 2,546 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# ==== Purpose ====
#
# Assert that SHOW WARNINGS contains the expected warnings and nothing else.
#
# ==== Usage ====
#
# [--let $expect_deprecation_warning = 1]
# [--let $expect_truncation_warning = 1]
# --source ../inc/assertions_for_sysvar_warnings.inc
#
# Parameters:
#   $expect_deprecation_warning
#     Expect ER_WARN_DEPRECATED_SYNTAX.
#
#   $expect_truncation_warning
#     Expect ER_TRUNCATED_WRONG_VALUE.
#
# ==== Implementation notes ====
#
# Since statements other than SHOW WARNINGS resets the warnings, we
# can't use SQL to check the warnings. So we are limited to mtr
# language, which makes it impossible to use assert.inc, and have to
# use a bit of copy-paste coding.

--let $_csw_expected_warning_count = 0
--let $_csw_expected_warning_desc =
if ($expect_deprecation_warning) {
  --inc $_csw_expected_warning_count
  --let $_csw_expected_warning_desc = $_csw_expected_warning_desc deprecation
  --let $_csw_deprecation_warning_number = convert_error(ER_WARN_DEPRECATED_SYNTAX)
}
if ($expect_truncation_warning) {
  --inc $_csw_expected_warning_count
  --let $_csw_expected_warning_desc = $_csw_expected_warning_desc truncation
  --let $_csw_truncation_warning_number = convert_error(ER_TRUNCATED_WRONG_VALUE)
}

--let $_csw_found_error = 0

--let $_csw_warning_count = `SHOW COUNT(*) WARNINGS`
if ($_csw_warning_count != $_csw_expected_warning_count) {
  --let $_csw_found_error = 1
}

--let $_csw_warning_counter = 1
while ($_csw_warning_counter <= $_csw_warning_count) {
  --let $_csw_warning_error_code = query_get_value("SHOW WARNINGS", Code, $_csw_warning_counter)

  --let $_csw_is_expected_warning = 0
  if ($expect_deprecation_warning) {
    if ($_csw_warning_error_code == $_csw_deprecation_warning_number) {
      --let $_csw_is_expected_warning = 1
    }
  }
  if ($expect_truncation_warning) {
    if ($_csw_warning_error_code == $_csw_truncation_warning_number) {
      --let $_csw_is_expected_warning = 1
    }
  }
  if (!$_csw_is_expected_warning) {
    --let $_csw_found_error = 1
  }

  --inc $_csw_warning_counter
}

if ($_csw_found_error) {
  # Print debug info and fail
  --disable_abort_on_error
  SELECT @@$scope.$variable;
  SELECT @@$scope.$name;
  SELECT @@$scope.$alias;
  SELECT * FROM performance_schema.session_variables WHERE VARIABLE_NAME IN ('$variable', '$name', '$alias');
  SHOW WARNINGS;
  --echo Error: got the $_csw_warning_count warnings above, but expected $_csw_expected_warning_count warnings of types: $_csw_expected_warning_desc
  --die Error: Did not get the expected warnings
}