Skip to content
/ server Public

Commit 95e62e1

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 95e62e1

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

mysql-test/main/innodb_full_scan.result

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,39 @@ 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;
216+
# Range access
217+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
218+
insert into t10 select seq, uuid() from seq_1_to_10000;
219+
create table t11(a int) engine=innodb;
220+
explain
221+
insert into t11 select a from t10 where a > 30;
222+
id select_type table type possible_keys key key_len ref rows Extra
223+
1 SIMPLE t10 range a a 5 NULL 10000 Using where; Using index
224+
insert into t11 select a from t10 where a > 30;
225+
## +11, was +11
226+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
227+
COUNT
228+
27
229+
drop table t10, t11;
197230
set global innodb_monitor_enable=default;
198231
Warnings:
199232
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,32 @@ 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+
--echo # Range access
193+
create table t10 (a int, b varchar(100), index(a)) engine=innodb;
194+
insert into t10 select seq, uuid() from seq_1_to_10000;
195+
create table t11(a int) engine=innodb;
196+
explain
197+
insert into t11 select a from t10 where a > 30;
198+
insert into t11 select a from t10 where a > 30;
199+
--echo ## +11, was +11
200+
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created';
201+
drop table t10, t11;
202+
175203
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)