#At file:///home/tomas/mysql_src/cge-6.2/
2626 Tomas Ulin 2008-06-18
Bug #30452 add a --no-binlog option to ndb_restore
added:
mysql-test/suite/ndb_binlog/r/ndb_binlog_restore.result
mysql-test/suite/ndb_binlog/t/ndb_binlog_restore.test
modified:
mysql-test/suite/ndb/t/ndb_restore.test
storage/ndb/tools/restore/consumer_restore.cpp
storage/ndb/tools/restore/restore_main.cpp
=== modified file 'mysql-test/suite/ndb/t/ndb_restore.test'
--- a/mysql-test/suite/ndb/t/ndb_restore.test 2008-02-11 12:30:36 +0000
+++ b/mysql-test/suite/ndb/t/ndb_restore.test 2008-06-18 15:03:43 +0000
@@ -328,8 +328,12 @@ select count(*)
select * from t9_c) a;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r
--ndb-nodegroup_map '(0,0)' --print --print_meta
$NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print
--print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m
--ndb-nodegroup_map '(0,0)' --print --print_meta
$NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+show tables;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -r
--ndb-nodegroup_map '(0,0)' --print --print_meta
$NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+show binlog events from limit 1;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --binlog -b $the_backup_id -n 2 -r
--print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >>
$NDB_TOOLS_OUTPUT
+show binlog events from limit 1;
select count(*) from t1;
select count(*) from t1_c;
=== added file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_restore.result'
--- a/mysql-test/suite/ndb_binlog/r/ndb_binlog_restore.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_binlog/r/ndb_binlog_restore.result 2008-06-18 15:03:43 +0000
@@ -0,0 +1,101 @@
+drop table if exists t1;
+#
+# create a table with some data with and without binlogging
+#
+create table t1 (a int key, b int) engine ndb;
+insert into t1 values (1,1);
+@the_backup_id:=backup_id
+<the_backup_id>
+#
+# extra table to be used to ensure data has arrived to binlog
+create table t2 (a int key, b int) engine ndb;
+#
+# reset and restore schema
+drop table t1;
+reset master;
+show tables;
+Tables_in_test
+t2
+t1
+#
+# restore and _no_ binlog
+#
+# check the binlog, should be empty
+# extra insert (not logged) to ensure data has arrived to binlog
+set SQL_LOG_BIN=0;
+insert into t2 values (1,1);
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+#
+# reset and restore schema again
+drop table t1;
+reset master;
+show tables;
+Tables_in_test
+t2
+t1
+#
+# restore and binlog should now happen
+#
+# check the binlog, should contain data
+# extra insert (not logged) to ensure data has arrived to binlog
+set SQL_LOG_BIN=0;
+insert into t2 values (2,2);
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # BEGIN
+master-bin.000001 # Table_map 1 # table_id: # (test.t1)
+master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status)
+master-bin.000001 # Write_rows 1 # table_id: #
+master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
+master-bin.000001 # Query 1 # COMMIT
+drop table t1, t2;
+#
+# Now more complex using "BANK schema" including restore of log
+#
+CREATE DATABASE IF NOT EXISTS BANK;
+DROP DATABASE BANK;
+CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
+USE BANK;
+CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL,
+ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+BALANCE INT UNSIGNED NOT NULL,
+DEPOSIT_COUNT INT UNSIGNED NOT NULL,
+DEPOSIT_SUM INT UNSIGNED NOT NULL,
+WITHDRAWAL_COUNT INT UNSIGNED NOT NULL,
+WITHDRAWAL_SUM INT UNSIGNED NOT NULL,
+PURGED INT UNSIGNED NOT NULL,
+PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE))
+ENGINE = NDB;
+CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL,
+OWNER INT UNSIGNED NOT NULL,
+BALANCE INT UNSIGNED NOT NULL,
+ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+PRIMARY KEY USING HASH (ACCOUNT_ID))
+ENGINE = NDB;
+CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL,
+ACCOUNT INT UNSIGNED NOT NULL,
+ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+OTHER_ACCOUNT INT UNSIGNED NOT NULL,
+TRANSACTION_TYPE INT UNSIGNED NOT NULL,
+TIME BIGINT UNSIGNED NOT NULL,
+AMOUNT INT UNSIGNED NOT NULL,
+PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT))
+ENGINE = NDB;
+CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL,
+VALUE BIGINT UNSIGNED NOT NULL,
+PRIMARY KEY USING HASH (SYSTEM_VALUES_ID))
+ENGINE = NDB;
+CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL,
+DESCRIPTION CHAR(64) NOT NULL,
+PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID))
+ENGINE = NDB;
+#
+# reset, restore and binlog should _not_ happen
+reset master;
+select count(*) from TRANSACTION;
+count(*)
+3444
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+DROP DATABASE BANK;
=== added file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_restore.test'
--- a/mysql-test/suite/ndb_binlog/t/ndb_binlog_restore.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_binlog/t/ndb_binlog_restore.test 2008-06-18 15:03:43 +0000
@@ -0,0 +1,126 @@
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_mixed_or_row.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo #
+--echo # create a table with some data with and without binlogging
+--echo #
+create table t1 (a int key, b int) engine ndb;
+insert into t1 values (1,1);
+
+# backup and drop data
+--disable_query_log
+--source include/ndb_backup.inc
+--enable_query_log
+
+--echo #
+--echo # extra table to be used to ensure data has arrived to binlog
+create table t2 (a int key, b int) engine ndb;
+
+--echo #
+--echo # reset and restore schema
+drop table t1;
+reset master;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m --print
--print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+show tables;
+
+--echo #
+--echo # restore and _no_ binlog
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --no-binlog -b $the_backup_id -n 1 -r
--print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >>
$NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --no-binlog -b $the_backup_id -n 2 -r
--print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >>
$NDB_TOOLS_OUTPUT
+
+--echo #
+--echo # check the binlog, should be empty
+--echo # extra insert (not logged) to ensure data has arrived to binlog
+set SQL_LOG_BIN=0;
+insert into t2 values (1,1);
+--source include/show_binlog_events2.inc
+
+--echo #
+--echo # reset and restore schema again
+drop table t1;
+reset master;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m --print
--print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+show tables;
+
+--echo #
+--echo # restore and binlog should now happen
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -r --print
--print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print
--print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+
+--echo #
+--echo # check the binlog, should contain data
+--echo # extra insert (not logged) to ensure data has arrived to binlog
+set SQL_LOG_BIN=0;
+insert into t2 values (2,2);
+--source include/show_binlog_events2.inc
+
+drop table t1, t2;
+
+
+
+--echo #
+--echo # Now more complex using "BANK schema" including restore of log
+--echo #
+--disable_warnings
+CREATE DATABASE IF NOT EXISTS BANK;
+DROP DATABASE BANK;
+--enable_warnings
+CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
+
+#
+# These tables should correspond to the table definitions in
+# storage/ndb/test/src/NDBT_Tables.cpp
+#
+USE BANK;
+CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ BALANCE INT UNSIGNED NOT NULL,
+ DEPOSIT_COUNT INT UNSIGNED NOT NULL,
+ DEPOSIT_SUM INT UNSIGNED NOT NULL,
+ WITHDRAWAL_COUNT INT UNSIGNED NOT NULL,
+ WITHDRAWAL_SUM INT UNSIGNED NOT NULL,
+ PURGED INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE))
+ ENGINE = NDB;
+
+CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL,
+ OWNER INT UNSIGNED NOT NULL,
+ BALANCE INT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (ACCOUNT_ID))
+ ENGINE = NDB;
+
+CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL,
+ ACCOUNT INT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ OTHER_ACCOUNT INT UNSIGNED NOT NULL,
+ TRANSACTION_TYPE INT UNSIGNED NOT NULL,
+ TIME BIGINT UNSIGNED NOT NULL,
+ AMOUNT INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT))
+ ENGINE = NDB;
+
+CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL,
+ VALUE BIGINT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (SYSTEM_VALUES_ID))
+ ENGINE = NDB;
+
+CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL,
+ DESCRIPTION CHAR(64) NOT NULL,
+ PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID))
+ ENGINE = NDB;
+
+--echo #
+--echo # reset, restore and binlog should _not_ happen
+reset master;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --no-binlog -b 1 -n 1 -p 1 -r
$MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --no-binlog -b 1 -n 2 -p 1 -r
$MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
+
+select count(*) from TRANSACTION;
+--source include/show_binlog_events2.inc
+
+DROP DATABASE BANK;
=== modified file 'storage/ndb/tools/restore/consumer_restore.cpp'
--- a/storage/ndb/tools/restore/consumer_restore.cpp 2007-12-20 15:36:18 +0000
+++ b/storage/ndb/tools/restore/consumer_restore.cpp 2008-06-18 15:03:43 +0000
@@ -21,6 +21,8 @@
#include <ndb_internal.hpp>
#include <ndb_logevent.h>
+#define NDB_ANYVALUE_FOR_NOLOGGING 0xFFFFFFFF
+
extern my_bool opt_core;
extern FilteredNdbOut err;
@@ -34,6 +36,8 @@ static Uint32 get_part_id(const NdbDicti
extern const char * g_connect_string;
extern BaseString g_options;
+extern unsigned int opt_no_binlog;
+
bool
BackupRestore::init()
{
@@ -1314,6 +1318,11 @@ void BackupRestore::tuple_a(restore_call
exitHandler();
}
+ if (opt_no_binlog)
+ {
+ op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING);
+ }
+
// Prepare transaction (the transaction is NOT yet sent to NDB)
cb->n_bytes= n_bytes;
cb->connection->executeAsynchPrepare(NdbTransaction::Commit,
@@ -1562,6 +1571,10 @@ BackupRestore::logEntry(const LogEntry &
} // if
}
+ if (opt_no_binlog)
+ {
+ op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING);
+ }
const int ret = trans->execute(NdbTransaction::Commit);
if (ret != 0)
{
=== modified file 'storage/ndb/tools/restore/restore_main.cpp'
--- a/storage/ndb/tools/restore/restore_main.cpp 2008-06-09 11:57:17 +0000
+++ b/storage/ndb/tools/restore/restore_main.cpp 2008-06-18 15:03:43 +0000
@@ -55,6 +55,7 @@ unsigned int g_report_next;
Vector<BaseString> g_databases;
Vector<BaseString> g_tables;
NdbRecordPrintFormat g_ndbrecord_print_format;
+unsigned int opt_no_binlog;
NDB_STD_OPTS_VARS;
@@ -89,6 +90,7 @@ enum ndb_restore_options {
OPT_LINES_TERMINATED_BY,
OPT_APPEND,
OPT_PROGRESS_FREQUENCY,
+ OPT_NO_BINLOG,
OPT_VERBOSE
};
static const char *opt_fields_enclosed_by= NULL;
@@ -197,6 +199,10 @@ static struct my_option my_long_options[
"Print status uf restore periodically in given seconds",
(uchar**) &opt_progress_frequency, (uchar**) &opt_progress_frequency, 0,
GET_INT, REQUIRED_ARG, 0, 0, 65535, 0, 0, 0 },
+ { "no-binlog", OPT_NO_BINLOG,
+ "If a mysqld is connected and has binary log, do not log the restored data",
+ (uchar**) &opt_no_binlog, (uchar**) &opt_no_binlog, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "verbose", OPT_VERBOSE,
"verbosity",
(uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (tomas.ulin:2626) | Tomas Ulin | 18 Jun |