home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / mysql-test / t / bdb-deadlock.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  1.1 KB  |  49 lines  |  [TEXT/ttxt]

  1. # This test doesn't work with the embedded version as this code
  2. # assumes that one query is running while we are doing queries on
  3. # a second connection.
  4. # This would work if mysqltest run would be threaded and handle each
  5. # connection in a separate thread.
  6. #
  7.  
  8. #-- source include/not_embedded.inc
  9. -- source include/have_bdb.inc
  10.  
  11. connect (con1,localhost,root,,);
  12. connect (con2,localhost,root,,);
  13.  
  14. drop table if exists t1,t2;
  15. connection con1;
  16. create table t1 (id integer, x integer) type=BDB;
  17. create table t2 (id integer, x integer) type=BDB;
  18. insert into t1 values(0, 0);
  19. insert into t2 values(0, 0);
  20. set autocommit=0;
  21. update t1 set x = 1 where id = 0;
  22.  
  23. connection con2;
  24. set autocommit=0;
  25. update t2 set x = 1 where id = 0;
  26.  
  27. # The following query should hang because con1 is locking the page
  28. --send
  29. select x from t1 where id = 0;
  30.  
  31. connection con1;
  32. # This should generate a deadlock as we are trying to access a locked row
  33. --error 1213
  34. select x from t2 where id = 0;
  35. commit;
  36.  
  37. connection con2;
  38. reap;
  39. commit;
  40. select * from t1;
  41. select * from t2;
  42. commit;
  43.  
  44. connection con1;
  45. select * from t1;
  46. select * from t2;
  47. commit;
  48. drop table t1,t2;
  49.