Skip to content
/ server Public

Commit d0baf71

Browse files
MDEV-24813 [to-squash] Add invocation of init_table_full_scan_if_needed in join_read_first and join_read_last
Missed these places of full index scans in the previous commit
1 parent 97830d0 commit d0baf71

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

mysql-test/main/innodb_full_scan.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_
194194
COUNT
195195
16
196196
drop table t1, t2;
197+
# Full index scan
198+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
199+
insert into t10 select seq, uuid() from seq_1_to_10000;
200+
create table t11(a int) engine=innodb;
201+
insert into t11 select a from t10;
202+
## +0, was +11
203+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
204+
COUNT
205+
16
206+
drop table t10, t11;
207+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
208+
insert into t10 select seq, uuid() from seq_1_to_10000;
209+
create table t11(a int) engine=innodb;
210+
insert into t11 select a from t10 order by a desc;
211+
## +0, was +11
212+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
213+
COUNT
214+
16
215+
drop table t10, t11;
197216
set global innodb_monitor_enable=default;
198217
Warnings:
199218
Warning 1230 Default value is not defined for this set option. Please specify correct counter or module name.

mysql-test/main/innodb_full_scan.test

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,31 @@ SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_
172172

173173
drop table t1, t2;
174174

175+
--echo # Full index scan
176+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
177+
insert into t10 select seq, uuid() from seq_1_to_10000;
178+
create table t11(a int) engine=innodb;
179+
insert into t11 select a from t10;
180+
--echo ## +0, was +11
181+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
182+
drop table t10, t11;
183+
184+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
185+
insert into t10 select seq, uuid() from seq_1_to_10000;
186+
create table t11(a int) engine=innodb;
187+
insert into t11 select a from t10 order by a desc;
188+
--echo ## +0, was +11
189+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
190+
drop table t10, t11;
191+
192+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
193+
insert into t10 select seq, uuid() from seq_1_to_10000;
194+
create table t11(a int) engine=innodb;
195+
explain
196+
insert into t11 select a from t10 where a > 30;
197+
insert into t11 select a from t10 where a > 30;
198+
--echo ## +0, was +11
199+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
200+
drop table t10, t11;
201+
175202
set global innodb_monitor_enable=default;

sql/sql_select.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25464,6 +25464,9 @@ join_read_first(JOIN_TAB *tab)
2546425464
tab->table->status=0;
2546525465
tab->read_record.read_record_func= join_read_next;
2546625466
tab->read_record.table=table;
25467+
init_table_full_scan_if_needed(tab->table,
25468+
tab->select ? tab->select->cond : NULL,
25469+
tab->join->unit->lim.get_select_limit());
2546725470
if (!table->file->inited)
2546825471
error= table->file->ha_index_init(tab->index, tab->sorted);
2546925472
if (likely(!error))
@@ -25503,6 +25506,9 @@ join_read_last(JOIN_TAB *tab)
2550325506
tab->table->status=0;
2550425507
tab->read_record.read_record_func= join_read_prev;
2550525508
tab->read_record.table=table;
25509+
init_table_full_scan_if_needed(tab->table,
25510+
tab->select ? tab->select->cond : NULL,
25511+
tab->join->unit->lim.get_select_limit());
2550625512
if (!table->file->inited)
2550725513
error= table->file->ha_index_init(tab->index, 1);
2550825514
if (likely(!error))

0 commit comments

Comments
 (0)