Commit bbbfd3e2 authored by unknown's avatar unknown

Added NULL value tests for UNIQUE index

parent 6c81b518
......@@ -44,6 +44,51 @@ a b c
7 8 3
8 2 3
drop table t1;
CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned,
c int unsigned,
UNIQUE bc(b,c)
) engine = ndb;
insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL);
select * from t1 use index (bc) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc)order by a;
a b c
1 1 1
2 NULL 2
3 NULL NULL
4 4 NULL
select * from t1 use index (bc) order by a;
a b c
1 1 1
2 NULL 2
3 NULL NULL
4 4 NULL
select * from t1 use index (PRIMARY) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc) where b IS NULL and c IS NULL order by a;
a b c
select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
a b c
select * from t1 use index (bc) where b < 4 order by a;
a b c
1 1 1
select * from t1 use index (bc) where b IS NOT NULL order by a;
a b c
1 1 1
4 4 NULL
insert into t1 values(5,1,1);
ERROR 23000: Duplicate entry '5' for key 1
drop table t1;
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
......
......@@ -30,6 +30,32 @@ select * from t1 order by a;
drop table t1;
#
# Indexing NULL values
#
CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned,
c int unsigned,
UNIQUE bc(b,c)
) engine = ndb;
insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL);
select * from t1 use index (bc) where b IS NULL order by a;
select * from t1 use index (bc)order by a;
select * from t1 use index (bc) order by a;
select * from t1 use index (PRIMARY) where b IS NULL order by a;
select * from t1 use index (bc) where b IS NULL order by a;
select * from t1 use index (bc) where b IS NULL and c IS NULL order by a;
select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
select * from t1 use index (bc) where b < 4 order by a;
select * from t1 use index (bc) where b IS NOT NULL order by a;
-- error 1062
insert into t1 values(5,1,1);
drop table t1;
#
# Show use of UNIQUE USING HASH indexes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment