Debian Codegraph @

mysql-test/suite/rpl/include/rpl_check_table_consistency.inc

raw
1 # This file provides logic to ensure that all tables in a database are the
2 # same between two connections.
3 #
4 # param $check_db : The name of the database to validate all tables are the
5 # same within (test by default)
6 # param $con1 : The connection name of the primary server, defaults to
7 # master
8 # param $con2 : The connection name of the replica server, defaults to
9 # slave
10
11 --let $include_filename= rpl_check_table_consistency.inc
12 --source include/begin_include_file.inc
13
14 if (!$con1)
15 {
16 --let $con1= master
17 }
18 if (!$con2)
19 {
20 --let $con2= slave
21 }
22 if (!$check_db)
23 {
24 --let $check_db= test
25 }
26
27 --connection $con2
28 --let $n_tables= `select count(*) from information_schema.tables WHERE table_schema = '$check_db'`
29
30 --echo # Checking consistency of '$check_db' database tables between $con1 and $con2
31
32 --connection $con1
33 --let $c1_n_tables= `select count(*) from information_schema.tables WHERE table_schema = '$check_db'`
34 if (`SELECT $c1_n_tables != $n_tables`)
35 {
36 die "$con1 had $c1_n_tables tables but $con2 had $n_tables after binlog replay";
37 }
38 --echo # Both servers have $n_tables tables
39
40 --let $ctr= 1
41 --echo # Verifying integrity of tables..
42 while($ctr <= $n_tables)
43 {
44 --let $cksum_tbl= query_get_value(SELECT table_name FROM information_schema.tables WHERE table_schema = 'test' ORDER BY table_name ASC, table_name, $ctr)
45 --connection $con1
46 --let $c1_cksum= `CHECKSUM TABLE $cksum_tbl`
47 --connection $con2
48 --let $c2_cksum= `CHECKSUM TABLE $cksum_tbl`
49
50 if ($c1_cksum != $c2_cksum)
51 {
52 die "Table $cksum_tbl differs between connections $con1 and $con2";
53 }
54 if ($c1_cksum == $c2_cksum)
55 {
56 --echo # $cksum_tbl is equivalent on $con1 and $con2
57 }
58 --let $ctr= `SELECT $ctr+1`
59 }
60 --echo # All tables are consistent
61
62 --let $include_filename= rpl_check_table_consistency.inc
63 --source include/end_include_file.inc