File: compare_digests.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 (68 lines) | stat: -rw-r--r-- 2,319 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
# This include file checks that the function statement_digest() and
# performance_schema produce the same digests.
#
# - $compare_digests_fn is the function called.
#
# - $compare_digests_query - is what the function is called with.
#
# - $compare_digests_pfs_query is executed and its digest picked up from
#   performance_schema.
#
# - $compare_digests_pfs_column is the column that is compared with the result
#   of the function.
#
# Only single quotes may be used in the queries.

--disable_query_log
SELECT enabled INTO @original_setting
FROM performance_schema.setup_consumers
WHERE NAME = 'statements_digest';

UPDATE performance_schema.setup_consumers
SET enabled = 'NO'
WHERE NAME = 'statements_digest';

# We inactivate statement digests in performance_schema before calling
# statement_digest(), as the function should work anyway.
eval SET @the_digest =
  $compare_digests_fn( "$compare_digests_query" );
--enable_query_log

--disable_query_log
UPDATE performance_schema.setup_consumers
SET enabled = 'YES'
WHERE NAME = 'statements_digest';

eval SET @ps_protocol = $PS_PROTOCOL;
--enable_query_log

--eval $compare_digests_pfs_query

# We do the conversion to 'utf8' (in fact UTF-8 mb3) here for the few cases
# when the SQL text is UTF-8 mb4. For all other cases, this conversion
# doesn't change anything as long as we use UTF-8.
#
# We're doing a little trick if the test runs under --ps-protocol. In this
# case the digests won't match up, obviously, since the queries aren't parsed
# normally and hence aren't in performance_schema. In this case we just answer
# 'YES'. Even if we don't get any useful result, it is still necessary to run
# the tests to check for assertions.
eval
SELECT digest_text, IF( @the_digest = $compare_digests_pfs_column, 'YES', 'NO' )
AS digest_is_correct
FROM performance_schema.events_statements_history
WHERE sql_text = convert( "$compare_digests_pfs_query" USING utf8 )
UNION
SELECT statement_digest_text( "$compare_digests_pfs_query" ), 'YES'
FROM (SELECT 1) a1 JOIN (SELECT @ps_protocol) a2;

--disable_query_log
UPDATE performance_schema.setup_consumers
SET enabled = @original_setting
WHERE NAME = 'statements_digest';
--enable_query_log

--let $compare_digests_fn=
--let $compare_digests_query=
--let $compare_digests_pfs_query=
--let $compare_digests_pfs_column=