#At file:///home2/mydev/bzrroot/mysql-6.0-bug39076/
2727 Ingo Struewing 2008-11-07
Bug#39076 - The test backup_nodata_driver fails with blackhole
and federated in build.
It was reported that the test fails on RESTORE with "Table
'bup_data.myisam1' doesn't exist". But this error was correct.
I added the expected error directive.
However, at first the test case did not start on Linux at all.
The example storage engine is built as a dynamically loadable
plugin only. I added the required prerequisites. But now the
test case is skipped on Windows. Currently we do not have
Windows support for dynamically loadable plugins.
See WL#3653 - Loadable Engine on Windows
I added/reworked comments in the test case to make clear what
happens, is required, and why everything is fine.
added:
mysql-test/suite/backup/t/backup_nodata_driver-master.opt
modified:
mysql-test/suite/backup/r/backup_nodata_driver.result
mysql-test/suite/backup/t/backup_nodata_driver.test
per-file messages:
mysql-test/suite/backup/r/backup_nodata_driver.result
Bug#39076 - The test backup_nodata_driver fails with blackhole
and federated in build.
Updated result file.
mysql-test/suite/backup/t/backup_nodata_driver-master.opt
Bug#39076 - The test backup_nodata_driver fails with blackhole
and federated in build.
New options file to support dynamic loading of EXAMPLE.
mysql-test/suite/backup/t/backup_nodata_driver.test
Bug#39076 - The test backup_nodata_driver fails with blackhole
and federated in build.
Added loadable EXAMPLE engine support for *nix.
Added/reworked comments to make clear what happens, is required,
and why everything is fine.
Added a required --error directive.
=== modified file 'mysql-test/suite/backup/r/backup_nodata_driver.result'
--- a/mysql-test/suite/backup/r/backup_nodata_driver.result 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_nodata_driver.result 2008-11-07 15:42:46 +0000
@@ -1,7 +1,10 @@
+INSTALL PLUGIN example SONAME 'ha_example.so';
DROP DATABASE IF EXISTS bup_nodata;
DROP DATABASE IF EXISTS bup_data;
-Creating tables
-CREATE DATABASE bup_nodata;
+#
+# Create a database with tables that can work as
+# base tables for MERGE and FEDERATED.
+#
CREATE DATABASE bup_data;
CREATE TABLE bup_data.myisam1 (a int, b char(30)) ENGINE=MYISAM;
CREATE TABLE bup_data.myisam2 (a int, b char(30)) ENGINE=MYISAM;
@@ -14,6 +17,10 @@ CREATE TABLE bup_data.f1 (
`name` varchar(32) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
+#
+# Create a database with tables from no-data engines.
+#
+CREATE DATABASE bup_nodata;
CREATE TABLE bup_nodata.merge1 (a int, b char(30))
ENGINE=MERGE UNION=(bup_data.myisam1, bup_data.myisam2, bup_data.myisam3);
CREATE TABLE bup_nodata.f1 (
@@ -30,7 +37,9 @@ CREATE TABLE bup_nodata.e1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Vapor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=example;
-Inserting data
+#
+# Insert some data.
+#
INSERT INTO bup_data.myisam1 VALUES (11, 'table 1');
INSERT INTO bup_data.myisam1 VALUES (12, 'table 1');
INSERT INTO bup_data.myisam1 VALUES (13, 'table 1');
@@ -45,7 +54,9 @@ INSERT INTO bup_data.f1 (id, name) VALUE
INSERT INTO bup_data.f1 (id, `group`) VALUES (3, 42);
INSERT INTO bup_data.f1 (id, `batch`) VALUES (4, 23);
INSERT INTO bup_data.f1 (id, `qty`) VALUES (5, 1);
-show data
+#
+# Show the data.
+#
SHOW FULL TABLES FROM bup_data;
Tables_in_bup_data Table_type
f1 BASE TABLE
@@ -80,13 +91,21 @@ SELECT * FROM bup_nodata.b1;
a b c
SELECT * FROM bup_nodata.e1;
Period Vapor_period
+#
+# Backup the bup_data DB, which tables contain data.
+#
BACKUP DATABASE bup_data TO 'bup_data.bak';
backup_id
#
+#
+# Backup the bup_nodata DB, which tables do not contain data.
+#
BACKUP DATABASE bup_nodata TO 'bup_nodata.bak';
backup_id
#
-show data
+#
+# Show the data again. Backup did not modify them.
+#
SHOW FULL TABLES FROM bup_data;
Tables_in_bup_data Table_type
f1 BASE TABLE
@@ -121,8 +140,15 @@ SELECT * FROM bup_nodata.b1;
a b c
SELECT * FROM bup_nodata.e1;
Period Vapor_period
+#
+# Now drop the bup_data database.
+#
DROP DATABASE bup_data;
-show data
+#
+# Show that the data have gone.
+# The MERGE and FEDERATED tables have errors since
+# their base tables have been dropped with bup_data.
+#
SHOW FULL TABLES FROM bup_nodata;
Tables_in_bup_nodata Table_type
b1 BASE TABLE
@@ -137,12 +163,27 @@ SELECT * FROM bup_nodata.b1;
a b c
SELECT * FROM bup_nodata.e1;
Period Vapor_period
+#
+# Now drop the bup_nodata database too.
+#
DROP DATABASE bup_nodata;
-Restoring nodata database.
+#
+# Now try to restore the bup_nodata database. This fails because
+# restore opens the tables for filling them with data, even when
+# they were empty on backup. 'bup_nodata.bak' does not contain
+# the base tables for the MERGE and FEDERATED tables.
+# NOTE: Since restore fails after restoring the meta data,
+# after creating the tables that is, we have the same
+# situation as before. The tables exist, but the base
+# tables for MERGE and FEDERATED do not exist.
+#
RESTORE FROM 'bup_nodata.bak';
-backup_id
+Got one of the listed errors
+#
+# Show what we have.
+# NOTE: If restore would work as all or nothing,
+# all of the SHOW and SELECT statements in this section would fail.
#
-show data
SHOW FULL TABLES FROM bup_nodata;
Tables_in_bup_nodata Table_type
b1 BASE TABLE
@@ -157,11 +198,17 @@ SELECT * FROM bup_nodata.b1;
a b c
SELECT * FROM bup_nodata.e1;
Period Vapor_period
-Restoring data database.
+#
+# Now restore the bup_data database as well.
+#
RESTORE FROM 'bup_data.bak';
backup_id
#
-show data
+#
+# Show that everything is well.
+# NOTE: If restore would work as all or nothing,
+# the bup_nodata tables would not exist here.
+#
SHOW FULL TABLES FROM bup_data;
Tables_in_bup_data Table_type
f1 BASE TABLE
@@ -196,5 +243,72 @@ SELECT * FROM bup_nodata.b1;
a b c
SELECT * FROM bup_nodata.e1;
Period Vapor_period
+#
+# Now restore the bup_nodata database and see if it is the same
+# as above. Note that this step would not be required here
+# because all bup_nodata tables have no data and were created
+# by the failed restore. Anyway, the correct approach is to do a
+# succeeding restore before assuming that everything exists again.
+#
+RESTORE FROM 'bup_nodata.bak';
+backup_id
+#
+#
+# Show that everything is well.
+#
+SHOW FULL TABLES FROM bup_nodata;
+Tables_in_bup_nodata Table_type
+b1 BASE TABLE
+e1 BASE TABLE
+f1 BASE TABLE
+merge1 BASE TABLE
+SELECT * FROM bup_nodata.merge1;
+a b
+11 table 1
+12 table 1
+13 table 1
+21 table 2
+22 table 2
+23 table 2
+31 table 3
+32 table 3
+33 table 3
+SELECT * FROM bup_nodata.f1;
+id group batch qty name
+1 0 0 0 foo
+2 0 0 0 fee
+3 42 0 0
+4 0 23 0
+5 0 0 1
+SELECT * FROM bup_nodata.b1;
+a b c
+SELECT * FROM bup_nodata.e1;
+Period Vapor_period
+#
+# Now drop the bup_data database with the base tables again.
+#
DROP DATABASE bup_data;
+#
+# Show that the data have gone.
+# The MERGE and FEDERATED tables have errors since
+# their base tables have been dropped with bup_data.
+#
+SHOW FULL TABLES FROM bup_nodata;
+Tables_in_bup_nodata Table_type
+b1 BASE TABLE
+e1 BASE TABLE
+f1 BASE TABLE
+merge1 BASE TABLE
+SELECT * FROM bup_nodata.merge1;
+ERROR 42S02: Table 'bup_data.myisam1' doesn't exist
+SELECT * FROM bup_nodata.f1;
+Got one of the listed errors
+SELECT * FROM bup_nodata.b1;
+a b c
+SELECT * FROM bup_nodata.e1;
+Period Vapor_period
+#
+# Cleanup.
+#
DROP DATABASE bup_nodata;
+UNINSTALL PLUGIN example;
=== added file 'mysql-test/suite/backup/t/backup_nodata_driver-master.opt'
--- a/mysql-test/suite/backup/t/backup_nodata_driver-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_nodata_driver-master.opt 2008-11-07 15:42:46 +0000
@@ -0,0 +1 @@
+$EXAMPLE_PLUGIN_OPT
=== modified file 'mysql-test/suite/backup/t/backup_nodata_driver.test'
--- a/mysql-test/suite/backup/t/backup_nodata_driver.test 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_nodata_driver.test 2008-11-07 15:42:46 +0000
@@ -1,5 +1,9 @@
#
# This test tests the backup using no data engines.
+# These are engines which tables don't contain data.
+# This is obvious for BLACKHOLE and EXAMPLE.
+# Other engines behave like placeholders for tables of other
+# engines and don't have data themselves. Examples are MERGE and FEDERATED.
# It was made a separate test due to the possibility that some
# of the engines used may not be available on all platforms or
# builds.
@@ -10,18 +14,26 @@
#
--source include/not_embedded.inc
--source include/have_federated_db.inc
---source include/have_exampledb.inc
+# MERGE is always available --source include/have_merge.inc
--source include/have_blackhole.inc
+#
+# Example engine must be loaded as plugin.
+# Currently this does not work on Windows yet.
+#
+--source include/not_windows.inc
+--source include/have_example_plugin.inc
+INSTALL PLUGIN example SONAME 'ha_example.so';
+--source include/have_exampledb.inc
--disable_warnings
DROP DATABASE IF EXISTS bup_nodata;
DROP DATABASE IF EXISTS bup_data;
--enable_warnings
-# Create data
---echo Creating tables
-CREATE DATABASE bup_nodata;
-
+--echo #
+--echo # Create a database with tables that can work as
+--echo # base tables for MERGE and FEDERATED.
+--echo #
CREATE DATABASE bup_data;
CREATE TABLE bup_data.myisam1 (a int, b char(30)) ENGINE=MYISAM;
@@ -39,6 +51,11 @@ CREATE TABLE bup_data.f1 (
)
DEFAULT CHARSET=latin1;
+--echo #
+--echo # Create a database with tables from no-data engines.
+--echo #
+CREATE DATABASE bup_nodata;
+
CREATE TABLE bup_nodata.merge1 (a int, b char(30))
ENGINE=MERGE UNION=(bup_data.myisam1, bup_data.myisam2, bup_data.myisam3);
@@ -60,8 +77,9 @@ CREATE TABLE bup_nodata.e1 (
Vapor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=example;
-# Insert some data (for merge and federated to ensure proper working tables)
---echo Inserting data
+--echo #
+--echo # Insert some data.
+--echo #
INSERT INTO bup_data.myisam1 VALUES (11, 'table 1');
INSERT INTO bup_data.myisam1 VALUES (12, 'table 1');
INSERT INTO bup_data.myisam1 VALUES (13, 'table 1');
@@ -78,43 +96,49 @@ INSERT INTO bup_data.f1 (id, `group`) VA
INSERT INTO bup_data.f1 (id, `batch`) VALUES (4, 23);
INSERT INTO bup_data.f1 (id, `qty`) VALUES (5, 1);
-# Show the data
---echo show data
+--echo #
+--echo # Show the data.
+--echo #
SHOW FULL TABLES FROM bup_data;
SHOW FULL TABLES FROM bup_nodata;
-
SELECT * FROM bup_nodata.merge1;
SELECT * FROM bup_nodata.f1;
SELECT * FROM bup_nodata.b1;
SELECT * FROM bup_nodata.e1;
-# Do the backup of the bup_data DB.
+--echo #
+--echo # Backup the bup_data DB, which tables contain data.
+--echo #
--replace_column 1 #
BACKUP DATABASE bup_data TO 'bup_data.bak';
-# Do the backup of the bup_nodata DB.
+--echo #
+--echo # Backup the bup_nodata DB, which tables do not contain data.
+--echo #
--replace_column 1 #
BACKUP DATABASE bup_nodata TO 'bup_nodata.bak';
-# Show the data
---echo show data
+--echo #
+--echo # Show the data again. Backup did not modify them.
+--echo #
SHOW FULL TABLES FROM bup_data;
SHOW FULL TABLES FROM bup_nodata;
-
SELECT * FROM bup_nodata.merge1;
SELECT * FROM bup_nodata.f1;
SELECT * FROM bup_nodata.b1;
SELECT * FROM bup_nodata.e1;
-# Now drop the data database and show what is left
-
+--echo #
+--echo # Now drop the bup_data database.
+--echo #
DROP DATABASE bup_data;
-# Show the data
---echo show data
+--echo #
+--echo # Show that the data have gone.
+--echo # The MERGE and FEDERATED tables have errors since
+--echo # their base tables have been dropped with bup_data.
+--echo #
SHOW FULL TABLES FROM bup_nodata;
-
-# The merge and federated tables should have errors since data is missing.
--error ER_NO_SUCH_TABLE
SELECT * FROM bup_nodata.merge1;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
@@ -122,18 +146,31 @@ SELECT * FROM bup_nodata.f1;
SELECT * FROM bup_nodata.b1;
SELECT * FROM bup_nodata.e1;
+--echo #
+--echo # Now drop the bup_nodata database too.
+--echo #
DROP DATABASE bup_nodata;
-# Now restore the nodata database and see if it is the same as above.
---echo Restoring nodata database.
+--echo #
+--echo # Now try to restore the bup_nodata database. This fails because
+--echo # restore opens the tables for filling them with data, even when
+--echo # they were empty on backup. 'bup_nodata.bak' does not contain
+--echo # the base tables for the MERGE and FEDERATED tables.
+--echo # NOTE: Since restore fails after restoring the meta data,
+--echo # after creating the tables that is, we have the same
+--echo # situation as before. The tables exist, but the base
+--echo # tables for MERGE and FEDERATED do not exist.
+--echo #
--replace_column 1 #
+--error ER_NO_SUCH_TABLE,ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
RESTORE FROM 'bup_nodata.bak';
-# Show the data
---echo show data
+--echo #
+--echo # Show what we have.
+--echo # NOTE: If restore would work as all or nothing,
+--echo # all of the SHOW and SELECT statements in this section would fail.
+--echo #
SHOW FULL TABLES FROM bup_nodata;
-
-# The merge and federated tables should have errors since data is missing.
--error ER_NO_SUCH_TABLE
SELECT * FROM bup_nodata.merge1;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
@@ -141,22 +178,64 @@ SELECT * FROM bup_nodata.f1;
SELECT * FROM bup_nodata.b1;
SELECT * FROM bup_nodata.e1;
-# Now restore the data database and see that all is well.
---echo Restoring data database.
+--echo #
+--echo # Now restore the bup_data database as well.
+--echo #
--replace_column 1 #
RESTORE FROM 'bup_data.bak';
-# Show the data
---echo show data
+--echo #
+--echo # Show that everything is well.
+--echo # NOTE: If restore would work as all or nothing,
+--echo # the bup_nodata tables would not exist here.
+--echo #
SHOW FULL TABLES FROM bup_data;
SHOW FULL TABLES FROM bup_nodata;
+SELECT * FROM bup_nodata.merge1;
+SELECT * FROM bup_nodata.f1;
+SELECT * FROM bup_nodata.b1;
+SELECT * FROM bup_nodata.e1;
+
+--echo #
+--echo # Now restore the bup_nodata database and see if it is the same
+--echo # as above. Note that this step would not be required here
+--echo # because all bup_nodata tables have no data and were created
+--echo # by the failed restore. Anyway, the correct approach is to do a
+--echo # succeeding restore before assuming that everything exists again.
+--echo #
+--replace_column 1 #
+RESTORE FROM 'bup_nodata.bak';
+--echo #
+--echo # Show that everything is well.
+--echo #
+SHOW FULL TABLES FROM bup_nodata;
SELECT * FROM bup_nodata.merge1;
SELECT * FROM bup_nodata.f1;
SELECT * FROM bup_nodata.b1;
SELECT * FROM bup_nodata.e1;
+--echo #
+--echo # Now drop the bup_data database with the base tables again.
+--echo #
DROP DATABASE bup_data;
+
+--echo #
+--echo # Show that the data have gone.
+--echo # The MERGE and FEDERATED tables have errors since
+--echo # their base tables have been dropped with bup_data.
+--echo #
+SHOW FULL TABLES FROM bup_nodata;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM bup_nodata.merge1;
+--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
+SELECT * FROM bup_nodata.f1;
+SELECT * FROM bup_nodata.b1;
+SELECT * FROM bup_nodata.e1;
+
+--echo #
+--echo # Cleanup.
+--echo #
DROP DATABASE bup_nodata;
--error 0,1
@@ -164,3 +243,5 @@ DROP DATABASE bup_nodata;
--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/bup_nodata.bak
+UNINSTALL PLUGIN example;
+