mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
merge
This commit is contained in:
commit
7eaf0975ac
35 changed files with 519 additions and 72 deletions
|
@ -77,9 +77,7 @@ IF(UNIX)
|
|||
IF(INSTALL_LAYOUT MATCHES "RPM")
|
||||
SET(default_prefix "/usr")
|
||||
ELSEIF(INSTALL_LAYOUT MATCHES "DEB")
|
||||
SET(default_prefix "/opt/mysql/server-${MYSQL_BASE_VERSION}")
|
||||
# This is required to avoid "cpack -GDEB" default of prefix=/usr
|
||||
SET(CPACK_SET_DESTDIR ON)
|
||||
SET(default_prefix "/usr")
|
||||
ELSEIF(INSTALL_LAYOUT MATCHES "SVR4")
|
||||
SET(default_prefix "/opt/mysql/mysql")
|
||||
ELSE()
|
||||
|
@ -191,7 +189,7 @@ SET(INSTALL_SUPPORTFILESDIR_DEB "support-files")
|
|||
SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql")
|
||||
SET(INSTALL_PLUGINTESTDIR_DEB ${plugin_tests})
|
||||
|
||||
SET(INSTALL_UNIX_ADDRDIR_DEB "/tmp/mysql.sock")
|
||||
SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock")
|
||||
#
|
||||
# SVR4 layout
|
||||
#
|
||||
|
|
|
@ -20,7 +20,17 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 range g g 34 NULL 8 Using where
|
||||
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
||||
fid AsText(g)
|
||||
1 LINESTRING(150 150,150 150)
|
||||
3 LINESTRING(148 148,152 152)
|
||||
4 LINESTRING(147 147,153 153)
|
||||
5 LINESTRING(146 146,154 154)
|
||||
6 LINESTRING(145 145,155 155)
|
||||
7 LINESTRING(144 144,156 156)
|
||||
8 LINESTRING(143 143,157 157)
|
||||
9 LINESTRING(142 142,158 158)
|
||||
10 LINESTRING(141 141,159 159)
|
||||
11 LINESTRING(140 140,160 160)
|
||||
2 LINESTRING(149 149,151 151)
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
|
@ -45,5 +55,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
|
||||
GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
|
||||
fid AsText(g)
|
||||
46 LINESTRING(51 41,60 50)
|
||||
56 LINESTRING(41 41,50 50)
|
||||
45 LINESTRING(51 51,60 60)
|
||||
DROP TABLE t1;
|
||||
End of 5.5 tests.
|
||||
|
|
|
@ -170,7 +170,17 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 range g g 34 NULL 8 Using where
|
||||
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
||||
fid AsText(g)
|
||||
1 LINESTRING(150 150,150 150)
|
||||
3 LINESTRING(148 148,152 152)
|
||||
4 LINESTRING(147 147,153 153)
|
||||
5 LINESTRING(146 146,154 154)
|
||||
6 LINESTRING(145 145,155 155)
|
||||
7 LINESTRING(144 144,156 156)
|
||||
8 LINESTRING(143 143,157 157)
|
||||
9 LINESTRING(142 142,158 158)
|
||||
10 LINESTRING(141 141,159 159)
|
||||
11 LINESTRING(140 140,160 160)
|
||||
2 LINESTRING(149 149,151 151)
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t2 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
|
@ -295,6 +305,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
||||
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
||||
fid AsText(g)
|
||||
46 LINESTRING(51 41,60 50)
|
||||
56 LINESTRING(41 41,50 50)
|
||||
45 LINESTRING(51 51,60 60)
|
||||
55 LINESTRING(41 51,50 60)
|
||||
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
|
||||
SELECT count(*) FROM t2;
|
||||
count(*)
|
||||
|
|
|
@ -745,4 +745,36 @@ WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref i,v i 5 const 2 Using where
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows
|
||||
#
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
pk int auto_increment,
|
||||
zone_id int,
|
||||
modified tinyint,
|
||||
primary key(pk),
|
||||
key (zone_id),
|
||||
key (modified)
|
||||
) engine=innodb;
|
||||
insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D;
|
||||
update t1 set zone_id=487, modified=9 where pk=7259;
|
||||
update t1 set zone_id=487, modified=9 where pk=7260;
|
||||
update t1 set zone_id=830, modified=9 where pk=8434;
|
||||
update t1 set zone_id=830, modified=9 where pk=8435;
|
||||
update t1 set zone_id=830, modified=9 where pk=8436;
|
||||
update t1 set zone_id=830, modified=9 where pk=8437;
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
pk zone_id modified
|
||||
8434 830 9
|
||||
8435 830 9
|
||||
8436 830 9
|
||||
8437 830 9
|
||||
begin;
|
||||
DELETE t1 FROM t1 WHERE t1.zone_id=830 AND modified=9;
|
||||
commit;
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
pk zone_id modified
|
||||
drop table t0, t1;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
|
|
@ -165,7 +165,7 @@ WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
|
|||
ORDER BY ts DESC
|
||||
LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -914,4 +914,23 @@ Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
|||
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# BUG#1000051: Query with simple join and ORDER BY takes thousands times longer when run with ICP
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (a int, col int, filler char(100), key(a, col));
|
||||
insert into t1 select A.a + 10*B.a, 1234, 'filler' from t0 A, t0 B, t0 C;
|
||||
set @tmp_10000051= @@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
# Must not use ICP:
|
||||
explain select * from t1 where a between 5 and 8 order by a desc, col desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 39 Using where
|
||||
set optimizer_switch= @tmp_10000051;
|
||||
# Must not use ICP:
|
||||
explain select * from t1 where a=3 and col > 500 order by a desc, col desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 10 NULL 10 Using where
|
||||
drop table t0, t1;
|
||||
set optimizer_switch=@myisam_icp_tmp;
|
||||
|
|
|
@ -75,18 +75,16 @@ connection default;
|
|||
set global read_only=1;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables ;
|
||||
send set global read_only=1;
|
||||
set global read_only=1;
|
||||
connection con1;
|
||||
select @@global.read_only;
|
||||
@@global.read_only
|
||||
0
|
||||
unlock tables ;
|
||||
select @@global.read_only;
|
||||
@@global.read_only
|
||||
1
|
||||
connection con1;
|
||||
select @@global.read_only;
|
||||
@@global.read_only
|
||||
1
|
||||
unlock tables ;
|
||||
connection default;
|
||||
reap;
|
||||
connection default;
|
||||
set global read_only=0;
|
||||
BEGIN;
|
||||
|
|
|
@ -43,6 +43,15 @@ a
|
|||
1
|
||||
COMMIT;
|
||||
UNLOCK TABLES;
|
||||
connection con1;
|
||||
lock table t1 read;
|
||||
connection default;
|
||||
set global read_only=1;
|
||||
connection con1;
|
||||
unlock tables;
|
||||
connection default;
|
||||
SET GLOBAL read_only=0;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
DROP USER test@localhost;
|
||||
echo End of 5.1 tests
|
||||
|
|
|
@ -3100,7 +3100,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -6571,5 +6571,23 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
# HAVING, UNION in subquery
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
|
|
@ -376,4 +376,19 @@ GROUP BY 1
|
|||
MAX( f1 )
|
||||
NULL
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#1006231 crash in select_describe
|
||||
#
|
||||
create table t1(a1 int) ENGINE=InnoDB;
|
||||
insert into t1 values (1);
|
||||
explain
|
||||
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 1
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
set optimizer_switch=@subselect_innodb_tmp;
|
||||
|
|
|
@ -3106,7 +3106,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -6570,6 +6570,24 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
# HAVING, UNION in subquery
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -3102,7 +3102,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -6566,6 +6566,24 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
# HAVING, UNION in subquery
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -3106,7 +3106,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -6577,6 +6577,24 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
# HAVING, UNION in subquery
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -3102,7 +3102,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -6566,6 +6566,24 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
# HAVING, UNION in subquery
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -2753,4 +2753,18 @@ AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
|
|||
GROUP BY field1;
|
||||
field1
|
||||
DROP TABLE t1,t3,t2;
|
||||
#
|
||||
# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(6);
|
||||
SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
|
||||
FROM t2
|
||||
WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
|
||||
GROUP BY b
|
||||
HAVING t1sum <> 1;
|
||||
t1sum b
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
|
|
@ -2767,6 +2767,20 @@ AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
|
|||
GROUP BY field1;
|
||||
field1
|
||||
DROP TABLE t1,t3,t2;
|
||||
#
|
||||
# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(6);
|
||||
SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
|
||||
FROM t2
|
||||
WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
|
||||
GROUP BY b
|
||||
HAVING t1sum <> 1;
|
||||
t1sum b
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
|
|
@ -167,7 +167,7 @@ WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
|
|||
ORDER BY ts DESC
|
||||
LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
|
|
@ -306,6 +306,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
||||
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
||||
fid AsText(g)
|
||||
45 LINESTRING(51 51,60 60)
|
||||
46 LINESTRING(51 41,60 50)
|
||||
55 LINESTRING(41 51,50 60)
|
||||
56 LINESTRING(41 41,50 50)
|
||||
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
|
||||
SELECT count(*) FROM t2;
|
||||
count(*)
|
||||
|
|
|
@ -306,6 +306,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
||||
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
||||
fid AsText(g)
|
||||
45 LINESTRING(51 51,60 60)
|
||||
46 LINESTRING(51 41,60 50)
|
||||
55 LINESTRING(41 51,50 60)
|
||||
56 LINESTRING(41 41,50 50)
|
||||
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
|
||||
SELECT count(*) FROM t2;
|
||||
count(*)
|
||||
|
|
|
@ -306,6 +306,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
||||
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
||||
fid AsText(g)
|
||||
45 LINESTRING(51 51,60 60)
|
||||
46 LINESTRING(51 41,60 50)
|
||||
55 LINESTRING(41 51,50 60)
|
||||
56 LINESTRING(41 41,50 50)
|
||||
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
|
||||
SELECT count(*) FROM t2;
|
||||
count(*)
|
||||
|
|
|
@ -124,5 +124,38 @@ WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
|
|||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows
|
||||
--echo #
|
||||
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t1 (
|
||||
pk int auto_increment,
|
||||
zone_id int,
|
||||
modified tinyint,
|
||||
primary key(pk),
|
||||
key (zone_id),
|
||||
key (modified)
|
||||
) engine=innodb;
|
||||
|
||||
insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D;
|
||||
update t1 set zone_id=487, modified=9 where pk=7259;
|
||||
update t1 set zone_id=487, modified=9 where pk=7260;
|
||||
update t1 set zone_id=830, modified=9 where pk=8434;
|
||||
update t1 set zone_id=830, modified=9 where pk=8435;
|
||||
update t1 set zone_id=830, modified=9 where pk=8436;
|
||||
update t1 set zone_id=830, modified=9 where pk=8437;
|
||||
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
begin;
|
||||
DELETE t1 FROM t1 WHERE t1.zone_id=830 AND modified=9;
|
||||
commit;
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
|
||||
drop table t0, t1;
|
||||
|
||||
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
||||
|
|
|
@ -262,5 +262,25 @@ SET optimizer_switch=@save_optimizer_switch;
|
|||
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#1000051: Query with simple join and ORDER BY takes thousands times longer when run with ICP
|
||||
--echo #
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t1 (a int, col int, filler char(100), key(a, col));
|
||||
insert into t1 select A.a + 10*B.a, 1234, 'filler' from t0 A, t0 B, t0 C;
|
||||
|
||||
set @tmp_10000051= @@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
--echo # Must not use ICP:
|
||||
explain select * from t1 where a between 5 and 8 order by a desc, col desc;
|
||||
set optimizer_switch= @tmp_10000051;
|
||||
|
||||
--echo # Must not use ICP:
|
||||
explain select * from t1 where a=3 and col > 500 order by a desc, col desc;
|
||||
|
||||
drop table t0, t1;
|
||||
|
||||
set optimizer_switch=@myisam_icp_tmp;
|
||||
|
||||
|
|
|
@ -169,23 +169,19 @@ connection default;
|
|||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
set global read_only=1;
|
||||
unlock tables ;
|
||||
# The following call blocks until con1 releases the read lock.
|
||||
# Blocking is a limitation, and could be improved.
|
||||
--echo send set global read_only=1;
|
||||
send set global read_only=1;
|
||||
|
||||
# after unlock tables in current connection
|
||||
# the next command must be executed successfully
|
||||
set global read_only=1;
|
||||
select @@global.read_only;
|
||||
|
||||
--echo connection con1;
|
||||
connection con1;
|
||||
select @@global.read_only;
|
||||
unlock tables ;
|
||||
let $wait_condition= SELECT @@global.read_only= 1;
|
||||
--source include/wait_condition.inc
|
||||
select @@global.read_only;
|
||||
|
||||
--echo connection default;
|
||||
connection default;
|
||||
--echo reap;
|
||||
reap;
|
||||
|
||||
# pending transaction / READ_ONLY
|
||||
# - is an error in the same connection
|
||||
|
|
|
@ -75,7 +75,29 @@ BEGIN;
|
|||
SELECT * FROM t1;
|
||||
COMMIT;
|
||||
|
||||
#
|
||||
# Tests that LOCK TABLE doesn't block the SET READ_ONLY=1 for the InnoDB tables
|
||||
#
|
||||
|
||||
connection default;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--echo connection con1;
|
||||
connection con1;
|
||||
lock table t1 read;
|
||||
|
||||
--echo connection default;
|
||||
connection default;
|
||||
set global read_only=1;
|
||||
|
||||
--echo connection con1;
|
||||
connection con1;
|
||||
unlock tables;
|
||||
|
||||
--echo connection default;
|
||||
connection default;
|
||||
SET GLOBAL read_only=0;
|
||||
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
DROP USER test@localhost;
|
||||
|
|
|
@ -5540,6 +5540,21 @@ SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE
|
|||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
|
||||
--echo # HAVING, UNION in subquery
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (7),(0);
|
||||
CREATE TABLE t2 (b INT);
|
||||
|
||||
EXPLAIN
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
|
||||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo # return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
|
|
@ -365,4 +365,16 @@ WHERE f2 >= (
|
|||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#1006231 crash in select_describe
|
||||
--echo #
|
||||
|
||||
create table t1(a1 int) ENGINE=InnoDB;
|
||||
insert into t1 values (1);
|
||||
explain
|
||||
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
|
||||
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
|
||||
drop table t1;
|
||||
|
||||
|
||||
set optimizer_switch=@subselect_innodb_tmp;
|
||||
|
|
|
@ -2445,5 +2445,22 @@ GROUP BY field1;
|
|||
|
||||
DROP TABLE t1,t3,t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
|
||||
--echo #
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(6);
|
||||
|
||||
SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
|
||||
FROM t2
|
||||
WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
|
||||
GROUP BY b
|
||||
HAVING t1sum <> 1;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
|
|
@ -4736,7 +4736,7 @@ longlong Item_func_like::val_int()
|
|||
|
||||
Item_func::optimize_type Item_func_like::select_optimize() const
|
||||
{
|
||||
if (args[1]->const_item())
|
||||
if (args[1]->const_item() && !args[1]->is_expensive())
|
||||
{
|
||||
String* res2= args[1]->val_str((String *)&cmp.value2);
|
||||
const char *ptr2;
|
||||
|
@ -4823,7 +4823,8 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
|
|||
We could also do boyer-more for non-const items, but as we would have to
|
||||
recompute the tables for each row it's not worth it.
|
||||
*/
|
||||
if (args[1]->const_item() && !use_strnxfrm(collation.collation))
|
||||
if (args[1]->const_item() && !use_strnxfrm(collation.collation) &&
|
||||
!args[1]->is_expensive())
|
||||
{
|
||||
String* res2 = args[1]->val_str(&cmp.value2);
|
||||
if (!res2)
|
||||
|
|
|
@ -904,13 +904,21 @@ void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
|
|||
|
||||
void Item_maxmin_subselect::no_rows_in_result()
|
||||
{
|
||||
value= 0;
|
||||
value= Item_cache::get_cache(new Item_null());
|
||||
null_value= 0;
|
||||
was_values= 0;
|
||||
make_const();
|
||||
}
|
||||
|
||||
|
||||
void Item_singlerow_subselect::no_rows_in_result()
|
||||
{
|
||||
value= Item_cache::get_cache(new Item_null());
|
||||
reset();
|
||||
make_const();
|
||||
}
|
||||
|
||||
|
||||
void Item_singlerow_subselect::reset()
|
||||
{
|
||||
Item_subselect::reset();
|
||||
|
|
|
@ -279,7 +279,7 @@ public:
|
|||
subs_type substype() { return SINGLEROW_SUBS; }
|
||||
|
||||
void reset();
|
||||
void no_rows_in_result() { reset(); make_const(); }
|
||||
void no_rows_in_result();
|
||||
bool select_transformer(JOIN *join);
|
||||
void store(uint i, Item* item);
|
||||
double val_real();
|
||||
|
|
|
@ -3222,6 +3222,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
|
|||
if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 +
|
||||
time_zone_len + 1 +
|
||||
data_len + 1 +
|
||||
QUERY_CACHE_DB_LENGTH_SIZE +
|
||||
QUERY_CACHE_FLAGS_SIZE +
|
||||
user.length + 1 +
|
||||
host.length + 1 +
|
||||
|
|
|
@ -1616,6 +1616,9 @@ int imerge_list_or_tree(RANGE_OPT_PARAM *param,
|
|||
param Context info for the operation
|
||||
merges IN/OUT List of imerges to push the range part of 'tree' into
|
||||
tree SEL_TREE whose range part is to be pushed into imerges
|
||||
replace if the pushdow operation for a imerge is a success
|
||||
then the original imerge is replaced for the result
|
||||
of the pushdown
|
||||
|
||||
DESCRIPTION
|
||||
For each imerge from the list merges the function pushes the range part
|
||||
|
@ -1633,7 +1636,12 @@ int imerge_list_or_tree(RANGE_OPT_PARAM *param,
|
|||
If the result of the pushdown operation for the imerge mi returns an
|
||||
imerge with no trees then then not only nothing is added to the list
|
||||
merges but mi itself is removed from the list.
|
||||
|
||||
|
||||
TODO
|
||||
Optimize the code in order to not create new SEL_IMERGE and new SER_TREE
|
||||
objects when 'replace' is TRUE. (Currently this function is called always
|
||||
with this parameter equal to TRUE.)
|
||||
|
||||
RETURN
|
||||
1 if no imerges are left in the list merges
|
||||
0 otherwise
|
||||
|
@ -1642,7 +1650,8 @@ int imerge_list_or_tree(RANGE_OPT_PARAM *param,
|
|||
static
|
||||
int imerge_list_and_tree(RANGE_OPT_PARAM *param,
|
||||
List<SEL_IMERGE> *merges,
|
||||
SEL_TREE *tree)
|
||||
SEL_TREE *tree,
|
||||
bool replace)
|
||||
{
|
||||
SEL_IMERGE *imerge;
|
||||
SEL_IMERGE *new_imerge= NULL;
|
||||
|
@ -1659,8 +1668,11 @@ int imerge_list_and_tree(RANGE_OPT_PARAM *param,
|
|||
if (new_imerge->trees == new_imerge->trees_next)
|
||||
it.remove();
|
||||
else
|
||||
{
|
||||
new_merges.push_back(new_imerge);
|
||||
{
|
||||
if (replace)
|
||||
it.replace(new_imerge);
|
||||
else
|
||||
new_merges.push_back(new_imerge);
|
||||
new_imerge= NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2056,7 +2068,24 @@ end:
|
|||
doing_key_read= 1;
|
||||
head->mark_columns_used_by_index(index);
|
||||
}
|
||||
|
||||
head->prepare_for_position();
|
||||
|
||||
if (head->no_keyread)
|
||||
{
|
||||
/*
|
||||
We can get here when doing multi-table delete and having index_merge
|
||||
condition on a table that we're deleting from. It probably doesn't make
|
||||
sense to use index_merge, but de-facto it is used.
|
||||
|
||||
When it is used, we need to index columns to be read (before maria-5.3,
|
||||
read_multi_range_first() would set it).
|
||||
We shouldn't call mark_columns_used_by_index(), because it calls
|
||||
enable_keyread(), which is not allowed.
|
||||
*/
|
||||
head->mark_columns_used_by_index_no_reset(index, head->read_set);
|
||||
}
|
||||
|
||||
head->file= org_file;
|
||||
head->key_read= org_key_read;
|
||||
bitmap_copy(&column_bitmap, head->read_set);
|
||||
|
@ -8011,10 +8040,10 @@ int and_range_trees(RANGE_OPT_PARAM *param, SEL_TREE *tree1, SEL_TREE *tree2,
|
|||
tree1 represents the formula RT1 AND MT1,
|
||||
where RT1 = R1_1 AND ... AND R1_k1, MT1=M1_1 AND ... AND M1_l1;
|
||||
tree2 represents the formula RT2 AND MT2
|
||||
where RT2 = R2_1 AND ... AND R2_k2, MT2=M2_1 and ... and M2_l2.
|
||||
where RT2 = R2_1 AND ... AND R2_k2, MT2=M2_1 AND ... AND M2_l2.
|
||||
|
||||
The result tree will represent the formula of the the following structure:
|
||||
RT AND MT1 AND MT2 AND RT1MT2 AND RT2MT1, such that
|
||||
RT AND RT1MT2 AND RT2MT1, such that
|
||||
rt is a tree obtained by range intersection of trees tree1 and tree2,
|
||||
RT1MT2 = RT1M2_1 AND ... AND RT1M2_l2,
|
||||
RT2MT1 = RT2M1_1 AND ... AND RT2M1_l1,
|
||||
|
@ -8032,11 +8061,22 @@ int and_range_trees(RANGE_OPT_PARAM *param, SEL_TREE *tree1, SEL_TREE *tree2,
|
|||
tree, while the corresponding imerges are removed altogether from its
|
||||
imerge part.
|
||||
|
||||
NOTE.
|
||||
NOTE
|
||||
The pushdown operation of range trees into imerges is needed to be able
|
||||
to construct valid imerges for the condition like this:
|
||||
key1_p1=c1 AND (key1_p2 BETWEEN c21 AND c22 OR key2 < c2)
|
||||
|
||||
NOTE
|
||||
Currently we do not support intersection between indexes and index merges.
|
||||
When this will be supported the list of imerges for the result tree
|
||||
should include also imerges from M1 and M2. That's why an extra parameter
|
||||
is added to the function imerge_list_and_tree. If we call the function
|
||||
with the last parameter equal to FALSE then MT1 and MT2 will be preserved
|
||||
in the imerge list of the result tree. This can lead to the exponential
|
||||
growth of the imerge list though.
|
||||
Currently the last parameter of imerge_list_and_tree calls is always
|
||||
TRUE.
|
||||
|
||||
RETURN
|
||||
The result tree, if a success
|
||||
0 - otherwise.
|
||||
|
@ -8067,9 +8107,9 @@ SEL_TREE *tree_and(RANGE_OPT_PARAM *param, SEL_TREE *tree1, SEL_TREE *tree2)
|
|||
}
|
||||
|
||||
if (!tree1->merges.is_empty())
|
||||
imerge_list_and_tree(param, &tree1->merges, tree2);
|
||||
imerge_list_and_tree(param, &tree1->merges, tree2, TRUE);
|
||||
if (!tree2->merges.is_empty())
|
||||
imerge_list_and_tree(param, &tree2->merges, tree1);
|
||||
imerge_list_and_tree(param, &tree2->merges, tree1, TRUE);
|
||||
if (and_range_trees(param, tree1, tree2, tree1))
|
||||
DBUG_RETURN(tree1);
|
||||
imerge_list_and_list(&tree1->merges, &tree2->merges);
|
||||
|
|
|
@ -2332,6 +2332,8 @@ JOIN::exec()
|
|||
List<Item> *curr_all_fields= &all_fields;
|
||||
List<Item> *curr_fields_list= &fields_list;
|
||||
TABLE *curr_tmp_table= 0;
|
||||
bool tmp_having_used_tables_updated= FALSE;
|
||||
|
||||
/*
|
||||
Initialize examined rows here because the values from all join parts
|
||||
must be accumulated in examined_row_count. Hence every join
|
||||
|
@ -2580,12 +2582,22 @@ JOIN::exec()
|
|||
if (curr_tmp_table->distinct)
|
||||
curr_join->select_distinct=0; /* Each row is unique */
|
||||
|
||||
|
||||
/*
|
||||
curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not
|
||||
be safe to call update_used_tables() after that.
|
||||
*/
|
||||
if (curr_join->tmp_having)
|
||||
{
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
tmp_having_used_tables_updated= TRUE;
|
||||
}
|
||||
|
||||
curr_join->join_free(); /* Free quick selects */
|
||||
|
||||
if (curr_join->select_distinct && ! curr_join->group_list)
|
||||
{
|
||||
thd_proc_info(thd, "Removing duplicates");
|
||||
if (curr_join->tmp_having)
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
if (remove_duplicates(curr_join, curr_tmp_table,
|
||||
*curr_fields_list, curr_join->tmp_having))
|
||||
DBUG_VOID_RETURN;
|
||||
|
@ -2662,7 +2674,8 @@ JOIN::exec()
|
|||
! curr_join->sort_and_group)
|
||||
{
|
||||
// Some tables may have been const
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
if (!tmp_having_used_tables_updated)
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables];
|
||||
table_map used_tables= (curr_join->const_table_map |
|
||||
curr_table->table->map);
|
||||
|
@ -18644,6 +18657,14 @@ check_reverse_order:
|
|||
tab->limit= 0;
|
||||
goto use_filesort; // Reverse sort failed -> filesort
|
||||
}
|
||||
/*
|
||||
Cancel Pushed Index Condition, as it doesn't work for reverse scans.
|
||||
*/
|
||||
if (tab->select && tab->select->pre_idx_push_select_cond)
|
||||
{
|
||||
tab->set_cond(tab->select->pre_idx_push_select_cond);
|
||||
tab->table->file->cancel_pushed_idx_cond();
|
||||
}
|
||||
if (select->quick == save_quick)
|
||||
save_quick= 0; // make_reverse() consumed it
|
||||
select->set_quick(tmp);
|
||||
|
@ -18659,6 +18680,14 @@ check_reverse_order:
|
|||
*/
|
||||
tab->read_first_record= join_read_last_key;
|
||||
tab->read_record.read_record= join_read_prev_same;
|
||||
/*
|
||||
Cancel Pushed Index Condition, as it doesn't work for reverse scans.
|
||||
*/
|
||||
if (tab->select && tab->select->pre_idx_push_select_cond)
|
||||
{
|
||||
tab->set_cond(tab->select->pre_idx_push_select_cond);
|
||||
tab->table->file->cancel_pushed_idx_cond();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (select && select->quick)
|
||||
|
|
|
@ -1596,14 +1596,15 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
|
|||
}
|
||||
|
||||
/*
|
||||
Perform a 'FLUSH TABLES WITH READ LOCK'.
|
||||
This is a 3 step process:
|
||||
- [1] lock_global_read_lock()
|
||||
- [2] close_cached_tables()
|
||||
- [3] make_global_read_lock_block_commit()
|
||||
[1] prevents new connections from obtaining tables locked for write.
|
||||
[2] waits until all existing connections close their tables.
|
||||
[3] prevents transactions from being committed.
|
||||
READ_ONLY=1 prevents write locks from being taken on tables and
|
||||
blocks transactions from committing. We therefore should make sure
|
||||
that no such events occur while setting the read_only variable.
|
||||
This is a 2 step process:
|
||||
[1] lock_global_read_lock()
|
||||
Prevents connections from obtaining new write locks on
|
||||
tables. Note that we can still have active rw transactions.
|
||||
[2] make_global_read_lock_block_commit()
|
||||
Prevents transactions from committing.
|
||||
*/
|
||||
|
||||
read_only= opt_readonly;
|
||||
|
@ -1612,19 +1613,6 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
|
|||
if (thd->global_read_lock.lock_global_read_lock(thd))
|
||||
goto end_with_mutex_unlock;
|
||||
|
||||
/*
|
||||
This call will be blocked by any connection holding a READ or WRITE lock.
|
||||
Ideally, we want to wait only for pending WRITE locks, but since:
|
||||
con 1> LOCK TABLE T FOR READ;
|
||||
con 2> LOCK TABLE T FOR WRITE; (blocked by con 1)
|
||||
con 3> SET GLOBAL READ ONLY=1; (blocked by con 2)
|
||||
can cause to wait on a read lock, it's required for the client application
|
||||
to unlock everything, and acceptable for the server to wait on all locks.
|
||||
*/
|
||||
if ((result= close_cached_tables(thd, NULL, TRUE,
|
||||
thd->variables.lock_wait_timeout)))
|
||||
goto end_with_read_lock;
|
||||
|
||||
if ((result= thd->global_read_lock.make_global_read_lock_block_commit(thd)))
|
||||
goto end_with_read_lock;
|
||||
|
||||
|
|
|
@ -196,6 +196,12 @@ int maria_rtree_find_first(MARIA_HA *info, MARIA_KEY *key, uint32 search_flag)
|
|||
uint nod_cmp_flag;
|
||||
MARIA_KEYDEF *keyinfo= key->keyinfo;
|
||||
|
||||
/*
|
||||
At the moment index can only properly handle the
|
||||
MBR_INTERSECT, so we use it for all sorts of queries.
|
||||
TODO: better searsh for CONTAINS/WITHIN.
|
||||
*/
|
||||
search_flag= nod_cmp_flag= MBR_INTERSECT;
|
||||
if ((root= info->s->state.key_root[keyinfo->key_nr]) == HA_OFFSET_ERROR)
|
||||
{
|
||||
my_errno= HA_ERR_END_OF_FILE;
|
||||
|
@ -213,8 +219,11 @@ int maria_rtree_find_first(MARIA_HA *info, MARIA_KEY *key, uint32 search_flag)
|
|||
info->maria_rtree_recursion_depth= -1;
|
||||
info->keyread_buff_used= 1;
|
||||
|
||||
nod_cmp_flag= ((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT);
|
||||
/*
|
||||
TODO better search for CONTAINS/WITHIN.
|
||||
nod_cmp_flag= ((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT);
|
||||
*/
|
||||
return maria_rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root,
|
||||
0);
|
||||
}
|
||||
|
@ -241,6 +250,12 @@ int maria_rtree_find_next(MARIA_HA *info, uint keynr, uint32 search_flag)
|
|||
uint32 nod_cmp_flag;
|
||||
MARIA_KEYDEF *keyinfo= info->s->keyinfo + keynr;
|
||||
DBUG_ASSERT(info->last_key.keyinfo == keyinfo);
|
||||
/*
|
||||
At the moment index can only properly handle the
|
||||
MBR_INTERSECT, so we use it for all sorts of queries.
|
||||
TODO: better searsh for CONTAINS/WITHIN.
|
||||
*/
|
||||
search_flag= nod_cmp_flag= MBR_INTERSECT;
|
||||
|
||||
if (info->update & HA_STATE_DELETED)
|
||||
return maria_rtree_find_first(info, &info->last_key, search_flag);
|
||||
|
@ -284,8 +299,11 @@ int maria_rtree_find_next(MARIA_HA *info, uint keynr, uint32 search_flag)
|
|||
return -1;
|
||||
}
|
||||
|
||||
nod_cmp_flag= (((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT));
|
||||
/*
|
||||
TODO better search for CONTAINS/WITHIN.
|
||||
nod_cmp_flag= (((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT));
|
||||
*/
|
||||
return maria_rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root,
|
||||
0);
|
||||
}
|
||||
|
|
|
@ -175,6 +175,13 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
|
|||
uint nod_cmp_flag;
|
||||
MI_KEYDEF *keyinfo = info->s->keyinfo + keynr;
|
||||
|
||||
/*
|
||||
At the moment index can only properly handle the
|
||||
MBR_INTERSECT, so we use it for all sorts of queries.
|
||||
TODO: better searsh for CONTAINS/WITHIN.
|
||||
*/
|
||||
search_flag= nod_cmp_flag= MBR_INTERSECT;
|
||||
|
||||
if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
|
||||
{
|
||||
my_errno= HA_ERR_END_OF_FILE;
|
||||
|
@ -192,8 +199,11 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
|
|||
info->rtree_recursion_depth = -1;
|
||||
info->buff_used = 1;
|
||||
|
||||
nod_cmp_flag = ((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT);
|
||||
/*
|
||||
TODO better search for CONTAINS/WITHIN.
|
||||
nod_cmp_flag= ((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT);
|
||||
*/
|
||||
return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
|
||||
}
|
||||
|
||||
|
@ -218,6 +228,12 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
|
|||
my_off_t root;
|
||||
uint nod_cmp_flag;
|
||||
MI_KEYDEF *keyinfo = info->s->keyinfo + keynr;
|
||||
/*
|
||||
At the moment index can only properly handle the
|
||||
MBR_INTERSECT, so we use it for all sorts of queries.
|
||||
TODO: better searsh for CONTAINS/WITHIN.
|
||||
*/
|
||||
search_flag= nod_cmp_flag= MBR_INTERSECT;
|
||||
|
||||
if (info->update & HA_STATE_DELETED)
|
||||
return rtree_find_first(info, keynr, info->lastkey, info->lastkey_length,
|
||||
|
@ -252,8 +268,11 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
|
|||
return -1;
|
||||
}
|
||||
|
||||
nod_cmp_flag = ((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT);
|
||||
/*
|
||||
TODO better search for CONTAINS/WITHIN.
|
||||
nod_cmp_flag= (((search_flag & (MBR_EQUAL | MBR_WITHIN)) ?
|
||||
MBR_WITHIN : MBR_INTERSECT));
|
||||
*/
|
||||
return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue