move notembedded part of the test to _notembedded

This commit is contained in:
Sergei Golubchik 2025-06-10 09:12:33 +02:00
parent 7e29204534
commit 4e9ec4c2ea
4 changed files with 103 additions and 60 deletions

View File

@ -42,24 +42,6 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select c + 1 from t order by vc limit 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL vc 5 NULL 2
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select c + 1 from t order by c + 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL c 5 NULL 10000 Using index; Using filesort
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
[
{
"location": "ORDER BY",
"from": "t.c + 1",
"to": "t.vc"
}
]
set optimizer_trace=@old_optimizer_trace;
drop table t;
create table t (c int, key (c));
insert into t select seq from seq_1_to_10000;
@ -108,27 +90,4 @@ add index(vc1);
alter table t
add column vc2 int as (1 - c),
add index(vc2);
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t order by c + 1, 1 - c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL c 5 NULL 10000 Using index; Using filesort
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
[
{
"location": "ORDER BY",
"from": "t.c + 1",
"to": "t.vc1"
},
{
"location": "ORDER BY",
"from": "1 - t.c",
"to": "t.vc2"
}
]
set optimizer_trace=@old_optimizer_trace;
drop table t;

View File

@ -0,0 +1,59 @@
#
# MDEV-36132 Optimizer support for functional indexes: handle GROUP/ORDER BY
#
create table t (c int, key (c));
insert into t select seq from seq_1_to_10000;
alter table t
add column vc int as (c + 1),
add index(vc);
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select c + 1 from t order by c + 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL c 5 NULL 10000 Using index; Using filesort
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
[
{
"location": "ORDER BY",
"from": "t.c + 1",
"to": "t.vc"
}
]
set optimizer_trace=@old_optimizer_trace;
drop table t;
create table t (c int, key (c));
insert into t select seq from seq_1_to_10000;
alter table t
add column vc1 int as (c + 1),
add index(vc1);
alter table t
add column vc2 int as (1 - c),
add index(vc2);
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t order by c + 1, 1 - c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL c 5 NULL 10000 Using index; Using filesort
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
[
{
"location": "ORDER BY",
"from": "t.c + 1",
"to": "t.vc1"
},
{
"location": "ORDER BY",
"from": "1 - t.c",
"to": "t.vc2"
}
]
set optimizer_trace=@old_optimizer_trace;
drop table t;

View File

@ -26,17 +26,6 @@ explain select vc from t order by c + 1 limit 2;
explain select c + 1 from t order by c + 1 limit 2;
explain select c + 1 from t order by vc limit 2;
## optimizer trace
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select c + 1 from t order by c + 1;
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
set optimizer_trace=@old_optimizer_trace;
drop table t;
# vcol on vcol
@ -84,12 +73,4 @@ alter table t
alter table t
add column vc2 int as (1 - c),
add index(vc2);
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t order by c + 1, 1 - c;
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
set optimizer_trace=@old_optimizer_trace;
drop table t;

View File

@ -0,0 +1,44 @@
--echo #
--echo # MDEV-36132 Optimizer support for functional indexes: handle GROUP/ORDER BY
--echo #
--source include/not_embedded.inc
--source include/have_sequence.inc
create table t (c int, key (c));
insert into t select seq from seq_1_to_10000;
alter table t
add column vc int as (c + 1),
add index(vc);
## optimizer trace
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select c + 1 from t order by c + 1;
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
set optimizer_trace=@old_optimizer_trace;
drop table t;
# multiple items in order by
create table t (c int, key (c));
insert into t select seq from seq_1_to_10000;
alter table t
add column vc1 int as (c + 1),
add index(vc1);
alter table t
add column vc2 int as (1 - c),
add index(vc2);
set @old_optimizer_trace=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t order by c + 1, 1 - c;
select
json_detailed(json_extract(trace, '$**.virtual_column_substitution'))
from
information_schema.optimizer_trace;
set optimizer_trace=@old_optimizer_trace;
drop table t;