Commit b31912fd authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-24033: SIGSEGV in __memcmp_avx2_movbe from queue_insert | SIGSEGV in...

MDEV-24033: SIGSEGV in __memcmp_avx2_movbe from queue_insert | SIGSEGV in __memcmp_avx2_movbe from native_compare

don't allow too small max_sort_length values
parent 59bbe873
...@@ -1585,7 +1585,7 @@ drop table t1; ...@@ -1585,7 +1585,7 @@ drop table t1;
--echo # --echo #
--echo # Check strnxfrm() with odd length --echo # Check strnxfrm() with odd length
--echo # --echo #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine; eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine;
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
......
...@@ -1492,6 +1492,8 @@ ab ...@@ -1492,6 +1492,8 @@ ab
AE AE
AE AE
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SELECT * FROM t1 ORDER BY s1; SELECT * FROM t1 ORDER BY s1;
s1 s1
ab ab
......
...@@ -1765,6 +1765,8 @@ ab ...@@ -1765,6 +1765,8 @@ ab
AE AE
AE AE
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SELECT * FROM t1 ORDER BY s1; SELECT * FROM t1 ORDER BY s1;
s1 s1
ab ab
......
...@@ -1505,6 +1505,8 @@ ab ...@@ -1505,6 +1505,8 @@ ab
AE AE
AE AE
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SELECT * FROM t1 ORDER BY s1; SELECT * FROM t1 ORDER BY s1;
s1 s1
ab ab
......
...@@ -6755,9 +6755,11 @@ DFFFDFFF9CFF9DFF9EFF ...@@ -6755,9 +6755,11 @@ DFFFDFFF9CFF9DFF9EFF
# Checking strnxfrm() with odd length # Checking strnxfrm() with odd length
# #
set max_sort_length=9; set max_sort_length=9;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '9'
select @@max_sort_length; select @@max_sort_length;
@@max_sort_length @@max_sort_length
9 64
create table t1 (a varchar(128) character set utf8 collate utf8_general_ci); create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
select * from t1 order by a; select * from t1 order by a;
......
...@@ -2371,10 +2371,10 @@ drop table t1; ...@@ -2371,10 +2371,10 @@ drop table t1;
# #
# Check strnxfrm() with odd length # Check strnxfrm() with odd length
# #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
@@max_sort_length @@max_sort_length
9 65
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci); create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
select * from t1 order by a; select * from t1 order by a;
......
...@@ -2203,10 +2203,10 @@ drop table t1; ...@@ -2203,10 +2203,10 @@ drop table t1;
# #
# Check strnxfrm() with odd length # Check strnxfrm() with odd length
# #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
@@max_sort_length @@max_sort_length
9 65
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine heap; create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine heap;
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
select * from t1 order by a; select * from t1 order by a;
......
...@@ -2331,10 +2331,10 @@ drop table t1; ...@@ -2331,10 +2331,10 @@ drop table t1;
# #
# Check strnxfrm() with odd length # Check strnxfrm() with odd length
# #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
@@max_sort_length @@max_sort_length
9 65
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB; create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB;
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
select * from t1 order by a; select * from t1 order by a;
......
...@@ -2331,10 +2331,10 @@ drop table t1; ...@@ -2331,10 +2331,10 @@ drop table t1;
# #
# Check strnxfrm() with odd length # Check strnxfrm() with odd length
# #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
@@max_sort_length @@max_sort_length
9 65
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine MyISAM; create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine MyISAM;
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
select * from t1 order by a; select * from t1 order by a;
......
...@@ -763,18 +763,20 @@ col2 col col ...@@ -763,18 +763,20 @@ col2 col col
2 2 2 2 2 2
1 3 3 1 3 3
drop table t1, t2; drop table t1, t2;
create table t1 (a char(25)); create table t1 (a char(70));
insert into t1 set a = repeat('x', 20); insert into t1 set a = repeat('x', 20);
insert into t1 set a = concat(repeat('x', 19), 'z'); insert into t1 set a = concat(repeat('x', 63), 'z');
insert into t1 set a = concat(repeat('x', 19), 'ab'); insert into t1 set a = concat(repeat('x', 63), 'ab');
insert into t1 set a = concat(repeat('x', 19), 'aa'); insert into t1 set a = concat(repeat('x', 63), 'aa');
set max_sort_length=20; set max_sort_length=20;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '20'
select a from t1 order by a; select a from t1 order by a;
a a
xxxxxxxxxxxxxxxxxxxab
xxxxxxxxxxxxxxxxxxxaa
xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxz xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxab
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaa
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz
drop table t1; drop table t1;
create table t1 ( create table t1 (
`sid` decimal(8,0) default null, `sid` decimal(8,0) default null,
...@@ -3241,6 +3243,8 @@ drop table t1; ...@@ -3241,6 +3243,8 @@ drop table t1;
SET @save_sort_buffer_size= @@sort_buffer_size; SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_sort_length= @@max_sort_length; SET @save_max_sort_length= @@max_sort_length;
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SET sort_buffer_size=1024; SET sort_buffer_size=1024;
CREATE TABLE t1(a INT, b DECIMAL(65), c BLOB); 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;
...@@ -3308,6 +3312,8 @@ SET @save_max_sort_length= @@max_sort_length; ...@@ -3308,6 +3312,8 @@ SET @save_max_sort_length= @@max_sort_length;
SET @save_sort_buffer_size= @@sort_buffer_size; SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_length_for_sort_data= @@max_length_for_sort_data; SET @save_max_length_for_sort_data= @@max_length_for_sort_data;
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SET sort_buffer_size=1024; SET sort_buffer_size=1024;
SET max_length_for_sort_data=7000; SET max_length_for_sort_data=7000;
CREATE TABLE t1(a VARCHAR(64), b VARCHAR(2048))DEFAULT CHARSET=utf8; CREATE TABLE t1(a VARCHAR(64), b VARCHAR(2048))DEFAULT CHARSET=utf8;
...@@ -3443,6 +3449,8 @@ INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); ...@@ -3443,6 +3449,8 @@ INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
SET max_length_for_sort_data= 30; SET max_length_for_sort_data= 30;
SET sql_select_limit = 3; SET sql_select_limit = 3;
SET max_sort_length=8; SET max_sort_length=8;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8'
SELECT * FROM t1 ORDER BY a+1; SELECT * FROM t1 ORDER BY a+1;
a b a b
1 1 1 1
......
...@@ -814,33 +814,33 @@ select @@character_set_results; ...@@ -814,33 +814,33 @@ select @@character_set_results;
NULL NULL
set character_set_results=default; set character_set_results=default;
set GLOBAL query_cache_size=1355776; set GLOBAL query_cache_size=1355776;
create table t1 (id int auto_increment primary key, c char(25)); create table t1 (id int auto_increment primary key, c char(65));
insert into t1 set c = repeat('x',24); insert into t1 set c = repeat('x',24);
insert into t1 set c = concat(repeat('x',24),'x'); insert into t1 set c = concat(repeat('x',64),'x');
insert into t1 set c = concat(repeat('x',24),'w'); insert into t1 set c = concat(repeat('x',64),'w');
insert into t1 set c = concat(repeat('x',24),'y'); insert into t1 set c = concat(repeat('x',64),'y');
set max_sort_length=200; set max_sort_length=200;
select c from t1 order by c, id; select c from t1 order by c, id;
c c
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxw xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxw
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxy xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy
reset query cache; reset query cache;
set max_sort_length=20; set max_sort_length=64;
select c from t1 order by c, id; select c from t1 order by c, id;
c c
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxw xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxw
xxxxxxxxxxxxxxxxxxxxxxxxy xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy
set max_sort_length=200; set max_sort_length=200;
select c from t1 order by c, id; select c from t1 order by c, id;
c c
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxw xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxw
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxy xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy
set max_sort_length=default; set max_sort_length=default;
select '1' || '3' from t1; select '1' || '3' from t1;
'1' || '3' '1' || '3'
......
SET @start_global_value = @@global.max_sort_length;
SELECT @start_global_value;
@start_global_value
1024
SET @start_session_value = @@session.max_sort_length;
SELECT @start_session_value;
@start_session_value
1024
'#--------------------FN_DYNVARS_084_01-------------------------#'
SET @@global.max_sort_length = 1000;
SET @@global.max_sort_length = DEFAULT;
SELECT @@global.max_sort_length;
@@global.max_sort_length
1024
SET @@session.max_sort_length = 1000;
SET @@session.max_sort_length = DEFAULT;
SELECT @@session.max_sort_length;
@@session.max_sort_length
1024
'#--------------------FN_DYNVARS_084_02-------------------------#'
SET @@global.max_sort_length = DEFAULT;
SELECT @@global.max_sort_length = 1024;
@@global.max_sort_length = 1024
1
SET @@session.max_sort_length = DEFAULT;
SELECT @@session.max_sort_length = 1024;
@@session.max_sort_length = 1024
1
'#--------------------FN_DYNVARS_084_03-------------------------#'
SET @@global.max_sort_length = 8;
SELECT @@global.max_sort_length;
@@global.max_sort_length
8
SET @@global.max_sort_length = 9;
SELECT @@global.max_sort_length;
@@global.max_sort_length
9
SET @@global.max_sort_length = 8388608;
SELECT @@global.max_sort_length;
@@global.max_sort_length
8388608
SET @@global.max_sort_length = 8388607;
SELECT @@global.max_sort_length;
@@global.max_sort_length
8388607
SET @@global.max_sort_length = 65536;
SELECT @@global.max_sort_length;
@@global.max_sort_length
65536
'#--------------------FN_DYNVARS_084_04-------------------------#'
SET @@session.max_sort_length = 8;
SELECT @@session.max_sort_length;
@@session.max_sort_length
8
SET @@session.max_sort_length = 9;
SELECT @@session.max_sort_length;
@@session.max_sort_length
9
SET @@session.max_sort_length = 8388608;
SELECT @@session.max_sort_length;
@@session.max_sort_length
8388608
SET @@session.max_sort_length = 8388607;
SELECT @@session.max_sort_length;
@@session.max_sort_length
8388607
SET @@session.max_sort_length = 65536;
SELECT @@session.max_sort_length;
@@session.max_sort_length
65536
'#------------------FN_DYNVARS_084_05-----------------------#'
SET @@global.max_sort_length = -1024;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '-1024'
SELECT @@global.max_sort_length;
@@global.max_sort_length
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
8
SET @@global.max_sort_length = 8388609;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8388609'
SELECT @@global.max_sort_length;
@@global.max_sort_length
8388608
SET @@global.max_sort_length = 0;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
SELECT @@global.max_sort_length;
@@global.max_sort_length
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
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
8
SET @@session.max_sort_length = 8388610;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '8388610'
SELECT @@session.max_sort_length;
@@session.max_sort_length
8388608
SET @@session.max_sort_length = -1;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '-1'
SELECT @@session.max_sort_length;
@@session.max_sort_length
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
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
8
SET @@session.max_sort_length = 65530.34;
ERROR 42000: Incorrect argument type to variable 'max_sort_length'
SET @@session.max_sort_length = 10737418241;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '10737418241'
SELECT @@session.max_sort_length;
@@session.max_sort_length
8388608
SET @@session.max_sort_length = test;
ERROR 42000: Incorrect argument type to variable 'max_sort_length'
SELECT @@session.max_sort_length;
@@session.max_sort_length
8388608
'#------------------FN_DYNVARS_084_06-----------------------#'
SELECT @@global.max_sort_length = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='max_sort_length';
@@global.max_sort_length = VARIABLE_VALUE
1
'#------------------FN_DYNVARS_084_07-----------------------#'
SELECT @@session.max_sort_length = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='max_sort_length';
@@session.max_sort_length = VARIABLE_VALUE
1
'#------------------FN_DYNVARS_084_08-----------------------#'
SET @@global.max_sort_length = TRUE;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '1'
SELECT @@global.max_sort_length;
@@global.max_sort_length
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
8
'#---------------------FN_DYNVARS_084_09----------------------#'
SET @@global.max_sort_length = 2048;
SELECT @@max_sort_length = @@global.max_sort_length;
@@max_sort_length = @@global.max_sort_length
0
'#---------------------FN_DYNVARS_084_10----------------------#'
SET @@max_sort_length = 100000;
SELECT @@max_sort_length = @@local.max_sort_length;
@@max_sort_length = @@local.max_sort_length
1
SELECT @@local.max_sort_length = @@session.max_sort_length;
@@local.max_sort_length = @@session.max_sort_length
1
'#---------------------FN_DYNVARS_084_11----------------------#'
SET max_sort_length = 1024;
SELECT @@max_sort_length;
@@max_sort_length
1024
SELECT local.max_sort_length;
ERROR 42S02: Unknown table 'local' in field list
SELECT session.max_sort_length;
ERROR 42S02: Unknown table 'session' in field list
SELECT max_sort_length = @@session.max_sort_length;
ERROR 42S22: Unknown column 'max_sort_length' in 'field list'
SET @@global.max_sort_length = @start_global_value;
SELECT @@global.max_sort_length;
@@global.max_sort_length
1024
SET @@session.max_sort_length = @start_session_value;
SELECT @@session.max_sort_length;
@@session.max_sort_length
1024
...@@ -1766,7 +1766,7 @@ VARIABLE_NAME MAX_SORT_LENGTH ...@@ -1766,7 +1766,7 @@ VARIABLE_NAME MAX_SORT_LENGTH
VARIABLE_SCOPE SESSION VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED 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) 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 8 NUMERIC_MIN_VALUE 64
NUMERIC_MAX_VALUE 8388608 NUMERIC_MAX_VALUE 8388608
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
......
...@@ -1906,7 +1906,7 @@ VARIABLE_NAME MAX_SORT_LENGTH ...@@ -1906,7 +1906,7 @@ VARIABLE_NAME MAX_SORT_LENGTH
VARIABLE_SCOPE SESSION VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED 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) 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 8 NUMERIC_MIN_VALUE 64
NUMERIC_MAX_VALUE 8388608 NUMERIC_MAX_VALUE 8388608
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
......
############## mysql-test\t\max_sort_length_basic.test ###############
# #
# Variable Name: max_sort_length #
# Scope: GLOBAL | SESSION #
# Access Type: Dynamic #
# Data Type: numeric #
# Default Value: 1024 #
# Range: 4-8388608 #
# #
# #
# Creation Date: 2008-02-07 #
# Author: Salman #
# #
# Description: Test Cases of Dynamic System Variable max_sort_length #
# that checks the behavior of this variable in the following ways#
# * Default Value #
# * Valid & Invalid values #
# * Scope & Access method #
# * Data Integrity #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html #
# #
###############################################################################
--source include/load_sysvars.inc
############################################
# START OF max_sort_length TESTS #
############################################
#############################################################
# Save initial value #
#############################################################
SET @start_global_value = @@global.max_sort_length;
SELECT @start_global_value;
SET @start_session_value = @@session.max_sort_length;
SELECT @start_session_value;
--echo '#--------------------FN_DYNVARS_084_01-------------------------#'
#######################################################
# Display the DEFAULT value of max_sort_length #
#######################################################
SET @@global.max_sort_length = 1000;
SET @@global.max_sort_length = DEFAULT;
SELECT @@global.max_sort_length;
SET @@session.max_sort_length = 1000;
SET @@session.max_sort_length = DEFAULT;
SELECT @@session.max_sort_length;
--echo '#--------------------FN_DYNVARS_084_02-------------------------#'
#######################################################
# Check the DEFAULT value of max_sort_length #
#######################################################
SET @@global.max_sort_length = DEFAULT;
SELECT @@global.max_sort_length = 1024;
SET @@session.max_sort_length = DEFAULT;
SELECT @@session.max_sort_length = 1024;
--echo '#--------------------FN_DYNVARS_084_03-------------------------#'
#########################################################################
# Change the value of max_sort_length to a valid value for GLOBAL Scope #
#########################################################################
SET @@global.max_sort_length = 8;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 9;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 8388608;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 8388607;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 65536;
SELECT @@global.max_sort_length;
--echo '#--------------------FN_DYNVARS_084_04-------------------------#'
##########################################################################
# Change the value of max_sort_length to a valid value for SESSION Scope #
##########################################################################
SET @@session.max_sort_length = 8;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 9;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 8388608;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 8388607;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 65536;
SELECT @@session.max_sort_length;
--echo '#------------------FN_DYNVARS_084_05-----------------------#'
###########################################################
# Change the value of max_sort_length to an invalid value #
###########################################################
SET @@global.max_sort_length = -1024;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 3;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 8388609;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = 0;
SELECT @@global.max_sort_length;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.max_sort_length = 65530.34;
SELECT @@global.max_sort_length;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.max_sort_length = test;
SELECT @@global.max_sort_length;
SET @@session.max_sort_length = 8388610;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = -1;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 3;
SELECT @@session.max_sort_length;
SET @@session.max_sort_length = 0;
SELECT @@session.max_sort_length;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.max_sort_length = 65530.34;
SET @@session.max_sort_length = 10737418241;
SELECT @@session.max_sort_length;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.max_sort_length = test;
SELECT @@session.max_sort_length;
--echo '#------------------FN_DYNVARS_084_06-----------------------#'
####################################################################
# Check if the value in GLOBAL Table matches value in variable #
####################################################################
SELECT @@global.max_sort_length = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='max_sort_length';
--echo '#------------------FN_DYNVARS_084_07-----------------------#'
####################################################################
# Check if the value in SESSION Table matches value in variable #
####################################################################
SELECT @@session.max_sort_length = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='max_sort_length';
--echo '#------------------FN_DYNVARS_084_08-----------------------#'
####################################################################
# Check if TRUE and FALSE values can be used on variable #
####################################################################
SET @@global.max_sort_length = TRUE;
SELECT @@global.max_sort_length;
SET @@global.max_sort_length = FALSE;
SELECT @@global.max_sort_length;
--echo '#---------------------FN_DYNVARS_084_09----------------------#'
#################################################################################
# Check if accessing variable with and without GLOBAL point to same variable #
#################################################################################
SET @@global.max_sort_length = 2048;
SELECT @@max_sort_length = @@global.max_sort_length;
--echo '#---------------------FN_DYNVARS_084_10----------------------#'
########################################################################################################
# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
########################################################################################################
SET @@max_sort_length = 100000;
SELECT @@max_sort_length = @@local.max_sort_length;
SELECT @@local.max_sort_length = @@session.max_sort_length;
--echo '#---------------------FN_DYNVARS_084_11----------------------#'
##########################################################################
# Check if max_sort_length can be accessed with and without @@ sign #
##########################################################################
SET max_sort_length = 1024;
SELECT @@max_sort_length;
--Error ER_UNKNOWN_TABLE
SELECT local.max_sort_length;
--Error ER_UNKNOWN_TABLE
SELECT session.max_sort_length;
--Error ER_BAD_FIELD_ERROR
SELECT max_sort_length = @@session.max_sort_length;
####################################
# Restore initial value #
####################################
SET @@global.max_sort_length = @start_global_value;
SELECT @@global.max_sort_length;
SET @@session.max_sort_length = @start_session_value;
SELECT @@session.max_sort_length;
####################################################
# END OF max_sort_length TESTS #
####################################################
...@@ -26,70 +26,40 @@ ...@@ -26,70 +26,40 @@
SET @start_value= @@global.max_sort_length; SET @start_value= @@global.max_sort_length;
SET @session_max_sort_length = @@Session.max_sort_length;
--disable_warnings
DROP TABLE IF EXISTS t;
--enable_warnings
######################### #########################
# Creating new table # # Creating new table #
######################### #########################
--echo ** creating tables ** --echo ** creating tables **
CREATE TABLE t CREATE TABLE t (id INT AUTO_INCREMENT PRIMARY KEY, c TEXT);
( CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, c BLOB);
id INT AUTO_INCREMENT PRIMARY KEY, CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY, c TEXT);
c TEXT(30)
);
CREATE TABLE t1
(
id INT AUTO_INCREMENT PRIMARY KEY,
c BLOB(30)
);
CREATE TABLE t2
(
id INT AUTO_INCREMENT PRIMARY KEY,
c TEXT(30)
);
--echo '#--------------------FN_DYNVARS_098_01-------------------------#' --echo '#--------------------FN_DYNVARS_098_01-------------------------#'
########################################################## ##########################################################
# Test behavior of variable on new connection # 01 # # Test behavior of variable on new connection # 01 #
########################################################## ##########################################################
connect (test_con1,localhost,root,,); connect (test_con1,localhost,root,,);
connection test_con1;
# Value of session & global vairable here should be 10
SELECT @@global.max_sort_length = 10;
SELECT @@session.max_sort_length = 10;
# Setting global value of variable and inserting data in table # Setting global value of variable and inserting data in table
--echo ** Setting value to 30 and inserting data ** --echo ** Setting value to 70 and inserting data **
SET @@global.max_sort_length = 30; SET @@global.max_sort_length = 70;
SELECT @@global.max_sort_length; SELECT @@global.max_sort_length;
INSERT INTO t set c = repeat('x',29); INSERT INTO t set c = repeat('x',69);
INSERT INTO t set c = concat(repeat('x',28),'r','x'); INSERT INTO t set c = concat(repeat('x',68),'r','x');
INSERT INTO t set c = concat(repeat('x',28),'s','y'); INSERT INTO t set c = concat(repeat('x',68),'s','y');
INSERT INTO t set c = concat(repeat('x',28),'g','w'); INSERT INTO t set c = concat(repeat('x',68),'g','w');
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
# Setting session value of variable and inserting data in table # Setting session value of variable and inserting data in table
SET @@session.max_sort_length = 29; SET @@session.max_sort_length = 69;
SELECT @@session.max_sort_length; SELECT @@session.max_sort_length;
INSERT INTO t set c = repeat('x',29); INSERT INTO t set c = repeat('x',69);
INSERT INTO t set c = concat(repeat('x',28),'r','x'); INSERT INTO t set c = concat(repeat('x',68),'r','x');
INSERT INTO t set c = concat(repeat('x',28),'s','y'); INSERT INTO t set c = concat(repeat('x',68),'s','y');
INSERT INTO t set c = concat(repeat('x',28),'g','w'); INSERT INTO t set c = concat(repeat('x',68),'g','w');
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
...@@ -99,72 +69,69 @@ SELECT c from t ORDER BY c, id; ...@@ -99,72 +69,69 @@ SELECT c from t ORDER BY c, id;
########################################################## ##########################################################
connect (test_con2,localhost,root,,); connect (test_con2,localhost,root,,);
connection test_con2;
## Setting global value of variable and inserting data in table ## Setting global value of variable and inserting data in table
SET @@global.max_sort_length = 30; SET @@global.max_sort_length = 70;
SELECT @@global.max_sort_length; SELECT @@global.max_sort_length;
INSERT INTO t set c = repeat('x',29); INSERT INTO t set c = repeat('x',69);
INSERT INTO t set c = concat(repeat('x',28),'r','x'); INSERT INTO t set c = concat(repeat('x',68),'r','x');
INSERT INTO t set c = concat(repeat('x',28),'s','y'); INSERT INTO t set c = concat(repeat('x',68),'s','y');
INSERT INTO t set c = concat(repeat('x',28),'g','w'); INSERT INTO t set c = concat(repeat('x',68),'g','w');
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
# Setting session value of variable and inserting data in table # Setting session value of variable and inserting data in table
SET @@session.max_sort_length = 20; SET @@session.max_sort_length = 64;
SELECT @@session.max_sort_length; SELECT @@session.max_sort_length;
INSERT INTO t set c = repeat('x',29); INSERT INTO t set c = repeat('x',69);
INSERT INTO t set c = concat(repeat('x',28),'r','x'); INSERT INTO t set c = concat(repeat('x',68),'r','x');
INSERT INTO t set c = concat(repeat('x',28),'s','y'); INSERT INTO t set c = concat(repeat('x',68),'s','y');
INSERT INTO t set c = concat(repeat('x',28),'g','w'); INSERT INTO t set c = concat(repeat('x',68),'g','w');
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should not be sorted ** --echo ** Results should not be sorted **
--echo '#--------------------FN_DYNVARS_098_03-------------------------#' --echo '#--------------------FN_DYNVARS_098_03-------------------------#'
######################################################### #########################################################
#Check if sorting is applied with the max_sort_length=20# #Check if sorting is applied with the max_sort_length=64#
######################################################### #########################################################
########################################### ###########################################
# Setting new value for max_sort_length # # Setting new value for max_sort_length #
########################################### ###########################################
SET max_sort_length=20; SET max_sort_length=64;
################################### ###################################
# Inserting values in table t # # Inserting values in table t #
################################### ###################################
INSERT INTO t set c = repeat('x',29); INSERT INTO t set c = repeat('x',69);
INSERT INTO t set c = concat(repeat('x',28),'r','x'); INSERT INTO t set c = concat(repeat('x',68),'r','x');
INSERT INTO t set c = concat(repeat('x',28),'s','y'); INSERT INTO t set c = concat(repeat('x',68),'s','y');
INSERT INTO t set c = concat(repeat('x',28),'g','w'); INSERT INTO t set c = concat(repeat('x',68),'g','w');
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should not be sorted ** --echo ** Results should not be sorted **
RESET QUERY CACHE; RESET QUERY CACHE;
--echo '#--------------------FN_DYNVARS_098_04-------------------------#' --echo '#--------------------FN_DYNVARS_098_04-------------------------#'
######################################################### #########################################################
#Check if sorting is applied with the max_sort_length=29# #Check if sorting is applied with the max_sort_length=69#
######################################################### #########################################################
SET max_sort_length=29; SET max_sort_length=69;
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
--echo '#--------------------FN_DYNVARS_098_05-------------------------#' --echo '#--------------------FN_DYNVARS_098_05-------------------------#'
######################################################### #########################################################
#Check if sorting is applied with the max_sort_length=30# #Check if sorting is applied with the max_sort_length=70#
######################################################### #########################################################
SET max_sort_length=30; SET max_sort_length=70;
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
...@@ -173,34 +140,33 @@ SELECT c from t ORDER BY c, id; ...@@ -173,34 +140,33 @@ SELECT c from t ORDER BY c, id;
#Check if sorting is applied with the max_sort_length=Default# #Check if sorting is applied with the max_sort_length=Default#
############################################################## ##############################################################
SET max_sort_length=default; SET max_sort_length=default;
SELECT @@max_sort_length;
SELECT c from t ORDER BY c, id; SELECT c from t ORDER BY c, id;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
--echo '#--------------------FN_DYNVARS_098_07-------------------------#' --echo '#--------------------FN_DYNVARS_098_07-------------------------#'
########################################### ###########################################
#Check if sorting is applied on BLOB type # #Check if sorting is applied on BLOB type #
########################################### ###########################################
--echo Testing type BLOB --echo Testing type BLOB
# Setting global value of variable and inserting data in table # Setting global value of variable and inserting data in table
SET @@global.max_sort_length = 30; SET @@max_sort_length = 70;
SELECT @@global.max_sort_length; SELECT @@max_sort_length;
INSERT INTO t1 set c = repeat('x',29); INSERT INTO t1 set c = repeat('x',69);
INSERT INTO t1 set c = concat(repeat('x',28),'r','x'); INSERT INTO t1 set c = concat(repeat('x',68),'r','x');
INSERT INTO t1 set c = concat(repeat('x',28),'s','y'); INSERT INTO t1 set c = concat(repeat('x',68),'s','y');
INSERT INTO t1 set c = concat(repeat('x',28),'g','w'); INSERT INTO t1 set c = concat(repeat('x',68),'g','w');
SELECT c from t1 ORDER BY c, id; SELECT c from t1 ORDER BY c, id DESC;
--echo ** Results should be sorted ** --echo ** Results should be sorted **
# Setting session value of variable and inserting data in table # Setting session value of variable and inserting data in table
SET @@session.max_sort_length = 20; SET @@session.max_sort_length = 64;
SELECT @@session.max_sort_length; SELECT @@session.max_sort_length;
INSERT INTO t1 set c = repeat('x',29); INSERT INTO t1 set c = repeat('x',69);
INSERT INTO t1 set c = concat(repeat('x',28),'r','x'); INSERT INTO t1 set c = concat(repeat('x',68),'r','x');
INSERT INTO t1 set c = concat(repeat('x',28),'s','y'); INSERT INTO t1 set c = concat(repeat('x',68),'s','y');
INSERT INTO t1 set c = concat(repeat('x',28),'g','w'); INSERT INTO t1 set c = concat(repeat('x',68),'g','w');
SELECT c from t1 ORDER BY c, id; SELECT c from t1 ORDER BY c, id;
--echo ** Results should not be sorted ** --echo ** Results should not be sorted **
...@@ -210,26 +176,25 @@ SELECT c from t1 ORDER BY c, id; ...@@ -210,26 +176,25 @@ SELECT c from t1 ORDER BY c, id;
########################################### ###########################################
--echo Testing type CHAR --echo Testing type CHAR
# Setting global value of variable and inserting data in table # Setting global value of variable and inserting data in table
SET @@global.max_sort_length = 30; SET @@global.max_sort_length = 70;
SELECT @@global.max_sort_length; SELECT @@global.max_sort_length;
INSERT INTO t2 set c = repeat('x',29); INSERT INTO t2 set c = repeat('x',69);
INSERT INTO t2 set c = concat(repeat('x',28),'r','x'); INSERT INTO t2 set c = concat(repeat('x',68),'r','x');
INSERT INTO t2 set c = concat(repeat('x',28),'s','y'); INSERT INTO t2 set c = concat(repeat('x',68),'s','y');
INSERT INTO t2 set c = concat(repeat('x',28),'g','w'); INSERT INTO t2 set c = concat(repeat('x',68),'g','w');
SELECT c from t2 ORDER BY c, id; SELECT c from t2 ORDER BY c, id;
--echo ** Results should not be sorted ** --echo ** Results should not be sorted **
# Setting session value of variable and inserting data in table # Setting session value of variable and inserting data in table
SET @@session.max_sort_length = 20; SET @@session.max_sort_length = 64;
SELECT @@session.max_sort_length; SELECT @@session.max_sort_length;
INSERT INTO t2 set c = repeat('x',29); INSERT INTO t2 set c = repeat('x',69);
INSERT INTO t2 set c = concat(repeat('x',28),'r','x'); INSERT INTO t2 set c = concat(repeat('x',68),'r','x');
INSERT INTO t2 set c = concat(repeat('x',28),'s','y'); INSERT INTO t2 set c = concat(repeat('x',68),'s','y');
INSERT INTO t2 set c = concat(repeat('x',28),'g','w'); INSERT INTO t2 set c = concat(repeat('x',68),'g','w');
SELECT c from t2 ORDER BY c, id; SELECT c from t2 ORDER BY c, id;
--echo ** Results should not be sorted ** --echo ** Results should not be sorted **
# #
# Cleanup # Cleanup
# #
...@@ -239,12 +204,6 @@ connection default; ...@@ -239,12 +204,6 @@ connection default;
disconnect test_con1; disconnect test_con1;
disconnect test_con2; disconnect test_con2;
SET @@SESSION.max_sort_length = @session_max_sort_length; DROP TABLE t, t1, t2;
--disable_warnings
DROP TABLE IF EXISTS t;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
SET @@global.max_sort_length= @start_value; SET @@global.max_sort_length= @start_value;
...@@ -1520,7 +1520,7 @@ drop table t1; ...@@ -1520,7 +1520,7 @@ drop table t1;
--echo # --echo #
--echo # Check strnxfrm() with odd length --echo # Check strnxfrm() with odd length
--echo # --echo #
set max_sort_length=9; set max_sort_length=65;
select @@max_sort_length; select @@max_sort_length;
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci); create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c'); insert into t1 values ('a'),('b'),('c');
......
...@@ -531,11 +531,11 @@ drop table t1, t2; ...@@ -531,11 +531,11 @@ drop table t1, t2;
# Bug #5428: a problem with small max_sort_length value # Bug #5428: a problem with small max_sort_length value
# #
create table t1 (a char(25)); create table t1 (a char(70));
insert into t1 set a = repeat('x', 20); insert into t1 set a = repeat('x', 20);
insert into t1 set a = concat(repeat('x', 19), 'z'); insert into t1 set a = concat(repeat('x', 63), 'z');
insert into t1 set a = concat(repeat('x', 19), 'ab'); insert into t1 set a = concat(repeat('x', 63), 'ab');
insert into t1 set a = concat(repeat('x', 19), 'aa'); insert into t1 set a = concat(repeat('x', 63), 'aa');
set max_sort_length=20; set max_sort_length=20;
select a from t1 order by a; select a from t1 order by a;
drop table t1; drop table t1;
......
...@@ -606,15 +606,15 @@ set character_set_results=default; ...@@ -606,15 +606,15 @@ set character_set_results=default;
# #
# max_sort_length # max_sort_length
set GLOBAL query_cache_size=1355776; set GLOBAL query_cache_size=1355776;
create table t1 (id int auto_increment primary key, c char(25)); create table t1 (id int auto_increment primary key, c char(65));
insert into t1 set c = repeat('x',24); insert into t1 set c = repeat('x',24);
insert into t1 set c = concat(repeat('x',24),'x'); insert into t1 set c = concat(repeat('x',64),'x');
insert into t1 set c = concat(repeat('x',24),'w'); insert into t1 set c = concat(repeat('x',64),'w');
insert into t1 set c = concat(repeat('x',24),'y'); insert into t1 set c = concat(repeat('x',64),'y');
set max_sort_length=200; set max_sort_length=200;
select c from t1 order by c, id; select c from t1 order by c, id;
reset query cache; reset query cache;
set max_sort_length=20; set max_sort_length=64;
select c from t1 order by c, id; select c from t1 order by c, id;
set max_sort_length=200; set max_sort_length=200;
select c from t1 order by c, id; select c from t1 order by c, id;
......
...@@ -2224,7 +2224,7 @@ static Sys_var_ulong Sys_max_sort_length( ...@@ -2224,7 +2224,7 @@ static Sys_var_ulong Sys_max_sort_length(
"the first max_sort_length bytes of each value are used; the rest " "the first max_sort_length bytes of each value are used; the rest "
"are ignored)", "are ignored)",
SESSION_VAR(max_sort_length), CMD_LINE(REQUIRED_ARG), SESSION_VAR(max_sort_length), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(8, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1)); VALID_RANGE(64, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1));
static Sys_var_ulong Sys_max_sp_recursion_depth( static Sys_var_ulong Sys_max_sp_recursion_depth(
"max_sp_recursion_depth", "max_sp_recursion_depth",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment