Commit b2d0a33e authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-4373:

Valgrind complained on usage of uninitialized memory.
parent 1ae352af
...@@ -850,4 +850,21 @@ set optimizer_switch=@save_optimizer_switch; ...@@ -850,4 +850,21 @@ set optimizer_switch=@save_optimizer_switch;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2; DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4373: condition on a short varchar column
# with optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a varchar(1));
INSERT INTO t1 VALUES ('x'), ('y');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
SELECT * FROM t1 WHERE a <= 'w';
a
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
...@@ -858,6 +858,23 @@ set optimizer_switch=@save_optimizer_switch; ...@@ -858,6 +858,23 @@ set optimizer_switch=@save_optimizer_switch;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2; DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4373: condition on a short varchar column
# with optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a varchar(1));
INSERT INTO t1 VALUES ('x'), ('y');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
SELECT * FROM t1 WHERE a <= 'w';
a
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test; set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT; SET SESSION STORAGE_ENGINE=DEFAULT;
...@@ -444,5 +444,28 @@ DROP TABLE t1,t2; ...@@ -444,5 +444,28 @@ DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables; 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;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
...@@ -6202,14 +6202,16 @@ double Field_str::middle_point_pos(Field *min, Field *max) ...@@ -6202,14 +6202,16 @@ double Field_str::middle_point_pos(Field *min, Field *max)
uchar minp_prefix[sizeof(ulonglong)]; uchar minp_prefix[sizeof(ulonglong)];
uchar maxp_prefix[sizeof(ulonglong)]; uchar maxp_prefix[sizeof(ulonglong)];
ulonglong mp, minp, maxp; ulonglong mp, minp, maxp;
uint dsz= min(field_length, sizeof(ulonglong) * charset()->mbmaxlen);
memset(mp_prefix, 0, sizeof(ulonglong));
memset(minp_prefix, 0, sizeof(ulonglong));
memset(maxp_prefix, 0, sizeof(ulonglong));
my_strnxfrm(charset(), mp_prefix, sizeof(mp), my_strnxfrm(charset(), mp_prefix, sizeof(mp),
ptr + length_size(), sizeof(mp) * charset()->mbmaxlen); ptr + length_size(), dsz);
my_strnxfrm(charset(), minp_prefix, sizeof(minp), my_strnxfrm(charset(), minp_prefix, sizeof(minp),
min->ptr + length_size(), min->ptr + length_size(), dsz);
sizeof(minp) * charset()->mbmaxlen);
my_strnxfrm(charset(), maxp_prefix, sizeof(maxp), my_strnxfrm(charset(), maxp_prefix, sizeof(maxp),
max->ptr + length_size(), max->ptr + length_size(), dsz);
sizeof(maxp) * charset()->mbmaxlen);
mp= char_prefix_to_ulonglong(mp_prefix); mp= char_prefix_to_ulonglong(mp_prefix);
minp= char_prefix_to_ulonglong(minp_prefix); minp= char_prefix_to_ulonglong(minp_prefix);
maxp= char_prefix_to_ulonglong(maxp_prefix); maxp= char_prefix_to_ulonglong(maxp_prefix);
......
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