mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
merge
This commit is contained in:
@ -263,3 +263,84 @@ score count(*)
|
||||
2 1
|
||||
1 2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a char(1));
|
||||
INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL);
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 5
|
||||
B 5
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
binary a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
binary a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SET SQL_BIG_TABLES=1;
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 5
|
||||
B 5
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
binary a
|
||||
NULL
|
||||
A
|
||||
B
|
||||
a
|
||||
b
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
binary a count(*)
|
||||
NULL 3
|
||||
A 4
|
||||
B 4
|
||||
a 1
|
||||
b 1
|
||||
SET SQL_BIG_TABLES=0;
|
||||
drop table t1;
|
||||
|
@ -165,3 +165,29 @@ explain select * from t1 where btn="a" and new_col="a";
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref btn btn 11 const,const 10 where used
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a (a),
|
||||
UNIQUE b (b)
|
||||
) type=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref a a 5 const 10 where used
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref b b 5 const 1 where used
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
Duplicate entry '3' for key 1
|
||||
DROP TABLE t1;
|
||||
|
@ -40,7 +40,6 @@ insert into t1 values (null);
|
||||
select * from t1 where x != 0;
|
||||
x
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
indexed_field int default NULL,
|
||||
KEY indexed_field (indexed_field)
|
||||
|
@ -286,15 +286,15 @@ a b c
|
||||
1 NULL NULL
|
||||
explain select * from t1 where a = 1 order by a desc, b desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref a a 4 const 5 where used; Using index; Using filesort
|
||||
t1 ref a a 4 const 5 where used; Using index
|
||||
select * from t1 where a = 1 order by a desc, b desc;
|
||||
a b c
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 NULL
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 NULL NULL
|
||||
1 NULL b
|
||||
1 NULL NULL
|
||||
explain select * from t1 where a = 1 and b is null order by a desc, b desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref a a 9 const,const 2 where used; Using index; Using filesort
|
||||
|
@ -243,3 +243,26 @@ select sql_big_result spid,sum(userid) from t1 group by spid desc;
|
||||
explain select sql_big_result score,count(*) from t1 group by score desc;
|
||||
select sql_big_result score,count(*) from t1 group by score desc;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Compare with hash keys
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a char(1));
|
||||
INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL);
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
# Do the same tests with MyISAM temporary tables
|
||||
SET SQL_BIG_TABLES=1;
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
SELECT a,count(*) FROM t1 GROUP BY a;
|
||||
SELECT a FROM t1 GROUP BY binary a;
|
||||
SELECT a,count(*) FROM t1 GROUP BY binary a;
|
||||
SELECT binary a FROM t1 GROUP BY 1;
|
||||
SELECT binary a,count(*) FROM t1 GROUP BY 1;
|
||||
SET SQL_BIG_TABLES=0;
|
||||
drop table t1;
|
||||
|
@ -100,3 +100,25 @@ update t1 set new_col=btn;
|
||||
explain select * from t1 where btn="a";
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test of NULL keys
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a (a),
|
||||
UNIQUE b (b)
|
||||
) type=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
|
||||
--error 1062
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
DROP TABLE t1;
|
||||
|
@ -25,7 +25,6 @@ drop table t1;
|
||||
# Test problem med index on NULL columns and testing with =NULL;
|
||||
#
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
indexed_field int default NULL,
|
||||
KEY indexed_field (indexed_field)
|
||||
|
Reference in New Issue
Block a user