Commit a1cd28e2 authored by Igor Babaev's avatar Igor Babaev

Merge 10.0-base -> 10.0

parents 0e7410a1 43fe53ac
......@@ -21,8 +21,8 @@ source ./VERSION
UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}"
RELEASE_EXTRA=""
RELEASE_NAME=mariadb
PATCHLEVEL=""
RELEASE_NAME=""
PATCHLEVEL="+maria"
LOGSTRING="MariaDB build"
# Look up distro-version specific stuff.
......
......@@ -21,7 +21,7 @@ invoke() {
fi
}
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --default-storage-engine=myisam"
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --default-storage-engine=myisam"
test_mysql_access() {
mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
......
......@@ -21,7 +21,7 @@ invoke() {
fi
}
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --default-storage-engine=myisam"
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --default-storage-engine=myisam"
test_mysql_access() {
mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
......
......@@ -604,7 +604,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
// FIXME initialize binlog_filter and rpl_filter if not already done
// corresponding delete is in clean_up()
if(!binlog_filter) binlog_filter = new Rpl_filter;
if(!rpl_filter) rpl_filter = new Rpl_filter;
if(!global_rpl_filter) global_rpl_filter = new Rpl_filter;
if (opt_init_file)
{
......
......@@ -4786,6 +4786,9 @@ sub extract_warning_lines ($$) {
qr|Warning: io_setup\(\) failed|,
qr|Warning: io_setup\(\) attempt|,
qr|setrlimit could not change the size of core files to 'infinity';|,
qr|feedback plugin: failed to retrieve the MAC address|,
qr|Plugin 'FEEDBACK' init function returned error|,
qr|Plugin 'FEEDBACK' registration as a INFORMATION SCHEMA failed|,
);
my $matched_lines= [];
......
......@@ -5,7 +5,10 @@ a VARCHAR(100),
INDEX(a)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
SET debug_sync= 'myisam_after_repair_by_sort SIGNAL waiting WAIT_FOR go';
ALTER TABLE t1 ENABLE KEYS;
SET debug_sync= 'now WAIT_FOR waiting';
SET debug_sync= 'now SIGNAL go';
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Dynamic 100000 27 # # # 0 NULL # # # latin1_swedish_ci NULL
......
......@@ -208,6 +208,13 @@ The following options may be given as the first argument:
use a distinct domain_id. For simple tree-shaped
replication topologies, it can be left at its default, 0.
-?, --help Display this help and exit.
--histogram-size=# Number of bytes used for a histogram. If set to 0, no
histograms are created by ANALYZE.
--histogram-type=name
Specifies type of the histograms created by ANALYZE.
Possible values are: SINGLE_PREC_HB - single precision
height-balanced, DOUBLE_PREC_HB - double precision
height-balanced.
--ignore-builtin-innodb
Disable initialization of builtin InnoDB plugin
--ignore-db-dirs=name
......@@ -504,6 +511,21 @@ The following options may be given as the first argument:
partial_match_table_scan, semijoin, semijoin_with_cache,
subquery_cache, table_elimination, extended_keys,
exists_to_in } and val is one of {on, off, default}
--optimizer-use-condition-selectivity=#
Controls selectivity of which conditions the optimizer
takes into account to calculate cardinality of a partial
join when it searches for the best execution plan
Meaning: 1 - use selectivity of index backed range
conditions to calculate the cardinality of a partial join
if the last joined table is accessed by full table scan
or an index scan, 2 - use selectivity of index backed
range conditions to calculate the cardinality of a
partial join in any case, 3 - additionally always use
selectivity of range conditions that are not backed by
any index to calculate the cardinality of a partial join,
4 - use histograms to calculate selectivity of range
conditions that are not backed by any index to calculate
the cardinality of a partial join.
--performance-schema
Enable the performance schema.
--performance-schema-accounts-size=#
......@@ -1016,6 +1038,8 @@ general-log FALSE
group-concat-max-len 1024
gtid-domain-id 0
help TRUE
histogram-size 0
histogram-type SINGLE_PREC_HB
ignore-builtin-innodb FALSE
ignore-db-dirs
init-connect
......@@ -1106,6 +1130,7 @@ old-style-user-limits FALSE
optimizer-prune-level 1
optimizer-search-depth 62
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on
optimizer-use-condition-selectivity 1
performance-schema FALSE
performance-schema-accounts-size 100
performance-schema-consumer-events-stages-current FALSE
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -94,7 +94,7 @@ a1 a2
explain extended
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 50.00 Using where; Using index; LooseScan
1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 40.00 Using where; Using index; LooseScan
1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
Warnings:
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where ((`test`.`t1i`.`a1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0'))
......@@ -117,7 +117,7 @@ a1 a2
explain extended
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 50.00 Using where; Using index; LooseScan
1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 40.00 Using where; Using index; LooseScan
1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
Warnings:
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where ((`test`.`t1i`.`a1` = `test`.`t2i`.`b1`) and (`test`.`t1i`.`a2` = `test`.`t2i`.`b2`) and (`test`.`t2i`.`b1` > '0'))
......@@ -319,7 +319,7 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2i index it2i1,it2i2,it2i3 # # # 5 50.00 #
1 PRIMARY t2i index it2i1,it2i2,it2i3 # # # 5 40.00 #
1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 #
1 PRIMARY t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 #
1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 2 100.00 #
......@@ -407,7 +407,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED t2 ALL NULL # # # 5 100.00 #
4 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
3 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 50.00 #
7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 40.00 #
7 UNION t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 #
7 UNION t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 #
7 UNION t2i ref it2i1,it2i2,it2i3 # # # 2 100.00 #
......
......@@ -292,6 +292,9 @@ column_stats CREATE TABLE `column_stats` (
`nulls_ratio` decimal(12,4) DEFAULT NULL,
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
......
......@@ -13,6 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references
def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8 utf8_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') select,insert,update,references
def mysql column_stats max_value 5 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats min_value 4 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
......@@ -304,6 +307,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 blob NULL NULL
1.0000 longblob NULL NULL
1.0000 varbinary NULL NULL
1.0000 char latin1 latin1_bin
1.0000 char latin1 latin1_swedish_ci
1.0000 varchar latin1 latin1_swedish_ci
......@@ -377,6 +381,9 @@ NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp
NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned
3.0000 mysql column_stats hist_type enum 14 42 utf8 utf8_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')
1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255)
3.0000 mysql db Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql db Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16)
......
......@@ -13,6 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255)
def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned
def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8 utf8_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')
def mysql column_stats max_value 5 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255)
def mysql column_stats min_value 4 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255)
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
......@@ -304,6 +307,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 blob NULL NULL
1.0000 longblob NULL NULL
1.0000 varbinary NULL NULL
1.0000 char latin1 latin1_bin
1.0000 char latin1 latin1_swedish_ci
1.0000 varchar latin1 latin1_swedish_ci
......@@ -377,6 +381,9 @@ NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp
NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned
3.0000 mysql column_stats hist_type enum 14 42 utf8 utf8_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')
1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255)
3.0000 mysql db Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql db Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16)
......
......@@ -36,7 +36,7 @@ let $wait_condition =
# depending on platform.
#
connection con1;
-- error 1317, 2006, 2013
-- error 1317, 2006, 2013, ER_CONNECTION_KILLED
reap;
connection default;
DROP TABLE bug51920;
......
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
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='';
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
--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 #
###################################################
--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 #
#####################################################
\ No newline at end of file
--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 #
########################################################################
......@@ -3,6 +3,7 @@
#
--source include/big_test.inc
--source include/have_debug_sync.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
......@@ -29,15 +30,18 @@ while ($1)
--enable_query_log
--connect(con1,localhost,root,,)
--send
SET debug_sync= 'myisam_after_repair_by_sort SIGNAL waiting WAIT_FOR go';
send
ALTER TABLE t1 ENABLE KEYS;
--connection default
--let $wait_timeout=10
--let $wait_timeout=60
--let $show_statement= SHOW PROCESSLIST
--let $field= State
--let $condition= = 'Repair by sorting'
--source include/wait_show_condition.inc
SET debug_sync= 'now WAIT_FOR waiting';
SET debug_sync= 'now SIGNAL go';
--replace_column 7 # 8 # 9 # 12 # 13 # 14 #
SHOW TABLE STATUS LIKE 't1';
......
This diff is collapsed.
--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;
......@@ -165,6 +165,37 @@ SELECT
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 3';
DELETE FROM mysql.column_stats;
set histogram_size=4;
ANALYZE TABLE t1;
SELECT db_name, table_name, column_name,
min_value, max_value,
nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
DELETE FROM mysql.column_stats;
set histogram_size=8;
set histogram_type='DOUBLE_PREC_HB';
ANALYZE TABLE t1;
SELECT db_name, table_name, column_name,
min_value, max_value,
nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=default;
ANALYZE TABLE t1;
CREATE TABLE t3 (
a int NOT NULL PRIMARY KEY,
b varchar(32),
......@@ -559,6 +590,96 @@ DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
--echo #
--echo # Bug mdev-4357: empty string as a value of the HIST_SIZE column
--echo # from mysql.column_stats
--echo #
create table t1 (a int);
insert into t1 values (1),(2),(3);
set histogram_size=10;
analyze table t1 persistent for all;
select db_name, table_name, column_name,
min_value, max_value,
nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
set histogram_size=default;
drop table t1;
--echo #
--echo # Bug mdev-4359: wrong setting of the HIST_SIZE column
--echo # (see also mdev-4357) from mysql.column_stats
--echo #
create table t1 ( a int);
insert into t1 values (1),(2),(3),(4),(5);
set histogram_size=10;
set histogram_type='double_prec_hb';
show variables like 'histogram%';
analyze table t1 persistent for all;
select db_name, table_name, column_name,
min_value, max_value,
nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
set histogram_size=default;
set histogram_type=default;
drop table t1;
--echo #
--echo # Bug mdev-4369: histogram for a column with many distinct values
--echo #
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int);
INSERT INTO t1 (id) VALUES (1), (1), (1),(1);
INSERT INTO t1 (id) SELECT id FROM t1;
INSERT INTO t1 SELECT id+1 FROM t1;
INSERT INTO t1 SELECT id+2 FROM t1;
INSERT INTO t1 SELECT id+4 FROM t1;
INSERT INTO t1 SELECT id+8 FROM t1;
INSERT INTO t1 SELECT id+16 FROM t1;
INSERT INTO t1 SELECT id+32 FROM t1;
INSERT INTO t1 SELECT id+64 FROM t1;
INSERT INTO t1 SELECT id+128 FROM t1;
INSERT INTO t1 SELECT id+256 FROM t1;
INSERT INTO t1 SELECT id+512 FROM t1;
INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand();
SELECT COUNT(*) FROM t2;
SELECT COUNT(DISTINCT id) FROM t2;
set @@tmp_table_size=1024*16;
set @@max_heap_table_size=1024*16;
set histogram_size=63;
analyze table t2 persistent for all;
select db_name, table_name, column_name,
min_value, max_value,
nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
set histogram_size=default;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
\ No newline at end of file
......@@ -153,6 +153,6 @@ set @had_proxies_priv_table= @@warning_count != 0;
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varchar(255) DEFAULT NULL, max_value varchar(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,column_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varchar(255) DEFAULT NULL, max_value varchar(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB'), histogram varbinary(255), PRIMARY KEY (db_name,table_name,column_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
......@@ -1273,6 +1273,37 @@ out_of_range:
return 1;
}
/**
@brief
Determine the relative position of the field value in a numeric interval
@details
The function returns a double number between 0.0 and 1.0 as the relative
position of the value of the this field in the numeric interval of [min,max].
If the value is not in the interval the the function returns 0.0 when
the value is less than min, and, 1.0 when the value is greater than max.
@param min value of the left end of the interval
@param max value of the right end of the interval
@return
relative position of the field value in the numeric interval [min,max]
*/
double Field_num::pos_in_interval(Field *min, Field *max)
{
double n, d;
n= val_real() - min->val_real();
if (n < 0)
return 0.0;
d= max->val_real() - min->val_real();
if (d <= 0)
return 1.0;
return min(n/d, 1.0);
}
/**
Process decimal library return codes and issue warnings for overflow and
truncation.
......@@ -1344,6 +1375,8 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
comment.length=0;
field_index= 0;
is_stat_field= FALSE;
cond_selectivity= 1.0;
next_equal_field= NULL;
}
......@@ -6165,6 +6198,79 @@ int Field_str::store(double nr)
return store(buff, length, &my_charset_numeric);
}
static
inline ulonglong char_prefix_to_ulonglong(uchar *src)
{
uint sz= sizeof(ulonglong);
for (uint i= 0; i < sz/2; i++)
{
uchar tmp= src[i];
src[i]= src[sz-1-i];
src[sz-1-i]= tmp;
}
return uint8korr(src);
}
/**
@brief
Determine the relative position of the field value in a string interval
@details
The function returns a double number between 0.0 and 1.0 as the relative
position of the value of the this field in the string interval of [min,max].
If the value is not in the interval the the function returns 0.0 when
the value is less than min, and, 1.0 when the value is greater than max.
@note
To calculate the relative position of the string value v in the interval
[min, max] the function first converts the beginning of these three
strings v, min, max into the strings that are used for byte comparison.
For each string not more sizeof(ulonglong) first bytes are taken
from the result of conversion. Then these bytes are interpreted as the
big-endian representation of an ulonglong integer. The values of these
integer numbers obtained for the strings v, min, max are used to calculate
the position of v in [min,max] in the same way is it's done for numeric
fields (see Field_num::pos_in_interval).
@todo
Improve the procedure for the case when min and max have the same
beginning
@param min value of the left end of the interval
@param max value of the right end of the interval
@return
relative position of the field value in the string interval [min,max]
*/
double Field_str::pos_in_interval(Field *min, Field *max)
{
uchar mp_prefix[sizeof(ulonglong)];
uchar minp_prefix[sizeof(ulonglong)];
uchar maxp_prefix[sizeof(ulonglong)];
ulonglong mp, minp, maxp;
my_strnxfrm(charset(), mp_prefix, sizeof(mp),
ptr + length_size(),
data_length());
my_strnxfrm(charset(), minp_prefix, sizeof(minp),
min->ptr + length_size(),
min->data_length());
my_strnxfrm(charset(), maxp_prefix, sizeof(maxp),
max->ptr + length_size(),
max->data_length());
mp= char_prefix_to_ulonglong(mp_prefix);
minp= char_prefix_to_ulonglong(minp_prefix);
maxp= char_prefix_to_ulonglong(maxp_prefix);
double n, d;
n= mp - minp;
if (n < 0)
return 0.0;
d= maxp - minp;
if (d <= 0)
return 1.0;
return min(n/d, 1.0);
}
uint Field::is_equal(Create_field *new_field)
{
......@@ -8376,6 +8482,36 @@ my_decimal *Field_bit::val_decimal(my_decimal *deciaml_value)
}
/**
@brief
Determine the relative position of the field value in a bit interval
@details
The function returns a double number between 0.0 and 1.0 as the relative
position of the value of the this field in the bit interval of [min,max].
If the value is not in the interval the the function returns 0.0 when
the value is less than min, and, 1.0 when the value is greater than max.
@param min value of the left end of the interval
@param max value of the right end of the interval
@return
relative position of the field value in the bit interval [min,max]
*/
double Field_bit::pos_in_interval(Field *min, Field *max)
{
double n, d;
n= val_real() - min->val_real();
if (n < 0)
return 0.0;
d= max->val_real() - min->val_real();
if (d <= 0)
return 1.0;
return min(n/d, 1.0);
}
/*
Compare two bit fields using pointers within the record.
SYNOPSIS
......
......@@ -220,7 +220,23 @@ public:
*/
bool is_created_from_null_item;
bool is_stat_field; /* TRUE in Field objects created for column min/max values */
/* TRUE in Field objects created for column min/max values */
bool is_stat_field;
/*
Selectivity of the range condition over this field.
When calculating this selectivity a range predicate
is taken into account only if:
- it is extracted from the WHERE clause
- it depends only on the table the field belongs to
*/
double cond_selectivity;
/*
The next field in the class of equal fields at the top AND level
of the WHERE clause
*/
Field *next_equal_field;
/*
This structure is used for statistical data on the column
......@@ -456,6 +472,10 @@ public:
}
return update_fl;
}
virtual void store_field_value(uchar *val, uint len)
{
memcpy(ptr, val, len);
}
virtual uint decimals() const { return 0; }
/*
Caller beware: sql_type can change str.Ptr, so check
......@@ -703,6 +723,12 @@ public:
virtual bool hash_join_is_possible() { return TRUE; }
virtual bool eq_cmp_as_binary() { return TRUE; }
/* Position of the field value within the interval of [min, max] */
virtual double pos_in_interval(Field *min, Field *max)
{
return (double) 0.5;
}
friend int cre_myisam(char * name, register TABLE *form, uint options,
ulonglong auto_increment_value);
friend class Copy_field;
......@@ -821,6 +847,7 @@ public:
bool get_int(CHARSET_INFO *cs, const char *from, uint len,
longlong *rnd, ulonglong unsigned_max,
longlong signed_min, longlong signed_max);
double pos_in_interval(Field *min, Field *max);
};
......@@ -866,6 +893,8 @@ public:
virtual bool str_needs_quotes() { return TRUE; }
uint is_equal(Create_field *new_field);
bool eq_cmp_as_binary() { return test(flags & BINARY_FLAG); }
virtual uint length_size() { return 0; }
double pos_in_interval(Field *min, Field *max);
};
/* base class for Field_string, Field_varstring and Field_blob */
......@@ -1894,6 +1923,7 @@ public:
uint new_null_bit);
uint is_equal(Create_field *new_field);
void hash(ulong *nr, ulong *nr2);
uint length_size() { return length_bytes; }
private:
int do_save_field_metadata(uchar *first_byte);
};
......@@ -2275,6 +2305,11 @@ public:
}
return update_fl;
}
void store_field_value(uchar *val, uint len)
{
store(*((longlong *)val), TRUE);
}
double pos_in_interval(Field *min, Field *max);
void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
{ get_key_image(buff, length, itRAW); }
void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
......
......@@ -5568,7 +5568,8 @@ Item *Item_bool_rowready_func2::negated_item()
*/
Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
: Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL)
: Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL),
link_equal_fields(FALSE)
{
const_item_cache= 0;
with_const= with_const_item;
......@@ -5592,7 +5593,8 @@ Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
*/
Item_equal::Item_equal(Item_equal *item_equal)
: Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL)
: Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL),
link_equal_fields(FALSE)
{
const_item_cache= 0;
List_iterator_fast<Item> li(item_equal->equal_items);
......@@ -5918,6 +5920,9 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
DBUG_ASSERT(fixed == 0);
Item_equal_fields_iterator it(*this);
Item *item;
Field *first_equal_field;
Field *last_equal_field;
Field *prev_equal_field= NULL;
not_null_tables_cache= used_tables_cache= 0;
const_item_cache= 0;
while ((item= it++))
......@@ -5931,7 +5936,18 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
maybe_null= 1;
if (!item->get_item_equal())
item->set_item_equal(this);
if (link_equal_fields && item->real_item()->type() == FIELD_ITEM)
{
last_equal_field= ((Item_field *) (item->real_item()))->field;
if (!prev_equal_field)
first_equal_field= last_equal_field;
else
prev_equal_field->next_equal_field= last_equal_field;
prev_equal_field= last_equal_field;
}
}
if (prev_equal_field && last_equal_field != first_equal_field)
last_equal_field->next_equal_field= first_equal_field;
fix_length_and_dec();
fixed= 1;
return FALSE;
......
......@@ -1737,6 +1737,8 @@ class Item_equal: public Item_bool_func
*/
Item_field *context_field;
bool link_equal_fields;
public:
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
......@@ -1774,6 +1776,8 @@ public:
CHARSET_INFO *compare_collation();
void set_context_field(Item_field *ctx_field) { context_field= ctx_field; }
void set_link_equal_fields(bool flag) { link_equal_fields= flag; }
friend class Item_equal_fields_iterator;
friend class Item_equal_iterator<List_iterator_fast,Item>;
friend class Item_equal_iterator<List_iterator,Item>;
friend Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
......
......@@ -20,6 +20,7 @@
****************************************************************************/
NAMED_ILIST key_caches;
NAMED_ILIST rpl_filters;
/**
ilink (intrusive list element) with a name
......@@ -66,6 +67,23 @@ uchar* find_named(I_List<NAMED_ILINK> *list, const char *name, uint length,
}
bool NAMED_ILIST::delete_element(const char *name, uint length, void (*free_element)(const char *name, uchar*))
{
I_List_iterator<NAMED_ILINK> it(*this);
NAMED_ILINK *element;
DBUG_ENTER("NAMED_ILIST::delete_element");
while ((element= it++))
{
if (element->cmp(name, length))
{
(*free_element)(element->name, element->data);
delete element;
DBUG_RETURN(0);
}
}
DBUG_RETURN(1);
}
void NAMED_ILIST::delete_elements(void (*free_element)(const char *name, uchar*))
{
NAMED_ILINK *element;
......@@ -159,3 +177,51 @@ bool process_key_caches(process_key_cache_t func, void *param)
return res != 0;
}
/* Rpl_filter functions */
LEX_STRING default_rpl_filter_base= {C_STRING_WITH_LEN("")};
Rpl_filter *get_rpl_filter(LEX_STRING *filter_name)
{
if (!filter_name->length)
filter_name= &default_rpl_filter_base;
return ((Rpl_filter*) find_named(&rpl_filters,
filter_name->str, filter_name->length, 0));
}
Rpl_filter *create_rpl_filter(const char *name, uint length)
{
Rpl_filter *filter;
DBUG_ENTER("create_rpl_filter");
DBUG_PRINT("enter",("name: %.*s", length, name));
filter= new Rpl_filter;
if (filter)
{
if (!new NAMED_ILINK(&rpl_filters, name, length, (uchar*) filter))
{
delete filter;
filter= 0;
}
}
DBUG_RETURN(filter);
}
Rpl_filter *get_or_create_rpl_filter(const char *name, uint length)
{
LEX_STRING rpl_filter_name;
Rpl_filter *filter;
rpl_filter_name.str= (char *) name;
rpl_filter_name.length= length;
if (!(filter= get_rpl_filter(&rpl_filter_name)))
filter= create_rpl_filter(name, length);
return filter;
}
void free_rpl_filter(const char *name, Rpl_filter *filter)
{
delete filter;
}
......@@ -18,6 +18,7 @@
#include "sql_list.h"
#include <keycache.h>
#include <rpl_filter.h>
extern "C"
{
......@@ -30,8 +31,10 @@ class NAMED_ILIST: public I_List<NAMED_ILINK>
{
public:
void delete_elements(void (*free_element)(const char*, uchar*));
bool delete_element(const char *name, uint length, void (*free_element)(const char*, uchar*));
};
/* For key cache */
extern LEX_STRING default_key_cache_base;
extern KEY_CACHE zero_key_cache;
extern NAMED_ILIST key_caches;
......@@ -42,4 +45,13 @@ KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE *key_cache);
bool process_key_caches(process_key_cache_t func, void *param);
/* For Rpl_filter */
extern LEX_STRING default_rpl_filter_base;
extern NAMED_ILIST rpl_filters;
Rpl_filter *create_rpl_filter(const char *name, uint length);
Rpl_filter *get_rpl_filter(LEX_STRING *filter_name);
Rpl_filter *get_or_create_rpl_filter(const char *name, uint length);
void free_rpl_filter(const char *name, Rpl_filter *filter);
#endif /* KEYCACHES_INCLUDED */
......@@ -3756,6 +3756,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
HA_CREATE_INFO db_options;
uint64 sub_id= 0;
rpl_gtid gtid;
Rpl_filter *rpl_filter= rli->mi->rpl_filter;
DBUG_ENTER("Query_log_event::do_apply_event");
/*
......@@ -5439,6 +5440,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
bool use_rli_only_for_errors)
{
LEX_STRING new_db;
Rpl_filter *rpl_filter= rli->mi->rpl_filter;
DBUG_ENTER("Load_log_event::do_apply_event");
new_db.length= db_len;
......@@ -10040,8 +10042,8 @@ check_table_map(Relay_log_info const *rli, RPL_TABLE_LIST *table_list)
enum_tbl_map_status res= OK_TO_PROCESS;
if (rli->sql_thd->slave_thread /* filtering is for slave only */ &&
(!rpl_filter->db_ok(table_list->db) ||
(rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list))))
(!rli->mi->rpl_filter->db_ok(table_list->db) ||
(rli->mi->rpl_filter->is_on() && !rli->mi->rpl_filter->tables_ok("", table_list))))
res= FILTERED_OUT;
else
{
......@@ -10075,6 +10077,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
char *db_mem, *tname_mem;
size_t dummy_len;
void *memory;
Rpl_filter *filter;
DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)");
DBUG_ASSERT(rli->sql_thd == thd);
......@@ -10088,7 +10091,9 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
strmov(db_mem, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len));
/* call from mysql_client_binlog_statement() will not set rli->mi */
filter= rli->sql_thd->slave_thread ? rli->mi->rpl_filter : global_rpl_filter;
strmov(db_mem, filter->get_rewrite_db(m_dbnam, &dummy_len));
strmov(tname_mem, m_tblnam);
table_list->init_one_table(db_mem, strlen(db_mem),
......
This diff is collapsed.
This diff is collapsed.
......@@ -1042,6 +1042,8 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
table_map read_tables, COND *conds,
bool allow_null_cond, int *error);
bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item *cond);
#ifdef WITH_PARTITION_STORAGE_ENGINE
bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
void store_key_image_to_rec(Field *field, uchar *ptr, uint len);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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