Commit 33ede50f authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-22251: get_key_scans_params: Conditional jump or move depends on uninitialised value

Apply the patch based on the patch by Varun Gupta:

PARAM::is_ror_scan might be used unitialized when check_quick_select()
is invoked for a "degenerate" SEL_ARG tree (e.g. one having type
SEL_ARG::IMPOSSIBLE).

Make check_quick_select() always initialize PARAM::is_ror_scan.
parent 3a89ae33
......@@ -3184,5 +3184,22 @@ SELECT * FROM t1 JOIN t2 ON (t2.code = t1.b) WHERE t1.a NOT IN ('baz', 'qux') OR
id a b code num
DROP TABLE t1, t2;
#
# MDEV-22251: get_key_scans_params: Conditional jump or move depends on uninitialised value
#
create table t1 (pk int, i int, v int, primary key (pk), key(v));
insert into t1 (pk,i,v) values (1,1,2),(2,2,4),(3,3,6),(4,4,8),(5,5,10),(6,6,12),(7,7,14),(8,8,16);
create table t2 (a int, b int);
insert into t2 values (1,2),(2,4);
EXPLAIN
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t1 ALL PRIMARY,v NULL NULL NULL 8 Range checked for each record (index map: 0x3)
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
pk i v a b
1 1 2 1 2
2 2 4 2 4
drop table t1, t2;
#
# End of 10.2 tests
#
......@@ -3196,6 +3196,23 @@ SELECT * FROM t1 JOIN t2 ON (t2.code = t1.b) WHERE t1.a NOT IN ('baz', 'qux') OR
id a b code num
DROP TABLE t1, t2;
#
# MDEV-22251: get_key_scans_params: Conditional jump or move depends on uninitialised value
#
create table t1 (pk int, i int, v int, primary key (pk), key(v));
insert into t1 (pk,i,v) values (1,1,2),(2,2,4),(3,3,6),(4,4,8),(5,5,10),(6,6,12),(7,7,14),(8,8,16);
create table t2 (a int, b int);
insert into t2 values (1,2),(2,4);
EXPLAIN
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t1 ALL PRIMARY,v NULL NULL NULL 8 Range checked for each record (index map: 0x3)
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
pk i v a b
1 1 2 1 2
2 2 4 2 4
drop table t1, t2;
#
# End of 10.2 tests
#
set optimizer_switch=@mrr_icp_extra_tmp;
......@@ -2217,6 +2217,20 @@ SELECT * FROM t1 JOIN t2 ON (t2.code = t1.b) WHERE t1.a NOT IN ('baz', 'qux') OR
DROP TABLE t1, t2;
--echo #
--echo # MDEV-22251: get_key_scans_params: Conditional jump or move depends on uninitialised value
--echo #
create table t1 (pk int, i int, v int, primary key (pk), key(v));
insert into t1 (pk,i,v) values (1,1,2),(2,2,4),(3,3,6),(4,4,8),(5,5,10),(6,6,12),(7,7,14),(8,8,16);
create table t2 (a int, b int);
insert into t2 values (1,2),(2,4);
EXPLAIN
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk);
drop table t1, t2;
--echo #
--echo # End of 10.2 tests
--echo #
......
......@@ -10385,6 +10385,7 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
uint keynr= param->real_keynr[idx];
DBUG_ENTER("check_quick_select");
param->is_ror_scan= FALSE;
/* Handle cases when we don't have a valid non-empty list of range */
if (!tree)
DBUG_RETURN(HA_POS_ERROR);
......
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