mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge 10.11 -> 11.2
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#ifdef _ARCH_PWR8
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/platform/ppc.h>
|
||||
/* Very low priority */
|
||||
#define HMT_very_low() __ppc_set_ppr_very_low()
|
||||
@ -37,6 +38,18 @@
|
||||
#define HMT_medium_high() __ppc_set_ppr_med_high()
|
||||
/* High priority */
|
||||
#define HMT_high() asm volatile("or 3,3,3")
|
||||
#else /* GLIBC */
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#define HMT_very_low() __asm__ volatile ("or 31,31,31")
|
||||
#define HMT_low() __asm__ volatile ("or 1,1,1")
|
||||
#define HMT_medium_low() __asm__ volatile ("or 6,6,6")
|
||||
#define HMT_medium() __asm__ volatile ("or 2,2,2")
|
||||
#define HMT_medium_high() __asm__ volatile ("or 5,5,5")
|
||||
#define HMT_high() asm volatile("or 3,3,3")
|
||||
#endif /* GLIBC */
|
||||
#else
|
||||
#define HMT_very_low()
|
||||
#define HMT_low()
|
||||
@ -81,7 +94,13 @@ static inline void MY_RELAX_CPU(void)
|
||||
__asm__ __volatile__ ("pause");
|
||||
#endif
|
||||
#elif defined(_ARCH_PWR8)
|
||||
__ppc_get_timebase();
|
||||
#ifdef __FreeBSD__
|
||||
uint64_t __tb;
|
||||
__asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
|
||||
#else
|
||||
/* Changed from __ppc_get_timebase for musl compatibility */
|
||||
__builtin_ppc_get_timebase();
|
||||
#endif
|
||||
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
||||
/* Mainly, prevent the compiler from optimizing away delay loops */
|
||||
__asm__ __volatile__ ("":::"memory");
|
||||
|
@ -3508,6 +3508,74 @@ SET OPTIMIZER_USE_CONDITION_SELECTIVITY=@tmp;
|
||||
DROP TABLE t1,t2;
|
||||
# End of 10.6 tests
|
||||
#
|
||||
# MDEV-34894: Poor query plan, because range estimates are not reused for ref(const)
|
||||
#
|
||||
create table t0 (
|
||||
a int,
|
||||
b int,
|
||||
dummy int
|
||||
);
|
||||
insert into t0 select seq,seq,seq from seq_1_to_10;
|
||||
create table t1 (
|
||||
pk1 int,
|
||||
pk2 int,
|
||||
pk3 int,
|
||||
key1 int,
|
||||
key(key1),
|
||||
filler char(100),
|
||||
primary key(pk1,pk2,pk3)
|
||||
);
|
||||
insert into t1
|
||||
select
|
||||
seq, seq, seq,
|
||||
FLOOR(seq/2),
|
||||
'filler-data'
|
||||
from seq_1_to_10000;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
update t1 set pk1=1 where pk1 between 1 and 200;
|
||||
explain select * from t1 where pk1=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 231
|
||||
explain select * from t0,t1 where t1.pk1=t0.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 4 test.t0.a 1
|
||||
create table t2 (
|
||||
col int
|
||||
);
|
||||
insert into t2 select seq from seq_1_to_10000;
|
||||
# This must use this good query plan:
|
||||
# t0 - ALL
|
||||
# t1 - ref, key=key1, not PRIMARY as pk1=1 is true for 20% of all rows
|
||||
# t2 - ALL
|
||||
explain select * from t0, t1, t2
|
||||
where
|
||||
t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and
|
||||
t1.key1=t0.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE t1 ref PRIMARY,key1 key1 5 test.t0.b 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 10000 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t2;
|
||||
CREATE OR REPLACE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT, key(a,b,c)) ENGINE=Aria;
|
||||
INSERT INTO t1 select seq/10,mod(seq,2),seq from seq_1_to_1000;
|
||||
update t1 set a=10 WHERE c < 100;
|
||||
update t1 set a=12 WHERE a=11;
|
||||
insert into t1 values (11,1,11), (11,2,11);
|
||||
create or replace table t2 select seq from seq_1_to_10;
|
||||
explain select count(*) from t1, t2 as seq where a=10 and b=seq.seq;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE seq ALL NULL NULL NULL NULL 10
|
||||
1 SIMPLE t1 ref a a 8 const,test.seq.seq 5 Using where; Using index
|
||||
explain select count(*) from t1, t2 as seq where a=11 and b=seq.seq;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 4 const 2 Using index
|
||||
1 SIMPLE seq ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-30256 Wrong result (missing rows) upon join with empty table
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
|
@ -1909,6 +1909,70 @@ SET OPTIMIZER_USE_CONDITION_SELECTIVITY=@tmp;
|
||||
DROP TABLE t1,t2;
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-34894: Poor query plan, because range estimates are not reused for ref(const)
|
||||
--echo #
|
||||
create table t0 (
|
||||
a int,
|
||||
b int,
|
||||
dummy int
|
||||
);
|
||||
insert into t0 select seq,seq,seq from seq_1_to_10;
|
||||
|
||||
create table t1 (
|
||||
pk1 int,
|
||||
pk2 int,
|
||||
pk3 int,
|
||||
key1 int,
|
||||
key(key1),
|
||||
filler char(100),
|
||||
primary key(pk1,pk2,pk3)
|
||||
);
|
||||
|
||||
insert into t1
|
||||
select
|
||||
seq, seq, seq,
|
||||
FLOOR(seq/2),
|
||||
'filler-data'
|
||||
from seq_1_to_10000;
|
||||
analyze table t1;
|
||||
|
||||
update t1 set pk1=1 where pk1 between 1 and 200;
|
||||
|
||||
explain select * from t1 where pk1=1;
|
||||
|
||||
explain select * from t0,t1 where t1.pk1=t0.a;
|
||||
|
||||
create table t2 (
|
||||
col int
|
||||
);
|
||||
insert into t2 select seq from seq_1_to_10000;
|
||||
|
||||
--echo # This must use this good query plan:
|
||||
--echo # t0 - ALL
|
||||
--echo # t1 - ref, key=key1, not PRIMARY as pk1=1 is true for 20% of all rows
|
||||
--echo # t2 - ALL
|
||||
explain select * from t0, t1, t2
|
||||
where
|
||||
t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and
|
||||
t1.key1=t0.b;
|
||||
|
||||
drop table t0,t1,t2;
|
||||
|
||||
CREATE OR REPLACE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT, key(a,b,c)) ENGINE=Aria;
|
||||
INSERT INTO t1 select seq/10,mod(seq,2),seq from seq_1_to_1000;
|
||||
update t1 set a=10 WHERE c < 100;
|
||||
update t1 set a=12 WHERE a=11;
|
||||
insert into t1 values (11,1,11), (11,2,11);
|
||||
create or replace table t2 select seq from seq_1_to_10;
|
||||
|
||||
explain select count(*) from t1, t2 as seq where a=10 and b=seq.seq;
|
||||
# This will execute code in ReuseRangeEstimateForRef-4
|
||||
explain select count(*) from t1, t2 as seq where a=11 and b=seq.seq;
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-30256 Wrong result (missing rows) upon join with empty table
|
||||
--echo #
|
||||
|
@ -447,9 +447,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
|
||||
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
|
||||
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
|
||||
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 3 Using index
|
||||
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
|
||||
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where
|
||||
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 3 Using index
|
||||
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
|
||||
1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where
|
||||
1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where
|
||||
1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where
|
||||
@ -469,9 +469,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
|
||||
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
|
||||
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
|
||||
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 3 Using index
|
||||
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
|
||||
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where
|
||||
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 3 Using index
|
||||
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
|
||||
1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where
|
||||
1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where
|
||||
1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where
|
||||
|
@ -90,6 +90,243 @@ DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
# End of 10.4 tests
|
||||
#
|
||||
# MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1
|
||||
#
|
||||
CREATE TABLE t1 (id INT, value INT);
|
||||
CREATE TABLE t2 (id INT);
|
||||
PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
|
||||
EXECUTE stmt;
|
||||
INSERT INTO t1 VALUES (1,10),(2,10),(3,10);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXECUTE stmt;
|
||||
SELECT * FROM t1;
|
||||
id value
|
||||
1 1
|
||||
2 1
|
||||
3 NULL
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
# Memory leak also could take place on running the DELETE statement
|
||||
# with the LIMIT clause. Check it.
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1), (2), (3);
|
||||
CREATE PROCEDURE p1(p1 INT)
|
||||
DELETE FROM t1 LIMIT p1;
|
||||
CALL p1(0);
|
||||
CALL p1(1);
|
||||
CALL p1(2);
|
||||
# Clean up
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
#
|
||||
# MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning
|
||||
#
|
||||
CREATE TABLE t1 (id INT, value INT);
|
||||
CREATE TABLE t2 (id INT);
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
|
||||
EXECUTE stmt;
|
||||
INSERT INTO t1 VALUES (1,10),(2,10),(3,10);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXECUTE stmt;
|
||||
SELECT * FROM t1;
|
||||
id value
|
||||
1 10
|
||||
2 10
|
||||
3 10
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (null,1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
1
|
||||
3
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (null,1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
|
||||
execute stmt using @var1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
execute stmt using @var2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using buffer
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
execute stmt using @var1, @var1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1), (2), (3);
|
||||
CREATE PROCEDURE p1(p1 INT)
|
||||
EXPLAIN DELETE FROM t1 LIMIT p1;
|
||||
CALL p1(0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
CALL p1(1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
CALL p1(2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
# Clean up
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'DELETE FROM t1 where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?';
|
||||
execute stmt using @var1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
execute stmt using @var2;
|
||||
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;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
execute stmt using @var1, @var1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL 3 Deleting all rows
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON
|
||||
#
|
||||
CREATE TABLE t (a INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?";
|
||||
EXECUTE stmt USING 0;
|
||||
EXECUTE stmt USING 1;
|
||||
DROP TABLE t;
|
||||
# End of 10.5 tests
|
||||
#
|
||||
# MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT
|
||||
#
|
||||
CREATE OR REPLACE TABLE t1(a INT);
|
||||
|
@ -5,6 +5,7 @@
|
||||
# The cmake option -DWITH_PROTECT_STATEMENT_MEMROOT is used only
|
||||
# for debug build
|
||||
--source include/have_debug.inc
|
||||
--source include/have_partition.inc
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-32369: Memory leak when executing PS for query with IN subquery
|
||||
@ -111,6 +112,219 @@ DROP TABLE t1;
|
||||
|
||||
--echo # End of 10.4 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1
|
||||
--echo #
|
||||
CREATE TABLE t1 (id INT, value INT);
|
||||
CREATE TABLE t2 (id INT);
|
||||
|
||||
PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
|
||||
EXECUTE stmt;
|
||||
INSERT INTO t1 VALUES (1,10),(2,10),(3,10);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXECUTE stmt;
|
||||
SELECT * FROM t1;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo # Memory leak also could take place on running the DELETE statement
|
||||
--echo # with the LIMIT clause. Check it.
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1), (2), (3);
|
||||
|
||||
CREATE PROCEDURE p1(p1 INT)
|
||||
DELETE FROM t1 LIMIT p1;
|
||||
|
||||
CALL p1(0);
|
||||
CALL p1(1);
|
||||
CALL p1(2);
|
||||
|
||||
--echo # Clean up
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning
|
||||
--echo #
|
||||
# same as the first MDEV-34444 testcase but with explain
|
||||
CREATE TABLE t1 (id INT, value INT);
|
||||
CREATE TABLE t2 (id INT);
|
||||
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
|
||||
# we are testing 2nd ps assertion failure, not explain output, which
|
||||
# may vary from version to version
|
||||
--disable_result_log
|
||||
EXECUTE stmt;
|
||||
--enable_result_log
|
||||
INSERT INTO t1 VALUES (1,10),(2,10),(3,10);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
--disable_result_log
|
||||
EXECUTE stmt;
|
||||
--enable_result_log
|
||||
SELECT * FROM t1;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# 2nd ps mem leak; partition pruning
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (null,1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
|
||||
# same but with explain
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (null,1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
|
||||
# top level impossible where
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
|
||||
PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
# top level impossible where, with explain
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
|
||||
PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
# Now we do delete instead of update
|
||||
|
||||
# same as the second MDEV-34447 testcase but with explain
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1), (2), (3);
|
||||
|
||||
CREATE PROCEDURE p1(p1 INT)
|
||||
EXPLAIN DELETE FROM t1 LIMIT p1;
|
||||
|
||||
CALL p1(0);
|
||||
CALL p1(1);
|
||||
CALL p1(2);
|
||||
|
||||
--echo # Clean up
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
# partition pruning
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'DELETE FROM t1 where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
|
||||
# same but with explain
|
||||
set @var1=5;
|
||||
set @var2=4;
|
||||
create table t1 (a int) partition by list(a) (
|
||||
partition p0 values in (1,2),
|
||||
partition p1 values in (3,4)
|
||||
);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3),(4);
|
||||
insert into t2 values (4);
|
||||
PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?';
|
||||
execute stmt using @var1;
|
||||
select * from t1;
|
||||
execute stmt using @var2;
|
||||
select * from t1;
|
||||
deallocate prepare stmt;
|
||||
drop table t1, t2;
|
||||
|
||||
# top level impossible where
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
|
||||
PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
# top level impossible where, with explain
|
||||
set @var1=1;
|
||||
set @var2=2;
|
||||
CREATE TABLE t1 ( id INT(10), value INT(10) );
|
||||
CREATE TABLE t2 ( id INT(10) );
|
||||
insert into t1 values (1,10),(2,10),(3,10);
|
||||
insert into t2 values (1),(2);
|
||||
|
||||
PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?';
|
||||
execute stmt using @var1, @var2;
|
||||
execute stmt using @var1, @var1;
|
||||
deallocate prepare stmt;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (a INT);
|
||||
INSERT INTO t VALUES (1),(2); # Optional, fails either way
|
||||
PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?";
|
||||
EXECUTE stmt USING 0;
|
||||
EXECUTE stmt USING 1;
|
||||
|
||||
# CLeanup
|
||||
DROP TABLE t;
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT
|
||||
--echo #
|
||||
|
@ -66,7 +66,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
|
||||
def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 8
|
||||
def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 8
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63
|
||||
def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 1 N 4097 0 8
|
||||
def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 8
|
||||
def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63
|
||||
@ -652,7 +652,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
|
||||
def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 63
|
||||
def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 63
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63
|
||||
def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 6 N 4097 0 63
|
||||
def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 63
|
||||
def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63
|
||||
@ -923,7 +923,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
|
||||
def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 192 2 N 4097 0 33
|
||||
def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 192 7 N 4097 0 33
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63
|
||||
def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63
|
||||
def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 192 1 N 4097 0 33
|
||||
def information_schema STATISTICS STATISTICS COLLATION Collation 253 3 1 Y 4096 0 33
|
||||
def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63
|
||||
|
@ -373,7 +373,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL
|
||||
def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) select NEVER NULL
|
||||
def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(3) select NEVER NULL
|
||||
def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(10) select NEVER NULL
|
||||
def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) select NEVER NULL
|
||||
def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned select NEVER NULL
|
||||
def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select NEVER NULL
|
||||
def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL
|
||||
def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL
|
||||
@ -931,7 +931,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5)
|
||||
NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1)
|
||||
3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2)
|
||||
NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned
|
||||
3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8mb3 utf8mb3_general_ci varchar(1)
|
||||
NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21)
|
||||
|
@ -373,7 +373,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL
|
||||
def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) NEVER NULL
|
||||
def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(3) NEVER NULL
|
||||
def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(10) NEVER NULL
|
||||
def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) NEVER NULL
|
||||
def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned NEVER NULL
|
||||
def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) NEVER NULL
|
||||
def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL
|
||||
def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL
|
||||
@ -931,7 +931,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5)
|
||||
NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1)
|
||||
3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2)
|
||||
NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned
|
||||
3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||
3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8mb3 utf8mb3_general_ci varchar(1)
|
||||
NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21)
|
||||
|
@ -34,7 +34,7 @@ TABLE_NAME varchar(64) NO NULL
|
||||
NON_UNIQUE bigint(1) NO NULL
|
||||
INDEX_SCHEMA varchar(64) NO NULL
|
||||
INDEX_NAME varchar(64) NO NULL
|
||||
SEQ_IN_INDEX bigint(2) NO NULL
|
||||
SEQ_IN_INDEX int(2) unsigned NO NULL
|
||||
COLUMN_NAME varchar(64) NO NULL
|
||||
COLLATION varchar(1) YES NULL
|
||||
CARDINALITY bigint(21) YES NULL
|
||||
@ -54,7 +54,7 @@ STATISTICS CREATE TEMPORARY TABLE `STATISTICS` (
|
||||
`NON_UNIQUE` bigint(1) NOT NULL,
|
||||
`INDEX_SCHEMA` varchar(64) NOT NULL,
|
||||
`INDEX_NAME` varchar(64) NOT NULL,
|
||||
`SEQ_IN_INDEX` bigint(2) NOT NULL,
|
||||
`SEQ_IN_INDEX` int(2) unsigned NOT NULL,
|
||||
`COLUMN_NAME` varchar(64) NOT NULL,
|
||||
`COLLATION` varchar(1),
|
||||
`CARDINALITY` bigint(21),
|
||||
@ -74,7 +74,7 @@ TABLE_NAME varchar(64) NO NULL
|
||||
NON_UNIQUE bigint(1) NO NULL
|
||||
INDEX_SCHEMA varchar(64) NO NULL
|
||||
INDEX_NAME varchar(64) NO NULL
|
||||
SEQ_IN_INDEX bigint(2) NO NULL
|
||||
SEQ_IN_INDEX int(2) unsigned NO NULL
|
||||
COLUMN_NAME varchar(64) NO NULL
|
||||
COLLATION varchar(1) YES NULL
|
||||
CARDINALITY bigint(21) YES NULL
|
||||
|
@ -455,7 +455,7 @@ static int arch_ppc_probe(void) {
|
||||
|
||||
return arch_ppc_crc32;
|
||||
}
|
||||
# elif defined __FreeBSD_version && __FreeBSD_version >= 1200000
|
||||
# elif defined __FreeBSD__
|
||||
# include <machine/cpu.h>
|
||||
# include <sys/auxv.h>
|
||||
# include <sys/elf_common.h>
|
||||
|
@ -209,7 +209,7 @@ typedef fp_except fp_except_t;
|
||||
|
||||
inline void setup_fpu()
|
||||
{
|
||||
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT)
|
||||
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) && defined(FP_X_INV)
|
||||
/* We can't handle floating point exceptions with threads, so disable
|
||||
this on freebsd
|
||||
Don't fall for overflow, underflow,divide-by-zero or loss of precision.
|
||||
@ -222,7 +222,7 @@ inline void setup_fpu()
|
||||
fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ |
|
||||
FP_X_IMP));
|
||||
#endif /* FP_X_DNML */
|
||||
#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT */
|
||||
#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT && FP_X_INV */
|
||||
|
||||
#ifdef HAVE_FEDISABLEEXCEPT
|
||||
fedisableexcept(FE_ALL_EXCEPT);
|
||||
|
@ -494,6 +494,12 @@ bool Sql_cmd_delete::delete_from_single_table(THD *thd)
|
||||
if (thd->binlog_for_noop_dml(transactional_table))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (!thd->lex->current_select->leaf_tables_saved)
|
||||
{
|
||||
thd->lex->current_select->save_leaf_tables(thd);
|
||||
thd->lex->current_select->leaf_tables_saved= true;
|
||||
}
|
||||
|
||||
my_ok(thd, 0);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -7174,12 +7174,13 @@ Item_equal::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
|
||||
}
|
||||
|
||||
|
||||
static uint
|
||||
static inline uint
|
||||
max_part_bit(key_part_map bits)
|
||||
{
|
||||
uint found;
|
||||
for (found=0; bits & 1 ; found++,bits>>=1) ;
|
||||
return found;
|
||||
if (bits == 0)
|
||||
return 0;
|
||||
/* find first zero bit by reverting all bits and find first bit */
|
||||
return my_find_first_bit(~(ulonglong) bits);
|
||||
}
|
||||
|
||||
|
||||
@ -8608,6 +8609,7 @@ best_access_path(JOIN *join,
|
||||
if (s->keyuse)
|
||||
{ /* Use key if possible */
|
||||
KEYUSE *keyuse, *start_key= 0;
|
||||
const char *cause= NULL;
|
||||
uint max_key_part=0;
|
||||
enum join_type type= JT_UNKNOWN;
|
||||
double cur_cost, copy_cost, cached_prev_record_reads= 0.0;
|
||||
@ -8618,7 +8620,6 @@ best_access_path(JOIN *join,
|
||||
for (keyuse=s->keyuse ; keyuse->table == table ;)
|
||||
{
|
||||
KEY *keyinfo;
|
||||
const char *cause= NULL;
|
||||
ulong key_flags;
|
||||
uint key_parts;
|
||||
key_part_map found_part= 0;
|
||||
@ -8626,6 +8627,7 @@ best_access_path(JOIN *join,
|
||||
key_part_map notnull_part=0;
|
||||
table_map found_ref= 0;
|
||||
uint key= keyuse->key;
|
||||
uint max_const_parts;
|
||||
bool ft_key= (keyuse->keypart == FT_KEYPART);
|
||||
/* Bitmap of keyparts where the ref access is over 'keypart=const': */
|
||||
key_part_map const_part= 0;
|
||||
@ -8752,6 +8754,8 @@ best_access_path(JOIN *join,
|
||||
rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables
|
||||
|
||||
Json_writer_object trace_access_idx(thd);
|
||||
max_const_parts= max_part_bit(const_part);
|
||||
|
||||
/*
|
||||
full text keys require special treatment
|
||||
*/
|
||||
@ -8898,9 +8902,7 @@ best_access_path(JOIN *join,
|
||||
in ReuseRangeEstimateForRef-3.
|
||||
*/
|
||||
if (table->opt_range_keys.is_set(key) &&
|
||||
(const_part &
|
||||
(((key_part_map)1 << table->opt_range[key].key_parts)-1)) ==
|
||||
(((key_part_map)1 << table->opt_range[key].key_parts)-1) &&
|
||||
table->opt_range[key].key_parts <= max_const_parts &&
|
||||
table->opt_range[key].ranges == 1 &&
|
||||
records > (double) table->opt_range[key].rows)
|
||||
{
|
||||
@ -8948,6 +8950,8 @@ best_access_path(JOIN *join,
|
||||
double extra_cost= 0;
|
||||
|
||||
max_key_part= max_part_bit(found_part);
|
||||
bool all_used_equalities_are_const= (max_key_part ==
|
||||
max_const_parts);
|
||||
/*
|
||||
ReuseRangeEstimateForRef-3:
|
||||
We're now considering a ref[or_null] access via
|
||||
@ -8962,7 +8966,7 @@ best_access_path(JOIN *join,
|
||||
create quick select over another index), so we can't compare
|
||||
them to (**). We'll make indirect judgements instead.
|
||||
The sufficient conditions for re-use are:
|
||||
(C1) All e_i in (**) are constants, i.e. found_ref==FALSE. (if
|
||||
(C1) All e_i in (**) are constants (if
|
||||
this is not satisfied we have no way to know which ranges
|
||||
will be actually scanned by 'ref' until we execute the
|
||||
join)
|
||||
@ -8987,7 +8991,8 @@ best_access_path(JOIN *join,
|
||||
|
||||
(C3) "range optimizer used (have ref_or_null?2:1) intervals"
|
||||
*/
|
||||
if (table->opt_range_keys.is_set(key) && !found_ref && //(C1)
|
||||
if (table->opt_range_keys.is_set(key) &&
|
||||
all_used_equalities_are_const && // (C1)
|
||||
table->opt_range[key].key_parts == max_key_part && //(C2)
|
||||
(table->opt_range[key].ranges ==
|
||||
1 + MY_TEST(ref_or_null_part))) //(C3)
|
||||
@ -9033,7 +9038,7 @@ best_access_path(JOIN *join,
|
||||
This is the case when we have only one const range
|
||||
and it consist of more parts than what we used for REF.
|
||||
*/
|
||||
if (!found_ref &&
|
||||
if (all_used_equalities_are_const &&
|
||||
table->opt_range[key].key_parts > max_key_part &&
|
||||
table->opt_range[key].ranges <=
|
||||
(uint) (1 + MY_TEST(ref_or_null_part)))
|
||||
@ -9045,7 +9050,7 @@ best_access_path(JOIN *join,
|
||||
}
|
||||
}
|
||||
rows= (double) table->opt_range[key].rows;
|
||||
if (!found_ref && // (1)
|
||||
if (all_used_equalities_are_const && // (1)
|
||||
records < rows) // (3)
|
||||
{
|
||||
trace_access_idx.add("used_range_estimates",
|
||||
@ -9113,16 +9118,17 @@ best_access_path(JOIN *join,
|
||||
applied to first table->quick_key_parts[key] key parts.
|
||||
*/
|
||||
if (table->opt_range_keys.is_set(key) &&
|
||||
table->opt_range[key].key_parts <= max_key_part &&
|
||||
const_part &
|
||||
((key_part_map)1 << table->opt_range[key].key_parts) &&
|
||||
table->opt_range[key].key_parts <= max_const_parts &&
|
||||
table->opt_range[key].ranges == (1 +
|
||||
MY_TEST(ref_or_null_part &
|
||||
const_part)) &&
|
||||
records > (double) table->opt_range[key].rows)
|
||||
{
|
||||
trace_access_idx.add("used_range_estimates", true);
|
||||
records= (double) table->opt_range[key].rows;
|
||||
// psergey-merge-sept: remove: if (table->opt_range[key].key_parts <= max_const_parts)
|
||||
{
|
||||
trace_access_idx.add("used_range_estimates", true);
|
||||
records= (double) table->opt_range[key].rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9251,6 +9257,7 @@ best_access_path(JOIN *join,
|
||||
add("cost", cur_cost);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The COST_EPS is here to ensure we use the first key if there are
|
||||
two 'identical keys' that could be used.
|
||||
|
@ -9754,7 +9754,7 @@ ST_FIELD_INFO stat_fields_info[]=
|
||||
Column("NON_UNIQUE", SLonglong(1),NOT_NULL, "Non_unique", OPEN_FRM_ONLY),
|
||||
Column("INDEX_SCHEMA", Name(), NOT_NULL, OPEN_FRM_ONLY),
|
||||
Column("INDEX_NAME", Name(), NOT_NULL, "Key_name", OPEN_FRM_ONLY),
|
||||
Column("SEQ_IN_INDEX", SLonglong(2),NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY),
|
||||
Column("SEQ_IN_INDEX", ULong(2), NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY),
|
||||
Column("COLUMN_NAME", Name(), NOT_NULL, "Column_name", OPEN_FRM_ONLY),
|
||||
Column("COLLATION", Varchar(1), NULLABLE, "Collation", OPEN_FULL_TABLE),
|
||||
Column("CARDINALITY", SLonglong(), NULLABLE, "Cardinality", OPEN_FULL_TABLE),
|
||||
|
@ -463,6 +463,12 @@ bool Sql_cmd_update::update_single_table(THD *thd)
|
||||
if (thd->binlog_for_noop_dml(transactional_table))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (!thd->lex->current_select->leaf_tables_saved)
|
||||
{
|
||||
thd->lex->current_select->save_leaf_tables(thd);
|
||||
thd->lex->current_select->leaf_tables_saved= true;
|
||||
}
|
||||
|
||||
my_ok(thd); // No matching records
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}")
|
||||
IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
|
||||
CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR
|
||||
CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|
||||
SET(PCRE_INCLUDES "${PCRE_INCLUDE_DIRS}")
|
||||
add_subdirectory(columnstore)
|
||||
|
||||
IF(TARGET columnstore)
|
||||
|
@ -190,6 +190,7 @@ int main(int args, char **argv)
|
||||
pthread_t request_thr[N_THREADS];
|
||||
int i;
|
||||
|
||||
my_mutex_init();
|
||||
my_thread_global_init();
|
||||
|
||||
mysql_mutex_init(0, &apc_counters_mutex, MY_MUTEX_INIT_FAST);
|
||||
|
Reference in New Issue
Block a user