You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.6 KiB

  1. -- source include/have_innodb.inc
  2. --disable_warnings
  3. drop table if exists t1,t2;
  4. --enable_warnings
  5. # BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer
  6. # (repeatable only w/innodb).
  7. create table t1 (
  8. c_id int(11) not null default '0',
  9. org_id int(11) default null,
  10. unique key contacts$c_id (c_id),
  11. key contacts$org_id (org_id)
  12. ) engine=innodb;
  13. insert into t1 values
  14. (2,null),(120,null),(141,null),(218,7), (128,1),
  15. (151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
  16. (246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
  17. create table t2 (
  18. slai_id int(11) not null default '0',
  19. owner_tbl int(11) default null,
  20. owner_id int(11) default null,
  21. sla_id int(11) default null,
  22. inc_web int(11) default null,
  23. inc_email int(11) default null,
  24. inc_chat int(11) default null,
  25. inc_csr int(11) default null,
  26. inc_total int(11) default null,
  27. time_billed int(11) default null,
  28. activedate timestamp null default null,
  29. expiredate timestamp null default null,
  30. state int(11) default null,
  31. sla_set int(11) default null,
  32. unique key t2$slai_id (slai_id),
  33. key t2$owner_id (owner_id),
  34. key t2$sla_id (sla_id)
  35. ) engine=innodb;
  36. insert into t2(slai_id, owner_tbl, owner_id, sla_id) values
  37. (1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7),
  38. (8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12);
  39. flush tables;
  40. select si.slai_id
  41. from t1 c join t2 si on
  42. ((si.owner_tbl = 3 and si.owner_id = c.org_id) or
  43. ( si.owner_tbl = 2 and si.owner_id = c.c_id))
  44. where
  45. c.c_id = 218 and expiredate is null;
  46. select * from t1 where org_id is null;
  47. select si.slai_id
  48. from t1 c join t2 si on
  49. ((si.owner_tbl = 3 and si.owner_id = c.org_id) or
  50. ( si.owner_tbl = 2 and si.owner_id = c.c_id))
  51. where
  52. c.c_id = 218 and expiredate is null;
  53. drop table t1, t2;
  54. #
  55. # Bug#17212: results not sorted correctly by ORDER BY when using index
  56. # (repeatable only w/innodb because of index props)
  57. #
  58. CREATE TABLE t1 (a int, b int, KEY b (b)) Engine=InnoDB;
  59. CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)) Engine=InnoDB;
  60. CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
  61. UNIQUE KEY b (b,c), KEY a (a,b,c)) Engine=InnoDB;
  62. INSERT INTO t1 VALUES (1, 1);
  63. INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
  64. INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
  65. INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
  66. INSERT INTO t2 SELECT a + 1, b FROM t2;
  67. DELETE FROM t2 WHERE a = 1 AND b < 2;
  68. INSERT INTO t3 VALUES (1,1,1),(2,1,2);
  69. INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
  70. INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
  71. # demonstrate a problem when a must-use-sort table flag
  72. # (sort_by_table=1) is being neglected.
  73. SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
  74. t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
  75. ORDER BY t1.b LIMIT 2;
  76. # demonstrate the problem described in the bug report
  77. SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
  78. t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
  79. ORDER BY t1.b LIMIT 5;
  80. DROP TABLE t1, t2, t3;
  81. # BUG#21077 (The testcase is not deterministic so correct execution doesn't
  82. # prove anything) For proof one should track if sequence of ha_innodb::* func
  83. # calls is correct.
  84. CREATE TABLE `t1` (`id1` INT) ;
  85. INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
  86. CREATE TABLE `t2` (
  87. `id1` INT,
  88. `id2` INT NOT NULL,
  89. `id3` INT,
  90. `id4` INT NOT NULL,
  91. UNIQUE (`id2`,`id4`),
  92. KEY (`id1`)
  93. ) ENGINE=InnoDB;
  94. INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
  95. (1,1,1,0),
  96. (1,1,2,1),
  97. (5,1,2,2),
  98. (6,1,2,3),
  99. (1,2,2,2),
  100. (1,2,1,1);
  101. SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
  102. DROP TABLE t1, t2;
  103. #
  104. # BUG#18819: DELETE IGNORE hangs on foreign key parent delete
  105. #
  106. # The bug itself does not relate to InnoDB, but we have to use foreign
  107. # keys to reproduce it.
  108. #
  109. --disable_warnings
  110. DROP TABLE IF EXISTS t2, t1;
  111. --enable_warnings
  112. CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB;
  113. CREATE TABLE t2 (
  114. i INT NOT NULL,
  115. FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION
  116. ) ENGINE= InnoDB;
  117. INSERT INTO t1 VALUES (1);
  118. INSERT INTO t2 VALUES (1);
  119. DELETE IGNORE FROM t1 WHERE i = 1;
  120. SELECT * FROM t1, t2;
  121. DROP TABLE t2, t1;
  122. #
  123. # Bug #22728 - Handler_rollback value is growing
  124. #
  125. flush status;
  126. create table t1 (c1 int) engine=innodb;
  127. connect (con1,localhost,root,,);
  128. connect (con2,localhost,root,,);
  129. connection con2;
  130. handler t1 open;
  131. handler t1 read first;
  132. disconnect con2;
  133. connection con1;
  134. show /*!50002 GLOBAL */ status like 'Handler_rollback';
  135. connection default;
  136. drop table t1;
  137. disconnect con1;
  138. --echo End of 4.1 tests