mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed LP bug #892725.
A non-first execution of a prepared statement missed a call of the TABLE_LIST::process_index_hints() method in the code of the function setup_tables(). At some scenarios this could lead to the choice of a quite inefficient execution plan for the base query of the prepared statement.
This commit is contained in:
@ -3058,3 +3058,60 @@ date('2010-10-10') between '2010-09-09' and ?
|
||||
execute stmt using @a;
|
||||
date('2010-10-10') between '2010-09-09' and ?
|
||||
0
|
||||
#
|
||||
# Bug #892725: look-up is changed for a full scan when executing PS
|
||||
#
|
||||
create table t1 (a int primary key, b int);
|
||||
insert into t1 values
|
||||
(7,70), (3,40), (4,40), (8,70), (1,70), (9,50), (2,70);
|
||||
prepare st from 'select * from t1 where a=8';
|
||||
flush status;
|
||||
execute st;
|
||||
a b
|
||||
8 70
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
execute st;
|
||||
a b
|
||||
8 70
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
select * from t1 use index() where a=3;
|
||||
a b
|
||||
3 40
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 8
|
||||
flush status;
|
||||
execute st;
|
||||
a b
|
||||
8 70
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 0
|
||||
deallocate prepare st;
|
||||
drop table t1;
|
||||
|
@ -3119,3 +3119,30 @@ set @a='2010-08-08';
|
||||
execute stmt using @a;
|
||||
execute stmt using @a;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #892725: look-up is changed for a full scan when executing PS
|
||||
--echo #
|
||||
|
||||
create table t1 (a int primary key, b int);
|
||||
insert into t1 values
|
||||
(7,70), (3,40), (4,40), (8,70), (1,70), (9,50), (2,70);
|
||||
|
||||
prepare st from 'select * from t1 where a=8';
|
||||
|
||||
flush status;
|
||||
execute st;
|
||||
show status like '%Handler_read%';
|
||||
flush status;
|
||||
execute st;
|
||||
show status like '%Handler_read%';
|
||||
flush status;
|
||||
select * from t1 use index() where a=3;
|
||||
show status like '%Handler_read%';
|
||||
flush status;
|
||||
execute st;
|
||||
show status like '%Handler_read%';
|
||||
|
||||
deallocate prepare st;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
@ -7864,6 +7864,8 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
|
||||
table_list->table->map= table_list->map_exec;
|
||||
table_list->table->maybe_null= table_list->maybe_null_exec;
|
||||
table_list->table->pos_in_table_list= table_list;
|
||||
if (table_list->process_index_hints(table_list->table))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
select_lex->leaf_tables.push_back(table_list);
|
||||
}
|
||||
|
Reference in New Issue
Block a user