#Start server with MyISAM
--source include/force_myisam_default.inc

--disable_query_log
if (`select locate('semijoin', @@optimizer_switch) > 0`) 
{
  set optimizer_switch='semijoin=off';
}
if (`select locate('materialization', @@optimizer_switch) > 0`) 
{
  set optimizer_switch='materialization=off';
}
if (`select locate('index_condition_pushdown', @@optimizer_switch) > 0`) 
{
  set optimizer_switch='index_condition_pushdown=off';
}
if (`select locate('mrr', @@optimizer_switch) > 0`) 
{
  set optimizer_switch='mrr=off';
}
--enable_query_log

if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL
            + $VIEW_PROTOCOL > 0`)
{
   --skip Need normal protocol
}

--source suite/opt_trace/include/bugs.inc

--echo #
--echo # BUG#18365641: SERVER EXIT IN TRACE OF QUICK SELECT
--echo #

CREATE TABLE t1 (  
  pk INT(11),
  i1 INT(11),
  vc VARCHAR(10),  
  vc2 VARCHAR(10),
  PRIMARY KEY (pk), 
  KEY i1 (i1),
  KEY vc (vc)
) ENGINE=InnoDB;

INSERT INTO t1 VALUES (1, -1281753088,'p','r');
INSERT INTO t1 VALUES (4, NULL,'a','i');
INSERT INTO t1 VALUES (5, NULL,'lhtrovamzq','t');
INSERT INTO t1 VALUES (6, 3,'d','RZDUH');
INSERT INTO t1 VALUES (7, 951910400,'z','it\'s');
INSERT INTO t1 VALUES (8, 1067319296,'get','WZJHD');
INSERT INTO t1 VALUES (9, -1666187264,'zqrdcenchy','me');
INSERT INTO t1 VALUES (10, NULL,'what','there');

CREATE TABLE t2 (
  vc VARCHAR(10),
  pk INT(11),
  PRIMARY KEY (pk),
  KEY vc2 (vc)
);

INSERT INTO t2 VALUES ('ukkoeiwsgp',1);

# Opt trace needs to be 'on' to reproduce, but the 
# trace itself is not interesting

EXPLAIN
SELECT *
FROM t1 LEFT JOIN t2
     ON t1.i1 < t2.vc
WHERE t1.vc IN ( 'AVZPQ' )
      OR t1.i1 IS NULL AND t1.pk >= 9;

SELECT *
FROM t1 LEFT JOIN t2
     ON t1.i1 < t2.vc
WHERE t1.vc IN ( 'AVZPQ' )
      OR t1.i1 IS NULL AND t1.pk >= 9;

DROP TABLE t1, t2;
