SET @@storage_engine = Falcon;
#
# Mantis bug #233: Loss of data after INSERT and ALTER with two 
#                  interleaving transactions
#
--echo *** Bug #233 ***
--disable_warnings
DROP DATABASE IF EXISTS falcon6;
--enable_warnings
CREATE DATABASE falcon6;
USE falcon6;
SET @@autocommit = 0;
CREATE TABLE t (s1 int primary key, s2 varchar(10000), s3 blob);
INSERT INTO t VALUES (3,'a','a');

--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
SET @@storage_engine = Falcon;
USE falcon6;
# ALTER TABLE on table with pending transactions
# does not work with Falcon. However, the error message
# is misleading.
--error 1015
ALTER TABLE t DROP PRIMARY KEY;
SET @@autocommit = 0;
START TRANSACTION;
--send INSERT INTO t VALUES (3,'b','b')

--echo # Switch to connection default
connection default;
# We get a "multiple primary key defined", as the previous
# DROP PRIMARY KEY did not worked.
--error 1068
ALTER TABLE t ADD PRIMARY KEY (s1);
COMMIT;

--echo # Switch to connection conn1
connection conn1;
--error ER_DUP_ENTRY_WITH_KEY_NAME
--reap
COMMIT;
ALTER TABLE t DROP PRIMARY KEY;

--echo # Switch to connection default
connection default;
SELECT * FROM t;
COMMIT;

--echo # Switch to connection conn1
connection conn1;
COMMIT;

--echo # Switch to connection default
connection default;

# Final cleanup.
disconnect conn1;
DROP DATABASE falcon6;
USE test;
