--source include/have_falcon.inc

#
# Bug #28095: Falcon Drop table causes crash
#
# Note: This test consists of two phases involving a "soft"
#    server restart with --shutdown_server. We do the
#    restart with the help of include/restart_mysqld.inc.
#
--echo *** Bug #28095: First phase ***

# ----------------------------------------------------- #
# --- Initialisation                                --- #
# ----------------------------------------------------- #
let $engine = 'Falcon';
eval SET @@storage_engine = $engine;

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings

CREATE TABLE t1 (a int);

# ----------------------------------------------------- #
# --- Test                                          --- #
# ----------------------------------------------------- #
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
SELECT * FROM t1 ORDER BY a;

CREATE TABLE t2 (b int);

#
# We set a global variable to make sure that the
# following restart really works. Global variables
# should be resetted after a server restart.
#
--let $debug = `SELECT @@GLOBAL.falcon_debug_mask;`
--replace_result $debug 0
SELECT @@GLOBAL.falcon_debug_mask;
SET GLOBAL falcon_debug_mask = 4096;
SELECT @@GLOBAL.falcon_debug_mask;

# ----------------------------------------------------- #
# --- Restart server                                --- #
# ----------------------------------------------------- #
--source include/restart_mysqld.inc

--echo *** Bug #28095: Second phase ***
SELECT * FROM t1 ORDER BY a;

# ----------------------------------------------------- #
# --- Check                                         --- #
# ----------------------------------------------------- #
SELECT count(*) FROM t1;
--replace_result $debug 0
SELECT @@GLOBAL.falcon_debug_mask;

# ----------------------------------------------------- #
# --- Final cleanup                                 --- #
# ----------------------------------------------------- #
DROP TABLE t1;
DROP TABLE t2;
