Skip to content

Commit 48e4962

Browse files
committed
MDEV-29298 INSERT ... SELECT Does not produce an optimizer trace
Add INSERT ... SELECT to the list of commands that can be traced Approved by Sergei Petrunia (sergey@mariadb.com)
1 parent 5b0a415 commit 48e4962

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

mysql-test/main/opt_trace.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9231,5 +9231,17 @@ json_detailed(json_extract(trace, '$**.in_to_subquery_conversion'))
92319231
]
92329232
set in_predicate_conversion_threshold=@tmp;
92339233
drop table t0;
9234+
#
9235+
# MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace
9236+
#
9237+
create table t1 (a int, b int);
9238+
create table t2 (a int, b int);
9239+
insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5);
9240+
set optimizer_trace=1;
9241+
insert into t2 select * from t1 where a<= b and a>4;
9242+
select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
9243+
QUERY LENGTH(trace)>1
9244+
insert into t2 select * from t1 where a<= b and a>4 1
9245+
drop table t1, t2;
92349246
# End of 10.5 tests
92359247
set optimizer_trace='enabled=off';

mysql-test/main/opt_trace.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,5 +861,19 @@ set in_predicate_conversion_threshold=@tmp;
861861
drop table t0;
862862
--enable_view_protocol
863863

864+
--echo #
865+
--echo # MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace
866+
--echo #
867+
create table t1 (a int, b int);
868+
create table t2 (a int, b int);
869+
insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5);
870+
set optimizer_trace=1;
871+
872+
insert into t2 select * from t1 where a<= b and a>4;
873+
874+
select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
875+
876+
drop table t1, t2;
877+
864878
--echo # End of 10.5 tests
865879
set optimizer_trace='enabled=off';

sql/opt_trace.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ inline bool sql_command_can_be_traced(enum enum_sql_command sql_command)
103103
sql_command == SQLCOM_UPDATE ||
104104
sql_command == SQLCOM_DELETE ||
105105
sql_command == SQLCOM_DELETE_MULTI ||
106-
sql_command == SQLCOM_UPDATE_MULTI;
106+
sql_command == SQLCOM_UPDATE_MULTI ||
107+
sql_command == SQLCOM_INSERT_SELECT;
107108
}
108109

109110
void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex,

0 commit comments

Comments
 (0)