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.

105 lines
2.2 KiB

  1. # Initialize tables for the test
  2. --disable_warnings
  3. drop table if exists x1;
  4. drop table if exists x2;
  5. --enable_warnings
  6. set @tmp_subselect_nulls=@@optimizer_switch;
  7. set optimizer_switch='semijoin=off';
  8. create table x1(k int primary key, d1 int, d2 int);
  9. create table x2(k int primary key, d1 int, d2 int);
  10. insert into x1 values
  11. (10, 10, 10),
  12. (20, 20, 20),
  13. (21, 20, null),
  14. (30, null, 30),
  15. (40, 40, 40);
  16. insert into x2 values
  17. (10, 10, 10),
  18. (20, 20, 20),
  19. (21, 20, null),
  20. (30, null, 30);
  21. # Test various IN and EXISTS queries with NULL values and UNKNOWN
  22. # Q1 T=(10, 20) U=(21,30) F=(40)
  23. select *
  24. from x1
  25. where (d1, d2) in (select d1, d2
  26. from x2);
  27. select *
  28. from x1
  29. where (d1, d2) in (select d1, d2
  30. from x2) is true;
  31. select *
  32. from x1
  33. where (d1, d2) in (select d1, d2
  34. from x2) is false;
  35. select *
  36. from x1
  37. where (d1, d2) in (select d1, d2
  38. from x2) is unknown;
  39. # Q2 T=(10, 20) U=(30) F=(21, 40)
  40. select *
  41. from x1
  42. where d1 in (select d1
  43. from x2
  44. where x1.d2=x2.d2);
  45. select *
  46. from x1
  47. where d1 in (select d1
  48. from x2
  49. where x1.d2=x2.d2) is true;
  50. select *
  51. from x1
  52. where d1 in (select d1
  53. from x2
  54. where x1.d2=x2.d2) is false;
  55. select *
  56. from x1
  57. where d1 in (select d1
  58. from x2
  59. where x1.d2=x2.d2) is unknown;
  60. # Q3 T=(10, 20) U=() F=(21, 30, 40)
  61. select *
  62. from x1
  63. where 1 in (select 1
  64. from x2
  65. where x1.d1=x2.d1 and x1.d2=x2.d2);
  66. select *
  67. from x1
  68. where 1 in (select 1
  69. from x2
  70. where x1.d1=x2.d1 and x1.d2=x2.d2) is true;
  71. select *
  72. from x1
  73. where 1 in (select 1
  74. from x2
  75. where x1.d1=x2.d1 and x1.d2=x2.d2) is false;
  76. select *
  77. from x1
  78. where 1 in (select 1
  79. from x2
  80. where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown;
  81. # Q4 T=(10, 20) F=(21, 30, 40)
  82. select *
  83. from x1
  84. where exists (select *
  85. from x2
  86. where x1.d1=x2.d1 and x1.d2=x2.d2);
  87. set optimizer_switch= @tmp_subselect_nulls;
  88. drop table x1;
  89. drop table x2;
  90. #
  91. # MDEV-7339 Server crashes in Item_func_trig_cond::val_int
  92. #
  93. select (select 1, 2) in (select 3, 4);
  94. select (select NULL, NULL) in (select 3, 4);