mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into neptunus.(none):/home/msvensson/mysql/mysql-5.0
This commit is contained in:
@ -2355,6 +2355,74 @@ EXPLAIN SELECT i FROM t1 WHERE i=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
|
||||
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
|
||||
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
1 SIMPLE t2 ref a a 23 test.t1.a 2
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
1 SIMPLE t2 ref a a 23 test.t1.a 2
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 ( city char(30) );
|
||||
INSERT INTO t1 VALUES ('London');
|
||||
INSERT INTO t1 VALUES ('Paris');
|
||||
SELECT * FROM t1 WHERE city='London';
|
||||
city
|
||||
London
|
||||
SELECT * FROM t1 WHERE city='london';
|
||||
city
|
||||
London
|
||||
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
city
|
||||
London
|
||||
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
city
|
||||
London
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int(11) unsigned, b int(11) unsigned);
|
||||
insert into t1 values (1,0), (1,1), (1,2);
|
||||
select a-b from t1 order by 1;
|
||||
a-b
|
||||
0
|
||||
1
|
||||
18446744073709551615
|
||||
select a-b , (a-b < 0) from t1 order by 1;
|
||||
a-b (a-b < 0)
|
||||
0 0
|
||||
1 0
|
||||
18446744073709551615 0
|
||||
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
|
||||
d (a-b >= 0) b
|
||||
1 1 0
|
||||
0 1 1
|
||||
18446744073709551615 1 2
|
||||
select cast((a - b) as unsigned) from t1 order by 1;
|
||||
cast((a - b) as unsigned)
|
||||
0
|
||||
1
|
||||
18446744073709551615
|
||||
drop table t1;
|
||||
create table t1 (a int(11));
|
||||
select all all * from t1;
|
||||
a
|
||||
select distinct distinct * from t1;
|
||||
a
|
||||
select all distinct * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
select distinct all * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
|
||||
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
|
||||
@ -2486,3 +2554,125 @@ ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
select distinct all * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
|
||||
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
|
||||
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
1 SIMPLE t2 ref a a 23 test.t1.a 2
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
1 SIMPLE t2 ref a a 23 test.t1.a 2
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 ( city char(30) );
|
||||
INSERT INTO t1 VALUES ('London');
|
||||
INSERT INTO t1 VALUES ('Paris');
|
||||
SELECT * FROM t1 WHERE city='London';
|
||||
city
|
||||
London
|
||||
SELECT * FROM t1 WHERE city='london';
|
||||
city
|
||||
London
|
||||
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
city
|
||||
London
|
||||
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
city
|
||||
London
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int(11) unsigned, b int(11) unsigned);
|
||||
insert into t1 values (1,0), (1,1), (1,2);
|
||||
select a-b from t1 order by 1;
|
||||
a-b
|
||||
0
|
||||
1
|
||||
18446744073709551615
|
||||
select a-b , (a-b < 0) from t1 order by 1;
|
||||
a-b (a-b < 0)
|
||||
0 0
|
||||
1 0
|
||||
18446744073709551615 0
|
||||
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
|
||||
d (a-b >= 0) b
|
||||
1 1 0
|
||||
0 1 1
|
||||
18446744073709551615 1 2
|
||||
select cast((a - b) as unsigned) from t1 order by 1;
|
||||
cast((a - b) as unsigned)
|
||||
0
|
||||
1
|
||||
18446744073709551615
|
||||
drop table t1;
|
||||
create table t1 (a int(11));
|
||||
select all all * from t1;
|
||||
a
|
||||
select distinct distinct * from t1;
|
||||
a
|
||||
select all distinct * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
select distinct all * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
kunde_intern_id int(10) unsigned NOT NULL default '0',
|
||||
kunde_id int(10) unsigned NOT NULL default '0',
|
||||
FK_firma_id int(10) unsigned NOT NULL default '0',
|
||||
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
|
||||
vorname varchar(128) NOT NULL default '',
|
||||
nachname varchar(128) NOT NULL default '',
|
||||
geloescht enum('Ja','Nein') NOT NULL default 'Nein',
|
||||
firma varchar(128) NOT NULL default ''
|
||||
);
|
||||
INSERT INTO t1 VALUES
|
||||
(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'),
|
||||
(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX');
|
||||
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
( '' != '' AND firma LIKE CONCAT('%', '', '%'))
|
||||
OR
|
||||
(vorname LIKE CONCAT('%', 'Vorname1', '%') AND
|
||||
nachname LIKE CONCAT('%', '1Nachname', '%') AND
|
||||
'Vorname1' != '' AND 'xxxx' != '')
|
||||
)
|
||||
AND
|
||||
(
|
||||
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
|
||||
)
|
||||
)
|
||||
;
|
||||
kunde_id FK_firma_id aktuell vorname nachname geloescht
|
||||
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname,
|
||||
geloescht FROM t1
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
|
||||
)
|
||||
AND
|
||||
(
|
||||
( '' != '' AND firma LIKE CONCAT('%', '', '%') )
|
||||
OR
|
||||
( vorname LIKE CONCAT('%', 'Vorname1', '%') AND
|
||||
nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND
|
||||
'xxxx' != '')
|
||||
)
|
||||
)
|
||||
;
|
||||
kunde_id FK_firma_id aktuell vorname nachname geloescht
|
||||
SELECT COUNT(*) FROM t1 WHERE
|
||||
( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1))
|
||||
AND FK_firma_id = 2;
|
||||
COUNT(*)
|
||||
0
|
||||
drop table t1;
|
||||
|
@ -1939,6 +1939,64 @@ EXPLAIN SELECT i FROM t1 WHERE i=1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Test case for bug 7520: a wrong cost of the index for a BLOB field
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
|
||||
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
|
||||
|
||||
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
|
||||
#
|
||||
# Test case for bug 7098: substitution of a constant for a string field
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( city char(30) );
|
||||
INSERT INTO t1 VALUES ('London');
|
||||
INSERT INTO t1 VALUES ('Paris');
|
||||
|
||||
SELECT * FROM t1 WHERE city='London';
|
||||
SELECT * FROM t1 WHERE city='london';
|
||||
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
|
||||
#
|
||||
|
||||
create table t1 (a int(11) unsigned, b int(11) unsigned);
|
||||
insert into t1 values (1,0), (1,1), (1,2);
|
||||
select a-b from t1 order by 1;
|
||||
select a-b , (a-b < 0) from t1 order by 1;
|
||||
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
|
||||
select cast((a - b) as unsigned) from t1 order by 1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
#
|
||||
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
|
||||
#
|
||||
create table t1 (a int(11));
|
||||
select all all * from t1;
|
||||
select distinct distinct * from t1;
|
||||
--error 1221
|
||||
select all distinct * from t1;
|
||||
--error 1221
|
||||
select distinct all * from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test for bug #6474
|
||||
#
|
||||
@ -2072,3 +2130,119 @@ drop table t1;
|
||||
|
||||
|
||||
#
|
||||
# Test case for bug 7520: a wrong cost of the index for a BLOB field
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
|
||||
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
|
||||
|
||||
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
|
||||
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
|
||||
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
#
|
||||
# Test case for bug 7098: substitution of a constant for a string field
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( city char(30) );
|
||||
INSERT INTO t1 VALUES ('London');
|
||||
INSERT INTO t1 VALUES ('Paris');
|
||||
|
||||
SELECT * FROM t1 WHERE city='London';
|
||||
SELECT * FROM t1 WHERE city='london';
|
||||
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
SELECT * FROM t1 WHERE city='London' AND city='london';
|
||||
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
|
||||
#
|
||||
|
||||
create table t1 (a int(11) unsigned, b int(11) unsigned);
|
||||
insert into t1 values (1,0), (1,1), (1,2);
|
||||
select a-b from t1 order by 1;
|
||||
select a-b , (a-b < 0) from t1 order by 1;
|
||||
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
|
||||
select cast((a - b) as unsigned) from t1 order by 1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
#
|
||||
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
|
||||
#
|
||||
create table t1 (a int(11));
|
||||
select all all * from t1;
|
||||
select distinct distinct * from t1;
|
||||
--error 1221
|
||||
select all distinct * from t1;
|
||||
--error 1221
|
||||
select distinct all * from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test for BUG#10095
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
kunde_intern_id int(10) unsigned NOT NULL default '0',
|
||||
kunde_id int(10) unsigned NOT NULL default '0',
|
||||
FK_firma_id int(10) unsigned NOT NULL default '0',
|
||||
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
|
||||
vorname varchar(128) NOT NULL default '',
|
||||
nachname varchar(128) NOT NULL default '',
|
||||
geloescht enum('Ja','Nein') NOT NULL default 'Nein',
|
||||
firma varchar(128) NOT NULL default ''
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'),
|
||||
(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX');
|
||||
|
||||
|
||||
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
( '' != '' AND firma LIKE CONCAT('%', '', '%'))
|
||||
OR
|
||||
(vorname LIKE CONCAT('%', 'Vorname1', '%') AND
|
||||
nachname LIKE CONCAT('%', '1Nachname', '%') AND
|
||||
'Vorname1' != '' AND 'xxxx' != '')
|
||||
)
|
||||
AND
|
||||
(
|
||||
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname,
|
||||
geloescht FROM t1
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
|
||||
)
|
||||
AND
|
||||
(
|
||||
( '' != '' AND firma LIKE CONCAT('%', '', '%') )
|
||||
OR
|
||||
( vorname LIKE CONCAT('%', 'Vorname1', '%') AND
|
||||
nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND
|
||||
'xxxx' != '')
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
SELECT COUNT(*) FROM t1 WHERE
|
||||
( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1))
|
||||
AND FK_firma_id = 2;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
Reference in New Issue
Block a user