# Test how online backup handles tables using non-existent storage engines
# The server used to crash in this situation (BUG#30938)

--source include/not_embedded.inc

# .frm file for a table using non-existent storage engine
--let $table_def=$MYSQL_TEST_DIR/std_data/bug30938.frm

let $MYSQLD_DATADIR= `SELECT @@datadir`;
let $MYSQLD_BACKUPDIR= `SELECT @@backupdir`;
--disable_warnings
DROP DATABASE IF EXISTS db;
--enable_warnings

CREATE DATABASE db;
CREATE TABLE db.t1 (a int, b char(32))
;

# copy description of a table using non-existent storage engine
copy_file $table_def $MYSQLD_DATADIR/db/t2.frm;

# backup test database, the table with no storage engine will be ignored
--replace_column 1 #
BACKUP DATABASE db TO "db.backup";

# wipe-out backed-up database
DROP DATABASE db;
CREATE DATABASE db;

--replace_column 1 #
RESTORE FROM "db.backup";

# check that the table with no engine was excluded
SHOW TABLES IN db;
# check that table t was correctly restored
SHOW CREATE TABLE db.t1;	

# clean up
DROP DATABASE db;
remove_file $MYSQLD_BACKUPDIR/db.backup;
