| 1 |
# |
| 2 |
# Test for "Ndb_trans_hint_count_session" status variable |
| 3 |
# |
| 4 |
--source include/have_ndb.inc |
| 5 |
|
| 6 |
# Show that the counter is visible in SHOW STATUS and SHOW VARIABLES. |
| 7 |
# The variable is visible both in GLOBAL and SESSION scope |
| 8 |
# but always show the session value(this is indicated by |
| 9 |
# the suffix _session in the variable name). |
| 10 |
# |
| 11 |
--replace_column 2 # |
| 12 |
SHOW GLOBAL STATUS LIKE 'Ndb_trans_hint_count_session'; |
| 13 |
--replace_column 2 # |
| 14 |
SHOW SESSION STATUS LIKE 'Ndb_trans_hint_count_session'; |
| 15 |
--replace_column 2 # |
| 16 |
SHOW STATUS LIKE 'Ndb_trans_hint_count_session'; |
| 17 |
SELECT VARIABLE_NAME FROM performance_schema.global_status |
| 18 |
WHERE VARIABLE_NAME LIKE 'Ndb_trans_hint_count_session'; |
| 19 |
SELECT VARIABLE_NAME FROM performance_schema.session_status |
| 20 |
WHERE VARIABLE_NAME LIKE 'Ndb_trans_hint_count_session'; |
| 21 |
|
| 22 |
# Get initial counter value before using NDB |
| 23 |
let $initial_trans_hint = |
| 24 |
`SELECT VARIABLE_VALUE FROM performance_schema.session_status |
| 25 |
WHERE VARIABLE_NAME LIKE 'Ndb_trans_hint_count_session'`; |
| 26 |
#echo initial_trans_hint: $initial_trans_hint; |
| 27 |
|
| 28 |
# Get initial counter value for number of started NDB transactions |
| 29 |
let $initial_trans_start = |
| 30 |
`SELECT VARIABLE_VALUE FROM performance_schema.session_status |
| 31 |
WHERE VARIABLE_NAME LIKE 'Ndb_api_trans_start_count_session'`; |
| 32 |
#echo initial_trans_start: $initial_trans_start; |
| 33 |
|
| 34 |
CREATE TABLE t1 ( |
| 35 |
a int PRIMARY KEY |
| 36 |
) ENGINE = NDB; |
| 37 |
|
| 38 |
--echo # Show that counter is still same, no transactions ran yet |
| 39 |
let $trans_hint = |
| 40 |
`SELECT VARIABLE_VALUE FROM performance_schema.session_status |
| 41 |
WHERE VARIABLE_NAME LIKE 'Ndb_trans_hint_count_session'`; |
| 42 |
#echo trans_hint: $trans_hint; |
| 43 |
--disable_query_log ONCE |
| 44 |
eval select $trans_hint - $initial_trans_hint as still_zero; |
| 45 |
|
| 46 |
--echo # Run some NDB transactions |
| 47 |
INSERT INTO t1 VALUES (1); |
| 48 |
INSERT INTO t1 (a) VALUES (11); |
| 49 |
INSERT INTO t1 (a) VALUES (12), (37); |
| 50 |
SELECT * FROM t1 WHERE a = 1; |
| 51 |
REPLACE t1 (a) VALUES (12); |
| 52 |
SELECT * FROM t1 WHERE a = 12 ORDER BY a; |
| 53 |
DELETE FROM t1 WHERE a = 11; |
| 54 |
SELECT COUNT(*) FROM t1; |
| 55 |
DELETE FROM t1; |
| 56 |
|
| 57 |
--echo # Show that counter increased after performing NDB transactions |
| 58 |
let $trans_hint = |
| 59 |
`SELECT VARIABLE_VALUE FROM performance_schema.session_status |
| 60 |
WHERE VARIABLE_NAME LIKE 'Ndb_trans_hint_count_session'`; |
| 61 |
#echo trans_hint: $trans_hint; |
| 62 |
--disable_query_log ONCE |
| 63 |
eval select $trans_hint - $initial_trans_hint as seven_hinted_transactions; |
| 64 |
|
| 65 |
--echo # Compare with counter showing number of started NDB transactions, should |
| 66 |
--echo # be somewhat larger as not all transactions are hinted. |
| 67 |
let $trans_start = |
| 68 |
`SELECT VARIABLE_VALUE FROM performance_schema.session_status |
| 69 |
WHERE VARIABLE_NAME LIKE 'Ndb_api_trans_start_count_session'`; |
| 70 |
#echo trans_start: $trans_start; |
| 71 |
--disable_query_log ONCE |
| 72 |
eval select $trans_start - $initial_trans_start as twelve_started_transactions; |
| 73 |
|
| 74 |
DROP TABLE t1; |
| 75 |
|
| 76 |
|
| 77 |
|