mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge branch '10.6' into 10.8
This commit is contained in:
4
debian/autobake-deb.sh
vendored
4
debian/autobake-deb.sh
vendored
@@ -59,8 +59,8 @@ remove_rocksdb_tools()
|
||||
replace_uring_with_aio()
|
||||
{
|
||||
sed 's/liburing-dev/libaio-dev/g' -i debian/control
|
||||
sed -e '/-DIGNORE_AIO_CHECK=YES/d' \
|
||||
-e '/-DWITH_URING=YES/d' -i debian/rules
|
||||
sed -e '/-DIGNORE_AIO_CHECK=ON/d' \
|
||||
-e '/-DWITH_URING=ON/d' -i debian/rules
|
||||
}
|
||||
|
||||
disable_pmem()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates
|
||||
Copyright (c) 2017, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
|
||||
Copyright (c) 2017, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
|
||||
Copyright (c) 2017, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2017, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
Copyright (c) 2020, 2021, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
Submodule libmariadb updated: 12bd1d5511...c2b322d2ca
@@ -4247,3 +4247,71 @@ deallocate prepare stmt;
|
||||
drop view v;
|
||||
drop table t1,t2,t3;
|
||||
# End of 10.4 tests
|
||||
#
|
||||
# MDEV-31143: view with ORDER BY used in query with rownum() in WHERE
|
||||
#
|
||||
create table t1 (id int primary key);
|
||||
insert into t1 values (3), (7), (1);
|
||||
create table t2 (a int);
|
||||
insert into t2 values (2), (4);
|
||||
create view v as select a from t2 order by a;
|
||||
set big_tables= 1;
|
||||
Warnings:
|
||||
Warning 1287 '@@big_tables' is deprecated and will be removed in a future release
|
||||
select t1.id from v, t1 where rownum() = 1 group by t1.id;
|
||||
id
|
||||
1
|
||||
set big_tables=default;
|
||||
Warnings:
|
||||
Warning 1287 '@@big_tables' is deprecated and will be removed in a future release
|
||||
drop view v;
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-31162: multi-table mergeable view with ORDER BY used
|
||||
# in query with rownum() in WHERE
|
||||
#
|
||||
create table t1 (a INT) engine=MyISAM;
|
||||
insert into t1 values (1),(2);
|
||||
create table t2 (b INT) engine=MyISAM;
|
||||
insert into t2 values (3),(4);
|
||||
create view v1 AS select * from t1 join t2 order by b;
|
||||
explain select * from v1 where rownum() <= 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
select * from v1 where rownum() <= 2;
|
||||
a b
|
||||
1 3
|
||||
2 3
|
||||
prepare stmt from "select * from v1 where rownum() <= 2";
|
||||
execute stmt;
|
||||
a b
|
||||
1 3
|
||||
2 3
|
||||
execute stmt;
|
||||
a b
|
||||
1 3
|
||||
2 3
|
||||
deallocate prepare stmt;
|
||||
create view v2 AS select * from t1 join t2 order by b/a;
|
||||
explain select * from v2 where rownum() <= 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
select * from v2 where rownum() <= 2;
|
||||
a b
|
||||
2 3
|
||||
1 3
|
||||
prepare stmt from "select * from v2 where rownum() <= 2";
|
||||
execute stmt;
|
||||
a b
|
||||
2 3
|
||||
1 3
|
||||
execute stmt;
|
||||
a b
|
||||
2 3
|
||||
1 3
|
||||
deallocate prepare stmt;
|
||||
drop view v1,v2;
|
||||
drop table t1,t2;
|
||||
# End of 10.6 tests
|
||||
|
||||
@@ -2752,3 +2752,65 @@ drop view v;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo # End of 10.4 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31143: view with ORDER BY used in query with rownum() in WHERE
|
||||
--echo #
|
||||
|
||||
create table t1 (id int primary key);
|
||||
insert into t1 values (3), (7), (1);
|
||||
|
||||
create table t2 (a int);
|
||||
insert into t2 values (2), (4);
|
||||
|
||||
create view v as select a from t2 order by a;
|
||||
|
||||
set big_tables= 1;
|
||||
select t1.id from v, t1 where rownum() = 1 group by t1.id;
|
||||
|
||||
set big_tables=default;
|
||||
|
||||
drop view v;
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31162: multi-table mergeable view with ORDER BY used
|
||||
--echo # in query with rownum() in WHERE
|
||||
--echo #
|
||||
|
||||
create table t1 (a INT) engine=MyISAM;
|
||||
insert into t1 values (1),(2);
|
||||
|
||||
create table t2 (b INT) engine=MyISAM;
|
||||
insert into t2 values (3),(4);
|
||||
|
||||
create view v1 AS select * from t1 join t2 order by b;
|
||||
let $q1=
|
||||
select * from v1 where rownum() <= 2;
|
||||
|
||||
eval explain $q1;
|
||||
--sorted_result
|
||||
eval $q1;
|
||||
|
||||
eval prepare stmt from "$q1";
|
||||
--sorted_result
|
||||
execute stmt;
|
||||
--sorted_result
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
create view v2 AS select * from t1 join t2 order by b/a;
|
||||
let $q2=
|
||||
select * from v2 where rownum() <= 2;
|
||||
|
||||
eval explain $q2;
|
||||
eval $q2;
|
||||
eval prepare stmt from "$q2";
|
||||
execute stmt;
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
drop view v1,v2;
|
||||
drop table t1,t2;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
@@ -1093,6 +1093,7 @@ sum(distinct 1) sum(t1.d) > 5 c
|
||||
1 1 0
|
||||
1 0 5
|
||||
1 1 6
|
||||
SET @sort_buffer_size_save= @@sort_buffer_size;
|
||||
set @@sort_buffer_size=1024;
|
||||
insert into t1 select -seq,-seq from seq_1_to_100;
|
||||
select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000 from (t1 e join t1) group by t1.c having t1.c > -2 ;
|
||||
@@ -1106,6 +1107,19 @@ sum(distinct 1) sum(t1.d) > 2 length(group_concat(t1.d)) > 1000 c
|
||||
1 1 0 5
|
||||
1 1 0 6
|
||||
drop table t1;
|
||||
set @@sort_buffer_size=@sort_buffer_size_save;
|
||||
#
|
||||
# MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key
|
||||
# with DISTINCT and group function
|
||||
#
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
SELECT DISTINCT CONVERT(STDDEV(f), CHAR(16)) AS f1, UUID() AS f2 FROM t GROUP BY f2 WITH ROLLUP;
|
||||
f1 f2
|
||||
0.0000 #
|
||||
0.0000 #
|
||||
0.5000 #
|
||||
DROP TABLE t;
|
||||
# End of 10.4 tests
|
||||
#
|
||||
# MDEV-27382: OFFSET is ignored when it is combined with the DISTINCT, IN() and JOIN
|
||||
|
||||
@@ -834,11 +834,24 @@ select distinct sum(distinct 1), sum(t1.d) > 5 from (t1 e join t1) group by t1.c
|
||||
select distinct sum(distinct 1), sum(t1.d) > 5, t1.c from (t1 e join t1) group by t1.c;
|
||||
|
||||
# Force usage of remove_dup_with_compare() algorithm
|
||||
SET @sort_buffer_size_save= @@sort_buffer_size;
|
||||
set @@sort_buffer_size=1024;
|
||||
insert into t1 select -seq,-seq from seq_1_to_100;
|
||||
select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000 from (t1 e join t1) group by t1.c having t1.c > -2 ;
|
||||
select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000,t1.c from (t1 e join t1) group by t1.c having t1.c > -2;
|
||||
drop table t1;
|
||||
set @@sort_buffer_size=@sort_buffer_size_save;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key
|
||||
--echo # with DISTINCT and group function
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
--replace_column 2 #
|
||||
SELECT DISTINCT CONVERT(STDDEV(f), CHAR(16)) AS f1, UUID() AS f2 FROM t GROUP BY f2 WITH ROLLUP;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo # End of 10.4 tests
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ CREATE TEMPORARY TABLE v0 ( v1 TEXT ( 15 ) CHAR SET BINARY NOT NULL NOT NULL UNI
|
||||
ERROR HY000: Field 'v1' doesn't have a default value
|
||||
CREATE TEMPORARY TABLE t1 (i TEXT(15) NOT NULL DEFAULT '' UNIQUE CHECK (i)) engine=innodb
|
||||
REPLACE SELECT NULL AS a;
|
||||
ERROR HY000: Field 'DB_ROW_HASH_1' doesn't have a default value
|
||||
ERROR 23000: CONSTRAINT `t1.i` failed for `test`.`t1`
|
||||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
|
||||
@@ -71,7 +71,7 @@ DROP TABLE t2, t1;
|
||||
--error ER_NO_DEFAULT_FOR_FIELD
|
||||
CREATE TEMPORARY TABLE v0 ( v1 TEXT ( 15 ) CHAR SET BINARY NOT NULL NOT NULL UNIQUE CHECK ( v1 ) ) REPLACE SELECT NULL AS v3 , 74 AS v2 ;
|
||||
|
||||
--error ER_NO_DEFAULT_FOR_FIELD
|
||||
--error ER_CONSTRAINT_FAILED
|
||||
CREATE TEMPORARY TABLE t1 (i TEXT(15) NOT NULL DEFAULT '' UNIQUE CHECK (i)) engine=innodb
|
||||
REPLACE SELECT NULL AS a;
|
||||
|
||||
|
||||
105
mysql-test/main/join_cache_cardinality.result
Normal file
105
mysql-test/main/join_cache_cardinality.result
Normal file
@@ -0,0 +1,105 @@
|
||||
create table t1 (a int, b int, c int);
|
||||
insert into t1 select seq,seq/2, seq/4 from seq_1_to_100;
|
||||
create table t2 (a int, b int, c int);
|
||||
insert into t2 select seq, seq/2, seq/4 from seq_1_to_200;
|
||||
analyze table t1,t2 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
set optimizer_trace=1;
|
||||
set join_cache_level=6;
|
||||
set optimizer_switch='hash_join_cardinality=on';
|
||||
explain select *
|
||||
from t1, t2
|
||||
where t1.a=t2.a and t1.a=t2.b and t1.c=t2.c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 SIMPLE t2 hash_ALL NULL #hash#$hj 15 test.t1.a,test.t1.a,test.t1.c 200 Using where; Using join buffer (flat, BNLH join)
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
JS
|
||||
[
|
||||
{
|
||||
"hash_join_columns":
|
||||
[
|
||||
{
|
||||
"field": "a",
|
||||
"avg_frequency": 1
|
||||
},
|
||||
{
|
||||
"field": "b",
|
||||
"avg_frequency": 2
|
||||
},
|
||||
{
|
||||
"field": "c",
|
||||
"avg_frequency": 3.9216
|
||||
}
|
||||
],
|
||||
"rows": 1
|
||||
}
|
||||
]
|
||||
select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan'))
|
||||
as ROWS_FOR_PLAN;
|
||||
ROWS_FOR_PLAN
|
||||
[100]
|
||||
explain select *
|
||||
from t1, t2 where t1.c=t2.c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c 200 Using where; Using join buffer (flat, BNLH join)
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
JS
|
||||
[
|
||||
{
|
||||
"hash_join_columns":
|
||||
[
|
||||
{
|
||||
"field": "c",
|
||||
"avg_frequency": 3.9216
|
||||
}
|
||||
],
|
||||
"rows": 3.9216
|
||||
}
|
||||
]
|
||||
select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan'))
|
||||
as ROWS_FOR_PLAN;
|
||||
ROWS_FOR_PLAN
|
||||
[392.16]
|
||||
explain select *
|
||||
from t1 straight_join t2 where t1.c=t2.c and t2.a<30;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c 200 Using where; Using join buffer (flat, BNLH join)
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
# Note that rows is the same:
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
JS
|
||||
[
|
||||
{
|
||||
"hash_join_columns":
|
||||
[
|
||||
{
|
||||
"field": "c",
|
||||
"avg_frequency": 3.9216
|
||||
}
|
||||
],
|
||||
"rows": 3.9216
|
||||
}
|
||||
]
|
||||
# Despite available selectivity:
|
||||
select json_detailed(json_extract(@json, '$**.selectivity_for_columns')) as JS;
|
||||
JS
|
||||
[
|
||||
[
|
||||
{
|
||||
"column_name": "a",
|
||||
"ranges":
|
||||
["NULL < a < 30"],
|
||||
"selectivity_from_histogram": 0.145
|
||||
}
|
||||
]
|
||||
]
|
||||
drop table t1,t2;
|
||||
41
mysql-test/main/join_cache_cardinality.test
Normal file
41
mysql-test/main/join_cache_cardinality.test
Normal file
@@ -0,0 +1,41 @@
|
||||
--source include/have_sequence.inc
|
||||
|
||||
# Embedded doesn't have optimizer trace:
|
||||
--source include/not_embedded.inc
|
||||
|
||||
create table t1 (a int, b int, c int);
|
||||
insert into t1 select seq,seq/2, seq/4 from seq_1_to_100;
|
||||
|
||||
create table t2 (a int, b int, c int);
|
||||
insert into t2 select seq, seq/2, seq/4 from seq_1_to_200;
|
||||
|
||||
analyze table t1,t2 persistent for all;
|
||||
|
||||
set optimizer_trace=1;
|
||||
set join_cache_level=6;
|
||||
set optimizer_switch='hash_join_cardinality=on';
|
||||
explain select *
|
||||
from t1, t2
|
||||
where t1.a=t2.a and t1.a=t2.b and t1.c=t2.c;
|
||||
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan'))
|
||||
as ROWS_FOR_PLAN;
|
||||
|
||||
explain select *
|
||||
from t1, t2 where t1.c=t2.c;
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan'))
|
||||
as ROWS_FOR_PLAN;
|
||||
|
||||
explain select *
|
||||
from t1 straight_join t2 where t1.c=t2.c and t2.a<30;
|
||||
set @json= (select trace from information_schema.optimizer_trace);
|
||||
--echo # Note that rows is the same:
|
||||
select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS;
|
||||
|
||||
--echo # Despite available selectivity:
|
||||
select json_detailed(json_extract(@json, '$**.selectivity_for_columns')) as JS;
|
||||
drop table t1,t2;
|
||||
@@ -451,6 +451,12 @@ a b
|
||||
1 xxx
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value
|
||||
#
|
||||
create table t1 (f text not null, unique (f));
|
||||
insert into t1 (f) select 'f';
|
||||
drop table t1;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
#
|
||||
|
||||
@@ -443,6 +443,13 @@ insert into t1 (a,b) select 1,'xxx' from seq_1_to_5;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value
|
||||
--echo #
|
||||
create table t1 (f text not null, unique (f));
|
||||
insert into t1 (f) select 'f';
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
||||
@@ -738,7 +738,8 @@ The following specify which files/extra groups are read (specified before remain
|
||||
extended_keys, exists_to_in, orderby_uses_equalities,
|
||||
condition_pushdown_for_derived, split_materialized,
|
||||
condition_pushdown_for_subquery, rowid_filter,
|
||||
condition_pushdown_from_having, not_null_range_scan
|
||||
condition_pushdown_from_having, not_null_range_scan,
|
||||
hash_join_cardinality
|
||||
--optimizer-trace=name
|
||||
Controls tracing of the Optimizer:
|
||||
optimizer_trace=option=val[,option=val...], where option
|
||||
|
||||
@@ -38,7 +38,7 @@ SET @@session.session_track_system_variables='optimizer_switch';
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- optimizer_switch
|
||||
-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
|
||||
Warnings:
|
||||
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
|
||||
|
||||
@@ -139,6 +139,13 @@ select * from t1,t2 where t1.a=t2.a and rownum()<=2 order by t1.a,t2.a;
|
||||
a b a b
|
||||
2 20 2 21
|
||||
3 30 3 31
|
||||
create view v1 as
|
||||
select * from (select * from t1 order by a desc) as t where rownum() <= 2;
|
||||
select * from v1;
|
||||
a b
|
||||
3 30
|
||||
2 20
|
||||
drop view v1;
|
||||
#
|
||||
# Having
|
||||
#
|
||||
@@ -984,3 +991,29 @@ next row is 3
|
||||
3
|
||||
next row is 5
|
||||
5
|
||||
#
|
||||
# MDEV-31073: Server crash, assertion `table != 0 &&
|
||||
# view->field_translation != 0' failure with ROWNUM and view
|
||||
#
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT * FROM t;
|
||||
UPDATE v SET f = 10 WHERE ROWNUM() > 42 LIMIT 1;
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT f, 3 as e FROM t;
|
||||
UPDATE v SET f = 10 WHERE e > 42 LIMIT 1;
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT f, ROWNUM() as e FROM t;
|
||||
UPDATE v SET f = 10 WHERE e > 42 LIMIT 1;
|
||||
ERROR HY000: The target table v of the UPDATE is not updatable
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
#
|
||||
# End of 10.6 tests
|
||||
#
|
||||
|
||||
@@ -58,6 +58,11 @@ select *,rownum() from t1,t2 order by t2.a desc, t1.a desc;
|
||||
select * from (select * from t1 order by a desc) as t where rownum() <= 2;
|
||||
select * from t1,t2 where t1.a=t2.a and rownum()<=2 order by t1.a,t2.a;
|
||||
|
||||
create view v1 as
|
||||
select * from (select * from t1 order by a desc) as t where rownum() <= 2;
|
||||
select * from v1;
|
||||
drop view v1;
|
||||
|
||||
--echo #
|
||||
--echo # Having
|
||||
--echo #
|
||||
@@ -568,3 +573,40 @@ drop table t1;
|
||||
--echo # Table value constructors
|
||||
--echo #
|
||||
values ("first row"),("next row is 3"),(rownum()),("next row is 5"),(rownum());
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31073: Server crash, assertion `table != 0 &&
|
||||
--echo # view->field_translation != 0' failure with ROWNUM and view
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT * FROM t;
|
||||
UPDATE v SET f = 10 WHERE ROWNUM() > 42 LIMIT 1;
|
||||
|
||||
# Cleanup
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT f, 3 as e FROM t;
|
||||
UPDATE v SET f = 10 WHERE e > 42 LIMIT 1;
|
||||
|
||||
# Cleanup
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (f INT);
|
||||
INSERT INTO t VALUES (1),(2);
|
||||
CREATE VIEW v AS SELECT f, ROWNUM() as e FROM t;
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
UPDATE v SET f = 10 WHERE e > 42 LIMIT 1;
|
||||
|
||||
# Cleanup
|
||||
DROP VIEW v;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.6 tests
|
||||
--echo #
|
||||
|
||||
@@ -834,7 +834,7 @@ flush table t1;
|
||||
set optimizer_use_condition_selectivity=4;
|
||||
explain extended select * from t1 where a=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.39 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.78 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 0
|
||||
drop table t1;
|
||||
@@ -1941,9 +1941,78 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 25.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2
|
||||
DROP TABLE t1;
|
||||
# End of 10.2 tests
|
||||
#
|
||||
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
|
||||
#
|
||||
create table t0(a int);
|
||||
insert into t0 select 1 from seq_1_to_78;
|
||||
create table t1(a int);
|
||||
insert into t1 select 1 from seq_1_to_26;
|
||||
create table t10 (a int);
|
||||
insert into t10 select 0 from t0, seq_1_to_4;
|
||||
insert into t10 select 8693 from t1;
|
||||
insert into t10 select 8694 from t1;
|
||||
insert into t10 select 8695 from t1;
|
||||
insert into t10 select 34783 from t1;
|
||||
insert into t10 select 34784 from t1;
|
||||
insert into t10 select 34785 from t1;
|
||||
insert into t10 select 34785 from t0, seq_1_to_8;
|
||||
insert into t10 select 65214 from t1;
|
||||
insert into t10 select 65215 from t1;
|
||||
insert into t10 select 65216 from t1;
|
||||
insert into t10 select 65216 from t0, seq_1_to_52;
|
||||
insert into t10 select 65217 from t1;
|
||||
insert into t10 select 65218 from t1;
|
||||
insert into t10 select 65219 from t1;
|
||||
insert into t10 select 65219 from t0;
|
||||
insert into t10 select 73913 from t1;
|
||||
insert into t10 select 73914 from t1;
|
||||
insert into t10 select 73915 from t1;
|
||||
insert into t10 select 73915 from t0, seq_1_to_40;
|
||||
insert into t10 select 78257 from t1;
|
||||
insert into t10 select 78258 from t1;
|
||||
insert into t10 select 78259 from t1;
|
||||
insert into t10 select 91300 from t1;
|
||||
insert into t10 select 91301 from t1;
|
||||
insert into t10 select 91302 from t1;
|
||||
insert into t10 select 91302 from t0, seq_1_to_6;
|
||||
insert into t10 select 91303 from t1;
|
||||
insert into t10 select 91304 from t1;
|
||||
insert into t10 select 91305 from t1;
|
||||
insert into t10 select 91305 from t0, seq_1_to_8;
|
||||
insert into t10 select 99998 from t1;
|
||||
insert into t10 select 99999 from t1;
|
||||
insert into t10 select 100000 from t1;
|
||||
set use_stat_tables=preferably;
|
||||
analyze table t10 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t10 analyze status Engine-independent statistics collected
|
||||
test.t10 analyze status OK
|
||||
flush tables;
|
||||
set @tmp=@@optimizer_trace;
|
||||
set optimizer_trace=1;
|
||||
explain select * from t10 where a in (91303);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
|
||||
# Must have selectivity_from_histogram <= 1.0:
|
||||
select json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
|
||||
from information_schema.optimizer_trace;
|
||||
json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
|
||||
[
|
||||
[
|
||||
{
|
||||
"column_name": "a",
|
||||
"ranges":
|
||||
["91303 <= a <= 91303"],
|
||||
"selectivity_from_histogram": 0.035714283
|
||||
}
|
||||
]
|
||||
]
|
||||
set optimizer_trace=@tmp;
|
||||
drop table t0,t1,t10;
|
||||
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
DROP TABLE t1;
|
||||
# End of 10.2 tests
|
||||
set @@global.histogram_size=@save_histogram_size;
|
||||
|
||||
@@ -1321,14 +1321,93 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2;
|
||||
FLUSH TABLES;
|
||||
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2;
|
||||
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # End of 10.2 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
|
||||
--echo #
|
||||
create table t0(a int); # This holds how many rows we hold in a bucket.
|
||||
insert into t0 select 1 from seq_1_to_78;
|
||||
|
||||
create table t1(a int); # one-third of a bucket
|
||||
insert into t1 select 1 from seq_1_to_26;
|
||||
|
||||
create table t10 (a int);
|
||||
insert into t10 select 0 from t0, seq_1_to_4;
|
||||
|
||||
insert into t10 select 8693 from t1;
|
||||
insert into t10 select 8694 from t1;
|
||||
insert into t10 select 8695 from t1;
|
||||
|
||||
|
||||
insert into t10 select 34783 from t1;
|
||||
insert into t10 select 34784 from t1;
|
||||
insert into t10 select 34785 from t1;
|
||||
|
||||
|
||||
insert into t10 select 34785 from t0, seq_1_to_8;
|
||||
|
||||
insert into t10 select 65214 from t1;
|
||||
insert into t10 select 65215 from t1;
|
||||
insert into t10 select 65216 from t1;
|
||||
|
||||
insert into t10 select 65216 from t0, seq_1_to_52;
|
||||
|
||||
insert into t10 select 65217 from t1;
|
||||
insert into t10 select 65218 from t1;
|
||||
insert into t10 select 65219 from t1;
|
||||
|
||||
insert into t10 select 65219 from t0;
|
||||
|
||||
|
||||
insert into t10 select 73913 from t1;
|
||||
insert into t10 select 73914 from t1;
|
||||
insert into t10 select 73915 from t1;
|
||||
|
||||
insert into t10 select 73915 from t0, seq_1_to_40;
|
||||
|
||||
|
||||
insert into t10 select 78257 from t1;
|
||||
insert into t10 select 78258 from t1;
|
||||
insert into t10 select 78259 from t1;
|
||||
|
||||
insert into t10 select 91300 from t1;
|
||||
insert into t10 select 91301 from t1;
|
||||
insert into t10 select 91302 from t1;
|
||||
|
||||
insert into t10 select 91302 from t0, seq_1_to_6;
|
||||
|
||||
insert into t10 select 91303 from t1; # Only 1/3rd of bucket matches the search tuple
|
||||
insert into t10 select 91304 from t1;
|
||||
insert into t10 select 91305 from t1;
|
||||
|
||||
insert into t10 select 91305 from t0, seq_1_to_8;
|
||||
|
||||
insert into t10 select 99998 from t1;
|
||||
insert into t10 select 99999 from t1;
|
||||
insert into t10 select 100000 from t1;
|
||||
|
||||
set use_stat_tables=preferably;
|
||||
analyze table t10 persistent for all;
|
||||
flush tables;
|
||||
|
||||
set @tmp=@@optimizer_trace;
|
||||
set optimizer_trace=1;
|
||||
explain select * from t10 where a in (91303);
|
||||
|
||||
--echo # Must have selectivity_from_histogram <= 1.0:
|
||||
select json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
|
||||
from information_schema.optimizer_trace;
|
||||
|
||||
set optimizer_trace=@tmp;
|
||||
drop table t0,t1,t10;
|
||||
|
||||
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
#
|
||||
# Clean up
|
||||
#
|
||||
|
||||
@@ -845,7 +845,7 @@ flush table t1;
|
||||
set optimizer_use_condition_selectivity=4;
|
||||
explain extended select * from t1 where a=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.39 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.78 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 0
|
||||
drop table t1;
|
||||
@@ -1953,11 +1953,80 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 25.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2
|
||||
DROP TABLE t1;
|
||||
# End of 10.2 tests
|
||||
#
|
||||
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
|
||||
#
|
||||
create table t0(a int);
|
||||
insert into t0 select 1 from seq_1_to_78;
|
||||
create table t1(a int);
|
||||
insert into t1 select 1 from seq_1_to_26;
|
||||
create table t10 (a int);
|
||||
insert into t10 select 0 from t0, seq_1_to_4;
|
||||
insert into t10 select 8693 from t1;
|
||||
insert into t10 select 8694 from t1;
|
||||
insert into t10 select 8695 from t1;
|
||||
insert into t10 select 34783 from t1;
|
||||
insert into t10 select 34784 from t1;
|
||||
insert into t10 select 34785 from t1;
|
||||
insert into t10 select 34785 from t0, seq_1_to_8;
|
||||
insert into t10 select 65214 from t1;
|
||||
insert into t10 select 65215 from t1;
|
||||
insert into t10 select 65216 from t1;
|
||||
insert into t10 select 65216 from t0, seq_1_to_52;
|
||||
insert into t10 select 65217 from t1;
|
||||
insert into t10 select 65218 from t1;
|
||||
insert into t10 select 65219 from t1;
|
||||
insert into t10 select 65219 from t0;
|
||||
insert into t10 select 73913 from t1;
|
||||
insert into t10 select 73914 from t1;
|
||||
insert into t10 select 73915 from t1;
|
||||
insert into t10 select 73915 from t0, seq_1_to_40;
|
||||
insert into t10 select 78257 from t1;
|
||||
insert into t10 select 78258 from t1;
|
||||
insert into t10 select 78259 from t1;
|
||||
insert into t10 select 91300 from t1;
|
||||
insert into t10 select 91301 from t1;
|
||||
insert into t10 select 91302 from t1;
|
||||
insert into t10 select 91302 from t0, seq_1_to_6;
|
||||
insert into t10 select 91303 from t1;
|
||||
insert into t10 select 91304 from t1;
|
||||
insert into t10 select 91305 from t1;
|
||||
insert into t10 select 91305 from t0, seq_1_to_8;
|
||||
insert into t10 select 99998 from t1;
|
||||
insert into t10 select 99999 from t1;
|
||||
insert into t10 select 100000 from t1;
|
||||
set use_stat_tables=preferably;
|
||||
analyze table t10 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t10 analyze status Engine-independent statistics collected
|
||||
test.t10 analyze status OK
|
||||
flush tables;
|
||||
set @tmp=@@optimizer_trace;
|
||||
set optimizer_trace=1;
|
||||
explain select * from t10 where a in (91303);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
|
||||
# Must have selectivity_from_histogram <= 1.0:
|
||||
select json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
|
||||
from information_schema.optimizer_trace;
|
||||
json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
|
||||
[
|
||||
[
|
||||
{
|
||||
"column_name": "a",
|
||||
"ranges":
|
||||
["91303 <= a <= 91303"],
|
||||
"selectivity_from_histogram": 0.035714283
|
||||
}
|
||||
]
|
||||
]
|
||||
set optimizer_trace=@tmp;
|
||||
drop table t0,t1,t10;
|
||||
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
DROP TABLE t1;
|
||||
# End of 10.2 tests
|
||||
set @@global.histogram_size=@save_histogram_size;
|
||||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
|
||||
set @tmp_ust= @@use_stat_tables;
|
||||
|
||||
@@ -36,12 +36,12 @@ test.t2 analyze status OK
|
||||
# The following two must have the same in 'Extra' column:
|
||||
explain extended select * from t2 where col1 IN (20, 180);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.35 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` in (20,180)
|
||||
explain extended select * from t2 where col1 IN (180, 20);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.35 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` in (180,20)
|
||||
drop table t1, t2;
|
||||
@@ -102,7 +102,7 @@ test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
explain extended select * from t1 where col1 in (1,2,3);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 3.37 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 2.97 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` in (1,2,3)
|
||||
# Must not cause fp division by zero, or produce nonsense numbers:
|
||||
|
||||
BIN
mysql-test/std_data/rpl/master-bin-seq_10.3.36.000001
Normal file
BIN
mysql-test/std_data/rpl/master-bin-seq_10.3.36.000001
Normal file
Binary file not shown.
@@ -20,17 +20,25 @@ DROP TABLE t1;
|
||||
connection node_1;
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
||||
SET SESSION wsrep_retry_autocommit = 1;
|
||||
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
||||
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue';
|
||||
INSERT INTO t1 (f1) VALUES (3);
|
||||
connection node_1a;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
||||
connection node_2;
|
||||
TRUNCATE TABLE t1;
|
||||
connection node_1;
|
||||
connection node_1a;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached';
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
||||
connection node_1;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
1
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
SET GLOBAL debug_dbug = NULL;
|
||||
DROP TABLE t1;
|
||||
connection node_1;
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
||||
@@ -64,6 +72,8 @@ SET SESSION wsrep_retry_autocommit = 64;
|
||||
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
||||
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue EXECUTE 64';
|
||||
INSERT INTO t1 VALUES (5);
|
||||
connection node_2;
|
||||
connection node_1;
|
||||
connection node_1;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
|
||||
@@ -25,6 +25,8 @@ SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continu
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
||||
--source include/wait_condition.inc
|
||||
TRUNCATE TABLE t1;
|
||||
|
||||
--connection node_1
|
||||
@@ -44,6 +46,7 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
||||
|
||||
SET SESSION wsrep_retry_autocommit = 1;
|
||||
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
||||
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue';
|
||||
--send INSERT INTO t1 (f1) VALUES (3)
|
||||
|
||||
@@ -51,14 +54,21 @@ SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continu
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
||||
--source include/wait_condition.inc
|
||||
TRUNCATE TABLE t1;
|
||||
|
||||
--connection node_1a
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached';
|
||||
SELECT COUNT(*) FROM t1;
|
||||
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
||||
|
||||
--connection node_1
|
||||
--error 0,ER_LOCK_DEADLOCK
|
||||
--reap
|
||||
SELECT COUNT(*) FROM t1;
|
||||
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
SET GLOBAL debug_dbug = NULL;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
@@ -79,6 +89,8 @@ SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continu
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
||||
--source include/wait_condition.inc
|
||||
TRUNCATE TABLE t1;
|
||||
|
||||
--connection node_1a
|
||||
@@ -114,6 +126,11 @@ SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continu
|
||||
|
||||
--send INSERT INTO t1 VALUES (5)
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--connection node_1
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
--let $count = 64
|
||||
|
||||
15
mysql-test/suite/galera_sr/r/MDEV-30838.result
Normal file
15
mysql-test/suite/galera_sr/r/MDEV-30838.result
Normal file
@@ -0,0 +1,15 @@
|
||||
connection node_2;
|
||||
connection node_1;
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
|
||||
SET SESSION wsrep_trx_fragment_size=1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
SET debug_dbug='+d,ib_create_table_fail_too_many_trx';
|
||||
INSERT INTO t1 VALUES(2);
|
||||
ERROR HY000: Error while appending streaming replication fragment
|
||||
COMMIT;
|
||||
SELECT * FROM t1;
|
||||
f1
|
||||
SET debug_dbug='-d,ib_create_table_fail_too_many_trx';
|
||||
DROP TABLE t1;
|
||||
CALL mtr.add_suppression("Error writing into mysql.wsrep_streaming_log: 177");
|
||||
18
mysql-test/suite/galera_sr/t/MDEV-30838.test
Normal file
18
mysql-test/suite/galera_sr/t/MDEV-30838.test
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# MDEV-30838 - Assertion `m_thd == _current_thd()' failed in
|
||||
# virtual int Wsrep_client_service::bf_rollback()
|
||||
#
|
||||
--source include/galera_cluster.inc
|
||||
--source include/have_debug_sync.inc
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
|
||||
SET SESSION wsrep_trx_fragment_size=1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
SET debug_dbug='+d,ib_create_table_fail_too_many_trx';
|
||||
--error ER_ERROR_DURING_COMMIT
|
||||
INSERT INTO t1 VALUES(2);
|
||||
COMMIT;
|
||||
SELECT * FROM t1;
|
||||
SET debug_dbug='-d,ib_create_table_fail_too_many_trx';
|
||||
DROP TABLE t1;
|
||||
CALL mtr.add_suppression("Error writing into mysql.wsrep_streaming_log: 177");
|
||||
@@ -191,17 +191,17 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
|
||||
FROM performance_schema.events_statements_summary_by_digest
|
||||
ORDER BY DIGEST_TEXT;
|
||||
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
|
||||
test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 1
|
||||
test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
|
||||
test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
|
||||
test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
|
||||
test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
|
||||
test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 1
|
||||
test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 1
|
||||
test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 1
|
||||
test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 1
|
||||
test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 1
|
||||
test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
|
||||
test e0c034ab2f0273695ef8b19babc4bd32 EXPLAIN SELECT * FROM `test` . `v1` 1
|
||||
test 751b8637d21a37ff572c84fdf1574e51 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
|
||||
test 93ceaf1395bcc52bfc3ec4d6ec817616 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
|
||||
test 51a9abceb7c8cebe749a4a07f7f40169 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
|
||||
test 8df4eaa7c85bdd4fffa6920137c3072a EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
|
||||
test 7ada999dc73fa2ec7f721e5c8e124e7f SELECT * FROM `test` . `v1` 1
|
||||
test 1efd67df2b28ac47a49938d56094c8c4 SELECT * FROM `test` . `v1` WHERE `a` = ? 1
|
||||
test 9107a99dc94a65bd4d1c92756c2b60a6 SELECT * FROM `test` . `v1` WHERE `b` > ? 1
|
||||
test c25e5077415cf620b64c739153ce015b SELECT `a` , `b` FROM `test` . `v1` 1
|
||||
test 9b06d26cce3a78277e5d3b7abbfa7f3e SELECT `b` , `a` FROM `test` . `v1` 1
|
||||
test e7f13e133e0bda19894df88606c37ec3 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
|
||||
DROP TABLE test.v1;
|
||||
CREATE VIEW test.v1 AS SELECT * FROM test.t1;
|
||||
EXPLAIN SELECT * from test.v1;
|
||||
@@ -248,19 +248,19 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
|
||||
FROM performance_schema.events_statements_summary_by_digest
|
||||
ORDER BY DIGEST_TEXT;
|
||||
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
|
||||
test 342cd5e41944d5f857f92b1e374857de CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
|
||||
test 2653f30030efcb6125121daa8eadf418 DROP TABLE `test` . `v1` 1
|
||||
test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 2
|
||||
test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
|
||||
test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
|
||||
test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
|
||||
test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
|
||||
test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 2
|
||||
test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 2
|
||||
test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 2
|
||||
test a13cfeda6d474d29546719d76dcfa831 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
|
||||
test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 2
|
||||
test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 2
|
||||
test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
|
||||
test f584090c72167285107217a72a0b3060 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
|
||||
test 67a106b8a88c2880c3455f1c7fa0a4aa DROP TABLE `test` . `v1` 1
|
||||
test e0c034ab2f0273695ef8b19babc4bd32 EXPLAIN SELECT * FROM `test` . `v1` 2
|
||||
test 751b8637d21a37ff572c84fdf1574e51 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
|
||||
test 93ceaf1395bcc52bfc3ec4d6ec817616 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
|
||||
test 51a9abceb7c8cebe749a4a07f7f40169 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
|
||||
test 8df4eaa7c85bdd4fffa6920137c3072a EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
|
||||
test 7ada999dc73fa2ec7f721e5c8e124e7f SELECT * FROM `test` . `v1` 2
|
||||
test 1efd67df2b28ac47a49938d56094c8c4 SELECT * FROM `test` . `v1` WHERE `a` = ? 2
|
||||
test 9107a99dc94a65bd4d1c92756c2b60a6 SELECT * FROM `test` . `v1` WHERE `b` > ? 2
|
||||
test 375cc5223952495534c4034549d813e2 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
|
||||
test c25e5077415cf620b64c739153ce015b SELECT `a` , `b` FROM `test` . `v1` 2
|
||||
test 9b06d26cce3a78277e5d3b7abbfa7f3e SELECT `b` , `a` FROM `test` . `v1` 2
|
||||
test e7f13e133e0bda19894df88606c37ec3 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
|
||||
DROP VIEW test.v1;
|
||||
DROP TABLE test.t1;
|
||||
|
||||
@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
|
||||
####################################
|
||||
SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
|
||||
event_name digest digest_text sql_text
|
||||
statement/sql/select 1fd0cdb6b5aa22bd0809a39b2dc2ac70 SELECT ? + ? + SELECT ...
|
||||
statement/sql/truncate 0a9c405cebde6df4be315dae86ff398a TRUNCATE TABLE truncat...
|
||||
statement/sql/select dfe1e2b52a48f7294a6385d229770021 SELECT ? + ? + SELECT ...
|
||||
statement/sql/truncate f1b70d4cf1464d22965f02ab6d6b511b TRUNCATE TABLE truncat...
|
||||
|
||||
85
mysql-test/suite/rpl/r/rpl_parallel_seq.result
Normal file
85
mysql-test/suite/rpl/r/rpl_parallel_seq.result
Normal file
@@ -0,0 +1,85 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
# MDEV-29621 the sequence engine binlog_row_image-full events
|
||||
# MDL-deadlock on the parallel slave.
|
||||
connection master;
|
||||
CREATE SEQUENCE s1;
|
||||
SET @@session.binlog_row_image=FULL;
|
||||
SET @@session.debug_dbug="+d,binlog_force_commit_id";
|
||||
SET @commit_id=7;
|
||||
SET @@gtid_seq_no=100;
|
||||
SELECT NEXT VALUE FOR s1;
|
||||
NEXT VALUE FOR s1
|
||||
1
|
||||
INSERT INTO s1 VALUES(2, 1, 10, 1, 2, 1, 1, 0);
|
||||
SET @@session.debug_dbug="";
|
||||
connection slave;
|
||||
SET @@global.slave_parallel_threads=2;
|
||||
SET @@global.slave_parallel_mode=optimistic;
|
||||
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
|
||||
include/start_slave.inc
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
connection master;
|
||||
DROP SEQUENCE s1;
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
# Simulate buggy 10.3.36 master to prove the parallel applier
|
||||
# does not deadlock now at replaying the above master load.
|
||||
connection master;
|
||||
include/rpl_stop_server.inc [server_number=1]
|
||||
include/rpl_start_server.inc [server_number=1]
|
||||
connection slave;
|
||||
RESET MASTER;
|
||||
SET @@global.gtid_slave_pos="";
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_use_gtid=slave_pos;
|
||||
START SLAVE UNTIL MASTER_GTID_POS='0-1-102';
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
# Normal stop is expected
|
||||
include/wait_for_slave_to_stop.inc
|
||||
# MDEV-31077 ALTER SEQUENCE may end up in optimistic parallel slave binlog out-of-order
|
||||
# The test proves ALTER-SEQUENCE binlogs first before the following transaction does so.
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
Warnings:
|
||||
Note 1255 Slave already has been stopped
|
||||
RESET MASTER;
|
||||
SET @@global.gtid_slave_pos="";
|
||||
SET @@global.gtid_strict_mode=1;
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
CREATE TABLE ti (a INT) ENGINE=innodb;
|
||||
CREATE SEQUENCE s2 ENGINE=innodb;
|
||||
SET @@gtid_seq_no=100;
|
||||
ALTER SEQUENCE s2 restart with 1;
|
||||
INSERT INTO ti SET a=1;
|
||||
include/save_master_gtid.inc
|
||||
SELECT @@global.gtid_binlog_state "Master gtid state";
|
||||
Master gtid state
|
||||
0-1-101
|
||||
connection slave;
|
||||
include/start_slave.inc
|
||||
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "no 100,101 yet in both";
|
||||
@@global.gtid_binlog_state no 100,101 yet in both
|
||||
0-1-2 0-1-2
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
# Normal sync with master proves the fixes correct
|
||||
include/sync_with_master_gtid.inc
|
||||
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "all through 101 have been committed";
|
||||
@@global.gtid_binlog_state all through 101 have been committed
|
||||
0-1-101 0-1-101
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
SET debug_sync = RESET;
|
||||
SET @@global.slave_parallel_threads= 0;
|
||||
SET @@global.slave_parallel_mode= optimistic;
|
||||
SET @@global.debug_dbug = "";
|
||||
SET @@global.gtid_strict_mode=0;
|
||||
include/start_slave.inc
|
||||
connection master;
|
||||
DROP SEQUENCE s2;
|
||||
DROP TABLE ti;
|
||||
connection slave;
|
||||
include/rpl_end.inc
|
||||
@@ -17,10 +17,6 @@
|
||||
# BUG#12133 master.index file keeps mysqld from starting if bin log has been moved
|
||||
# BUG#42576 Relay logs in relay-log.info&localhost-relay-bin.index not processed after move
|
||||
|
||||
source include/master-slave.inc;
|
||||
# There is no need to run this test case on all binlog format
|
||||
source include/have_binlog_format_row.inc;
|
||||
|
||||
# Since this test relies heavily on filesystem operations (like
|
||||
# moving files around, backslashes and so forth) we avoid messing
|
||||
# around with windows access violations for not cluttering the
|
||||
@@ -28,6 +24,10 @@ source include/have_binlog_format_row.inc;
|
||||
# it is not 100% compliant.
|
||||
--source include/not_windows.inc
|
||||
|
||||
source include/master-slave.inc;
|
||||
# There is no need to run this test case on all binlog format
|
||||
source include/have_binlog_format_row.inc;
|
||||
|
||||
connection master;
|
||||
--let $master_datadir= `select @@datadir`
|
||||
connection slave;
|
||||
|
||||
@@ -2,10 +2,10 @@ if (`SELECT $PS_PROTOCOL != 0`)
|
||||
{
|
||||
--skip Test temporarily disabled for ps-protocol
|
||||
}
|
||||
--source include/no_valgrind_without_big.inc
|
||||
--let $rpl_topology=1->2
|
||||
--source include/rpl_init.inc
|
||||
--source include/have_innodb.inc
|
||||
--source include/no_valgrind_without_big.inc
|
||||
|
||||
--echo *** Test normal shutdown/restart of slave server configured as a GTID slave. ***
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#
|
||||
# (iii) master and slave tables do not differ
|
||||
#
|
||||
-- source include/master-slave.inc
|
||||
-- source include/not_windows.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
SET SQL_LOG_BIN=0;
|
||||
CREATE DATABASE B37656;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--source include/no_valgrind_without_big.inc
|
||||
--source include/have_innodb.inc
|
||||
--let $rpl_topology=1->2
|
||||
--source include/rpl_init.inc
|
||||
--source include/no_valgrind_without_big.inc
|
||||
|
||||
--connection server_2
|
||||
call mtr.add_suppression("The automatically created table.*name may not be entirely in lowercase");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--source include/not_windows.inc #unix shell escaping used for mysqlbinlog
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_binlog_format_statement.inc
|
||||
--source include/master-slave.inc
|
||||
--source include/not_windows.inc #unix shell escaping used for mysqlbinlog
|
||||
|
||||
# MDEV-382: multiple SQL injections in replication code.
|
||||
|
||||
|
||||
131
mysql-test/suite/rpl/t/rpl_parallel_seq.test
Normal file
131
mysql-test/suite/rpl/t/rpl_parallel_seq.test
Normal file
@@ -0,0 +1,131 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
--connection slave
|
||||
--source include/stop_slave.inc
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
|
||||
--echo # MDEV-29621 the sequence engine binlog_row_image-full events
|
||||
--echo # MDL-deadlock on the parallel slave.
|
||||
--connection master
|
||||
CREATE SEQUENCE s1;
|
||||
SET @@session.binlog_row_image=FULL;
|
||||
SET @@session.debug_dbug="+d,binlog_force_commit_id";
|
||||
SET @commit_id=7;
|
||||
SET @@gtid_seq_no=100;
|
||||
SELECT NEXT VALUE FOR s1;
|
||||
INSERT INTO s1 VALUES(2, 1, 10, 1, 2, 1, 1, 0);
|
||||
SET @@session.debug_dbug="";
|
||||
|
||||
--connection slave
|
||||
--let $slave_parallel_threads=`select @@global.slave_parallel_threads`
|
||||
--let $slave_parallel_mode=`select @@global.slave_parallel_mode`
|
||||
SET @@global.slave_parallel_threads=2;
|
||||
SET @@global.slave_parallel_mode=optimistic;
|
||||
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
|
||||
--source include/start_slave.inc
|
||||
|
||||
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit"
|
||||
--source include/wait_condition.inc
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
|
||||
--connection master
|
||||
DROP SEQUENCE s1;
|
||||
--sync_slave_with_master
|
||||
--source include/stop_slave.inc
|
||||
|
||||
--echo # Simulate buggy 10.3.36 master to prove the parallel applier
|
||||
--echo # does not deadlock now at replaying the above master load.
|
||||
--connection master
|
||||
--let $datadir= `SELECT @@datadir`
|
||||
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_stop_server.inc
|
||||
|
||||
--remove_file $datadir/master-bin.000001
|
||||
--copy_file $MYSQL_TEST_DIR/std_data/rpl/master-bin-seq_10.3.36.000001 $datadir/master-bin.000001
|
||||
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_start_server.inc
|
||||
|
||||
--source include/wait_until_connected_again.inc
|
||||
--save_master_pos
|
||||
|
||||
--connection slave
|
||||
RESET MASTER;
|
||||
SET @@global.gtid_slave_pos="";
|
||||
|
||||
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
|
||||
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_use_gtid=slave_pos;
|
||||
|
||||
START SLAVE UNTIL MASTER_GTID_POS='0-1-102';
|
||||
|
||||
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit"
|
||||
--source include/wait_condition.inc
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
|
||||
--echo # Normal stop is expected
|
||||
--source include/wait_for_slave_to_stop.inc
|
||||
|
||||
--echo # MDEV-31077 ALTER SEQUENCE may end up in optimistic parallel slave binlog out-of-order
|
||||
--echo # The test proves ALTER-SEQUENCE binlogs first before the following transaction does so.
|
||||
|
||||
--connection slave
|
||||
--source include/stop_slave.inc
|
||||
RESET MASTER;
|
||||
SET @@global.gtid_slave_pos="";
|
||||
--let $slave_gtid_strict_mode=`select @@global.gtid_strict_mode`
|
||||
SET @@global.gtid_strict_mode=1;
|
||||
--connection master
|
||||
RESET MASTER;
|
||||
|
||||
# Load from master
|
||||
CREATE TABLE ti (a INT) ENGINE=innodb;
|
||||
CREATE SEQUENCE s2 ENGINE=innodb;
|
||||
|
||||
SET @@gtid_seq_no=100;
|
||||
ALTER SEQUENCE s2 restart with 1;
|
||||
INSERT INTO ti SET a=1;
|
||||
--source include/save_master_gtid.inc
|
||||
SELECT @@global.gtid_binlog_state "Master gtid state";
|
||||
|
||||
--connection slave
|
||||
--source include/start_slave.inc
|
||||
|
||||
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit"
|
||||
--source include/wait_condition.inc
|
||||
|
||||
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "no 100,101 yet in both";
|
||||
|
||||
# DEBUG_DBUG extension point of hold_worker_on_schedule is reused
|
||||
# (gets deployed) in Sql_cmd_alter_sequence::execute.
|
||||
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
||||
|
||||
--echo # Normal sync with master proves the fixes correct
|
||||
--source include/sync_with_master_gtid.inc
|
||||
|
||||
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "all through 101 have been committed";
|
||||
|
||||
#
|
||||
# MDEV-29621/MDEV-31077 clean up.
|
||||
#
|
||||
--connection slave
|
||||
--source include/stop_slave.inc
|
||||
|
||||
SET debug_sync = RESET;
|
||||
--eval SET @@global.slave_parallel_threads= $slave_parallel_threads
|
||||
--eval SET @@global.slave_parallel_mode= $slave_parallel_mode
|
||||
SET @@global.debug_dbug = "";
|
||||
--eval SET @@global.gtid_strict_mode=$slave_gtid_strict_mode
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection master
|
||||
DROP SEQUENCE s2;
|
||||
DROP TABLE ti;
|
||||
|
||||
--sync_slave_with_master
|
||||
|
||||
--source include/rpl_end.inc
|
||||
@@ -3,10 +3,10 @@
|
||||
# For details look into extra/rpl_tests/rpl_lower_case_table_names.test
|
||||
#
|
||||
|
||||
-- source include/master-slave.inc
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/not_windows.inc
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_binlog_format_row.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
-- let $engine=InnoDB
|
||||
-- source include/rpl_lower_case_table_names.test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
source include/no_valgrind_without_big.inc;
|
||||
source include/not_embedded.inc;
|
||||
source include/have_innodb.inc;
|
||||
source include/master-slave.inc;
|
||||
source include/no_valgrind_without_big.inc;
|
||||
|
||||
let $engine_type= InnoDB;
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
# Please check all dependent tests after modifying it
|
||||
#
|
||||
|
||||
source include/no_valgrind_without_big.inc;
|
||||
source include/have_ssl_communication.inc;
|
||||
source include/master-slave.inc;
|
||||
source include/no_valgrind_without_big.inc;
|
||||
|
||||
# create a user for replication that requires ssl encryption
|
||||
connection master;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
# For details look into extra/rpl_tests/rpl_lower_case_table_names.test
|
||||
#
|
||||
|
||||
-- source include/not_windows.inc
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_binlog_format_mixed_or_statement.inc
|
||||
-- source include/master-slave.inc
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/not_windows.inc
|
||||
|
||||
-- let $engine=InnoDB
|
||||
-- source include/rpl_lower_case_table_names.test
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
set @@global.optimizer_switch=@@optimizer_switch;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
show global variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
show session variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select * from information_schema.global_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select * from information_schema.session_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=off
|
||||
set global optimizer_switch=4101;
|
||||
set session optimizer_switch=2058;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
set global optimizer_switch="index_merge_sort_union=on";
|
||||
set session optimizer_switch="index_merge=off";
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
show global variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
optimizer_switch index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
show session variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select * from information_schema.global_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
select * from information_schema.session_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
set session optimizer_switch="default";
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off,not_null_range_scan=off,hash_join_cardinality=off
|
||||
set optimizer_switch = replace(@@optimizer_switch, '=off', '=on');
|
||||
Warnings:
|
||||
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=on,hash_join_cardinality=on
|
||||
set global optimizer_switch=1.1;
|
||||
ERROR 42000: Incorrect argument type to variable 'optimizer_switch'
|
||||
set global optimizer_switch=1e1;
|
||||
|
||||
@@ -2299,7 +2299,7 @@ VARIABLE_COMMENT Fine-tune the optimizer behavior
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,rowid_filter,condition_pushdown_from_having,not_null_range_scan,default
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,rowid_filter,condition_pushdown_from_having,not_null_range_scan,hash_join_cardinality,default
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_TRACE
|
||||
|
||||
@@ -2469,7 +2469,7 @@ VARIABLE_COMMENT Fine-tune the optimizer behavior
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,rowid_filter,condition_pushdown_from_having,not_null_range_scan,default
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,rowid_filter,condition_pushdown_from_having,not_null_range_scan,hash_join_cardinality,default
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_TRACE
|
||||
|
||||
@@ -250,6 +250,8 @@ int ha_sequence::write_row(const uchar *buf)
|
||||
on master and slaves
|
||||
- Check that the new row is an accurate SEQUENCE object
|
||||
*/
|
||||
/* mark a full binlog image insert to force non-parallel slave */
|
||||
thd->transaction->stmt.mark_trans_did_ddl();
|
||||
if (table->s->tmp_table == NO_TMP_TABLE &&
|
||||
thd->mdl_context.upgrade_shared_lock(table->mdl_ticket,
|
||||
MDL_EXCLUSIVE,
|
||||
|
||||
10
sql/item.cc
10
sql/item.cc
@@ -10547,7 +10547,8 @@ int Item_cache_str::save_in_field(Field *field, bool no_conversions)
|
||||
bool Item_cache_row::allocate(THD *thd, uint num)
|
||||
{
|
||||
item_count= num;
|
||||
return (!(values=
|
||||
return (!values &&
|
||||
!(values=
|
||||
(Item_cache **) thd->calloc(sizeof(Item_cache *)*item_count)));
|
||||
}
|
||||
|
||||
@@ -10583,11 +10584,12 @@ bool Item_cache_row::setup(THD *thd, Item *item)
|
||||
return 1;
|
||||
for (uint i= 0; i < item_count; i++)
|
||||
{
|
||||
Item_cache *tmp;
|
||||
Item *el= item->element_index(i);
|
||||
if (!(tmp= values[i]= el->get_cache(thd)))
|
||||
|
||||
if ((!values[i]) && !(values[i]= el->get_cache(thd)))
|
||||
return 1;
|
||||
tmp->setup(thd, el);
|
||||
|
||||
values[i]->setup(thd, el);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
10
sql/item.h
10
sql/item.h
@@ -7115,6 +7115,9 @@ public:
|
||||
}
|
||||
|
||||
virtual void keep_array() {}
|
||||
#ifndef DBUG_OFF
|
||||
bool is_array_kept() { return TRUE; }
|
||||
#endif
|
||||
void print(String *str, enum_query_type query_type) override;
|
||||
bool eq_def(const Field *field)
|
||||
{
|
||||
@@ -7603,13 +7606,14 @@ public:
|
||||
bool null_inside() override;
|
||||
void bring_value() override;
|
||||
void keep_array() override { save_array= 1; }
|
||||
#ifndef DBUG_OFF
|
||||
bool is_array_kept() { return save_array; }
|
||||
#endif
|
||||
void cleanup() override
|
||||
{
|
||||
DBUG_ENTER("Item_cache_row::cleanup");
|
||||
Item_cache::cleanup();
|
||||
if (save_array)
|
||||
bzero(values, item_count*sizeof(Item**));
|
||||
else
|
||||
if (!save_array)
|
||||
values= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -1292,9 +1292,22 @@ bool Item_in_optimizer::fix_left(THD *thd)
|
||||
ref0= args[1]->get_IN_subquery()->left_exp_ptr();
|
||||
args[0]= (*ref0);
|
||||
}
|
||||
if ((*ref0)->fix_fields_if_needed(thd, ref0) ||
|
||||
(!cache && !(cache= (*ref0)->get_cache(thd))))
|
||||
if ((*ref0)->fix_fields_if_needed(thd, ref0))
|
||||
DBUG_RETURN(1);
|
||||
if (!cache)
|
||||
{
|
||||
Query_arena *arena, backup;
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
bool rc= !(cache= (*ref0)->get_cache(thd));
|
||||
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
|
||||
if (rc)
|
||||
DBUG_RETURN(1);
|
||||
cache->keep_array();
|
||||
}
|
||||
/*
|
||||
During fix_field() expression could be substituted.
|
||||
So we copy changes before use
|
||||
@@ -1654,19 +1667,10 @@ longlong Item_in_optimizer::val_int()
|
||||
}
|
||||
|
||||
|
||||
void Item_in_optimizer::keep_top_level_cache()
|
||||
{
|
||||
cache->keep_array();
|
||||
save_cache= 1;
|
||||
}
|
||||
|
||||
|
||||
void Item_in_optimizer::cleanup()
|
||||
{
|
||||
DBUG_ENTER("Item_in_optimizer::cleanup");
|
||||
Item_bool_func::cleanup();
|
||||
if (!save_cache)
|
||||
cache= 0;
|
||||
expr_cache= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -374,8 +374,7 @@ class Item_in_optimizer: public Item_bool_func
|
||||
protected:
|
||||
Item_cache *cache;
|
||||
Item *expr_cache;
|
||||
bool save_cache;
|
||||
/*
|
||||
/*
|
||||
Stores the value of "NULL IN (SELECT ...)" for uncorrelated subqueries:
|
||||
UNKNOWN - "NULL in (SELECT ...)" has not yet been evaluated
|
||||
FALSE - result is FALSE
|
||||
@@ -385,7 +384,7 @@ protected:
|
||||
public:
|
||||
Item_in_optimizer(THD *thd, Item *a, Item *b):
|
||||
Item_bool_func(thd, a, b), cache(0), expr_cache(0),
|
||||
save_cache(0), result_for_null_param(UNKNOWN)
|
||||
result_for_null_param(UNKNOWN)
|
||||
{
|
||||
with_flags|= item_with_t::SUBQUERY;
|
||||
}
|
||||
@@ -402,7 +401,6 @@ public:
|
||||
return name;
|
||||
}
|
||||
Item_cache **get_cache() { return &cache; }
|
||||
void keep_top_level_cache();
|
||||
Item *transform(THD *thd, Item_transformer transformer, uchar *arg) override;
|
||||
Item *expr_cache_insert_transformer(THD *thd, uchar *unused) override;
|
||||
bool is_expensive_processor(void *arg) override;
|
||||
|
||||
@@ -406,11 +406,11 @@ bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select,
|
||||
{
|
||||
is_correlated= TRUE;
|
||||
Ref_to_outside *upper;
|
||||
if (!(upper= new (thd->stmt_arena->mem_root) Ref_to_outside()))
|
||||
if (!(upper= new (thd->mem_root) Ref_to_outside()))
|
||||
return TRUE;
|
||||
upper->select= select;
|
||||
upper->item= item;
|
||||
if (upper_refs.push_back(upper, thd->stmt_arena->mem_root))
|
||||
if (upper_refs.push_back(upper, thd->mem_root))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -2066,7 +2066,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
|
||||
thd->lex->current_select= current;
|
||||
|
||||
/* We will refer to upper level cache array => we have to save it for SP */
|
||||
optimizer->keep_top_level_cache();
|
||||
DBUG_ASSERT(optimizer->get_cache()[0]->is_array_kept());
|
||||
|
||||
/*
|
||||
As far as Item_in_optimizer does not substitute itself on fix_fields
|
||||
@@ -2466,7 +2466,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
|
||||
}
|
||||
|
||||
// we will refer to upper level cache array => we have to save it in PS
|
||||
optimizer->keep_top_level_cache();
|
||||
DBUG_ASSERT(optimizer->get_cache()[0]->is_array_kept());
|
||||
|
||||
thd->lex->current_select= current;
|
||||
/*
|
||||
|
||||
@@ -7881,8 +7881,18 @@ Rows_log_event::write_row(rpl_group_info *rgi,
|
||||
int Rows_log_event::update_sequence()
|
||||
{
|
||||
TABLE *table= m_table; // pointer to event's table
|
||||
bool old_master= false;
|
||||
int err= 0;
|
||||
|
||||
if (!bitmap_is_set(table->rpl_write_set, MIN_VALUE_FIELD_NO))
|
||||
if (!bitmap_is_set(table->rpl_write_set, MIN_VALUE_FIELD_NO) ||
|
||||
(
|
||||
#if defined(WITH_WSREP)
|
||||
! WSREP(thd) &&
|
||||
#endif
|
||||
!(table->in_use->rgi_slave->gtid_ev_flags2 & Gtid_log_event::FL_DDL) &&
|
||||
!(old_master=
|
||||
rpl_master_has_bug(thd->rgi_slave->rli,
|
||||
29621, FALSE, FALSE, FALSE, TRUE))))
|
||||
{
|
||||
/* This event come from a setval function executed on the master.
|
||||
Update the sequence next_number and round, like we do with setval()
|
||||
@@ -7895,12 +7905,27 @@ int Rows_log_event::update_sequence()
|
||||
|
||||
return table->s->sequence->set_value(table, nextval, round, 0) > 0;
|
||||
}
|
||||
|
||||
if (old_master && !WSREP(thd) && thd->rgi_slave->is_parallel_exec)
|
||||
{
|
||||
DBUG_ASSERT(thd->rgi_slave->parallel_entry);
|
||||
/*
|
||||
With parallel replication enabled, we can't execute alongside any other
|
||||
transaction in which we may depend, so we force retry to release
|
||||
the server layer table lock for possible prior in binlog order
|
||||
same table transactions.
|
||||
*/
|
||||
if (thd->rgi_slave->parallel_entry->last_committed_sub_id <
|
||||
thd->rgi_slave->wait_commit_sub_id)
|
||||
{
|
||||
err= ER_LOCK_DEADLOCK;
|
||||
my_error(err, MYF(0));
|
||||
}
|
||||
}
|
||||
/*
|
||||
Update all fields in table and update the active sequence, like with
|
||||
ALTER SEQUENCE
|
||||
*/
|
||||
return table->file->ha_write_row(table->record[0]);
|
||||
return err == 0 ? table->file->ha_write_row(table->record[0]) : err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3173,7 +3173,12 @@ rpl_parallel::do_event(rpl_group_info *serial_rgi, Log_event *ev,
|
||||
|
||||
if (mode <= SLAVE_PARALLEL_MINIMAL ||
|
||||
!(gtid_flags & Gtid_log_event::FL_GROUP_COMMIT_ID) ||
|
||||
e->last_commit_id != gtid_ev->commit_id)
|
||||
e->last_commit_id != gtid_ev->commit_id ||
|
||||
/*
|
||||
MULTI_BATCH is also set when the current gtid even being a member
|
||||
of a commit group is flagged as DDL which disallows parallel.
|
||||
*/
|
||||
(gtid_flags & Gtid_log_event::FL_DDL))
|
||||
flags|= group_commit_orderer::MULTI_BATCH;
|
||||
/* Make sure we do not attempt to run DDL in parallel speculatively. */
|
||||
if (gtid_flags & Gtid_log_event::FL_DDL)
|
||||
|
||||
35
sql/slave.cc
35
sql/slave.cc
@@ -8244,14 +8244,15 @@ end:
|
||||
@return TRUE if master has the bug, FALSE if it does not.
|
||||
*/
|
||||
bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
|
||||
bool (*pred)(const void *), const void *param)
|
||||
bool (*pred)(const void *), const void *param,
|
||||
bool maria_master)
|
||||
{
|
||||
struct st_version_range_for_one_bug {
|
||||
uint bug_id;
|
||||
Version introduced_in; // first version with bug
|
||||
Version fixed_in; // first version with fix
|
||||
};
|
||||
static struct st_version_range_for_one_bug versions_for_all_bugs[]=
|
||||
static struct st_version_range_for_one_bug versions_for_their_bugs[]=
|
||||
{
|
||||
{24432, { 5, 0, 24 }, { 5, 0, 38 } },
|
||||
{24432, { 5, 1, 12 }, { 5, 1, 17 } },
|
||||
@@ -8259,11 +8260,27 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
|
||||
{33029, { 5, 1, 0 }, { 5, 1, 12 } },
|
||||
{37426, { 5, 1, 0 }, { 5, 1, 26 } },
|
||||
};
|
||||
static struct st_version_range_for_one_bug versions_for_our_bugs[]=
|
||||
{
|
||||
{29621, { 10, 3, 36 }, { 10, 3, 39 } },
|
||||
{29621, { 10, 4, 26 }, { 10, 4, 29 } },
|
||||
{29621, { 10, 5, 17 }, { 10, 5, 20 } },
|
||||
{29621, { 10, 6, 9 }, { 10, 6, 13 } },
|
||||
{29621, { 10, 7, 5 }, { 10, 7, 9 } },
|
||||
{29621, { 10, 8, 4 }, { 10, 8, 8 } },
|
||||
{29621, { 10, 9, 2 }, { 10, 9, 6 } },
|
||||
{29621, { 10, 10,1 }, { 10, 10,4 } },
|
||||
{29621, { 10, 11,1 }, { 10, 11,3 } },
|
||||
};
|
||||
const Version &master_ver=
|
||||
rli->relay_log.description_event_for_exec->server_version_split;
|
||||
struct st_version_range_for_one_bug* versions_for_all_bugs= maria_master ?
|
||||
versions_for_our_bugs : versions_for_their_bugs;
|
||||
uint all_size= maria_master ?
|
||||
sizeof(versions_for_our_bugs)/sizeof(*versions_for_our_bugs) :
|
||||
sizeof(versions_for_their_bugs)/sizeof(*versions_for_their_bugs);
|
||||
|
||||
for (uint i= 0;
|
||||
i < sizeof(versions_for_all_bugs)/sizeof(*versions_for_all_bugs);i++)
|
||||
for (uint i= 0; i < all_size; i++)
|
||||
{
|
||||
const Version &introduced_in= versions_for_all_bugs[i].introduced_in;
|
||||
const Version &fixed_in= versions_for_all_bugs[i].fixed_in;
|
||||
@@ -8272,18 +8289,21 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
|
||||
fixed_in > master_ver &&
|
||||
(pred == NULL || (*pred)(param)))
|
||||
{
|
||||
const char *bug_source= maria_master ?
|
||||
"https://jira.mariadb.org/browse/MDEV-" :
|
||||
"http://bugs.mysql.com/bug.php?id=";
|
||||
if (!report)
|
||||
return TRUE;
|
||||
// a short message for SHOW SLAVE STATUS (message length constraints)
|
||||
my_printf_error(ER_UNKNOWN_ERROR, "master may suffer from"
|
||||
" http://bugs.mysql.com/bug.php?id=%u"
|
||||
" %s%u"
|
||||
" so slave stops; check error log on slave"
|
||||
" for more info", MYF(0), bug_id);
|
||||
" for more info", MYF(0), bug_source, bug_id);
|
||||
// a verbose message for the error log
|
||||
rli->report(ERROR_LEVEL, ER_UNKNOWN_ERROR, NULL,
|
||||
"According to the master's version ('%s'),"
|
||||
" it is probable that master suffers from this bug:"
|
||||
" http://bugs.mysql.com/bug.php?id=%u"
|
||||
" %s%u"
|
||||
" and thus replicating the current binary log event"
|
||||
" may make the slave's data become different from the"
|
||||
" master's data."
|
||||
@@ -8297,6 +8317,7 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
|
||||
" equal to '%d.%d.%d'. Then replication can be"
|
||||
" restarted.",
|
||||
rli->relay_log.description_event_for_exec->server_version,
|
||||
bug_source,
|
||||
bug_id,
|
||||
fixed_in[0], fixed_in[1], fixed_in[2]);
|
||||
return TRUE;
|
||||
|
||||
@@ -231,7 +231,8 @@ bool show_all_master_info(THD* thd);
|
||||
void show_binlog_info_get_fields(THD *thd, List<Item> *field_list);
|
||||
bool show_binlog_info(THD* thd);
|
||||
bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
|
||||
bool (*pred)(const void *), const void *param);
|
||||
bool (*pred)(const void *), const void *param,
|
||||
bool maria_master= false);
|
||||
bool rpl_master_erroneous_autoinc(THD* thd);
|
||||
|
||||
const char *print_slave_db_safe(const char *db);
|
||||
|
||||
@@ -2257,7 +2257,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry, TABLE_LIST *t
|
||||
for (Field **field=entry->field ; *field ; field++)
|
||||
{
|
||||
if (!bitmap_is_set(write_set, (*field)->field_index) &&
|
||||
!(*field)->vers_sys_field() &&
|
||||
!(*field)->vers_sys_field() && !(*field)->vcol_info &&
|
||||
has_no_default_value(thd, *field, table_list) &&
|
||||
((*field)->real_type() != MYSQL_TYPE_ENUM))
|
||||
err=1;
|
||||
|
||||
@@ -886,7 +886,7 @@ void Lex_input_stream::body_utf8_start(THD *thd, const char *begin_ptr)
|
||||
}
|
||||
|
||||
|
||||
size_t Lex_input_stream::get_body_utf8_maximum_length(THD *thd)
|
||||
size_t Lex_input_stream::get_body_utf8_maximum_length(THD *thd) const
|
||||
{
|
||||
/*
|
||||
String literals can grow during escaping:
|
||||
@@ -1391,7 +1391,7 @@ Yacc_state::~Yacc_state()
|
||||
}
|
||||
|
||||
int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd,
|
||||
uint len, bool function)
|
||||
uint len, bool function) const
|
||||
{
|
||||
const char *tok= m_tok_start;
|
||||
|
||||
@@ -4090,7 +4090,7 @@ bool LEX::can_use_merged()
|
||||
TRUE - VIEWs with MERGE algorithms can be used
|
||||
*/
|
||||
|
||||
bool LEX::can_not_use_merged(bool no_update_or_delete)
|
||||
bool LEX::can_not_use_merged()
|
||||
{
|
||||
switch (sql_command) {
|
||||
case SQLCOM_CREATE_VIEW:
|
||||
@@ -4103,10 +4103,6 @@ bool LEX::can_not_use_merged(bool no_update_or_delete)
|
||||
case SQLCOM_SHOW_FIELDS:
|
||||
return TRUE;
|
||||
|
||||
case SQLCOM_UPDATE_MULTI:
|
||||
case SQLCOM_DELETE_MULTI:
|
||||
return no_update_or_delete;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@@ -9407,22 +9403,6 @@ bool LEX::add_grant_command(THD *thd, const List<LEX_COLUMN> &columns)
|
||||
}
|
||||
|
||||
|
||||
Item *LEX::make_item_func_substr(THD *thd, Item *a, Item *b, Item *c)
|
||||
{
|
||||
return (thd->variables.sql_mode & MODE_ORACLE) ?
|
||||
new (thd->mem_root) Item_func_substr_oracle(thd, a, b, c) :
|
||||
new (thd->mem_root) Item_func_substr(thd, a, b, c);
|
||||
}
|
||||
|
||||
|
||||
Item *LEX::make_item_func_substr(THD *thd, Item *a, Item *b)
|
||||
{
|
||||
return (thd->variables.sql_mode & MODE_ORACLE) ?
|
||||
new (thd->mem_root) Item_func_substr_oracle(thd, a, b) :
|
||||
new (thd->mem_root) Item_func_substr(thd, a, b);
|
||||
}
|
||||
|
||||
|
||||
Item *LEX::make_item_func_sysdate(THD *thd, uint fsp)
|
||||
{
|
||||
/*
|
||||
@@ -9443,17 +9423,6 @@ Item *LEX::make_item_func_sysdate(THD *thd, uint fsp)
|
||||
}
|
||||
|
||||
|
||||
Item *LEX::make_item_func_replace(THD *thd,
|
||||
Item *org,
|
||||
Item *find,
|
||||
Item *replace)
|
||||
{
|
||||
return (thd->variables.sql_mode & MODE_ORACLE) ?
|
||||
new (thd->mem_root) Item_func_replace_oracle(thd, org, find, replace) :
|
||||
new (thd->mem_root) Item_func_replace(thd, org, find, replace);
|
||||
}
|
||||
|
||||
|
||||
bool SELECT_LEX::vers_push_field(THD *thd, TABLE_LIST *table,
|
||||
const LEX_CSTRING field_name)
|
||||
{
|
||||
@@ -11891,3 +11860,9 @@ bool SELECT_LEX_UNIT::explainable() const
|
||||
derived->is_materialized_derived() : // (3)
|
||||
false;
|
||||
}
|
||||
|
||||
|
||||
bool st_select_lex::is_query_topmost(THD *thd)
|
||||
{
|
||||
return get_master() == &thd->lex->unit;
|
||||
}
|
||||
|
||||
@@ -1383,6 +1383,7 @@ public:
|
||||
return (st_select_lex_unit*) slave;
|
||||
}
|
||||
st_select_lex* outer_select();
|
||||
bool is_query_topmost(THD *thd);
|
||||
st_select_lex* next_select() { return (st_select_lex*) next; }
|
||||
st_select_lex* next_select_in_list()
|
||||
{
|
||||
@@ -2505,7 +2506,7 @@ private:
|
||||
Get the last character accepted.
|
||||
@return the last character accepted.
|
||||
*/
|
||||
unsigned char yyGetLast()
|
||||
unsigned char yyGetLast() const
|
||||
{
|
||||
return m_ptr[-1];
|
||||
}
|
||||
@@ -2513,7 +2514,7 @@ private:
|
||||
/**
|
||||
Look at the next character to parse, but do not accept it.
|
||||
*/
|
||||
unsigned char yyPeek()
|
||||
unsigned char yyPeek() const
|
||||
{
|
||||
return m_ptr[0];
|
||||
}
|
||||
@@ -2522,7 +2523,7 @@ private:
|
||||
Look ahead at some character to parse.
|
||||
@param n offset of the character to look up
|
||||
*/
|
||||
unsigned char yyPeekn(int n)
|
||||
unsigned char yyPeekn(int n) const
|
||||
{
|
||||
return m_ptr[n];
|
||||
}
|
||||
@@ -2583,7 +2584,7 @@ private:
|
||||
@param n number of characters expected
|
||||
@return true if there are less than n characters to parse
|
||||
*/
|
||||
bool eof(int n)
|
||||
bool eof(int n) const
|
||||
{
|
||||
return ((m_ptr + n) >= m_end_of_query);
|
||||
}
|
||||
@@ -2614,10 +2615,10 @@ private:
|
||||
Get the maximum length of the utf8-body buffer.
|
||||
The utf8 body can grow because of the character set conversion and escaping.
|
||||
*/
|
||||
size_t get_body_utf8_maximum_length(THD *thd);
|
||||
size_t get_body_utf8_maximum_length(THD *thd) const;
|
||||
|
||||
/** Get the length of the current token, in the raw buffer. */
|
||||
uint yyLength()
|
||||
uint yyLength() const
|
||||
{
|
||||
/*
|
||||
The assumption is that the lexical analyser is always 1 character ahead,
|
||||
@@ -2642,31 +2643,31 @@ public:
|
||||
End of file indicator for the query text to parse.
|
||||
@return true if there are no more characters to parse
|
||||
*/
|
||||
bool eof()
|
||||
bool eof() const
|
||||
{
|
||||
return (m_ptr >= m_end_of_query);
|
||||
}
|
||||
|
||||
/** Get the raw query buffer. */
|
||||
const char *get_buf()
|
||||
const char *get_buf() const
|
||||
{
|
||||
return m_buf;
|
||||
}
|
||||
|
||||
/** Get the pre-processed query buffer. */
|
||||
const char *get_cpp_buf()
|
||||
const char *get_cpp_buf() const
|
||||
{
|
||||
return m_cpp_buf;
|
||||
}
|
||||
|
||||
/** Get the end of the raw query buffer. */
|
||||
const char *get_end_of_query()
|
||||
const char *get_end_of_query() const
|
||||
{
|
||||
return m_end_of_query;
|
||||
}
|
||||
|
||||
/** Get the token start position, in the raw buffer. */
|
||||
const char *get_tok_start()
|
||||
const char *get_tok_start() const
|
||||
{
|
||||
return has_lookahead() ? m_tok_start_prev : m_tok_start;
|
||||
}
|
||||
@@ -2677,25 +2678,25 @@ public:
|
||||
}
|
||||
|
||||
/** Get the token end position, in the raw buffer. */
|
||||
const char *get_tok_end()
|
||||
const char *get_tok_end() const
|
||||
{
|
||||
return m_tok_end;
|
||||
}
|
||||
|
||||
/** Get the current stream pointer, in the raw buffer. */
|
||||
const char *get_ptr()
|
||||
const char *get_ptr() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
/** Get the token start position, in the pre-processed buffer. */
|
||||
const char *get_cpp_tok_start()
|
||||
const char *get_cpp_tok_start() const
|
||||
{
|
||||
return has_lookahead() ? m_cpp_tok_start_prev : m_cpp_tok_start;
|
||||
}
|
||||
|
||||
/** Get the token end position, in the pre-processed buffer. */
|
||||
const char *get_cpp_tok_end()
|
||||
const char *get_cpp_tok_end() const
|
||||
{
|
||||
return m_cpp_tok_end;
|
||||
}
|
||||
@@ -2704,7 +2705,7 @@ public:
|
||||
Get the token end position in the pre-processed buffer,
|
||||
with trailing spaces removed.
|
||||
*/
|
||||
const char *get_cpp_tok_end_rtrim()
|
||||
const char *get_cpp_tok_end_rtrim() const
|
||||
{
|
||||
const char *p;
|
||||
for (p= m_cpp_tok_end;
|
||||
@@ -2715,7 +2716,7 @@ public:
|
||||
}
|
||||
|
||||
/** Get the current stream pointer, in the pre-processed buffer. */
|
||||
const char *get_cpp_ptr()
|
||||
const char *get_cpp_ptr() const
|
||||
{
|
||||
return m_cpp_ptr;
|
||||
}
|
||||
@@ -2724,7 +2725,7 @@ public:
|
||||
Get the current stream pointer, in the pre-processed buffer,
|
||||
with traling spaces removed.
|
||||
*/
|
||||
const char *get_cpp_ptr_rtrim()
|
||||
const char *get_cpp_ptr_rtrim() const
|
||||
{
|
||||
const char *p;
|
||||
for (p= m_cpp_ptr;
|
||||
@@ -2734,13 +2735,13 @@ public:
|
||||
return p;
|
||||
}
|
||||
/** Get the utf8-body string. */
|
||||
const char *get_body_utf8_str()
|
||||
const char *get_body_utf8_str() const
|
||||
{
|
||||
return m_body_utf8;
|
||||
}
|
||||
|
||||
/** Get the utf8-body length. */
|
||||
size_t get_body_utf8_length()
|
||||
size_t get_body_utf8_length() const
|
||||
{
|
||||
return (size_t) (m_body_utf8_ptr - m_body_utf8);
|
||||
}
|
||||
@@ -2776,7 +2777,7 @@ private:
|
||||
|
||||
bool consume_comment(int remaining_recursions_permitted);
|
||||
int lex_one_token(union YYSTYPE *yylval, THD *thd);
|
||||
int find_keyword(Lex_ident_cli_st *str, uint len, bool function);
|
||||
int find_keyword(Lex_ident_cli_st *str, uint len, bool function) const;
|
||||
LEX_CSTRING get_token(uint skip, uint length);
|
||||
int scan_ident_sysvar(THD *thd, Lex_ident_cli_st *str);
|
||||
int scan_ident_start(THD *thd, Lex_ident_cli_st *str);
|
||||
@@ -3651,7 +3652,7 @@ public:
|
||||
|
||||
bool can_be_merged();
|
||||
bool can_use_merged();
|
||||
bool can_not_use_merged(bool no_update_or_delete);
|
||||
bool can_not_use_merged();
|
||||
bool only_view_structure();
|
||||
bool need_correct_ident();
|
||||
uint8 get_effective_with_check(TABLE_LIST *view);
|
||||
@@ -4125,9 +4126,6 @@ public:
|
||||
|
||||
Item *create_item_query_expression(THD *thd, st_select_lex_unit *unit);
|
||||
|
||||
Item *make_item_func_replace(THD *thd, Item *org, Item *find, Item *replace);
|
||||
Item *make_item_func_substr(THD *thd, Item *a, Item *b, Item *c);
|
||||
Item *make_item_func_substr(THD *thd, Item *a, Item *b);
|
||||
Item *make_item_func_sysdate(THD *thd, uint fsp);
|
||||
Item *make_item_func_call_generic(THD *thd, Lex_ident_cli_st *db,
|
||||
Lex_ident_cli_st *name, List<Item> *args);
|
||||
|
||||
@@ -234,6 +234,7 @@
|
||||
#define OPTIMIZER_SWITCH_USE_ROWID_FILTER (1ULL << 33)
|
||||
#define OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING (1ULL << 34)
|
||||
#define OPTIMIZER_SWITCH_NOT_NULL_RANGE_SCAN (1ULL << 35)
|
||||
#define OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY (1ULL << 36)
|
||||
|
||||
#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
|
||||
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
|
||||
|
||||
@@ -32,6 +32,14 @@ public:
|
||||
return thd->type_handler_for_datetime();
|
||||
return src;
|
||||
}
|
||||
|
||||
Item *make_item_func_replace(THD *thd,
|
||||
Item *subj,
|
||||
Item *find,
|
||||
Item *replace) const;
|
||||
Item *make_item_func_substr(THD *thd,
|
||||
const Lex_substring_spec_st &spec) const;
|
||||
Item *make_item_func_trim(THD *thd, const Lex_trim_st &spec) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -78,3 +86,56 @@ Schema *Schema::find_implied(THD *thd)
|
||||
return &maxdb_schema;
|
||||
return &mariadb_schema;
|
||||
}
|
||||
|
||||
|
||||
Item *Schema::make_item_func_replace(THD *thd,
|
||||
Item *subj,
|
||||
Item *find,
|
||||
Item *replace) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_replace(thd, subj, find, replace);
|
||||
}
|
||||
|
||||
|
||||
Item *Schema::make_item_func_substr(THD *thd,
|
||||
const Lex_substring_spec_st &spec) const
|
||||
{
|
||||
return spec.m_for ?
|
||||
new (thd->mem_root) Item_func_substr(thd, spec.m_subject, spec.m_from,
|
||||
spec.m_for) :
|
||||
new (thd->mem_root) Item_func_substr(thd, spec.m_subject, spec.m_from);
|
||||
}
|
||||
|
||||
|
||||
Item *Schema::make_item_func_trim(THD *thd, const Lex_trim_st &spec) const
|
||||
{
|
||||
return spec.make_item_func_trim_std(thd);
|
||||
}
|
||||
|
||||
|
||||
Item *Schema_oracle::make_item_func_replace(THD *thd,
|
||||
Item *subj,
|
||||
Item *find,
|
||||
Item *replace) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_replace_oracle(thd, subj, find, replace);
|
||||
}
|
||||
|
||||
|
||||
Item *Schema_oracle::make_item_func_substr(THD *thd,
|
||||
const Lex_substring_spec_st &spec) const
|
||||
{
|
||||
return spec.m_for ?
|
||||
new (thd->mem_root) Item_func_substr_oracle(thd, spec.m_subject,
|
||||
spec.m_from,
|
||||
spec.m_for) :
|
||||
new (thd->mem_root) Item_func_substr_oracle(thd, spec.m_subject,
|
||||
spec.m_from);
|
||||
}
|
||||
|
||||
|
||||
Item *Schema_oracle::make_item_func_trim(THD *thd,
|
||||
const Lex_trim_st &spec) const
|
||||
{
|
||||
return spec.make_item_func_trim_oracle(thd);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,17 @@ public:
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
// Builders for native SQL function with a special syntax in sql_yacc.yy
|
||||
virtual Item *make_item_func_replace(THD *thd,
|
||||
Item *subj,
|
||||
Item *find,
|
||||
Item *replace) const;
|
||||
virtual Item *make_item_func_substr(THD *thd,
|
||||
const Lex_substring_spec_st &spec) const;
|
||||
|
||||
virtual Item *make_item_func_trim(THD *thd, const Lex_trim_st &spec) const;
|
||||
|
||||
/*
|
||||
For now we have *hard-coded* compatibility schemas:
|
||||
schema_mariadb, schema_oracle, schema_maxdb.
|
||||
|
||||
@@ -5811,7 +5811,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
|
||||
/*
|
||||
Perform range analysis if there are keys it could use (1).
|
||||
Don't do range analysis for materialized subqueries (2).
|
||||
Don't do range analysis for materialized derived tables (3)
|
||||
Don't do range analysis for materialized derived tables/views (3)
|
||||
*/
|
||||
if ((!s->const_keys.is_clear_all() ||
|
||||
!bitmap_is_clear_all(&s->table->cond_set)) && // (1)
|
||||
@@ -7594,20 +7594,28 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
|
||||
Estimate how many records we will get if we read just this table and apply
|
||||
a part of WHERE that can be checked for it.
|
||||
|
||||
@param s Current JOIN_TAB
|
||||
@param use_cond_selectivity Value of optimizer_use_condition_selectivity.
|
||||
If > 1 then use table->cond_selecitivity.
|
||||
@param force_estiamte Set to 1 if we should not call
|
||||
use_found_constraint. To be deleted in 11.0
|
||||
@return 0.0 No matching rows
|
||||
@return >= 1.0 Number of expected matching rows
|
||||
|
||||
@detail
|
||||
Estimate how many records we will get if we
|
||||
- read the given table with its "independent" access method (either quick
|
||||
select or full table/index scan),
|
||||
- apply the part of WHERE that refers only to this table.
|
||||
|
||||
@seealso
|
||||
@see also
|
||||
table_cond_selectivity() produces selectivity of condition that is checked
|
||||
after joining rows from this table to rows from preceding tables.
|
||||
*/
|
||||
|
||||
inline
|
||||
double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint,
|
||||
uint use_cond_selectivity)
|
||||
static double apply_selectivity_for_table(JOIN_TAB *s,
|
||||
uint use_cond_selectivity,
|
||||
bool *force_estimate)
|
||||
{
|
||||
ha_rows records;
|
||||
double dbl_records;
|
||||
@@ -7618,34 +7626,47 @@ double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint,
|
||||
double sel= table->cond_selectivity;
|
||||
double table_records= rows2double(s->records);
|
||||
dbl_records= table_records * sel;
|
||||
*force_estimate= 1; // Don't call use_found_constraint()
|
||||
return dbl_records;
|
||||
}
|
||||
|
||||
records = s->found_records;
|
||||
|
||||
/*
|
||||
If there is a filtering condition on the table (i.e. ref analyzer found
|
||||
at least one "table.keyXpartY= exprZ", where exprZ refers only to tables
|
||||
preceding this table in the join order we're now considering), then
|
||||
assume that 25% of the rows will be filtered out by this condition.
|
||||
|
||||
This heuristic is supposed to force tables used in exprZ to be before
|
||||
this table in join order.
|
||||
If applicable, get a more accurate estimate.
|
||||
*/
|
||||
if (with_found_constraint)
|
||||
records-= records/4;
|
||||
|
||||
/*
|
||||
If applicable, get a more accurate estimate. Don't use the two
|
||||
heuristics at once.
|
||||
*/
|
||||
DBUG_ASSERT(s->table->opt_range_condition_rows <= s->found_records);
|
||||
if (s->table->opt_range_condition_rows != s->found_records)
|
||||
{
|
||||
*force_estimate= 1; // Don't call use_found_constraint()
|
||||
records= s->table->opt_range_condition_rows;
|
||||
}
|
||||
|
||||
dbl_records= (double)records;
|
||||
return dbl_records;
|
||||
}
|
||||
|
||||
/*
|
||||
Take into account that the table's WHERE clause has conditions on earlier
|
||||
tables that can reduce the number of accepted rows.
|
||||
|
||||
@param records Number of original rows (after selectivity)
|
||||
|
||||
If there is a filtering condition on the table (i.e. ref analyzer found
|
||||
at least one "table.keyXpartY= exprZ", where exprZ refers only to tables
|
||||
preceding this table in the join order we're now considering), then
|
||||
assume that 25% of the rows will be filtered out by this condition.
|
||||
|
||||
This heuristic is supposed to force tables used in exprZ to be before
|
||||
this table in join order.
|
||||
*/
|
||||
|
||||
inline double use_found_constraint(double records)
|
||||
{
|
||||
records-= records/4;
|
||||
return records;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Calculate the cost of reading a set of rows trough an index
|
||||
@@ -7702,6 +7723,92 @@ double adjust_quick_cost(double quick_cost, ha_rows records)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief
|
||||
Compute the fanout of hash join operation using EITS data
|
||||
*/
|
||||
|
||||
double hash_join_fanout(JOIN *join, JOIN_TAB *s, table_map remaining_tables,
|
||||
double rnd_records, KEYUSE *hj_start_key,
|
||||
bool *stats_found)
|
||||
{
|
||||
THD *thd= join->thd;
|
||||
/*
|
||||
Before doing the hash join, we will scan the table and apply the local part
|
||||
of the WHERE condition. This will produce rnd_records.
|
||||
|
||||
The EITS statistics describes the entire table. Calling
|
||||
|
||||
table->field[N]->get_avg_frequency()
|
||||
|
||||
produces average #rows in the table with some value.
|
||||
|
||||
What happens if we filter out rows so that rnd_records rows are left?
|
||||
Something between the two outcomes:
|
||||
A. filtering removes a fraction of rows for each value:
|
||||
avg_frequency=avg_frequency * condition_selectivity
|
||||
|
||||
B. filtering removes entire groups of rows with the same value, but
|
||||
the remaining groups remain of the same size.
|
||||
|
||||
We make pessimistic assumption and assume B.
|
||||
We also handle an edge case: if rnd_records is less than avg_frequency,
|
||||
assume we'll get rnd_records rows with the same value, and return
|
||||
rnd_records as the fanout estimate.
|
||||
*/
|
||||
double min_freq= rnd_records;
|
||||
|
||||
Json_writer_object trace_obj(thd, "hash_join_cardinality");
|
||||
/*
|
||||
There can be multiple KEYUSE referring to same or different columns
|
||||
|
||||
KEYUSE(tbl.col1 = ...)
|
||||
KEYUSE(tbl.col1 = ...)
|
||||
KEYUSE(tbl.col2 = ...)
|
||||
|
||||
Hash join code can use multiple columns: (col1, col2) for joining.
|
||||
We need n_distinct({col1, col2}).
|
||||
|
||||
EITS only has statistics on individual columns: n_distinct(col1),
|
||||
n_distinct(col2).
|
||||
|
||||
Our current solution is to be very conservative and use selectivity
|
||||
of one column with the lowest avg_frequency.
|
||||
|
||||
In the future, we should an approach that cautiosly takes into account
|
||||
multiple KEYUSEs either multiply by number of equalities or by sqrt
|
||||
of the second most selective equality.
|
||||
*/
|
||||
Json_writer_array trace_arr(thd, "hash_join_columns");
|
||||
for (KEYUSE *keyuse= hj_start_key;
|
||||
keyuse->table == s->table && is_hash_join_key_no(keyuse->key);
|
||||
keyuse++)
|
||||
{
|
||||
if (!(remaining_tables & keyuse->used_tables) &&
|
||||
(!keyuse->validity_ref || *keyuse->validity_ref) &&
|
||||
s->access_from_tables_is_allowed(keyuse->used_tables,
|
||||
join->sjm_lookup_tables))
|
||||
{
|
||||
Field *field= s->table->field[keyuse->keypart];
|
||||
if (is_eits_usable(field))
|
||||
{
|
||||
double freq= field->read_stats->get_avg_frequency();
|
||||
|
||||
Json_writer_object trace_field(thd);
|
||||
trace_field.add("field",field->field_name.str).
|
||||
add("avg_frequency", freq);
|
||||
if (freq < min_freq)
|
||||
min_freq= freq;
|
||||
*stats_found= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
trace_arr.end();
|
||||
trace_obj.add("rows", min_freq);
|
||||
return min_freq;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the best access path for an extension of a partial execution
|
||||
plan and add this path to the plan.
|
||||
@@ -8394,10 +8501,44 @@ best_access_path(JOIN *join,
|
||||
(!(s->table->map & join->outer_join) ||
|
||||
join->allowed_outer_join_with_cache)) // (2)
|
||||
{
|
||||
double join_sel= 0.1;
|
||||
double fanout;
|
||||
double join_sel;
|
||||
bool stats_found= 0, force_estimate= 0;
|
||||
Json_writer_object trace_access_hash(thd);
|
||||
trace_access_hash.add("type", "hash");
|
||||
trace_access_hash.add("index", "hj-key");
|
||||
/* Estimate the cost of the hash join access to the table */
|
||||
double rnd_records= matching_candidates_in_table(s, found_constraint,
|
||||
use_cond_selectivity);
|
||||
double rnd_records= apply_selectivity_for_table(s, use_cond_selectivity,
|
||||
&force_estimate);
|
||||
|
||||
DBUG_ASSERT(hj_start_key);
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY))
|
||||
{
|
||||
/*
|
||||
Starting from this point, rnd_records should not be used anymore.
|
||||
Use "fanout" for an estimate of # matching records.
|
||||
*/
|
||||
fanout= hash_join_fanout(join, s, remaining_tables, rnd_records,
|
||||
hj_start_key, &stats_found);
|
||||
join_sel= 1.0; // Don't do the "10% heuristic"
|
||||
}
|
||||
if (!stats_found)
|
||||
{
|
||||
/*
|
||||
No OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY or no field statistics
|
||||
found.
|
||||
|
||||
Take into account if there is non constant constraints used with
|
||||
earlier tables in the where expression.
|
||||
If yes, this will set fanout to rnd_records/4.
|
||||
We estimate that there will be HASH_FANOUT (10%)
|
||||
hash matches / row.
|
||||
*/
|
||||
if (found_constraint && !force_estimate)
|
||||
rnd_records= use_found_constraint(rnd_records);
|
||||
fanout= rnd_records;
|
||||
join_sel= 0.1;
|
||||
}
|
||||
|
||||
tmp= s->quick ? s->quick->read_time : s->scan_time();
|
||||
double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE;
|
||||
@@ -8409,20 +8550,37 @@ best_access_path(JOIN *join,
|
||||
record_count /
|
||||
(double) thd->variables.join_buff_size));
|
||||
tmp= COST_MULT(tmp, refills);
|
||||
best_time= COST_ADD(tmp,
|
||||
COST_MULT((record_count*join_sel) / TIME_FOR_COMPARE,
|
||||
rnd_records));
|
||||
|
||||
// Add cost of reading/writing the join buffer
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY))
|
||||
{
|
||||
/* Set it to be 1/10th of TIME_FOR_COMPARE */
|
||||
double row_copy_cost= 1.0 / (10*TIME_FOR_COMPARE);
|
||||
double join_buffer_operations=
|
||||
COST_ADD(
|
||||
COST_MULT(record_count, row_copy_cost),
|
||||
COST_MULT(record_count, fanout * (idx - join->const_tables))
|
||||
);
|
||||
double jbuf_use_cost= row_copy_cost * join_buffer_operations;
|
||||
trace_access_hash.add("jbuf_use_cost", jbuf_use_cost);
|
||||
tmp= COST_ADD(tmp, jbuf_use_cost);
|
||||
}
|
||||
|
||||
double where_cost= COST_MULT((fanout*join_sel) / TIME_FOR_COMPARE,
|
||||
record_count);
|
||||
trace_access_hash.add("extra_cond_check_cost", where_cost);
|
||||
|
||||
best_time= COST_ADD(tmp, where_cost);
|
||||
|
||||
best= tmp;
|
||||
records= rnd_records;
|
||||
records= fanout;
|
||||
best_key= hj_start_key;
|
||||
best_ref_depends_map= 0;
|
||||
best_uses_jbuf= TRUE;
|
||||
best_filter= 0;
|
||||
best_type= JT_HASH;
|
||||
Json_writer_object trace_access_hash(thd);
|
||||
trace_access_hash.add("type", "hash");
|
||||
trace_access_hash.add("index", "hj-key");
|
||||
trace_access_hash.add("rnd_records", rnd_records);
|
||||
trace_access_hash.add("records", records);
|
||||
trace_access_hash.add("cost", best);
|
||||
trace_access_hash.add("chosen", true);
|
||||
}
|
||||
@@ -8474,9 +8632,13 @@ best_access_path(JOIN *join,
|
||||
!(s->table->force_index && best_key && !s->quick) && // (4)
|
||||
!(best_key && s->table->pos_in_table_list->jtbm_subselect)) // (5)
|
||||
{ // Check full join
|
||||
double rnd_records= matching_candidates_in_table(s, found_constraint,
|
||||
use_cond_selectivity);
|
||||
|
||||
bool force_estimate= 0;
|
||||
double rnd_records= apply_selectivity_for_table(s,
|
||||
use_cond_selectivity,
|
||||
&force_estimate);
|
||||
rnd_records= ((found_constraint && !force_estimate) ?
|
||||
use_found_constraint(rnd_records) :
|
||||
rnd_records);
|
||||
/*
|
||||
Range optimizer never proposes a RANGE if it isn't better
|
||||
than FULL: so if RANGE is present, it's always preferred to FULL.
|
||||
@@ -9693,7 +9855,7 @@ double table_multi_eq_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
||||
with previous tables.
|
||||
|
||||
For quick selects and full table scans, selectivity of COND(this_table)
|
||||
is accounted for in matching_candidates_in_table(). Here, we only count
|
||||
is accounted for in apply_selectivity_for_table(). Here, we only count
|
||||
selectivity of COND(this_table, previous_tables).
|
||||
|
||||
For other access methods, we need to calculate selectivity of the whole
|
||||
@@ -9895,7 +10057,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
||||
/*
|
||||
The table is accessed with full table scan, or quick select.
|
||||
Selectivity of COND(table) is already accounted for in
|
||||
matching_candidates_in_table().
|
||||
apply_selectivity_for_table().
|
||||
*/
|
||||
sel= 1;
|
||||
}
|
||||
@@ -24900,7 +25062,7 @@ JOIN_TAB::remove_duplicates()
|
||||
if (!(sortorder= (SORT_FIELD*) my_malloc(PSI_INSTRUMENT_ME,
|
||||
(fields->elements+1) *
|
||||
sizeof(SORT_FIELD),
|
||||
MYF(MY_WME))))
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* Calculate how many saved fields there is in list */
|
||||
@@ -24919,7 +25081,6 @@ JOIN_TAB::remove_duplicates()
|
||||
else
|
||||
{
|
||||
/* Item is not stored in temporary table, remember it */
|
||||
sorder->field= 0; // Safety, not used
|
||||
sorder->item= item;
|
||||
/* Calculate sorder->length */
|
||||
item->type_handler()->sort_length(thd, item, sorder);
|
||||
@@ -28733,7 +28894,7 @@ void st_select_lex::print_item_list(THD *thd, String *str,
|
||||
outer_select() can not be used here because it is for name resolution
|
||||
and will return NULL at any end of name resolution chain (view/derived)
|
||||
*/
|
||||
bool top_level= (get_master() == &thd->lex->unit);
|
||||
bool top_level= is_query_topmost(thd);
|
||||
List_iterator_fast<Item> it(item_list);
|
||||
Item *item;
|
||||
while ((item= it++))
|
||||
@@ -28840,7 +29001,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
|
||||
return;
|
||||
}
|
||||
|
||||
bool top_level= (get_master() == &thd->lex->unit);
|
||||
bool top_level= is_query_topmost(thd);
|
||||
enum explainable_cmd_type sel_type= SELECT_CMD;
|
||||
if (top_level)
|
||||
sel_type= get_explainable_cmd_type(thd);
|
||||
|
||||
@@ -1011,10 +1011,19 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
|
||||
else
|
||||
table->file->print_error(error, MYF(0));
|
||||
seq->write_unlock(table);
|
||||
if (trans_commit_stmt(thd))
|
||||
error= 1;
|
||||
if (trans_commit_implicit(thd))
|
||||
error= 1;
|
||||
{
|
||||
wait_for_commit* suspended_wfc= thd->suspend_subsequent_commits();
|
||||
if (trans_commit_stmt(thd))
|
||||
error= 1;
|
||||
if (trans_commit_implicit(thd))
|
||||
error= 1;
|
||||
thd->resume_subsequent_commits(suspended_wfc);
|
||||
DBUG_EXECUTE_IF("hold_worker_on_schedule",
|
||||
{
|
||||
/* delay binlogging of a parent trx in rpl_parallel_seq */
|
||||
my_sleep(100000);
|
||||
});
|
||||
}
|
||||
if (likely(!error))
|
||||
error= write_bin_log(thd, 1, thd->query(), thd->query_length());
|
||||
if (likely(!error))
|
||||
|
||||
@@ -4024,50 +4024,16 @@ double Histogram_binary::point_selectivity(Field *field, key_range *endpoint,
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
/*
|
||||
The value 'pos' fits within one single histogram bucket.
|
||||
|
||||
Histogram_binary buckets have the same numbers of rows, but they cover
|
||||
different ranges of values.
|
||||
|
||||
We assume that values are uniformly distributed across the [0..1] value
|
||||
range.
|
||||
*/
|
||||
|
||||
/*
|
||||
If all buckets covered value ranges of the same size, the width of
|
||||
value range would be:
|
||||
We also have avg_sel which is per-table average selectivity of col=const.
|
||||
If there are popular values, this may be larger than one bucket, so
|
||||
cap the returned number by the selectivity of one bucket.
|
||||
*/
|
||||
double avg_bucket_width= 1.0 / (get_width() + 1);
|
||||
|
||||
/*
|
||||
Let's see what is the width of value range that our bucket is covering.
|
||||
(min==max currently. they are kept in the formula just in case we
|
||||
will want to extend it to handle multi-bucket case)
|
||||
*/
|
||||
double inv_prec_factor= (double) 1.0 / prec_factor();
|
||||
double current_bucket_width=
|
||||
(max + 1 == get_width() ? 1.0 : (get_value(max) * inv_prec_factor)) -
|
||||
(min == 0 ? 0.0 : (get_value(min-1) * inv_prec_factor));
|
||||
|
||||
DBUG_ASSERT(current_bucket_width); /* We shouldn't get a one zero-width bucket */
|
||||
|
||||
/*
|
||||
So:
|
||||
- each bucket has the same #rows
|
||||
- values are unformly distributed across the [min_value,max_value] domain.
|
||||
|
||||
If a bucket has value range that's N times bigger then average, than
|
||||
each value will have to have N times fewer rows than average.
|
||||
*/
|
||||
sel= avg_sel * avg_bucket_width / current_bucket_width;
|
||||
|
||||
/*
|
||||
(Q: if we just follow this proportion we may end up in a situation
|
||||
where number of different values we expect to find in this bucket
|
||||
exceeds the number of rows that this histogram has in a bucket. Are
|
||||
we ok with this or we would want to have certain caps?)
|
||||
*/
|
||||
sel= MY_MIN(avg_bucket_width, avg_sel);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
@@ -1808,7 +1808,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
|
||||
if (view_is_mergeable &&
|
||||
(table->select_lex->master_unit() != &old_lex->unit ||
|
||||
old_lex->can_use_merged()) &&
|
||||
!old_lex->can_not_use_merged(0))
|
||||
!old_lex->can_not_use_merged())
|
||||
{
|
||||
/* lex should contain at least one table */
|
||||
DBUG_ASSERT(view_main_select_tables != 0);
|
||||
@@ -1841,8 +1841,11 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
|
||||
*/
|
||||
if (!table->select_lex->master_unit()->is_unit_op() &&
|
||||
table->select_lex->order_list.elements == 0)
|
||||
{
|
||||
table->select_lex->order_list.
|
||||
push_back(&lex->first_select_lex()->order_list);
|
||||
lex->first_select_lex()->order_list.empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (old_lex->sql_command == SQLCOM_SELECT &&
|
||||
|
||||
@@ -226,6 +226,7 @@ void _CONCAT_UNDERSCORED(turn_parser_debug_on,yyparse)()
|
||||
Lex_for_loop_bounds_st for_loop_bounds;
|
||||
Lex_trim_st trim;
|
||||
Json_table_column::On_response json_on_response;
|
||||
Lex_substring_spec_st substring_spec;
|
||||
vers_history_point_t vers_history_point;
|
||||
struct
|
||||
{
|
||||
@@ -637,7 +638,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
||||
%token <kwd> RELEASE_SYM /* SQL-2003-R */
|
||||
%token <kwd> RENAME
|
||||
%token <kwd> REPEAT_SYM /* MYSQL-FUNC */
|
||||
%token <kwd> REPLACE /* MYSQL-FUNC */
|
||||
%token <kwd> REQUIRE_SYM
|
||||
%token <kwd> RESIGNAL_SYM /* SQL-2003-R */
|
||||
%token <kwd> RESTRICT
|
||||
@@ -674,7 +674,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
||||
%token <kwd> STDDEV_SAMP_SYM /* SQL-2003-N */
|
||||
%token <kwd> STD_SYM
|
||||
%token <kwd> STRAIGHT_JOIN
|
||||
%token <kwd> SUBSTRING /* SQL-2003-N */
|
||||
%token <kwd> SUM_SYM /* SQL-2003-N */
|
||||
%token <kwd> SYSDATE
|
||||
%token <kwd> TABLE_REF_PRIORITY
|
||||
@@ -687,7 +686,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
||||
%token <kwd> TO_SYM /* SQL-2003-R */
|
||||
%token <kwd> TRAILING /* SQL-2003-R */
|
||||
%token <kwd> TRIGGER_SYM /* SQL-2003-R */
|
||||
%token <kwd> TRIM /* SQL-2003-N */
|
||||
%token <kwd> TRUE_SYM /* SQL-2003-R */
|
||||
%token <kwd> UNDO_SYM /* FUTURE-USE */
|
||||
%token <kwd> UNION_SYM /* SQL-2003-R */
|
||||
@@ -732,6 +730,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
||||
%token <kwd> ROWTYPE_MARIADB_SYM // PLSQL-R
|
||||
%token <kwd> ROWNUM_SYM /* Oracle-R */
|
||||
|
||||
/*
|
||||
SQL functions with a special syntax
|
||||
*/
|
||||
%token <kwd> REPLACE /* MYSQL-FUNC */
|
||||
%token <kwd> SUBSTRING /* SQL-2003-N */
|
||||
%token <kwd> TRIM /* SQL-2003-N */
|
||||
|
||||
|
||||
/*
|
||||
Non-reserved keywords
|
||||
*/
|
||||
@@ -1764,6 +1770,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
||||
%type <for_loop> sp_for_loop_index_and_bounds
|
||||
%type <for_loop_bounds> sp_for_loop_bounds
|
||||
%type <trim> trim_operands
|
||||
%type <substring_spec> substring_operands
|
||||
%type <num> opt_sp_for_loop_direction
|
||||
%type <spvar_mode> sp_parameter_type
|
||||
%type <index_hint> index_hint_type
|
||||
@@ -9952,7 +9959,8 @@ function_call_keyword:
|
||||
}
|
||||
| TRIM '(' trim_operands ')'
|
||||
{
|
||||
if (unlikely(!($$= $3.make_item_func_trim(thd))))
|
||||
if (unlikely(!($$= Schema::find_implied(thd)->
|
||||
make_item_func_trim(thd, $3))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| USER_SYM '(' ')'
|
||||
@@ -9971,6 +9979,26 @@ function_call_keyword:
|
||||
}
|
||||
;
|
||||
|
||||
substring_operands:
|
||||
expr ',' expr ',' expr
|
||||
{
|
||||
$$= Lex_substring_spec_st::init($1, $3, $5);
|
||||
}
|
||||
| expr ',' expr
|
||||
{
|
||||
$$= Lex_substring_spec_st::init($1, $3);
|
||||
}
|
||||
| expr FROM expr FOR_SYM expr
|
||||
{
|
||||
$$= Lex_substring_spec_st::init($1, $3, $5);
|
||||
}
|
||||
| expr FROM expr
|
||||
{
|
||||
$$= Lex_substring_spec_st::init($1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
Function calls using non reserved keywords, with special syntaxic forms.
|
||||
Dedicated grammar rules are needed because of the syntax,
|
||||
@@ -10103,24 +10131,10 @@ function_call_nonkeyword:
|
||||
if (unlikely($$ == NULL))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| SUBSTRING '(' expr ',' expr ',' expr ')'
|
||||
| SUBSTRING '(' substring_operands ')'
|
||||
{
|
||||
if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| SUBSTRING '(' expr ',' expr ')'
|
||||
{
|
||||
if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
|
||||
{
|
||||
if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| SUBSTRING '(' expr FROM expr ')'
|
||||
{
|
||||
if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5))))
|
||||
if (unlikely(!($$= Schema::find_implied(thd)->
|
||||
make_item_func_substr(thd, $3))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
%ifdef ORACLE
|
||||
@@ -10335,7 +10349,8 @@ function_call_conflict:
|
||||
}
|
||||
| REPLACE '(' expr ',' expr ',' expr ')'
|
||||
{
|
||||
if (unlikely(!($$= Lex->make_item_func_replace(thd, $3, $5, $7))))
|
||||
if (unlikely(!($$= Schema::find_implied(thd)->
|
||||
make_item_func_replace(thd, $3, $5, $7))))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| REVERSE_SYM '(' expr ')'
|
||||
|
||||
@@ -793,6 +793,11 @@ public:
|
||||
}
|
||||
Item *make_item_func_trim_std(THD *thd) const;
|
||||
Item *make_item_func_trim_oracle(THD *thd) const;
|
||||
/*
|
||||
This method is still used to handle LTRIM and RTRIM,
|
||||
while the special syntax TRIM(... BOTH|LEADING|TRAILING)
|
||||
is now handled by Schema::make_item_func_trim().
|
||||
*/
|
||||
Item *make_item_func_trim(THD *thd) const;
|
||||
};
|
||||
|
||||
@@ -804,6 +809,25 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Lex_substring_spec_st
|
||||
{
|
||||
public:
|
||||
Item *m_subject;
|
||||
Item *m_from;
|
||||
Item *m_for;
|
||||
static Lex_substring_spec_st init(Item *subject,
|
||||
Item *from,
|
||||
Item *xfor= NULL)
|
||||
{
|
||||
Lex_substring_spec_st res;
|
||||
res.m_subject= subject;
|
||||
res.m_from= from;
|
||||
res.m_for= xfor;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class st_select_lex;
|
||||
|
||||
class Lex_select_lock
|
||||
|
||||
@@ -2779,6 +2779,7 @@ export const char *optimizer_switch_names[]=
|
||||
"rowid_filter",
|
||||
"condition_pushdown_from_having",
|
||||
"not_null_range_scan",
|
||||
"hash_join_cardinality",
|
||||
"default",
|
||||
NullS
|
||||
};
|
||||
|
||||
29
sql/table.cc
29
sql/table.cc
@@ -3461,7 +3461,6 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
|
||||
char *sql_copy;
|
||||
handler *file;
|
||||
LEX *old_lex;
|
||||
Query_arena *arena, backup;
|
||||
LEX tmp_lex;
|
||||
KEY *unused1;
|
||||
uint unused2;
|
||||
@@ -3488,12 +3487,6 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
|
||||
old_lex= thd->lex;
|
||||
thd->lex= &tmp_lex;
|
||||
|
||||
arena= thd->stmt_arena;
|
||||
if (arena->is_conventional())
|
||||
arena= 0;
|
||||
else
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
|
||||
thd->reset_db(&db);
|
||||
lex_start(thd);
|
||||
|
||||
@@ -3528,8 +3521,6 @@ ret:
|
||||
lex_end(thd->lex);
|
||||
thd->reset_db(&db_backup);
|
||||
thd->lex= old_lex;
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
reenable_binlog(thd);
|
||||
thd->variables.character_set_client= old_cs;
|
||||
if (unlikely(thd->is_error() || error))
|
||||
@@ -6743,7 +6734,7 @@ void TABLE_LIST::set_check_materialized()
|
||||
DBUG_ENTER("TABLE_LIST::set_check_materialized");
|
||||
SELECT_LEX_UNIT *derived= this->derived;
|
||||
if (view)
|
||||
derived= &view->unit;
|
||||
derived= this->derived= &view->unit;
|
||||
DBUG_ASSERT(derived);
|
||||
DBUG_ASSERT(!derived->is_excluded());
|
||||
if (!derived->first_select()->exclude_from_table_unique_test)
|
||||
@@ -9592,13 +9583,25 @@ bool TABLE_LIST::init_derived(THD *thd, bool init_view)
|
||||
{
|
||||
/* A subquery might be forced to be materialized due to a side-effect. */
|
||||
if (!is_materialized_derived() && unit->can_be_merged() &&
|
||||
(unit->outer_select() && !unit->outer_select()->with_rownum) &&
|
||||
/*
|
||||
Following is special case of
|
||||
SELECT * FROM (<limited-select>) WHERE ROWNUM() <= nnn
|
||||
*/
|
||||
(unit->outer_select() &&
|
||||
!(unit->outer_select()->with_rownum &&
|
||||
unit->outer_select()->table_list.elements == 1 &&
|
||||
(thd->lex->sql_command == SQLCOM_SELECT ||
|
||||
!unit->outer_select()->is_query_topmost(thd)) &&
|
||||
!is_view())) &&
|
||||
|
||||
(!thd->lex->with_rownum ||
|
||||
(!first_select->group_list.elements &&
|
||||
!first_select->order_list.elements)) &&
|
||||
(is_view() ||
|
||||
(optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_MERGE) &&
|
||||
!thd->lex->can_not_use_merged(1))) &&
|
||||
optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_MERGE)) &&
|
||||
!thd->lex->can_not_use_merged() &&
|
||||
!((thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
|
||||
thd->lex->sql_command == SQLCOM_DELETE_MULTI) && !is_view()) &&
|
||||
!is_recursive_with_table())
|
||||
set_merged_derived();
|
||||
else
|
||||
|
||||
@@ -1016,10 +1016,9 @@ int Wsrep_schema::append_fragment(THD* thd,
|
||||
Wsrep_schema_impl::store(frag_table, 3, flags);
|
||||
Wsrep_schema_impl::store(frag_table, 4, data.data(), data.size());
|
||||
|
||||
int error;
|
||||
if ((error= Wsrep_schema_impl::insert(frag_table))) {
|
||||
WSREP_ERROR("Failed to write to frag table: %d", error);
|
||||
if (Wsrep_schema_impl::insert(frag_table)) {
|
||||
trans_rollback_stmt(thd);
|
||||
close_thread_tables(thd);
|
||||
thd->lex->restore_backup_query_tables_list(&query_tables_list_backup);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,14 @@ static inline void wsrep_override_error(THD* thd,
|
||||
break;
|
||||
case wsrep::e_append_fragment_error:
|
||||
/* TODO: Figure out better error number */
|
||||
wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, 0, status);
|
||||
if (status)
|
||||
wsrep_override_error(thd, ER_ERROR_DURING_COMMIT,
|
||||
"Error while appending streaming replication fragment"
|
||||
"(provider status: %s)",
|
||||
wsrep::provider::to_string(status).c_str());
|
||||
else
|
||||
wsrep_override_error(thd, ER_ERROR_DURING_COMMIT,
|
||||
"Error while appending streaming replication fragment");
|
||||
break;
|
||||
case wsrep::e_not_supported_error:
|
||||
wsrep_override_error(thd, ER_NOT_SUPPORTED_YET);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2009, 2022, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2009, 2023, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user