Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä 2020-06-06 22:05:32 +03:00
commit c7a2fb1e08
32 changed files with 431 additions and 66 deletions

View file

@ -99,8 +99,14 @@ public:
reference operator*() { return *static_cast<pointer>(node_); }
pointer operator->() { return static_cast<pointer>(node_); }
bool operator==(const Iterator &rhs) { return node_ == rhs.node_; }
bool operator!=(const Iterator &rhs) { return !(*this == rhs); }
friend bool operator==(const Iterator &lhs, const Iterator &rhs)
{
return lhs.node_ == rhs.node_;
}
friend bool operator!=(const Iterator &lhs, const Iterator &rhs)
{
return !(lhs == rhs);
}
private:
ListNode *node_;

View file

@ -1587,7 +1587,7 @@ drop table t1;
--echo #
--echo # Check strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine;
insert into t1 values ('a'),('b'),('c');

View file

@ -3692,7 +3692,168 @@ select * from t1 as t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ALL NULL NULL NULL NULL 4
drop table t1,t2;
# End of 10.2 tests
#
# MDEV-22042: ANALYZE of query using stored function and recursive CTE
#
create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (
a2 varchar(20) primary key, b1 varchar(20), key (b1)
) engine=myisam;
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);
create function f1(id varchar(20)) returns varchar(50)
begin
declare res varchar (50);
select a2 into res from t2 where a2=id and b1=1 limit 1;
return res;
end$$
select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
fv
NULL
explain select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 23 func 1
5 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2
3 DERIVED t2 const PRIMARY PRIMARY 22 const 1 Using index
4 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 2 Using where
4 RECURSIVE UNION tt2 ref b1 b1 23 cte.a2 2
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
analyze format=json select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
ANALYZE
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"const_condition": "1",
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 3,
"r_rows": 3,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"table": {
"table_name": "<subquery5>",
"access_type": "eq_ref",
"possible_keys": ["distinct_key"],
"key": "distinct_key",
"key_length": "23",
"used_key_parts": ["a2"],
"ref": ["func"],
"r_loops": 3,
"rows": 1,
"r_rows": 0.3333,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"materialized": {
"unique": 1,
"query_block": {
"select_id": 5,
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 1,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"materialized": {
"query_block": {
"recursive_union": {
"table_name": "<union3,4>",
"access_type": "ALL",
"r_loops": 0,
"r_rows": null,
"query_specifications": [
{
"query_block": {
"select_id": 3,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "t2",
"access_type": "const",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "22",
"used_key_parts": ["a2"],
"ref": ["const"],
"r_loops": 0,
"rows": 1,
"r_rows": null,
"filtered": 100,
"r_filtered": null,
"using_index": true
}
}
},
{
"query_block": {
"select_id": 4,
"operation": "UNION",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 1,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "cte.a2 is not null"
},
"table": {
"table_name": "tt2",
"access_type": "ref",
"possible_keys": ["b1"],
"key": "b1",
"key_length": "23",
"used_key_parts": ["b1"],
"ref": ["cte.a2"],
"r_loops": 1,
"rows": 2,
"r_rows": 1,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
}
}
}
]
}
}
}
}
}
}
}
}
}
drop function f1;
drop table t1,t2;
End of 10.2 tests
#
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
#

View file

@ -2571,7 +2571,45 @@ select * from t1 as t;
drop table t1,t2;
--echo # End of 10.2 tests
--echo #
--echo # MDEV-22042: ANALYZE of query using stored function and recursive CTE
--echo #
create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (
a2 varchar(20) primary key, b1 varchar(20), key (b1)
) engine=myisam;
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);
delimiter $$;
create function f1(id varchar(20)) returns varchar(50)
begin
declare res varchar (50);
select a2 into res from t2 where a2=id and b1=1 limit 1;
return res;
end$$
delimiter ;$$
let q=
select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
eval $q;
eval explain $q;
--source include/analyze-format.inc
eval analyze format=json $q;
drop function f1;
drop table t1,t2;
--echo End of 10.2 tests
--echo #
--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field

View file

@ -1491,7 +1491,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab

View file

@ -723,7 +723,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;

View file

@ -1764,7 +1764,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab

View file

@ -685,7 +685,7 @@ CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;

View file

@ -1504,7 +1504,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab

View file

@ -779,7 +779,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;

View file

@ -6754,10 +6754,10 @@ DFFFDFFF9CFF9DFF9EFF
#
# Checking strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;

View file

@ -1767,7 +1767,7 @@ set @@collation_connection=utf8_bin;
--echo #
--echo # Checking strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
insert into t1 values ('a'),('b'),('c');

View file

@ -2371,10 +2371,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;

View file

@ -1520,7 +1520,7 @@ drop table t1;
--echo #
--echo # Check strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c');

View file

@ -2203,10 +2203,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine heap;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;

View file

@ -2329,10 +2329,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;

View file

@ -2336,10 +2336,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine MyISAM;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;

View file

@ -3312,6 +3312,71 @@ p 16
set @@sort_buffer_size= @save_sort_buffer_size;
drop table t1;
#
# MDEV-22715: SIGSEGV in radixsort_for_str_ptr and in native_compare/my_qsort2 (optimized builds)
#
SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_sort_length= @@max_sort_length;
SET max_sort_length=8;
SET sort_buffer_size=1024;
CREATE TABLE t1(a INT, b DECIMAL(65), c BLOB);
INSERT INTO t1 SELECT seq, seq, seq from seq_1_to_25;
INSERT INTO t1 SELECT seq, seq, seq from seq_1_to_25;
SELECT * FROM t1 ORDER BY a,b;
a b c
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
3 3 3
4 4 4
4 4 4
5 5 5
5 5 5
6 6 6
6 6 6
7 7 7
7 7 7
8 8 8
8 8 8
9 9 9
9 9 9
10 10 10
10 10 10
11 11 11
11 11 11
12 12 12
12 12 12
13 13 13
13 13 13
14 14 14
14 14 14
15 15 15
15 15 15
16 16 16
16 16 16
17 17 17
17 17 17
18 18 18
18 18 18
19 19 19
19 19 19
20 20 20
20 20 20
21 21 21
21 21 21
22 22 22
22 22 22
23 23 23
23 23 23
24 24 24
24 24 24
25 25 25
25 25 25
SET @@sort_buffer_size= @save_sort_buffer_size;
SET @@max_sort_length= @save_max_sort_length;
DROP TABLE t1;
#
# MDEV-13994: Bad join results with orderby_uses_equalities=on
#
CREATE TABLE books (
@ -3372,6 +3437,7 @@ NULLIF(GROUP_CONCAT(v1), null)
C
B
DROP TABLE t1;
# End of 10.2 tests
#
# MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY
#
@ -3429,6 +3495,7 @@ LIMIT 1)
908-8-123456
909-9-123456
drop table t1,t2;
# End of 10.3 tests
#
# MDEV-17761: Odd optimizer choice with ORDER BY LIMIT and condition selectivity
#
@ -3466,3 +3533,4 @@ Note 1003 select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` A
set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u,
optimizer_use_condition_selectivity=@tmp_o;
drop table t1,t2,t3,t4;
# End of 10.4 tests

View file

@ -14,6 +14,8 @@ call mtr.add_suppression("Out of sort memory; increase server sort buffer size")
# Test old ORDER BY bug
#
--source include/have_sequence.inc
CREATE TABLE t1 (
id int(6) DEFAULT '0' NOT NULL,
idservice int(5),
@ -2161,6 +2163,21 @@ select * from t1 order by b;
set @@sort_buffer_size= @save_sort_buffer_size;
drop table t1;
--echo #
--echo # MDEV-22715: SIGSEGV in radixsort_for_str_ptr and in native_compare/my_qsort2 (optimized builds)
--echo #
SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_sort_length= @@max_sort_length;
SET max_sort_length=8;
SET sort_buffer_size=1024;
CREATE TABLE t1(a INT, b DECIMAL(65), c BLOB);
INSERT INTO t1 SELECT seq, seq, seq from seq_1_to_25;
INSERT INTO t1 SELECT seq, seq, seq from seq_1_to_25;
SELECT * FROM t1 ORDER BY a,b;
SET @@sort_buffer_size= @save_sort_buffer_size;
SET @@max_sort_length= @save_max_sort_length;
DROP TABLE t1;
--echo #
--echo # MDEV-13994: Bad join results with orderby_uses_equalities=on
@ -2205,7 +2222,6 @@ set optimizer_switch= @save_optimizer_switch;
DROP TABLE books, wings;
--echo #
--echo # MDEV-17796: query with DISTINCT, GROUP BY and ORDER BY
--echo #
@ -2220,6 +2236,8 @@ ORDER BY id+1 DESC;
DROP TABLE t1;
--echo # End of 10.2 tests
--echo #
--echo # MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY
--echo #
@ -2257,6 +2275,8 @@ eval $query;
drop table t1,t2;
--echo # End of 10.3 tests
--echo #
--echo # MDEV-17761: Odd optimizer choice with ORDER BY LIMIT and condition selectivity
--echo #
@ -2292,3 +2312,5 @@ set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u,
optimizer_use_condition_selectivity=@tmp_o;
drop table t1,t2,t3,t4;
--echo # End of 10.4 tests

View file

@ -25,4 +25,38 @@ SUBPARTITIONS 2 (
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
ERROR HY000: The path specified for @0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@... is too long
SET @file_per_table=@@GLOBAL.innodb_file_per_table;
SET GLOBAL innodb_file_per_table=0;
CREATE TABLE mysqltest1.t1 (a INT) ENGINE=INNODB
PARTITION BY RANGE (a) SUBPARTITION BY HASH(a)
(PARTITION `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$`
VALUES LESS THAN (10)
(SUBPARTITION
`--------------------------abcdef0123456789abcdef0123456789abcdef`,
SUBPARTITION
`0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`)
);
SET GLOBAL innodb_file_per_table=@file_per_table;
SHOW CREATE TABLE mysqltest1.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (`a`)
SUBPARTITION BY HASH (`a`)
(PARTITION `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$` VALUES LESS THAN (10)
(SUBPARTITION `--------------------------abcdef0123456789abcdef0123456789abcdef` ENGINE = InnoDB,
SUBPARTITION `0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef` ENGINE = InnoDB))
INSERT INTO mysqltest1.t1 VALUES(1);
DROP TABLE mysqltest1.`#mysql50#t1#P#@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024#SP#0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`;
ERROR 42000: Incorrect table name '#mysql50#t1#P#@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@'
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'mysqltest1%';
NAME
mysqltest1/t1#P#@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024#SP#0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
mysqltest1/t1#P#@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024#SP#@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002d@002dabcdef0123456789abcdef0123456789abcdef
mysqltest1/test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#pmax#SP#pmaxsp0
mysqltest1/test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#pmax#SP#pmaxsp1
mysqltest1/test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#test_jfg_partition_name_with_60_chars_1234567890123456789012#SP#test_jfg_partition_name_with_60_chars_1234567890123456789012sp0
mysqltest1/test_jfg_table_name_with_64_chars_123456789012345678901234567890#P#test_jfg_partition_name_with_60_chars_1234567890123456789012#SP#test_jfg_partition_name_with_60_chars_1234567890123456789012sp1
drop database mysqltest1;

View file

@ -1,5 +1,7 @@
source include/have_innodb.inc;
source include/have_partition.inc;
# The absolute path names in the embedded server hit the limit earlier.
source include/not_embedded.inc;
set names utf8;
create database mysqltest1;
@ -29,4 +31,28 @@ PARTITION BY RANGE ( id )
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
SET @file_per_table=@@GLOBAL.innodb_file_per_table;
SET GLOBAL innodb_file_per_table=0;
CREATE TABLE mysqltest1.t1 (a INT) ENGINE=INNODB
PARTITION BY RANGE (a) SUBPARTITION BY HASH(a)
(PARTITION `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$`
VALUES LESS THAN (10)
(SUBPARTITION
`--------------------------abcdef0123456789abcdef0123456789abcdef`,
SUBPARTITION
`0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`)
);
SET GLOBAL innodb_file_per_table=@file_per_table;
SHOW CREATE TABLE mysqltest1.t1;
INSERT INTO mysqltest1.t1 VALUES(1);
--error ER_WRONG_TABLE_NAME
DROP TABLE mysqltest1.`#mysql50#t1#P#@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024@0024#SP#0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`;
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'mysqltest1%';
drop database mysqltest1;

View file

@ -27,14 +27,14 @@ SELECT @@session.max_sort_length = 1024;
@@session.max_sort_length = 1024
1
'#--------------------FN_DYNVARS_084_03-------------------------#'
SET @@global.max_sort_length = 4;
SET @@global.max_sort_length = 8;
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
SET @@global.max_sort_length = 5;
8
SET @@global.max_sort_length = 9;
SELECT @@global.max_sort_length;
@@global.max_sort_length
5
9
SET @@global.max_sort_length = 8388608;
SELECT @@global.max_sort_length;
@@global.max_sort_length
@ -48,14 +48,14 @@ SELECT @@global.max_sort_length;
@@global.max_sort_length
65536
'#--------------------FN_DYNVARS_084_04-------------------------#'
SET @@session.max_sort_length = 4;
SET @@session.max_sort_length = 8;
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
SET @@session.max_sort_length = 5;
8
SET @@session.max_sort_length = 9;
SELECT @@session.max_sort_length;
@@session.max_sort_length
5
9
SET @@session.max_sort_length = 8388608;
SELECT @@session.max_sort_length;
@@session.max_sort_length
@ -74,13 +74,13 @@ Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '-1024'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@global.max_sort_length = 3;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '3'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@global.max_sort_length = 8388609;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8388609'
@ -92,17 +92,17 @@ Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@global.max_sort_length = 65530.34;
ERROR 42000: Incorrect argument type to variable 'max_sort_length'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@global.max_sort_length = test;
ERROR 42000: Incorrect argument type to variable 'max_sort_length'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@session.max_sort_length = 8388610;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8388610'
@ -114,19 +114,19 @@ Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '-1'
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
8
SET @@session.max_sort_length = 3;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '3'
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
8
SET @@session.max_sort_length = 0;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
8
SET @@session.max_sort_length = 65530.34;
ERROR 42000: Incorrect argument type to variable 'max_sort_length'
SET @@session.max_sort_length = 10737418241;
@ -158,13 +158,13 @@ Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '1'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
SET @@global.max_sort_length = FALSE;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
8
'#---------------------FN_DYNVARS_084_09----------------------#'
SET @@global.max_sort_length = 2048;
SELECT @@max_sort_length = @@global.max_sort_length;

View file

@ -1946,7 +1946,7 @@ VARIABLE_NAME MAX_SORT_LENGTH
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored)
NUMERIC_MIN_VALUE 4
NUMERIC_MIN_VALUE 8
NUMERIC_MAX_VALUE 8388608
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL

View file

@ -2106,7 +2106,7 @@ VARIABLE_NAME MAX_SORT_LENGTH
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored)
NUMERIC_MIN_VALUE 4
NUMERIC_MIN_VALUE 8
NUMERIC_MAX_VALUE 8388608
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL

View file

@ -74,9 +74,9 @@ SELECT @@session.max_sort_length = 1024;
# Change the value of max_sort_length to a valid value for GLOBAL Scope #
#########################################################################
SET @@global.max_sort_length = 4;
SET @@global.max_sort_length = 8;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 5;
SET @@global.max_sort_length = 9;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 8388608;
SELECT @@global.max_sort_length;
@ -90,10 +90,10 @@ SELECT @@global.max_sort_length;
# Change the value of max_sort_length to a valid value for SESSION Scope #
##########################################################################
SET @@session.max_sort_length = 4;
SET @@session.max_sort_length = 8;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 5;
SET @@session.max_sort_length = 9;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 8388608;

View file

@ -3457,10 +3457,9 @@ int Field_new_decimal::cmp(const uchar *a,const uchar*b)
}
void Field_new_decimal::sort_string(uchar *buff,
uint)
void Field_new_decimal::sort_string(uchar *buff, uint length)
{
memcpy(buff, ptr, bin_size);
memcpy(buff, ptr, length);
}

View file

@ -1267,6 +1267,13 @@ public:
void make_sort_key(uchar *buff, uint length);
virtual void make_send_field(Send_field *);
/*
Some implementations actually may write up to 8 bytes regardless of what
size was requested. This is due to the minimum value of the system variable
max_sort_length.
*/
virtual void sort_string(uchar *buff,uint length)=0;
virtual bool optimize_range(uint idx, uint part) const;
virtual void free() {}

View file

@ -1152,6 +1152,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
backup_arena;
query_id_t old_query_id;
TABLE *old_derived_tables;
TABLE *old_rec_tables;
LEX *old_lex;
Item_change_list old_change_list;
String old_packet;
@ -1232,6 +1233,8 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
old_query_id= thd->query_id;
old_derived_tables= thd->derived_tables;
thd->derived_tables= 0;
old_rec_tables= thd->rec_tables;
thd->rec_tables= 0;
save_sql_mode= thd->variables.sql_mode;
thd->variables.sql_mode= m_sql_mode;
save_abort_on_warning= thd->abort_on_warning;
@ -1490,6 +1493,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
thd->set_query_id(old_query_id);
DBUG_ASSERT(!thd->derived_tables);
thd->derived_tables= old_derived_tables;
thd->rec_tables= old_rec_tables;
thd->variables.sql_mode= save_sql_mode;
thd->abort_on_warning= save_abort_on_warning;
thd->m_reprepare_observer= save_reprepare_observer;

View file

@ -2352,7 +2352,7 @@ static Sys_var_ulong Sys_max_sort_length(
"the first max_sort_length bytes of each value are used; the rest "
"are ignored)",
SESSION_VAR(max_sort_length), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(4, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1));
VALID_RANGE(8, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1));
static Sys_var_ulong Sys_max_sp_recursion_depth(
"max_sp_recursion_depth",

View file

@ -351,18 +351,18 @@ lock_check_trx_id_sanity(
dict_index_t* index, /*!< in: index */
const rec_offs* offsets) /*!< in: rec_get_offsets(rec, index) */
{
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!rec_is_metadata(rec, *index));
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!rec_is_metadata(rec, *index));
trx_id_t max_trx_id = trx_sys.get_max_trx_id();
ut_ad(max_trx_id || srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN);
trx_id_t max_trx_id= trx_sys.get_max_trx_id();
ut_ad(max_trx_id || srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN);
if (UNIV_LIKELY(max_trx_id) && UNIV_UNLIKELY(trx_id >= max_trx_id)) {
lock_report_trx_id_insanity(
trx_id, rec, index, offsets, max_trx_id);
return false;
}
return(true);
if (UNIV_LIKELY(max_trx_id != 0) && UNIV_UNLIKELY(trx_id >= max_trx_id))
{
lock_report_trx_id_insanity(trx_id, rec, index, offsets, max_trx_id);
return false;
}
return true;
}
/*********************************************************************//**

View file

@ -1705,8 +1705,9 @@ page_zip_fields_decode(
if (!val) {
val = ULINT_UNDEFINED;
} else if (UNIV_UNLIKELY(val >= n)) {
fail:
page_zip_fields_free(index);
index = NULL;
return NULL;
} else {
index->type = DICT_CLUSTERED;
}
@ -1715,8 +1716,7 @@ page_zip_fields_decode(
} else {
/* Decode the number of nullable fields. */
if (UNIV_UNLIKELY(index->n_nullable > val)) {
page_zip_fields_free(index);
index = NULL;
goto fail;
} else {
index->n_nullable = unsigned(val);
}

View file

@ -1,5 +1,5 @@
#
# This group is read both both by the client and the server
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]