From 62dc96cd7e5b910e7d1767965def3fac9f2da0d0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 6 Jun 2025 09:51:07 +0200 Subject: [PATCH] order by vcol test fixups --- mysql-test/suite/vcol/r/order_by_subst.result | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mysql-test/suite/vcol/r/order_by_subst.result b/mysql-test/suite/vcol/r/order_by_subst.result index 5f44c27e8b5..4edf04fbbfe 100644 --- a/mysql-test/suite/vcol/r/order_by_subst.result +++ b/mysql-test/suite/vcol/r/order_by_subst.result @@ -89,3 +89,46 @@ vc 2 2 drop table t; +create table t (c int); +insert into t select seq from seq_1_to_10000; +alter table t +add column vc1 int as (c + 1); +alter table t +add column vc2 int as (1 - c), +add index(vc1, vc2); +explain select vc1, vc2 from t order by c + 1, 1 - c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t ALL NULL NULL NULL NULL 10000 Using filesort +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;