36 changed files with 5574 additions and 344 deletions
-
25mysql-test/r/mysqld--help.result
-
1014mysql-test/r/selectivity.result
-
1024mysql-test/r/selectivity_innodb.result
-
570mysql-test/r/statistics.result
-
3mysql-test/r/system_mysql_db.result
-
7mysql-test/suite/funcs_1/r/is_columns_mysql.result
-
7mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
-
136mysql-test/suite/sys_vars/r/histogram_size_basic.result
-
79mysql-test/suite/sys_vars/r/histogram_type_basic.result
-
109mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result
-
142mysql-test/suite/sys_vars/t/histogram_size_basic.test
-
92mysql-test/suite/sys_vars/t/histogram_type_basic.test
-
142mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test
-
623mysql-test/t/selectivity.test
-
12mysql-test/t/selectivity_innodb.test
-
123mysql-test/t/statistics.test
-
2scripts/mysql_system_tables.sql
-
136sql/field.cc
-
37sql/field.h
-
20sql/item_cmpfunc.cc
-
4sql/item_cmpfunc.h
-
322sql/opt_range.cc
-
2sql/opt_range.h
-
6sql/opt_range_mrr.cc
-
2sql/opt_subselect.cc
-
1sql/opt_subselect.h
-
4sql/sql_class.h
-
1sql/sql_priv.h
-
376sql/sql_select.cc
-
8sql/sql_select.h
-
596sql/sql_statistics.cc
-
194sql/sql_statistics.h
-
37sql/sys_vars.cc
-
14sql/table.cc
-
8sql/table.h
-
40sql/uniques.cc
1014
mysql-test/r/selectivity.result
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1024
mysql-test/r/selectivity_innodb.result
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,136 @@ |
|||
SET @start_global_value = @@global.histogram_size; |
|||
SELECT @start_global_value; |
|||
@start_global_value |
|||
0 |
|||
SET @start_session_value = @@session.histogram_size; |
|||
SELECT @start_session_value; |
|||
@start_session_value |
|||
0 |
|||
'#--------------------FN_DYNVARS_053_01-------------------------#' |
|||
SET @@global.histogram_size = DEFAULT; |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
0 |
|||
SET @@session.histogram_size = DEFAULT; |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
0 |
|||
'#--------------------FN_DYNVARS_053_03-------------------------#' |
|||
SET @@global.histogram_size = 1; |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
1 |
|||
SET @@global.histogram_size = 31; |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
31 |
|||
SET @@global.histogram_size = 255; |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
255 |
|||
'#--------------------FN_DYNVARS_053_04-------------------------#' |
|||
SET @@session.histogram_size = 1; |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
1 |
|||
SET @@session.histogram_size = 31; |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
31 |
|||
SET @@session.histogram_size = 255; |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
255 |
|||
'#------------------FN_DYNVARS_053_05-----------------------#' |
|||
SET @@global.histogram_size = -1; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '-1' |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
0 |
|||
SET @@global.histogram_size = 256; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '256' |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
255 |
|||
SET @@global.histogram_size = 1024; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '1024' |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
255 |
|||
SET @@global.histogram_size = 4.5; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_size' |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
255 |
|||
SET @@global.histogram_size = test; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_size' |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
255 |
|||
SET @@session.histogram_size = -1; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '-1' |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
0 |
|||
SET @@session.histogram_size = 256; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '256' |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
255 |
|||
SET @@session.histogram_size = 1024; |
|||
Warnings: |
|||
Warning 1292 Truncated incorrect histogram_size value: '1024' |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
255 |
|||
SET @@session.histogram_size = 4.5; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_size' |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
255 |
|||
SET @@session.histogram_size = test; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_size' |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
255 |
|||
'#------------------FN_DYNVARS_053_06-----------------------#' |
|||
SELECT @@global.histogram_size = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_size'; |
|||
@@global.histogram_size = VARIABLE_VALUE |
|||
1 |
|||
'#------------------FN_DYNVARS_053_07-----------------------#' |
|||
SELECT @@session.histogram_size = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_size'; |
|||
@@session.histogram_size = VARIABLE_VALUE |
|||
1 |
|||
'#------------------FN_DYNVARS_053_08-----------------------#' |
|||
SET @@global.histogram_size = TRUE; |
|||
SET @@global.histogram_size = FALSE; |
|||
'#---------------------FN_DYNVARS_001_09----------------------#' |
|||
SET @@global.histogram_size = 10; |
|||
SELECT @@histogram_size = @@global.histogram_size; |
|||
@@histogram_size = @@global.histogram_size |
|||
0 |
|||
'#---------------------FN_DYNVARS_001_10----------------------#' |
|||
SET @@histogram_size = 100; |
|||
SELECT @@histogram_size = @@local.histogram_size; |
|||
@@histogram_size = @@local.histogram_size |
|||
1 |
|||
SELECT @@local.histogram_size = @@session.histogram_size; |
|||
@@local.histogram_size = @@session.histogram_size |
|||
1 |
|||
SET @@global.histogram_size = @start_global_value; |
|||
SELECT @@global.histogram_size; |
|||
@@global.histogram_size |
|||
0 |
|||
SET @@session.histogram_size = @start_session_value; |
|||
SELECT @@session.histogram_size; |
|||
@@session.histogram_size |
|||
0 |
@ -0,0 +1,79 @@ |
|||
SET @start_global_value = @@global.histogram_type; |
|||
SELECT @start_global_value; |
|||
@start_global_value |
|||
SINGLE_PREC_HB |
|||
SET @start_session_value = @@session.histogram_type; |
|||
SELECT @start_session_value; |
|||
@start_session_value |
|||
SINGLE_PREC_HB |
|||
SET @@global.histogram_type = 1; |
|||
SET @@global.histogram_type = DEFAULT; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@global.histogram_type = 0; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@global.histogram_type = 1; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
DOUBLE_PREC_HB |
|||
SET @@global.histogram_type = SINGLE_PREC_HB; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@global.histogram_type = DOUBLE_PREC_HB; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
DOUBLE_PREC_HB |
|||
SET @@session.histogram_type = 0; |
|||
SELECT @@session.histogram_type; |
|||
@@session.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@session.histogram_type = 1; |
|||
SELECT @@session.histogram_type; |
|||
@@session.histogram_type |
|||
DOUBLE_PREC_HB |
|||
SET @@session.histogram_type = SINGLE_PREC_HB; |
|||
SELECT @@session.histogram_type; |
|||
@@session.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@session.histogram_type = DOUBLE_PREC_HB; |
|||
SELECT @@session.histogram_type; |
|||
@@session.histogram_type |
|||
DOUBLE_PREC_HB |
|||
set sql_mode=TRADITIONAL; |
|||
SET @@global.histogram_type = 10; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of '10' |
|||
SET @@global.histogram_type = -1024; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of '-1024' |
|||
SET @@global.histogram_type = 2.4; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_type' |
|||
SET @@global.histogram_type = OFF; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of 'OFF' |
|||
SET @@session.histogram_type = 10; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of '10' |
|||
SET @@session.histogram_type = -2; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of '-2' |
|||
SET @@session.histogram_type = 1.2; |
|||
ERROR 42000: Incorrect argument type to variable 'histogram_type' |
|||
SET @@session.histogram_type = ON; |
|||
ERROR 42000: Variable 'histogram_type' can't be set to the value of 'ON' |
|||
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_type'; |
|||
VARIABLE_NAME VARIABLE_VALUE |
|||
HISTOGRAM_TYPE DOUBLE_PREC_HB |
|||
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_type'; |
|||
VARIABLE_NAME VARIABLE_VALUE |
|||
HISTOGRAM_TYPE DOUBLE_PREC_HB |
|||
SET @@global.histogram_type = @start_global_value; |
|||
SELECT @@global.histogram_type; |
|||
@@global.histogram_type |
|||
SINGLE_PREC_HB |
|||
SET @@session.histogram_type = @start_session_value; |
|||
SELECT @@session.histogram_type; |
|||
@@session.histogram_type |
|||
SINGLE_PREC_HB |
|||
set sql_mode=''; |
@ -0,0 +1,109 @@ |
|||
SET @start_global_value = @@global.optimizer_use_condition_selectivity; |
|||
SELECT @start_global_value; |
|||
@start_global_value |
|||
1 |
|||
SET @start_session_value = @@session.optimizer_use_condition_selectivity; |
|||
SELECT @start_session_value; |
|||
@start_session_value |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_01-------------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_02-------------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity = 1; |
|||
@@global.optimizer_use_condition_selectivity = 1 |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity = 1; |
|||
@@session.optimizer_use_condition_selectivity = 1 |
|||
1 |
|||
'#--------------------FN_DYNVARS_115_03-------------------------#' |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
2 |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
3 |
|||
SET @@global.optimizer_use_condition_selectivity = 4; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
4 |
|||
'#--------------------FN_DYNVARS_115_04-------------------------#' |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
2 |
|||
SET @@session.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
3 |
|||
SET @@session.optimizer_use_condition_selectivity = 4; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
4 |
|||
'#------------------FN_DYNVARS_115_05-----------------------#' |
|||
SET @@global.optimizer_use_condition_selectivity = ON; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@global.optimizer_use_condition_selectivity = OFF; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@session.optimizer_use_condition_selectivity = 65530.34; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
SET @@session.optimizer_use_condition_selectivity = test; |
|||
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity' |
|||
'#------------------FN_DYNVARS_115_06-----------------------#' |
|||
SELECT @@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
@@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
1 |
|||
'#------------------FN_DYNVARS_115_07-----------------------#' |
|||
SELECT @@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
@@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
1 |
|||
'#---------------------FN_DYNVARS_115_08----------------------#' |
|||
SET @@optimizer_use_condition_selectivity = 1; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity; |
|||
@@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity |
|||
0 |
|||
'#---------------------FN_DYNVARS_115_09----------------------#' |
|||
SET @@optimizer_use_condition_selectivity = 2; |
|||
SELECT @@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity; |
|||
@@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity |
|||
1 |
|||
SELECT @@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity; |
|||
@@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@global.optimizer_use_condition_selectivity = @start_global_value; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
@@global.optimizer_use_condition_selectivity |
|||
1 |
|||
SET @@session.optimizer_use_condition_selectivity = @start_session_value; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
@@session.optimizer_use_condition_selectivity |
|||
1 |
@ -0,0 +1,142 @@ |
|||
--source include/load_sysvars.inc |
|||
|
|||
############################################################## |
|||
# START OF histogram_size TESTS # |
|||
############################################################## |
|||
|
|||
|
|||
############################################################# |
|||
# Save initial value # |
|||
############################################################# |
|||
|
|||
SET @start_global_value = @@global.histogram_size; |
|||
SELECT @start_global_value; |
|||
SET @start_session_value = @@session.histogram_size; |
|||
SELECT @start_session_value; |
|||
|
|||
--echo '#--------------------FN_DYNVARS_053_01-------------------------#' |
|||
################################################################ |
|||
# Display the DEFAULT value of histogram_size # |
|||
################################################################ |
|||
|
|||
SET @@global.histogram_size = DEFAULT; |
|||
SELECT @@global.histogram_size; |
|||
|
|||
SET @@session.histogram_size = DEFAULT; |
|||
SELECT @@session.histogram_size; |
|||
|
|||
--echo '#--------------------FN_DYNVARS_053_03-------------------------#' |
|||
######################################################################## |
|||
# Change the value of histogram_size to a valid value for GLOBAL Scope # |
|||
######################################################################## |
|||
|
|||
SET @@global.histogram_size = 1; |
|||
SELECT @@global.histogram_size; |
|||
SET @@global.histogram_size = 31; |
|||
SELECT @@global.histogram_size; |
|||
SET @@global.histogram_size = 255; |
|||
SELECT @@global.histogram_size; |
|||
|
|||
--echo '#--------------------FN_DYNVARS_053_04-------------------------#' |
|||
######################################################################### |
|||
# Change the value of histogram_size to a valid value for SESSION Scope # |
|||
######################################################################### |
|||
|
|||
SET @@session.histogram_size = 1; |
|||
SELECT @@session.histogram_size; |
|||
SET @@session.histogram_size = 31; |
|||
SELECT @@session.histogram_size; |
|||
SET @@session.histogram_size = 255; |
|||
SELECT @@session.histogram_size; |
|||
|
|||
--echo '#------------------FN_DYNVARS_053_05-----------------------#' |
|||
########################################################## |
|||
# Change the value of histogram_size to an invalid value # |
|||
########################################################### |
|||
|
|||
SET @@global.histogram_size = -1; |
|||
SELECT @@global.histogram_size; |
|||
SET @@global.histogram_size = 256; |
|||
SELECT @@global.histogram_size; |
|||
SET @@global.histogram_size = 1024; |
|||
SELECT @@global.histogram_size; |
|||
|
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.histogram_size = 4.5; |
|||
SELECT @@global.histogram_size; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.histogram_size = test; |
|||
SELECT @@global.histogram_size; |
|||
|
|||
SET @@session.histogram_size = -1; |
|||
SELECT @@session.histogram_size; |
|||
SET @@session.histogram_size = 256; |
|||
SELECT @@session.histogram_size; |
|||
SET @@session.histogram_size = 1024; |
|||
SELECT @@session.histogram_size; |
|||
|
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.histogram_size = 4.5; |
|||
SELECT @@session.histogram_size; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.histogram_size = test; |
|||
SELECT @@session.histogram_size; |
|||
|
|||
--echo '#------------------FN_DYNVARS_053_06-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in GLOBAL Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
SELECT @@global.histogram_size = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_size'; |
|||
|
|||
--echo '#------------------FN_DYNVARS_053_07-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in SESSION Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
SELECT @@session.histogram_size = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_size'; |
|||
|
|||
|
|||
--echo '#------------------FN_DYNVARS_053_08-----------------------#' |
|||
#################################################################### |
|||
# Check if TRUE and FALSE values can be used on variable # |
|||
#################################################################### |
|||
|
|||
SET @@global.histogram_size = TRUE; |
|||
SET @@global.histogram_size = FALSE; |
|||
|
|||
--echo '#---------------------FN_DYNVARS_001_09----------------------#' |
|||
################################################################################# |
|||
# Check if accessing variable with and without GLOBAL point to same variable # |
|||
################################################################################# |
|||
|
|||
SET @@global.histogram_size = 10; |
|||
SELECT @@histogram_size = @@global.histogram_size; |
|||
|
|||
--echo '#---------------------FN_DYNVARS_001_10----------------------#' |
|||
######################################################################################################## |
|||
# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # |
|||
######################################################################################################## |
|||
|
|||
SET @@histogram_size = 100; |
|||
SELECT @@histogram_size = @@local.histogram_size; |
|||
SELECT @@local.histogram_size = @@session.histogram_size; |
|||
|
|||
#################################### |
|||
# Restore initial value # |
|||
#################################### |
|||
|
|||
SET @@global.histogram_size = @start_global_value; |
|||
SELECT @@global.histogram_size; |
|||
SET @@session.histogram_size = @start_session_value; |
|||
SELECT @@session.histogram_size; |
|||
|
|||
|
|||
################################################### |
|||
# END OF histogram_size TESTS # |
|||
################################################### |
|||
|
@ -0,0 +1,92 @@ |
|||
--source include/load_sysvars.inc |
|||
|
|||
############################################################# |
|||
# Save initial value # |
|||
############################################################# |
|||
|
|||
SET @start_global_value = @@global.histogram_type; |
|||
SELECT @start_global_value; |
|||
SET @start_session_value = @@session.histogram_type; |
|||
SELECT @start_session_value; |
|||
|
|||
############################################################## |
|||
# Display the DEFAULT value of histogram_type # |
|||
############################################################## |
|||
|
|||
SET @@global.histogram_type = 1; |
|||
SET @@global.histogram_type = DEFAULT; |
|||
SELECT @@global.histogram_type; |
|||
|
|||
################################################################################# |
|||
# Change the value of histogram_type to a valid value for GLOBAL Scope # |
|||
################################################################################# |
|||
|
|||
SET @@global.histogram_type = 0; |
|||
SELECT @@global.histogram_type; |
|||
SET @@global.histogram_type = 1; |
|||
SELECT @@global.histogram_type; |
|||
|
|||
SET @@global.histogram_type = SINGLE_PREC_HB; |
|||
SELECT @@global.histogram_type; |
|||
SET @@global.histogram_type = DOUBLE_PREC_HB; |
|||
SELECT @@global.histogram_type; |
|||
|
|||
################################################################################### |
|||
# Change the value of histogram_type to a valid value for SESSION Scope # |
|||
################################################################################### |
|||
|
|||
SET @@session.histogram_type = 0; |
|||
SELECT @@session.histogram_type; |
|||
SET @@session.histogram_type = 1; |
|||
SELECT @@session.histogram_type; |
|||
|
|||
SET @@session.histogram_type = SINGLE_PREC_HB; |
|||
SELECT @@session.histogram_type; |
|||
SET @@session.histogram_type = DOUBLE_PREC_HB; |
|||
SELECT @@session.histogram_type; |
|||
|
|||
#################################################################### |
|||
# Change the value of histogram_type to an invalid value # |
|||
#################################################################### |
|||
|
|||
set sql_mode=TRADITIONAL; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@global.histogram_type = 10; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@global.histogram_type = -1024; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.histogram_type = 2.4; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@global.histogram_type = OFF; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@session.histogram_type = 10; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@session.histogram_type = -2; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.histogram_type = 1.2; |
|||
--Error ER_WRONG_VALUE_FOR_VAR |
|||
SET @@session.histogram_type = ON; |
|||
|
|||
############################################################################### |
|||
# Check if the value in GLOBAL & SESSION Tables matches value in variable # |
|||
############################################################################### |
|||
|
|||
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_type'; |
|||
|
|||
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='histogram_type'; |
|||
|
|||
#################################### |
|||
# Restore initial value # |
|||
#################################### |
|||
|
|||
SET @@global.histogram_type = @start_global_value; |
|||
SELECT @@global.histogram_type; |
|||
SET @@session.histogram_type = @start_session_value; |
|||
SELECT @@session.histogram_type; |
|||
set sql_mode=''; |
|||
|
|||
##################################################### |
|||
# END OF histogram_type TESTS # |
|||
##################################################### |
@ -0,0 +1,142 @@ |
|||
|
|||
--source include/load_sysvars.inc |
|||
|
|||
################################################################# |
|||
# START OF optimizer_use_condition_selectivity TESTS # |
|||
################################################################# |
|||
|
|||
|
|||
############################################################# |
|||
# Save initial value # |
|||
############################################################# |
|||
|
|||
SET @start_global_value = @@global.optimizer_use_condition_selectivity; |
|||
SELECT @start_global_value; |
|||
SET @start_session_value = @@session.optimizer_use_condition_selectivity; |
|||
SELECT @start_session_value; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_01-------------------------#' |
|||
######################################################################### |
|||
# Display the DEFAULT value of optimizer_use_condition_selectivity # |
|||
######################################################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
|
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_02-------------------------#' |
|||
######################################################################### |
|||
# Check the DEFAULT value of optimizer_use_condition_selectivity # |
|||
######################################################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@global.optimizer_use_condition_selectivity = 1; |
|||
|
|||
SET @@session.optimizer_use_condition_selectivity = DEFAULT; |
|||
SELECT @@session.optimizer_use_condition_selectivity = 1; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_03-------------------------#' |
|||
############################################################################################# |
|||
# Change the value of optimizer_use_condition_selectivity to a valid value for GLOBAL Scope # |
|||
############################################################################################# |
|||
|
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@global.optimizer_use_condition_selectivity = 4; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#--------------------FN_DYNVARS_115_04-------------------------#' |
|||
############################################################################################# |
|||
# Change the value of optimizer_use_condition_selectivity to a valid value for SESSION Scope# |
|||
############################################################################################# |
|||
|
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 1; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 2; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = 4; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#------------------FN_DYNVARS_115_05-----------------------#' |
|||
############################################################################### |
|||
# Change the value of optimizer_use_condition_selectivity to an invalid value # |
|||
############################################################################## |
|||
|
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.optimizer_use_condition_selectivity = ON; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@global.optimizer_use_condition_selectivity = OFF; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.optimizer_use_condition_selectivity = 65530.34; |
|||
--Error ER_WRONG_TYPE_FOR_VAR |
|||
SET @@session.optimizer_use_condition_selectivity = test; |
|||
|
|||
--echo '#------------------FN_DYNVARS_115_06-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in GLOBAL Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
|
|||
SELECT @@global.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
|
|||
--echo '#------------------FN_DYNVARS_115_07-----------------------#' |
|||
#################################################################### |
|||
# Check if the value in SESSION Table matches value in variable # |
|||
#################################################################### |
|||
|
|||
SELECT @@session.optimizer_use_condition_selectivity = VARIABLE_VALUE |
|||
FROM INFORMATION_SCHEMA.SESSION_VARIABLES |
|||
WHERE VARIABLE_NAME='optimizer_use_condition_selectivity'; |
|||
|
|||
|
|||
--echo '#---------------------FN_DYNVARS_115_08----------------------#' |
|||
############################################################################### |
|||
# Check if global and session variable are independent of each other # |
|||
############################################################################### |
|||
|
|||
SET @@optimizer_use_condition_selectivity = 1; |
|||
SET @@global.optimizer_use_condition_selectivity = 3; |
|||
SELECT @@optimizer_use_condition_selectivity = @@global.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
--echo '#---------------------FN_DYNVARS_115_09----------------------#' |
|||
############################################################################### |
|||
# Check if accessing variable with SESSION,LOCAL and without SCOPE points # |
|||
# to same session variable # |
|||
############################################################################### |
|||
|
|||
SET @@optimizer_use_condition_selectivity = 2; |
|||
SELECT @@optimizer_use_condition_selectivity = @@local.optimizer_use_condition_selectivity; |
|||
SELECT @@local.optimizer_use_condition_selectivity = @@session.optimizer_use_condition_selectivity; |
|||
|
|||
|
|||
#################################### |
|||
# Restore initial value # |
|||
#################################### |
|||
|
|||
SET @@global.optimizer_use_condition_selectivity = @start_global_value; |
|||
SELECT @@global.optimizer_use_condition_selectivity; |
|||
SET @@session.optimizer_use_condition_selectivity = @start_session_value; |
|||
SELECT @@session.optimizer_use_condition_selectivity; |
|||
|
|||
######################################################################## |
|||
# END OF optimizer_use_condition_selectivity TESTS # |
|||
######################################################################## |
|||
|
@ -0,0 +1,623 @@ |
|||
--source include/have_stat_tables.inc |
|||
|
|||
select @@global.use_stat_tables; |
|||
select @@session.use_stat_tables; |
|||
|
|||
set @save_use_stat_tables=@@use_stat_tables; |
|||
|
|||
set use_stat_tables='preferably'; |
|||
|
|||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; |
|||
set @save_histogram_size=@@histogram_size; |
|||
set @save_histogram_type=@@histogram_type; |
|||
|
|||
# check that statistics on nulls is used |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
create table t1 (a int); |
|||
insert into t1 values |
|||
(9), (3), (2), (NULL), (NULL), (2), (NULL), (1), (5), (NULL); |
|||
|
|||
analyze table t1; |
|||
|
|||
select * from mysql.column_stats; |
|||
|
|||
flush table t1; |
|||
|
|||
explain extended |
|||
select * from t1 where a is null; |
|||
|
|||
explain extended |
|||
select * from t1 where a is not null; |
|||
|
|||
drop table t1; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
--disable_warnings |
|||
DROP DATABASE IF EXISTS dbt3_s001; |
|||
--enable_warnings |
|||
|
|||
CREATE DATABASE dbt3_s001; |
|||
|
|||
use dbt3_s001; |
|||
|
|||
--disable_query_log |
|||
--disable_result_log |
|||
--disable_warnings |
|||
--source include/dbt3_s001.inc |
|||
|
|||
ANALYZE TABLE |
|||
customer, lineitem, nation, orders, part, partsupp, region, supplier; |
|||
FLUSH TABLE |
|||
customer, lineitem, nation, orders, part, partsupp, region, supplier; |
|||
--enable_warnings |
|||
--enable_result_log |
|||
--enable_query_log |
|||
|
|||
|
|||
--echo === Q15 === |
|||
|
|||
create view revenue0 (supplier_no, total_revenue) as |
|||
select l_suppkey, sum(l_extendedprice * (1 - l_discount)) |
|||
from lineitem |
|||
where |
|||
l_shipdate >= '1995-08-01' |
|||
and l_shipdate < date_add('1995-08-01', interval 90 day) |
|||
group by l_suppkey; |
|||
|
|||
let $Q15= |
|||
select s_suppkey, s_name, s_address, s_phone, total_revenue |
|||
from supplier, revenue0 |
|||
where s_suppkey = supplier_no |
|||
and total_revenue = (select max(total_revenue) from revenue0) |
|||
order by s_suppkey; |
|||
|
|||
set @save_optimizer_switch=@@optimizer_switch; |
|||
set optimizer_switch='index_condition_pushdown=off'; |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
eval EXPLAIN EXTENDED $Q15; |
|||
eval $Q15; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
eval EXPLAIN EXTENDED $Q15; |
|||
eval $Q15; |
|||
|
|||
set optimizer_switch=@save_optimizer_switch; |
|||
|
|||
drop view revenue0; |
|||
|
|||
|
|||
--echo === Q16 === |
|||
|
|||
let $Q16= |
|||
select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt |
|||
from partsupp, part |
|||
where p_partkey = ps_partkey |
|||
and p_brand <> 'Brand#11' |
|||
and p_type not like 'SMALL POLISHED%' |
|||
and p_size in (49, 37, 27, 5, 40, 6, 22, 8) |
|||
and ps_suppkey not in (select s_suppkey from supplier |
|||
where s_comment like '%Customer%Complaints%') |
|||
group by p_brand, p_type, p_size |
|||
order by supplier_cnt desc, p_brand, p_type, p_size; |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
eval EXPLAIN EXTENDED $Q16; |
|||
eval $Q16; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
eval EXPLAIN EXTENDED $Q16; |
|||
eval $Q16; |
|||
|
|||
set optimizer_use_condition_selectivity=4; |
|||
eval EXPLAIN EXTENDED $Q16; |
|||
eval $Q16; |
|||
|
|||
|
|||
--echo === Q18 === |
|||
|
|||
let $Q18= |
|||
select |
|||
c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) |
|||
from customer, orders, lineitem |
|||
where |
|||
o_orderkey in (select l_orderkey from lineitem |
|||
group by l_orderkey having sum(l_quantity) > 250) |
|||
and c_custkey = o_custkey |
|||
and o_orderkey = l_orderkey |
|||
group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice |
|||
order by o_totalprice desc, o_orderdate; |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
eval EXPLAIN EXTENDED $Q18; |
|||
eval $Q18; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
eval EXPLAIN EXTENDED $Q18; |
|||
eval $Q18; |
|||
|
|||
|
|||
--echo === Q22 === |
|||
|
|||
let $Q22= |
|||
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal |
|||
from ( |
|||
select substr(c_phone, 1, 2) as cntrycode, c_acctbal |
|||
from customer |
|||
where |
|||
substr(c_phone, 1, 2) in ('10', '20', '14', '19', '11', '28', '25') |
|||
and c_acctbal > (select avg(c_acctbal) from customer |
|||
where c_acctbal > 0.00 |
|||
and substr(c_phone, 1, 2) in |
|||
('10', '20', '14', '19', '11', '28', '25')) |
|||
and not exists (select * from orders where o_custkey = c_custkey) |
|||
) as vip |
|||
group by cntrycode |
|||
order by cntrycode; |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
eval EXPLAIN EXTENDED $Q22; |
|||
eval $Q22; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
eval EXPLAIN EXTENDED $Q22; |
|||
eval $Q22; |
|||
|
|||
|
|||
--echo === Q20 === |
|||
|
|||
let $Q20= |
|||
select sql_calc_found_rows |
|||
s_name, s_address |
|||
from supplier, nation |
|||
where s_suppkey in (select ps_suppkey from partsupp |
|||
where ps_partkey in (select p_partkey from part |
|||
where p_name like 'g%') |
|||
and ps_availqty > |
|||
(select 0.5 * sum(l_quantity) |
|||
from lineitem |
|||
where l_partkey = ps_partkey |
|||
and l_suppkey = ps_suppkey |
|||
and l_shipdate >= date('1993-01-01') |
|||
and l_shipdate < date('1993-01-01') + |
|||
interval '1' year )) |
|||
and s_nationkey = n_nationkey |
|||
and n_name = 'UNITED STATES' |
|||
order by s_name |
|||
limit 10; |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
SELECT ((SELECT COUNT(*) FROM part WHERE p_name LIKE 'g%') / |
|||
(SELECT COUNT(*) FROM part)) AS sel; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
set histogram_size=127; |
|||
|
|||
ANALYZE TABLE part PERSISTENT FOR COLUMNS(p_name) INDEXES(); |
|||
|
|||
flush table part; |
|||
|
|||
set optimizer_use_condition_selectivity=4; |
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
set histogram_type='DOUBLE_PREC_HB'; |
|||
set histogram_size=126; |
|||
|
|||
ANALYZE TABLE part PERSISTENT FOR COLUMNS(p_name) INDEXES(); |
|||
|
|||
flush table part; |
|||
|
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
set histogram_type='SINGLE_PREC_HB'; |
|||
set histogram_size=24; |
|||
|
|||
ANALYZE TABLE nation PERSISTENT FOR COLUMNS(n_name) INDEXES(); |
|||
|
|||
flush table nation; |
|||
|
|||
eval EXPLAIN EXTENDED $Q20; |
|||
eval $Q20; |
|||
|
|||
|
|||
DROP DATABASE dbt3_s001; |
|||
|
|||
set histogram_type=@save_histogram_type; |
|||
set histogram_size=@save_histogram_size; |
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
use test; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4348: using view with use_condition_selectivity > 1 |
|||
--echo # |
|||
|
|||
set @tmp_use_stat_tables=@@use_stat_tables; |
|||
set use_stat_tables='never'; |
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
CREATE TABLE t1 (a int, b int); |
|||
INSERT t1 VALUES (7,1), (0,7); |
|||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; |
|||
|
|||
CREATE TABLE t2 (c int, d int, index idx(d)); |
|||
INSERT INTO t2 VALUES |
|||
(0,4), (8,6), (1,3), (8,5), (9,3), (2,2), (6,2), |
|||
(1,9), (6,3), (2,8), (4,1), (0,7), (4,8), (4,5); |
|||
|
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM v1 INNER JOIN t2 ON ( a = c AND b = d ); |
|||
|
|||
SELECT * FROM v1 INNER JOIN t2 ON ( a = c AND b = d ); |
|||
|
|||
DROP VIEW v1; |
|||
DROP TABLE t1,t2; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
set use_stat_tables=@tmp_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4349: impossible range for non-indexed column |
|||
--echo # |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
create table t1 (a int); |
|||
insert into t1 values |
|||
(3), (7), (2), (5), (7), (1), (2), (2); |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
explain extended |
|||
select * from t1 where a < 1 and a > 7; |
|||
select * from t1 where a < 1 and a > 7; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
explain extended |
|||
select * from t1 where a < 1 and a > 7; |
|||
select * from t1 where a < 1 and a > 7; |
|||
|
|||
drop table t1; |
|||
|
|||
create table t1 (a int); |
|||
insert into t1 values (1); |
|||
|
|||
create table t2 (b int); |
|||
insert into t2 values (2),(3); |
|||
|
|||
explain extended |
|||
select * from t1 where a in ( select b from t2 ) AND ( a > 3 ); |
|||
select * from t1 where a in ( select b from t2 ) AND ( a > 3 ); |
|||
|
|||
drop table t1,t2; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4350: erroneous negative selectivity |
|||
--echo # |
|||
|
|||
create table t1 (a int); |
|||
insert into t1 values (1), (1); |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 select * from t1; |
|||
insert into t1 values (0); |
|||
select count(*) from t1; |
|||
|
|||
set use_stat_tables='preferably'; |
|||
set histogram_size=127; |
|||
set histogram_type='SINGLE_PREC_HB'; |
|||
analyze table t1; |
|||
flush table t1; |
|||
|
|||
set optimizer_use_condition_selectivity=4; |
|||
explain extended select * from t1 where a=0; |
|||
|
|||
drop table t1; |
|||
|
|||
set histogram_size=@save_histogram_size; |
|||
set histogram_type=@save_histogram_type; |
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4367: 2-way join with an empty table |
|||
--echo # when optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
CREATE TABLE t1 (a varchar(1)) ENGINE=MyISAM; |
|||
INSERT INTO t1 VALUES ('j'),('k'); |
|||
|
|||
CREATE TABLE t2 (b varchar(1)) ENGINE=MyISAM; |
|||
INSERT INTO t2 VALUES ('x'),('y'); |
|||
|
|||
CREATE TABLE t3 (c varchar(1), KEY(c)) ENGINE=MyISAM; |
|||
|
|||
SELECT * FROM t1 STRAIGHT_JOIN (t2 JOIN t3 ON c = b AND b > 'z'); |
|||
|
|||
DROP TABLE t1,t2,t3; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4366: impossible condition on an indexed column discovered after |
|||
--echo # substitution of constant tables |
|||
--echo # with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
CREATE TABLE t1 (pk int PRIMARY KEY, a int); |
|||
INSERT INTO t1 VALUES |
|||
(1,4), (2,6), (3,3), (4,5); |
|||
|
|||
CREATE TABLE t2 (b int); |
|||
INSERT INTO t2 VALUES (1), (7); |
|||
|
|||
set optimizer_use_condition_selectivity=1; |
|||
EXPLAIN EXTENDED |
|||
SELECT 1 FROM t1, t2 WHERE pk = 6 AND a = 2 AND b = 10; |
|||
SELECT 1 FROM t1, t2 WHERE pk = 6 AND a = 2 AND b = 10; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
EXPLAIN EXTENDED |
|||
SELECT 1 FROM t1, t2 WHERE pk = 6 AND a = 2 AND b = 10; |
|||
SELECT 1 FROM t1, t2 WHERE pk = 6 AND a = 2 AND b = 10; |
|||
|
|||
DROP TABLE t1,t2; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4370: Histograms have bean created, but the query is run after |
|||
--echo # FLUSH TABLES with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
set histogram_size=10; |
|||
set histogram_type='SINGLE_PREC_HB'; |
|||
|
|||
CREATE TABLE t1 (a int); |
|||
INSERT INTO t1 VALUES (9), (1); |
|||
ANALYZE TABLE t1; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1 WHERE a > 3; |
|||
SELECT * FROM t1 WHERE a > 3; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1; |
|||
|
|||
set histogram_size=@save_histogram_size; |
|||
set histogram_type=@save_histogram_type; |
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4371: Join with condition supported by index on an empty table |
|||
--echo # with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
|
|||
CREATE TABLE t1 (a int, b int, INDEX(a)); |
|||
|
|||
CREATE TABLE t2 (c int); |
|||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6),(7),(8); |
|||
|
|||
ANALYZE TABLE t1, t2; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
set @save_optimizer_switch=@@optimizer_switch; |
|||
set optimizer_switch='index_condition_pushdown=off'; |
|||
|
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1, t2 WHERE a > 9; |
|||
SELECT * FROM t1, t2 WHERE a > 9; |
|||
|
|||
set optimizer_switch=@save_optimizer_switch; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1,t2; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4373: condition on a short varchar column |
|||
--echo # with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
|
|||
CREATE TABLE t1 (a varchar(1)); |
|||
INSERT INTO t1 VALUES ('x'), ('y'); |
|||
|
|||
ANALYZE TABLE t1; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
SELECT * FROM t1 WHERE a <= 'w'; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4372: exists subquery in WHERE |
|||
--echo # with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables = PREFERABLY; |
|||
|
|||
CREATE TABLE t1 (a int); |
|||
INSERT INTO t1 VALUES |
|||
(1),(7),(4),(7),(0),(2),(9),(4),(0),(9),(1),(3),(8),(8); |
|||
CREATE TABLE t2 (b int); |
|||
INSERT INTO t2 VALUES (4),(5),(2),(5),(1),(1),(2); |
|||
|
|||
ANALYZE TABLE t1, t2; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1, t2 WHERE EXISTS ( SELECT 1 FROM t1, t2 ) AND a != b OR a <= 4; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1,t2; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4363: selectivity of the condition a IS NULL OR IS NOT NULL |
|||
--echo # with optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables = PREFERABLY; |
|||
|
|||
CREATE TABLE t1 (a int); |
|||
INSERT INTO t1 VALUES |
|||
(1),(7),(4),(7),(NULL),(2),(NULL),(4),(NULL),(NULL),(1),(3),(8),(8); |
|||
|
|||
ANALYZE TABLE t1; |
|||
FLUSH TABLE t1; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1 WHERE a IS NULL; |
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1 WHERE a IS NOT NULL; |
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1 WHERE a IS NULL OR a IS NOT NULL; |
|||
EXPLAIN EXTENDED |
|||
SELECT * FROM t1 WHERE a IS NULL OR a < 5; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4378: 2-way join with a materialized IN subquery in WHERE |
|||
--echo # when optimizer_use_condition_selectivity=4 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
set histogram_size=50; |
|||
set histogram_type=SINGLE_PREC_HB; |
|||
|
|||
CREATE TABLE t1 (a INT) ENGINE=MyISAM; |
|||
INSERT INTO t1 VALUES (8),(9),(6); |
|||
|
|||
CREATE TABLE t2 (b INT) ENGINE=MyISAM; |
|||
INSERT INTO t2 VALUES (8),(1),(8),(9),(24),(6),(1),(6),(2),(4); |
|||
|
|||
CREATE TABLE t3 (ln VARCHAR(16)) ENGINE=MyISAM; |
|||
INSERT INTO t3 VALUES |
|||
('smith'),('black'),('white'),('jones'), |
|||
('brown'),('taylor'),('anderson'),('taylor'); |
|||
|
|||
ANALYZE TABLE t1, t2, t3; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=4; |
|||
|
|||
SELECT * FROM t1, t2 WHERE 'garcia' IN ( SELECT MIN( ln ) FROM t3 WHERE ln = 'sun' ); |
|||
|
|||
set histogram_size=@save_histogram_size; |
|||
set histogram_type=@save_histogram_type; |
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1,t2,t3; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4380: 2-way join with a materialized IN subquery in WHERE |
|||
--echo # when optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
CREATE TABLE t1 (a INT); |
|||
INSERT INTO t1 VALUES (5),(9); |
|||
|
|||
CREATE TABLE t2 (b VARCHAR(8)); |
|||
INSERT INTO t2 VALUES ('red'),('blue'); |
|||
|
|||
CREATE TABLE t3 (c VARCHAR(8), d VARCHAR(8)); |
|||
INSERT INTO t3 VALUES ('white','black'),('cyan','yellow'); |
|||
|
|||
ANALYZE TABLE t1, t2, t3; |
|||
FLUSH TABLES; |
|||
|
|||
set optimizer_use_condition_selectivity=3; |
|||
|
|||
SELECT * FROM t1, t2 WHERE ( 'orange', 'green' ) IN ( |
|||
SELECT MAX(c), MAX(d) FROM t3, t2 WHERE c >= d AND b = c |
|||
); |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1,t2,t3; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
--echo # |
|||
--echo # Bug mdev-4389: join with degenerated range condition in WHERE |
|||
--echo # when optimizer_use_condition_selectivity=3 |
|||
--echo # |
|||
|
|||
set use_stat_tables=PREFERABLY; |
|||
|
|||
CREATE TABLE t1 (f1 VARCHAR(1)); |
|||
INSERT t1 VALUES ('p'),('q'); |
|||
|
|||
CREATE TABLE t2 (f2 VARCHAR(1)); |
|||
INSERT INTO t2 VALUES |
|||
('o'),('v'),('f'),('f'),('e'),('l'),('j'),('p'),('r'),('j'), |
|||
('j'),('u'),('i'),('r'),('x'),('a'),('x'),('s'); |
|||
|
|||
ANALYZE TABLE t1, t2; |
|||
FLUSH TABLES; |
|||
|
|||
SET optimizer_use_condition_selectivity=3; |
|||
|
|||
SELECT * FROM t1, t2 AS t2a, t2 AS t2b WHERE f1 <= 'a' AND t2a.f2 = f1; |
|||
|
|||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; |
|||
|
|||
DROP TABLE t1,t2; |
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
|||
|
|||
|
|||
set use_stat_tables=@save_use_stat_tables; |
@ -0,0 +1,12 @@ |
|||
--source include/have_innodb.inc |
|||
|
|||
SET SESSION STORAGE_ENGINE='InnoDB'; |
|||
|
|||
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; |
|||
set optimizer_switch='extended_keys=on'; |
|||
|
|||
--source selectivity.test |
|||
|
|||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test; |
|||
|
|||
SET SESSION STORAGE_ENGINE=DEFAULT; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue