mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 10:18:13 +02:00
79 lines
1.6 KiB
Text
79 lines
1.6 KiB
Text
#
|
|
# MDEV-13330: Tests for the "ANALYZE command should collect SP execution time" feature
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t0,t1;
|
|
drop view if exists v1;
|
|
drop function if exists f1;
|
|
drop function if exists f2;
|
|
--enable_warnings
|
|
|
|
create table t0(a int);
|
|
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
delimiter |;
|
|
|
|
create function f1 (a int) returns int deterministic
|
|
begin
|
|
return a+1;
|
|
end|
|
|
|
|
create function f2 (a int) returns int deterministic
|
|
begin
|
|
return a+10;
|
|
end|
|
|
|
|
create function f3 (a int) returns int deterministic
|
|
begin
|
|
return f1(a) + f2(a);
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
--source include/analyze-format.inc
|
|
analyze format=json select a, f1(a),f2(a) from t0;
|
|
|
|
--echo # This will show only invocations of F3
|
|
--echo # F3 invokes F1 and F2 but we do counting "at top level" only
|
|
|
|
--source include/analyze-format.inc
|
|
analyze format=json select a, f3(a) from t0;
|
|
|
|
--source include/analyze-format.inc
|
|
analyze format=json select a, f1(a),f3(a) from t0;
|
|
|
|
--echo #
|
|
--echo # Test that trigger invocations are counted
|
|
--echo #
|
|
create table t1 (i int, j int);
|
|
|
|
delimiter |;
|
|
create trigger trg1 before insert on t1 for each row
|
|
begin
|
|
if new.j > 10 then
|
|
set new.j := 10;
|
|
end if;
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
--source include/analyze-format.inc
|
|
analyze format=json insert into t1 select a,a from t0;
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
# Test how it works with a non-mergeable VIEW:
|
|
#
|
|
create view v1 as select f1(max(a)) as COL from t0;
|
|
--source include/analyze-format.inc
|
|
analyze format=json select * from v1;
|
|
|
|
drop view v1;
|
|
|
|
drop table t0;
|
|
drop function f1;
|
|
drop function f2;
|
|
drop function f3;
|
|
|