mirror of
https://github.com/MariaDB/server.git
synced 2025-09-08 06:27:57 +03:00
Merge branch '10.6' into 10.11
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");
|
||||
|
@@ -3495,3 +3495,87 @@ a b c
|
||||
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;
|
||||
set optimizer_adjust_secondary_key_costs='fix_reuse_range_for_ref';
|
||||
# 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)
|
||||
set optimizer_adjust_secondary_key_costs='';
|
||||
# Bad query:
|
||||
# t0 - ALL
|
||||
# t1 - ref, key=PRIMARY
|
||||
# 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
|
||||
1 SIMPLE t1 ref PRIMARY,key1 PRIMARY 4 const 1 Using index condition; Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 10000 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t2;
|
||||
set @@optimizer_adjust_secondary_key_costs="fix_reuse_range_for_ref";
|
||||
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;
|
||||
set @@optimizer_adjust_secondary_key_costs=default;
|
||||
|
@@ -1904,3 +1904,81 @@ SELECT * FROM
|
||||
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;
|
||||
|
||||
set optimizer_adjust_secondary_key_costs='fix_reuse_range_for_ref';
|
||||
--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;
|
||||
|
||||
set optimizer_adjust_secondary_key_costs='';
|
||||
--echo # Bad query:
|
||||
--echo # t0 - ALL
|
||||
--echo # t1 - ref, key=PRIMARY
|
||||
--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;
|
||||
|
||||
set @@optimizer_adjust_secondary_key_costs="fix_reuse_range_for_ref";
|
||||
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;
|
||||
|
||||
set @@optimizer_adjust_secondary_key_costs=default;
|
||||
|
@@ -745,8 +745,10 @@ The following specify which files/extra groups are read (specified before remain
|
||||
disable_forced_index_in_group_by = Disable automatic
|
||||
forced index in GROUP BY. fix_innodb_cardinality =
|
||||
Disable doubling of the Cardinality for InnoDB secondary
|
||||
keys. This variable will be deleted in MariaDB 11.0 as it
|
||||
is not needed with the new 11.0 optimizer.
|
||||
keys. fix_reuse_range_for_ref = Do a better job at
|
||||
reusing range access estimates when estimating ref
|
||||
access. This variable will be deleted in MariaDB 11.0 as
|
||||
it is not needed with the new 11.0 optimizer.
|
||||
Use 'ALL' to set all combinations.
|
||||
--optimizer-extra-pruning-depth=#
|
||||
If the optimizer needs to enumerate join prefix of this
|
||||
@@ -1746,7 +1748,7 @@ old-alter-table DEFAULT
|
||||
old-mode UTF8_IS_UTF8MB3
|
||||
old-passwords FALSE
|
||||
old-style-user-limits FALSE
|
||||
optimizer-adjust-secondary-key-costs
|
||||
optimizer-adjust-secondary-key-costs fix_reuse_range_for_ref
|
||||
optimizer-extra-pruning-depth 8
|
||||
optimizer-join-limit-pref-ratio 0
|
||||
optimizer-max-sel-arg-weight 32000
|
||||
|
@@ -10854,8 +10854,6 @@ S
|
||||
{
|
||||
"access_type": "ref",
|
||||
"index": "PRIMARY",
|
||||
"rows": 1.79769e308,
|
||||
"cost": 1.79769e308,
|
||||
"chosen": false,
|
||||
"cause": "no predicate for first keypart"
|
||||
}
|
||||
|
@@ -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 #
|
||||
|
@@ -82,7 +82,7 @@ json_detailed(json_extract(@trace, '$**.considered_access_paths'))
|
||||
drop table t1, name, flag2;
|
||||
select @@optimizer_adjust_secondary_key_costs;
|
||||
@@optimizer_adjust_secondary_key_costs
|
||||
|
||||
fix_reuse_range_for_ref
|
||||
set @@optimizer_adjust_secondary_key_costs=7;
|
||||
select @@optimizer_adjust_secondary_key_costs;
|
||||
@@optimizer_adjust_secondary_key_costs
|
||||
|
@@ -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
|
||||
|
@@ -360,7 +360,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
|
||||
@@ -905,7 +905,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)
|
||||
|
@@ -360,7 +360,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
|
||||
@@ -905,7 +905,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
|
||||
|
@@ -2325,11 +2325,11 @@ COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE SET
|
||||
VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer.
|
||||
VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. fix_reuse_range_for_ref = Do a better job at reusing range access estimates when estimating ref access. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer.
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality
|
||||
ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality,fix_reuse_range_for_ref
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH
|
||||
|
@@ -2495,11 +2495,11 @@ COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE SET
|
||||
VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer.
|
||||
VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. fix_reuse_range_for_ref = Do a better job at reusing range access estimates when estimating ref access. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer.
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality
|
||||
ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality,fix_reuse_range_for_ref
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH
|
||||
|
@@ -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>
|
||||
|
@@ -207,7 +207,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.
|
||||
@@ -220,7 +220,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);
|
||||
|
@@ -523,6 +523,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
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);
|
||||
}
|
||||
@@ -558,6 +564,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
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); // Nothing to delete
|
||||
}
|
||||
@@ -937,10 +949,10 @@ cleanup:
|
||||
query_cache_invalidate3(thd, table_list, 1);
|
||||
}
|
||||
|
||||
if (thd->lex->current_select->first_cond_optimization)
|
||||
if (!thd->lex->current_select->leaf_tables_saved)
|
||||
{
|
||||
thd->lex->current_select->save_leaf_tables(thd);
|
||||
thd->lex->current_select->first_cond_optimization= 0;
|
||||
thd->lex->current_select->leaf_tables_saved= true;
|
||||
}
|
||||
|
||||
delete deltempfile;
|
||||
|
@@ -1411,10 +1411,10 @@ values_loop_end:
|
||||
::my_ok(thd, info.copied + info.deleted + updated, id, buff);
|
||||
}
|
||||
thd->abort_on_warning= 0;
|
||||
if (thd->lex->current_select->first_cond_optimization)
|
||||
if (!thd->lex->current_select->leaf_tables_saved)
|
||||
{
|
||||
thd->lex->current_select->save_leaf_tables(thd);
|
||||
thd->lex->current_select->first_cond_optimization= 0;
|
||||
thd->lex->current_select->leaf_tables_saved= true;
|
||||
}
|
||||
|
||||
my_free(readbuff);
|
||||
|
@@ -3026,6 +3026,7 @@ void st_select_lex::init_query()
|
||||
first_natural_join_processing= 1;
|
||||
first_cond_optimization= 1;
|
||||
first_rownum_optimization= true;
|
||||
leaf_tables_saved= false;
|
||||
no_wrap_view_item= 0;
|
||||
exclude_from_table_unique_test= 0;
|
||||
in_tvc= 0;
|
||||
|
@@ -1196,6 +1196,10 @@ public:
|
||||
can be transformed into IN-subselect defined with TVC.
|
||||
*/
|
||||
List<Item_func_in> in_funcs;
|
||||
/**
|
||||
Flag to guard against double initialization of leaf tables list
|
||||
*/
|
||||
bool leaf_tables_saved;
|
||||
List<TABLE_LIST> leaf_tables;
|
||||
List<TABLE_LIST> leaf_tables_exec;
|
||||
List<TABLE_LIST> leaf_tables_prep;
|
||||
|
@@ -279,6 +279,7 @@
|
||||
#define OPTIMIZER_ADJ_DISABLE_MAX_SEEKS (2)
|
||||
#define OPTIMIZER_ADJ_DISABLE_FORCE_INDEX_GROUP_BY (4)
|
||||
#define OPTIMIZER_FIX_INNODB_CARDINALITY (8)
|
||||
#define OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF (16)
|
||||
|
||||
/*
|
||||
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
|
||||
|
@@ -2263,12 +2263,14 @@ JOIN::optimize_inner()
|
||||
|
||||
add_table_function_dependencies(join_list, table_map(-1));
|
||||
|
||||
if (thd->is_error() || select_lex->save_leaf_tables(thd))
|
||||
if (thd->is_error() ||
|
||||
(!select_lex->leaf_tables_saved && select_lex->save_leaf_tables(thd)))
|
||||
{
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
select_lex->leaf_tables_saved= true;
|
||||
build_bitmap_for_nested_joins(join_list, 0);
|
||||
|
||||
sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0;
|
||||
@@ -7016,12 +7018,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -8193,7 +8196,6 @@ best_access_path(JOIN *join,
|
||||
SplM_plan_info *spl_plan= 0;
|
||||
table_map spl_pd_boundary= 0;
|
||||
Range_rowid_filter_cost_info *filter= 0;
|
||||
const char* cause= NULL;
|
||||
enum join_type best_type= JT_UNKNOWN, type= JT_UNKNOWN;
|
||||
|
||||
disable_jbuf= disable_jbuf || idx == join->const_tables;
|
||||
@@ -8223,6 +8225,7 @@ best_access_path(JOIN *join,
|
||||
TABLE *table= s->table;
|
||||
double best_records= DBL_MAX;
|
||||
uint max_key_part=0;
|
||||
const char *cause= NULL;
|
||||
|
||||
/* Test how we can use keys */
|
||||
rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key
|
||||
@@ -8235,6 +8238,7 @@ best_access_path(JOIN *join,
|
||||
key_part_map notnull_part=0; // key parts which won't have NULL in lookup tuple.
|
||||
table_map found_ref= 0;
|
||||
uint key= keyuse->key;
|
||||
uint max_const_parts;
|
||||
filter= 0;
|
||||
bool ft_key= (keyuse->keypart == FT_KEYPART);
|
||||
/* Bitmap of keyparts where the ref access is over 'keypart=const': */
|
||||
@@ -8338,6 +8342,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
|
||||
*/
|
||||
@@ -8455,9 +8461,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)
|
||||
{
|
||||
@@ -8503,6 +8507,17 @@ best_access_path(JOIN *join,
|
||||
found_part == PREV_BITS(uint,keyinfo->user_defined_key_parts)))
|
||||
{
|
||||
max_key_part= max_part_bit(found_part);
|
||||
bool all_used_equalities_are_const;
|
||||
if ((thd->variables.optimizer_adjust_secondary_key_costs &
|
||||
OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF))
|
||||
{
|
||||
all_used_equalities_are_const= (max_key_part == max_const_parts);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Old, incorrect check:
|
||||
all_used_equalities_are_const= !found_ref;
|
||||
}
|
||||
/*
|
||||
ReuseRangeEstimateForRef-3:
|
||||
We're now considering a ref[or_null] access via
|
||||
@@ -8517,7 +8532,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)
|
||||
@@ -8542,7 +8557,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)
|
||||
{
|
||||
@@ -8575,10 +8591,10 @@ best_access_path(JOIN *join,
|
||||
*/
|
||||
if (table->opt_range_keys.is_set(key))
|
||||
{
|
||||
double rows= (double) table->opt_range[key].rows;
|
||||
if (table->opt_range[key].key_parts >= max_key_part) // (2)
|
||||
{
|
||||
double 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", "clipped up");
|
||||
@@ -8646,15 +8662,26 @@ best_access_path(JOIN *join,
|
||||
*/
|
||||
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].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;
|
||||
bool all_parts_used;
|
||||
if ((thd->variables.optimizer_adjust_secondary_key_costs &
|
||||
OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF))
|
||||
{
|
||||
all_parts_used= table->opt_range[key].key_parts <= max_const_parts;
|
||||
}
|
||||
else
|
||||
all_parts_used= (bool) (const_part &
|
||||
((key_part_map)1
|
||||
<< table->opt_range[key].key_parts));
|
||||
if (all_parts_used)
|
||||
{
|
||||
trace_access_idx.add("used_range_estimates", true);
|
||||
records= (double) table->opt_range[key].rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8770,7 +8797,9 @@ best_access_path(JOIN *join,
|
||||
table->key_info[filter->key_no].name);
|
||||
}
|
||||
}
|
||||
trace_access_idx.add("rows", records).add("cost", tmp);
|
||||
|
||||
if (!cause)
|
||||
trace_access_idx.add("rows", records).add("cost", tmp);
|
||||
|
||||
if (tmp + 0.0001 < best_time - records/TIME_FOR_COMPARE)
|
||||
{
|
||||
@@ -8789,7 +8818,6 @@ best_access_path(JOIN *join,
|
||||
trace_access_idx.add("chosen", false)
|
||||
.add("cause", cause ? cause : "cost");
|
||||
}
|
||||
cause= nullptr;
|
||||
} /* for each key */
|
||||
records= best_records;
|
||||
}
|
||||
|
@@ -9601,7 +9601,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),
|
||||
|
@@ -577,6 +577,12 @@ int mysql_update(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);
|
||||
}
|
||||
@@ -611,6 +617,12 @@ int mysql_update(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);
|
||||
}
|
||||
@@ -1385,10 +1397,10 @@ update_end:
|
||||
}
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
|
||||
thd->abort_on_warning= 0;
|
||||
if (thd->lex->current_select->first_cond_optimization)
|
||||
if (!thd->lex->current_select->leaf_tables_saved)
|
||||
{
|
||||
thd->lex->current_select->save_leaf_tables(thd);
|
||||
thd->lex->current_select->first_cond_optimization= 0;
|
||||
thd->lex->current_select->leaf_tables_saved= true;
|
||||
}
|
||||
*found_return= found;
|
||||
*updated_return= updated;
|
||||
|
@@ -2958,7 +2958,8 @@ static Sys_var_ulong Sys_optimizer_trace_max_mem_size(
|
||||
*/
|
||||
static const char *adjust_secondary_key_cost[]=
|
||||
{
|
||||
"adjust_secondary_key_cost", "disable_max_seek", "disable_forced_index_in_group_by", "fix_innodb_cardinality",0
|
||||
"adjust_secondary_key_cost", "disable_max_seek", "disable_forced_index_in_group_by",
|
||||
"fix_innodb_cardinality", "fix_reuse_range_for_ref", 0
|
||||
};
|
||||
|
||||
|
||||
@@ -2973,10 +2974,12 @@ static Sys_var_set Sys_optimizer_adjust_secondary_key_costs(
|
||||
"GROUP BY. "
|
||||
"fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB "
|
||||
"secondary keys. "
|
||||
"fix_reuse_range_for_ref = Do a better job at reusing range access estimates "
|
||||
"when estimating ref access. "
|
||||
"This variable will be deleted in MariaDB 11.0 as it is not needed with the "
|
||||
"new 11.0 optimizer.",
|
||||
SESSION_VAR(optimizer_adjust_secondary_key_costs), CMD_LINE(REQUIRED_ARG),
|
||||
adjust_secondary_key_cost, DEFAULT(0));
|
||||
adjust_secondary_key_cost, DEFAULT(OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF));
|
||||
|
||||
|
||||
static Sys_var_charptr_fscs Sys_pid_file(
|
||||
|
@@ -26,6 +26,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