1# ==== Purpose ==== 2# 3# Assert that exactly one GTID (or a specified number) was added to 4# @@GLOBAL.GTID_EXECUTED since last call to gtid_step_reset.inc or 5# gtid_step_assert.inc 6# 7# ==== Usage ==== 8# 9# [--let $gtid_step_count= N] 10# [--let $gtid_step_only_count= [0|1]] 11# [--let $gtid_step_uuid= UUID] 12# [--let $gtid_step_check_table= [0|1]] 13# --source include/gtid_step_assert.inc 14# 15# Parameters: 16# $gtid_step_count 17# Assert that N GTIDs were added to @@GLOBAL.GTID_EXECUTED. If 18# this is not given, the default value is 1. 19# 20# $gtid_step_only_count 21# By default, this script checks the numeric component of the 22# GTIDs added to @@GLOBAL.GTID_EXECUTED to see that the correct 23# number was generated. If this parameter is nonzero, it only 24# counts the number of added GTIDs to see that it is equal to 25# $gtid_step_count, without caring that they were generated in 26# order (or generated on this server). 27# 28# $gtid_step_uuid 29# By default, when $gtid_step_count is not set, asserts that the 30# uuid component of all GTIDs added to @@GLOBAL.GTID_EXECUTED is 31# equal to @@GLOBAL.SERVER_UUID. If this parameter is given, uses 32# that UUID instead. 33# 34# $gtid_step_gtid_mode_agnostic 35# If this is set, the script will work also if gtid_mode=off. 36# In that case it will assert that no GTID was generated. 37# 38# $gtid_step_check_table 39# This script checks that exactly $_gtid_step_count GTIDs have been 40# added to mysql.gtid_executed since last invocation if this parameter 41# is nonzero. The check is skipped if this parameter is not set or zero. 42# 43# ==== Example ==== 44# 45# # (1) Remember the current position. 46# --source include/gtid_step_reset.inc 47# CREATE TABLE t1 (a INT); 48# # (2) Assert that exactly one GTID was generated since (1). 49# --source include/gtid_step_assert.inc 50# INSERT INTO t1 VALUES (1); 51# INSERT INTO t1 VALUES (2); 52# # (3) Assert that exactly 2 GTIDs were generated since (2). 53# --let $gtid_step_count= 2 54# --source include/gtid_step_assert.inc 55# # (4) Assert that no GTID was generated since (3). 56# --let $gtid_step_count= 0 57# --source include/gtid_step_assert.inc 58 59if ($uuidf == '') 60{ 61 --die You must source gtid_utils.inc before using gtid_step_assert.inc 62} 63 64--let $_gtid_step_count= 1 65if ($gtid_step_count != '') 66{ 67 --let $_gtid_step_count= $gtid_step_count 68} 69 70--let $_gtid_step_only_count= 0 71if ($gtid_step_only_count != '') 72{ 73 --let $_gtid_step_only_count= $gtid_step_only_count 74} 75 76--let $_gtid_step_print_count= [count=$_gtid_step_count, only_count=$_gtid_step_only_count] 77if ($_gtid_step_dont_print_count) 78{ 79 --let $_gtid_step_print_count= 80} 81 82--let $include_filename= gtid_step_assert.inc $_gtid_step_print_count 83--source include/begin_include_file.inc 84 85if ($gtid_step_gtid_mode_agnostic) 86{ 87 if (!$gtid_mode_on) 88 { 89 --let $_gtid_step_count= 0 90 } 91} 92 93--let $_gtid_step_uuid= $gtid_step_uuid 94if ($_gtid_step_uuid == '') 95{ 96 --let $_gtid_step_uuid= `SELECT @@GLOBAL.SERVER_UUID` 97} 98 99--let $_gsa_extra_debug_eval_old= $extra_debug_eval 100--let $extra_debug_eval= @@GLOBAL.GTID_EXECUTED, GTID_NEXT_GENERATED_MULTIPLE("$gtid_step_last", "$_gtid_step_uuid", $_gtid_step_count), GTID_SUBTRACT(@@GLOBAL.GTID_EXECUTED, "$gtid_step_last") 101 102if ($_gtid_step_only_count) 103{ 104 --let $assert_text= Exactly $_gtid_step_count GTIDs should have been committed since last invocation 105 --let $assert_cond= GTID_COUNT(GTID_SUBTRACT(@@GLOBAL.GTID_EXECUTED, "$gtid_step_last")) = $_gtid_step_count 106 --source include/assert.inc 107} 108if (!$_gtid_step_only_count) 109{ 110 --let $assert_text= Exactly $_gtid_step_count GTIDs should have been generated since last invocation 111 --let $assert_cond= GTID_NEXT_GENERATED_MULTIPLE("$gtid_step_last", "$_gtid_step_uuid", $_gtid_step_count) = GTID_SUBTRACT(@@GLOBAL.GTID_EXECUTED, "$gtid_step_last") 112 --source include/assert.inc 113} 114 115if ($gtid_step_check_table) 116{ 117 if ($_gtid_step_only_count) 118 { 119 --let $assert_text= Exactly $_gtid_step_count GTIDs should have been added to mysql.gtid_executed since last invocation 120 --let $assert_cond= GTID_COUNT(GTID_SUBTRACT(GTID_EXECUTED_FROM_TABLE(), "$gtid_step_last")) = $_gtid_step_count 121 --source include/assert.inc 122 } 123 if (!$_gtid_step_only_count) 124 { 125 --let $assert_text= Exactly $_gtid_step_count GTIDs should have been added to mysql.gtid_executed since last invocation 126 --let $assert_cond= GTID_NEXT_GENERATED_MULTIPLE("$gtid_step_last", "$_gtid_step_uuid", $_gtid_step_count) = GTID_SUBTRACT(GTID_EXECUTED_FROM_TABLE(), "$gtid_step_last") 127 --source include/assert.inc 128 } 129} 130 131--let $extra_debug_eval= $_gsa_extra_debug_eval_old 132 133--source include/gtid_step_reset.inc 134 135--let $include_filename= gtid_step_assert.inc 136--source include/end_include_file.inc 137