--source include/have_falcon.inc
#
# Bug #31295: NULL alter table operation causes falcon table to lose it's
#             tablespace assoc 
#
--echo *** Bug #31295 ***

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

--disable_warnings
DROP TABLE IF EXISTS t1;
--error 0,ER_NO_SUCH_TABLESPACE
eval DROP TABLESPACE ts1 ENGINE $engine;
--enable_warnings

eval CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.fts' ENGINE $engine;
CREATE TABLE t1(a int);

# ----------------------------------------------------- #
# --- Test                                          --- #
# ----------------------------------------------------- #
--replace_result $engine ENGINE
SHOW CREATE TABLE t1;
eval ALTER TABLE t1 TABLESPACE ts1 ENGINE $engine;
--replace_result $engine ENGINE
SHOW CREATE TABLE t1;
eval ALTER TABLE t1 ENGINE $engine;
--replace_result $engine ENGINE
SHOW CREATE TABLE t1;

# ----------------------------------------------------- #
# --- Check                                         --- #
# ----------------------------------------------------- #
SELECT count(*) FROM t1;

# ----------------------------------------------------- #
# --- Final cleanup                                 --- #
# ----------------------------------------------------- #
DROP TABLE t1;
eval DROP TABLESPACE ts1 ENGINE $engine;
