--echo #---- Bug 201 ----

SET STORAGE_ENGINE='Falcon';
#                                                                     #
# This test is derived from innodb.test                               #
#                                                                     #

--enable_abort_on_error

--disable_warnings
drop table if exists t1;
--enable_warnings

# Second test of falconx derived from innodb.test
# Heavy simplified variant
--echo # If I remove the auto_increment, the crash on the update disappers
CREATE TABLE t1 (
  id BIGINT NOT NULL auto_increment,
  parent_id BIGINT,
  PRIMARY KEY (id)
);

INSERT INTO t1 VALUES (9,2),(24,4);

--echo # This UPDATE gets a crash
update t1 set parent_id=parent_id+100;

# Is the server alive ?
SELECT * FROM t1;

DROP TABLE t1;

# Second test of falconx derived from innodb.test
# Slightly simplified variant
CREATE TABLE t1 (
  id int(11) NOT NULL auto_increment,
  parent_id int(11) DEFAULT '0' NOT NULL,
  level tinyint(4) DEFAULT '0' NOT NULL,
  PRIMARY KEY (id),
  KEY parent_id (parent_id),
  KEY level (level)
);

INSERT INTO t1 VALUES (9,2,2),(24,4,2);

--echo # This UPDATE gets a crash
update t1 set parent_id=parent_id+100;

--error ER_DUP_ENTRY_WITH_KEY_NAME,1022
update t1 set id=24 where id=9; 

# Is the server alive ?
SELECT * FROM t1;

# Final cleanup.
DROP TABLE t1;
