summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tomas@whalegate.ndb.mysql.com>2007-04-30 11:43:50 +0200
committerunknown <tomas@whalegate.ndb.mysql.com>2007-04-30 11:43:50 +0200
commit140f51910d14ed63fe196d85edb667691fece341 (patch)
tree41b4aff2b5d841ebd7b59c86d799caa6ed2f7565
parent5e14c3cdca4801227db8f06b516e8e5fb61f7b6c (diff)
downloadmariadb-git-140f51910d14ed63fe196d85edb667691fece341.tar.gz
ndb_restore to set correct value force varpart
+ some tests
-rw-r--r--mysql-test/r/ndb_restore.result6
-rw-r--r--mysql-test/r/ndb_restore_compat.result10
-rw-r--r--mysql-test/t/ndb_restore.test12
-rw-r--r--mysql-test/t/ndb_restore_compat.test20
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp16
5 files changed, 61 insertions, 3 deletions
diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result
index b57fc2e14ba..8ecffa437b0 100644
--- a/mysql-test/r/ndb_restore.result
+++ b/mysql-test/r/ndb_restore.result
@@ -23,7 +23,7 @@ CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
`capgotod` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`capgotod`,`CapGoaledatta`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED;
INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3);
CREATE TABLE `t4_c` (
`capfa` bigint(20) unsigned NOT NULL auto_increment,
@@ -129,6 +129,8 @@ create table t7 engine=myisam as select * from t7_c;
create table t8 engine=myisam as select * from t8_c;
create table t9 engine=myisam as select * from t9_c;
create table t10 engine=myisam as select * from t10_c;
+ForceVarPart: 0
+ForceVarPart: 1
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
DELETE FROM test.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
@@ -137,6 +139,8 @@ SELECT @the_backup_id:=backup_id FROM test.backup_info;
<the_backup_id>
DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
+ForceVarPart: 0
+ForceVarPart: 1
select count(*) from t1;
count(*)
5
diff --git a/mysql-test/r/ndb_restore_compat.result b/mysql-test/r/ndb_restore_compat.result
index d495aa28135..db17f9af32b 100644
--- a/mysql-test/r/ndb_restore_compat.result
+++ b/mysql-test/r/ndb_restore_compat.result
@@ -47,11 +47,21 @@ SYSTEM_VALUES_ID VALUE
SELECT * FROM mysql.ndb_apply_status WHERE server_id=0;
server_id epoch log_name start_pos end_pos
0 151 0 0
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
TRUNCATE GL;
TRUNCATE ACCOUNT;
TRUNCATE TRANSACTION;
TRUNCATE SYSTEM_VALUES;
TRUNCATE ACCOUNT_TYPE;
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
+ForceVarPart: 1
SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE;
TIME ACCOUNT_TYPE BALANCE DEPOSIT_COUNT DEPOSIT_SUM WITHDRAWAL_COUNT WITHDRAWAL_SUM PURGED
0 0 10000000 0 0 0 0 1
diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test
index 662eb43c422..61927a1f90a 100644
--- a/mysql-test/t/ndb_restore.test
+++ b/mysql-test/t/ndb_restore.test
@@ -35,11 +35,13 @@ CREATE TABLE `t2_c` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
+# Added ROW_FORMAT=FIXED to use below to see that setting is preserved
+# by restore
CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
`capgotod` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`capgotod`,`CapGoaledatta`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED;
INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3);
# Bug #27775 - mediumint auto inc not restored correctly
@@ -164,11 +166,19 @@ create table t8 engine=myisam as select * from t8_c;
create table t9 engine=myisam as select * from t9_c;
create table t10 engine=myisam as select * from t10_c;
+# check that force varpart is preserved by ndb_restore
+# t3_c has ROW_FORMAT=FIXED i.e. ForceVarPart=0
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t3_c | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t2_c | grep ForceVarPart
--source include/ndb_backup.inc
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 --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
+# check that force varpart is preserved by ndb_restore
+# t3_c has ROW_FORMAT=FIXED i.e. ForceVarPart=0
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t3_c | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t2_c | grep ForceVarPart
# random output order??
#show tables;
diff --git a/mysql-test/t/ndb_restore_compat.test b/mysql-test/t/ndb_restore_compat.test
index a95829a4354..2622aec1d50 100644
--- a/mysql-test/t/ndb_restore_compat.test
+++ b/mysql-test/t/ndb_restore_compat.test
@@ -13,9 +13,9 @@
DROP DATABASE IF EXISTS BANK;
--enable_warnings
CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
-USE BANK;
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -m -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
+USE BANK;
SHOW TABLES;
SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE;
SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID;
@@ -23,6 +23,13 @@ SELECT COUNT(*) FROM TRANSACTION;
SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID;
SELECT * FROM mysql.ndb_apply_status WHERE server_id=0;
+# Check that force varpart is set by ndb_restore
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK GL | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK TRANSACTION | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK SYSTEM_VALUES | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT_TYPE | grep ForceVarPart
+
#
# verify restore of 5.0 backup
# here we must use the already created tables as restoring the old
@@ -33,8 +40,19 @@ TRUNCATE ACCOUNT;
TRUNCATE TRANSACTION;
TRUNCATE SYSTEM_VALUES;
TRUNCATE ACCOUNT_TYPE;
+
+# Check that force varpart is not changed by truncate
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK GL | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK TRANSACTION | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK SYSTEM_VALUES | grep ForceVarPart
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT_TYPE | grep ForceVarPart
+
+# Restore data
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT
+
+# Check data
SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE;
SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID;
SELECT COUNT(*) FROM TRANSACTION;
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index 3aa36089e42..3dd4b072671 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -869,6 +869,22 @@ BackupRestore::table(const TableS & table){
copy.setFragmentData((const void *)ng_array, no_parts << 1);
}
+ /**
+ * Force of varpart was introduced in 5.1.18, telco 6.1.7 and 6.2.1
+ * Since default from mysqld is to add force of varpart (disable with
+ * ROW_FORMAT=FIXED) we force varpart onto tables when they are restored
+ * from backups taken with older versions. This will be wrong if
+ * ROW_FORMAT=FIXED was used on original table, however the likelyhood of
+ * this is low, since ROW_FORMAT= was a NOOP in older versions.
+ */
+
+ if (table.getBackupVersion() < MAKE_VERSION(5,1,18))
+ copy.setForceVarPart(true);
+ else if (getMajor(table.getBackupVersion()) == 6 &&
+ (table.getBackupVersion() < MAKE_VERSION(6,1,7) ||
+ table.getBackupVersion() == MAKE_VERSION(6,2,0)))
+ copy.setForceVarPart(true);
+
/*
update min and max rows to reflect the table, this to
ensure that memory is allocated properly in the ndb kernel