| 1 |
# |
| 2 |
# create a table with some data with and without binlogging |
| 3 |
# |
| 4 |
create table t1 (a int key, b int) engine ndb; |
| 5 |
insert into t1 values (1,1); |
| 6 |
# |
| 7 |
# reset and restore schema |
| 8 |
drop table t1; |
| 9 |
reset master; |
| 10 |
select * from t1 where 1=0 /* force discover table */; |
| 11 |
a b |
| 12 |
# |
| 13 |
# restore and _no_ binlog |
| 14 |
# |
| 15 |
# check the binlog, should be empty apart from our marker |
| 16 |
# create dummy table to wait for to ensure Binlog contains any previous events |
| 17 |
create table binlogmarker (a int) engine=ndb; |
| 18 |
include/show_binlog_events.inc |
| 19 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 20 |
binlog.000001 # Query # # use `test`; create table binlogmarker (a int) engine=ndb |
| 21 |
# |
| 22 |
# reset and restore schema again |
| 23 |
drop table binlogmarker; |
| 24 |
drop table t1; |
| 25 |
reset master; |
| 26 |
select * from t1 where 1=0 /* force discover table */; |
| 27 |
a b |
| 28 |
# |
| 29 |
# restore and binlog should now happen as well as the marker |
| 30 |
# |
| 31 |
# check the binlog, should contain data |
| 32 |
# create dummy table to wait for to ensure Binlog contains any previous events |
| 33 |
create table binlogmarker (a int) engine=ndb; |
| 34 |
include/show_binlog_events.inc |
| 35 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 36 |
binlog.000001 # Query # # BEGIN |
| 37 |
binlog.000001 # Table_map # # table_id: # (test.t1) |
| 38 |
binlog.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) |
| 39 |
binlog.000001 # Write_rows # # table_id: # |
| 40 |
binlog.000001 # Write_rows # # table_id: # flags: STMT_END_F |
| 41 |
binlog.000001 # Query # # COMMIT |
| 42 |
binlog.000001 # Query # # use `test`; create table binlogmarker (a int) engine=ndb |
| 43 |
drop table binlogmarker, t1; |
| 44 |
# |
| 45 |
# Now more complex using "BANK schema" including restore of log |
| 46 |
# |
| 47 |
CREATE DATABASE IF NOT EXISTS BANK; |
| 48 |
DROP DATABASE BANK; |
| 49 |
CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin; |
| 50 |
USE BANK; |
| 51 |
CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL, |
| 52 |
ACCOUNT_TYPE INT UNSIGNED NOT NULL, |
| 53 |
BALANCE INT UNSIGNED NOT NULL, |
| 54 |
DEPOSIT_COUNT INT UNSIGNED NOT NULL, |
| 55 |
DEPOSIT_SUM INT UNSIGNED NOT NULL, |
| 56 |
WITHDRAWAL_COUNT INT UNSIGNED NOT NULL, |
| 57 |
WITHDRAWAL_SUM INT UNSIGNED NOT NULL, |
| 58 |
PURGED INT UNSIGNED NOT NULL, |
| 59 |
PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE)) |
| 60 |
ENGINE = NDB; |
| 61 |
CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL, |
| 62 |
OWNER INT UNSIGNED NOT NULL, |
| 63 |
BALANCE INT UNSIGNED NOT NULL, |
| 64 |
ACCOUNT_TYPE INT UNSIGNED NOT NULL, |
| 65 |
PRIMARY KEY USING HASH (ACCOUNT_ID)) |
| 66 |
ENGINE = NDB; |
| 67 |
CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL, |
| 68 |
ACCOUNT INT UNSIGNED NOT NULL, |
| 69 |
ACCOUNT_TYPE INT UNSIGNED NOT NULL, |
| 70 |
OTHER_ACCOUNT INT UNSIGNED NOT NULL, |
| 71 |
TRANSACTION_TYPE INT UNSIGNED NOT NULL, |
| 72 |
TIME BIGINT UNSIGNED NOT NULL, |
| 73 |
AMOUNT INT UNSIGNED NOT NULL, |
| 74 |
PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT)) |
| 75 |
ENGINE = NDB; |
| 76 |
CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL, |
| 77 |
VALUE BIGINT UNSIGNED NOT NULL, |
| 78 |
PRIMARY KEY USING HASH (SYSTEM_VALUES_ID)) |
| 79 |
ENGINE = NDB; |
| 80 |
CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL, |
| 81 |
DESCRIPTION CHAR(64) NOT NULL, |
| 82 |
PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID)) |
| 83 |
ENGINE = NDB; |
| 84 |
# |
| 85 |
# reset, restore and binlog should _not_ happen |
| 86 |
reset master; |
| 87 |
select count(*) from TRANSACTION; |
| 88 |
count(*) |
| 89 |
3444 |
| 90 |
include/show_binlog_events.inc |
| 91 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 92 |
DROP DATABASE BANK; |