Debian Codegraph @

mysql-test/suite/ndb_binlog/t/ndb_binlog_restore.test

raw
1 #Server variable option 'lower_case_table_names' sets '0' as default value
2 #in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
3 #insensitive filsystem is not allowed.
4 -- source include/have_case_sensitive_file_system.inc
5 -- source include/have_ndb.inc
6 -- source include/have_binlog_format_mixed_or_row.inc
7 -- source suite/ndb/include/backup_restore_setup.inc
8
9 # Directory containing the saved backup files
10 let $backup_data_dir=$MYSQL_TEST_DIR/suite/ndb/backups;
11
12 --echo #
13 --echo # create a table with some data with and without binlogging
14 --echo #
15 create table t1 (a int key, b int) engine ndb;
16 insert into t1 values (1,1);
17
18 # backup and drop data
19 --disable_query_log
20 --source include/ndb_backup.inc
21 --enable_query_log
22
23 --echo #
24 --echo # reset and restore schema
25 drop table t1;
26 reset master;
27 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
28 select * from t1 where 1=0 /* force discover table */;
29
30 --echo #
31 --echo # restore and _no_ binlog
32 --exec $NDB_RESTORE --no-binlog -b $the_backup_id -n 1 -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
33 --exec $NDB_RESTORE --no-binlog -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
34
35 --echo #
36 --echo # check the binlog, should be empty apart from our marker
37 --echo # create dummy table to wait for to ensure Binlog contains any previous events
38
39 create table binlogmarker (a int) engine=ndb;
40 let $wait_binlog_event= binlogmarker;
41 --source include/wait_for_binlog_event.inc
42
43 --source include/show_binlog_events.inc
44
45 --echo #
46 --echo # reset and restore schema again
47 drop table binlogmarker;
48 drop table t1;
49 reset master;
50 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
51 select * from t1 where 1=0 /* force discover table */;
52
53 --echo #
54 --echo # restore and binlog should now happen as well as the marker
55 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
56 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
57
58 --echo #
59 --echo # check the binlog, should contain data
60 --echo # create dummy table to wait for to ensure Binlog contains any previous events
61
62 create table binlogmarker (a int) engine=ndb;
63 let $wait_binlog_event= binlogmarker;
64 --source include/wait_for_binlog_event.inc
65
66 --source include/show_binlog_events.inc
67
68 drop table binlogmarker, t1;
69
70
71
72 --echo #
73 --echo # Now more complex using "BANK schema" including restore of log
74 --echo #
75 --disable_warnings
76 CREATE DATABASE IF NOT EXISTS BANK;
77 DROP DATABASE BANK;
78 --enable_warnings
79 CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
80
81 #
82 # These tables should correspond to the table definitions in
83 # storage/ndb/test/src/NDBT_Tables.cpp
84 #
85 USE BANK;
86 CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL,
87 ACCOUNT_TYPE INT UNSIGNED NOT NULL,
88 BALANCE INT UNSIGNED NOT NULL,
89 DEPOSIT_COUNT INT UNSIGNED NOT NULL,
90 DEPOSIT_SUM INT UNSIGNED NOT NULL,
91 WITHDRAWAL_COUNT INT UNSIGNED NOT NULL,
92 WITHDRAWAL_SUM INT UNSIGNED NOT NULL,
93 PURGED INT UNSIGNED NOT NULL,
94 PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE))
95 ENGINE = NDB;
96
97 CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL,
98 OWNER INT UNSIGNED NOT NULL,
99 BALANCE INT UNSIGNED NOT NULL,
100 ACCOUNT_TYPE INT UNSIGNED NOT NULL,
101 PRIMARY KEY USING HASH (ACCOUNT_ID))
102 ENGINE = NDB;
103
104 CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL,
105 ACCOUNT INT UNSIGNED NOT NULL,
106 ACCOUNT_TYPE INT UNSIGNED NOT NULL,
107 OTHER_ACCOUNT INT UNSIGNED NOT NULL,
108 TRANSACTION_TYPE INT UNSIGNED NOT NULL,
109 TIME BIGINT UNSIGNED NOT NULL,
110 AMOUNT INT UNSIGNED NOT NULL,
111 PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT))
112 ENGINE = NDB;
113
114 CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL,
115 VALUE BIGINT UNSIGNED NOT NULL,
116 PRIMARY KEY USING HASH (SYSTEM_VALUES_ID))
117 ENGINE = NDB;
118
119 CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL,
120 DESCRIPTION CHAR(64) NOT NULL,
121 PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID))
122 ENGINE = NDB;
123
124 --echo #
125 --echo # reset, restore and binlog should _not_ happen
126 reset master;
127 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR --no-binlog -b 1 -n 1 -p 1 -r $backup_data_dir/51 >> $NDB_TOOLS_OUTPUT
128 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR --no-binlog -b 1 -n 2 -p 1 -r $backup_data_dir/51 >> $NDB_TOOLS_OUTPUT
129
130 select count(*) from TRANSACTION;
131 --source include/show_binlog_events.inc
132
133 DROP DATABASE BANK;
134 --source suite/ndb/include/backup_restore_cleanup.inc
135 --remove_file $NDB_TOOLS_OUTPUT