# subtest of the not yet pushed test mix1_falcon
# Please remove this test(falcon_bug_24079) if mix1_falcon is pushed, because mix1_falcon is the test where
# the bug was detected.

-- source include/have_innodb.inc
-- source include/have_falcon.inc
let $engine_type= Falcon;

eval SET SESSION STORAGE_ENGINE = $engine_type;

--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings

####### Bad
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,2);

CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
SELECT * FROM t3;
DROP TABLE t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;


####### Without INSERT into t1 -- good
CREATE TABLE t1 (a int, b int);
### insert into t1 values (1,2);

CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
SELECT * FROM t3;
DROP TABLE t3;
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;


####### Without t1 at all -- good
### CREATE TABLE t1 (a int, b int);
### insert into t1 values (1,2);

CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
SELECT * FROM t3;
DROP TABLE t3;
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
### DROP TABLE t1;
DROP TABLE t2;


####### first t2 is permanent instead of temporary table -- good
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,2);

#### CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
CREATE TABLE t3 ( f1 CHAR(10));
SELECT * FROM t3;
DROP TABLE t3;
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;


####### SELECT FROM first t3 omitted -- good
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,2);

CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
#### SELECT * FROM t3;
DROP TABLE t3;
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;


####### Without BEGIN -- bad on INSERT dupl key, but DROP TABLE t2 problem disappears
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,2);

CREATE TEMPORARY TABLE t3 ( f1 CHAR(10));
SELECT * FROM t3;
DROP TABLE t3;
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;

CREATE TABLE t2 (a int, b int, primary key (a));
SELECT * FROM t2;
### BEGIN;
INSERT INTO t2 values(100,100);
SELECT * FROM t2;

--error ER_DUP_ENTRY
INSERT INTO t2 select 1,1 UNION ALL SELECT 1,1;

SELECT * from t2;
ROLLBACK;

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;
