Drizzled Public API Documentation

select_for_update.inc

00001 # 
00002 # Test to verify updates from SELECT FOR UPDATE are handled 
00003 # properly, an update is not put in the log for a update that
00004 # times out. 
00005 # 
00006 
00007 SET @orig_lock_wait_timeout= @@innodb_lock_wait_timeout;
00008 SELECT @orig_lock_wait_timeout;
00009 SET GLOBAL innodb_lock_wait_timeout=2;
00010 
00011 --disable_warnings
00012 DROP TABLE IF EXISTS t1;
00013 --enable_warnings
00014 
00015 CREATE TABLE t1 (
00016   id INT NOT NULL
00017 , padding VARCHAR(200) NOT NULL
00018 , PRIMARY KEY (id)
00019 );
00020 
00021 INSERT INTO t1 VALUES (1, "I love testing.");
00022 INSERT INTO t1 VALUES (3, "I hate testing.");
00023 INSERT INTO t1 VALUES (5, "I still hate testing.");
00024 
00025 connect (conn1, localhost, root,,);
00026 connect (conn2, localhost, root,,);
00027 
00028 connection conn1;
00029 START TRANSACTION;
00030 SELECT id FROM t1 FOR UPDATE;
00031 
00032 connection conn2;
00033 # This should timeout and not appear in the transaction log
00034 --error ER_LOCK_WAIT_TIMEOUT
00035 UPDATE t1 SET id=1000 WHERE padding='I love testing.';
00036 
00037 connection conn1;
00038 UPDATE t1 SET id=id + 1;
00039 COMMIT;
00040 
00041 connection default;
00042 disconnect conn1;
00043 disconnect conn2;
00044 DROP TABLE t1;
00045 
00046 SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;