--source include/have_falcon.inc
#
# Bug #22842 - Falcon: unique-index creation quietly removes a row
#
--echo #***  Bug 22842 ***

SET storage_engine = Falcon;

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

--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);

--echo # Switch to connection default
connection default;

SET @@autocommit=0;
CREATE TABLE t1 (s1 int, s2 int) engine=falcon;
START TRANSACTION;
INSERT INTO t1 VALUES (1,1);

--echo # Switch to connection conn1
connection conn1;
SET @@autocommit = 0;
START TRANSACTION;
INSERT INTO t1 VALUES (1,2);


--echo # Switch to connection default
connection default;
--error ER_CANT_LOCK
CREATE UNIQUE INDEX i ON t1 (s1);
COMMIT;

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

--echo # Switch to connection default
connection default;
SELECT * FROM t1;

# Final cleanup
disconnect conn1;
DROP TABLE t1;
