config root man

Current Path : /home/usr.opt/mysql57/mysql-test/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : /home/usr.opt/mysql57/mysql-test/t/subquery_bugs.test

--echo #
--echo # Bug#27182010 SUBQUERY INCORRECTLY SHOWS DUPLICATE VALUES ON SUBQUERIES
--echo #

CREATE TABLE p (Id INT,PRIMARY KEY (Id));
INSERT INTO p VALUES (1);

--echo # Test UNIQUE KEY with NULL values
CREATE TABLE s (Id INT, u INT, UNIQUE KEY o(Id, u) );
INSERT INTO s VALUES (1, NULL),(1, NULL);

let query1= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s.Id FROM s WHERE Id=1 AND u IS NULL)ORDER BY Id DESC;
let query2= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s.Id FROM s WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC;

eval EXPLAIN $query1;
eval EXPLAIN $query2;

eval $query1;
eval $query2;

--echo # UNIQUE KEY without NULL values
CREATE TABLE s1 (Id INT, u INT, UNIQUE KEY o(Id, u) );
INSERT INTO s1 VALUES (1, 2),(1, 3);

let query3= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s1.Id FROM s1 WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC;
let query4= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s1.Id FROM s1 WHERE Id=1 AND u != 1) ORDER BY Id DESC;

eval EXPLAIN $query3;
eval EXPLAIN $query4;

eval $query3;
eval $query4;

--echo # NON UNIQUE KEY Scenario
CREATE TABLE s2 (Id INT, u INT, KEY o(Id, u) );
INSERT INTO s2 VALUES (1, NULL),(1, NULL);

let query5= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s.Id FROM s2 s WHERE Id=1 AND u IS NULL) ORDER BY Id DESC;

--echo #UNIQUE KEY with NON NULL FIELDS
CREATE TABLE s3 (Id INT NOT NULL, u INT NOT NULL, UNIQUE KEY o(Id, u));
INSERT INTO s3 VALUES (1, 2),(1, 3);

let query6= SELECT p.Id FROM (p) WHERE p.Id IN (
            SELECT s.Id FROM s3 s WHERE Id=1 AND u IS NOT NULL)
            ORDER BY Id DESC;

eval EXPLAIN $query5;
eval EXPLAIN $query6;

eval $query5;
eval $query6;

DROP TABLE p, s, s1, s2, s3;

Man Man