diff --git a/mysql-test/suite/oracle_compatibility/t/ora_profile_EXECUTION_TIME_keyword.test b/mysql-test/suite/oracle_compatibility/t/ora_profile_EXECUTION_TIME_keyword.test new file mode 100644 index 0000000000000000000000000000000000000000..225c1f036d509e20c2cd6d472317d943934aad03 --- /dev/null +++ b/mysql-test/suite/oracle_compatibility/t/ora_profile_EXECUTION_TIME_keyword.test @@ -0,0 +1,355 @@ +# +# Test add new keywords EXECUTION_TIME +# + +--echo ############################################################ +--echo CASE 1: test keywords as database name +--echo ############################################################ + +--disable_warnings +drop database if exists EXECUTION_TIME; +--enable_warnings + +create database EXECUTION_TIME; + +use EXECUTION_TIME; + +--echo ############################################################ +--echo CASE 2: test keywords as table name +--echo ############################################################ +--disable_warnings +drop table if exists EXECUTION_TIME; +--enable_warnings + +create table EXECUTION_TIME(a int, b int); + +insert into EXECUTION_TIME values(1,1); + +select * from EXECUTION_TIME; + +--echo ############################################################ +--echo CASE 3: test keywords as field name +--echo ############################################################ +--disable_warnings +drop table if exists EXECUTION_TIME_field_name; +--enable_warnings + +create table EXECUTION_TIME_field_name(a int, EXECUTION_TIME int); + +insert into EXECUTION_TIME_field_name values(1,1); + +select * from EXECUTION_TIME_field_name; + +--echo ############################################################ +--echo CASE 4: test keywords as view name +--echo ############################################################ + +rename table EXECUTION_TIME to EXECUTION_TIME_t1; + +create view EXECUTION_TIME as select a, b from EXECUTION_TIME.EXECUTION_TIME_t1; + +select * from EXECUTION_TIME; + +drop view EXECUTION_TIME; + +rename table EXECUTION_TIME_t1 to EXECUTION_TIME; + +--echo ############################################################ +--echo CASE 5: test keywords as table alias +--echo ############################################################ +drop table if exists EXECUTION_TIME; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int, b int); + +insert into t1 values(1, 2); + +select EXECUTION_TIME.a, EXECUTION_TIME.b from t1 as EXECUTION_TIME; + +--echo ############################################################ +--echo CASE 6: test keywords as column alias +--echo ############################################################ +--disable_warnings +drop table if exists t2; +--enable_warnings + +create table t2 (a int, b int); + +insert into t2 values(1, 2); + +select a as EXECUTION_TIME, b from t1; + +--echo ############################################################ +--echo CASE 7: test keywords as stored procedure name, parameter name, label name +--echo ############################################################ +--delimiter / + +--echo CASE 7.1: test keywords as stored procedure name +create procedure EXECUTION_TIME(a int, b int) +begin +insert into t1 values(a, b); +end +/ + +call EXECUTION_TIME(3, 4)/ +select * from t1/ + +--echo CASE 7.2: test keywords as stored procedure parameter name +create procedure p1(EXECUTION_TIME int, b int) +begin +insert into t1 values(EXECUTION_TIME, b); +end +/ + +call p1(5,6)/ +select * from t1/ + +--echo CASE 7.3: test keywords as stored procedure label name +create procedure p2() +begin +declare n int default 2; +EXECUTION_TIME: +while n > 0 +do +set n = n -1; +end while EXECUTION_TIME; +end/ + +--delimiter ; + +--echo ############################################################ +--echo CASE 8: test keywords as stored procedure internal variable name +--echo ############################################################ +--delimiter / + +create procedure pro1(b int) +begin +declare EXECUTION_TIME int; +set EXECUTION_TIME = 5; +insert into t1 values(EXECUTION_TIME, b); +end +/ + +create procedure pro11(b int) +begin +declare EXECUTION_TIME int; +select 10 into EXECUTION_TIME; +insert into t1 values(EXECUTION_TIME, b); +end +/ + +--delimiter ; + +call pro1(10); + +select * from t1; + +--echo ############################################################ +--echo CASE 9: test keywords as stored procedure internal variable name in oracle compatibility mode +--echo ############################################################ +set parse_mode = 2; + +--delimiter / + +--error ER_PARSE_ERROR +create procedure EXECUTION_TIME.pro2(num_para1 in number) +as +EXECUTION_TIME number; +begin +EXECUTION_TIME:=num_para1; +insert into t1 values(EXECUTION_TIME, 7); +end +/ + +--error ER_PARSE_ERROR +create procedure EXECUTION_TIME.pro22(a in number) +as +EXECUTION_TIME number; +begin +select 10 into EXECUTION_TIME; +insert into t1 values(EXECUTION_TIME, a); +end +/ + +--delimiter ; + +set parse_mode = default; + +--echo ############################################################ +--echo CASE 10: test keywords as stored function name, parameter name, label name +--echo ############################################################ + +--delimiter / + +--echo CASE 10.1: test keywords as stored function name + +--disable_warnings + +create function EXECUTION_TIME(a int) +returns int +deterministic +begin +return a+1; +end +/ + +--enable_warnings + +--error ER_PARSE_ERROR +select EXECUTION_TIME(1) from dual/ + +select EXECUTION_TIME.EXECUTION_TIME(1) from dual/ + +--echo CASE 10.2: test keywords as stored function parameter name + +create function fun1(EXECUTION_TIME int) +returns int +deterministic +begin +return EXECUTION_TIME+1; +end +/ + +select fun1(1) from dual/ + +--echo CASE 10.3: test keywords as stored function label name +create function fun2() +returns int +deterministic +begin +declare n int default 2; +EXECUTION_TIME: +while n > 0 +do +set n = n -1; +end while EXECUTION_TIME; +return n+1; +end +/ + +select fun2() from dual/ + +--delimiter ; + +--echo ############################################################ +--echo CASE 11: test keywords as stored function internal variable name +--echo ############################################################ +--delimiter / + +create function fun3() +returns int +deterministic +begin +declare EXECUTION_TIME int; +set EXECUTION_TIME = 5; +return EXECUTION_TIME; +end +/ + +create function fun31() +returns int +deterministic +begin +declare EXECUTION_TIME int; +select 10 into EXECUTION_TIME; +return EXECUTION_TIME; +end +/ + +--delimiter ; + +select fun3() from dual; +select fun31() from dual; +--echo ############################################################ +--echo CASE 12: test keywords as trigger name +--echo ############################################################ +--delimiter / + +create trigger EXECUTION_TIME +before update on t1 +for each row +begin +if new.a = 1 +then set new.b = 3; +end if; +end; +/ + +update t1 set a = 1 where a = 3/ + +select * from t1/ + +--delimiter ; + +--echo ############################################################ +--echo CASE 13: test keywords as user name and role name +--echo ############################################################ + +create user if not exists EXECUTION_TIME@localhost; + +create role 'EXECUTION_TIME'@'%'; + +drop user EXECUTION_TIME@localhost; + +drop role EXECUTION_TIME; + +--echo ############################################################ +--echo CASE 14: test keywords as tablespace name +--echo ############################################################ + +CREATE TABLESPACE EXECUTION_TIME ADD DATAFILE 'EXECUTION_TIME.ibd' engine=INNODB; + +--echo ############################################################ +--echo CASE 15: test keywords as local variable name +--echo ############################################################ +set @EXECUTION_TIME = @@global.long_query_time; + +select @EXECUTION_TIME; + +set @EXECUTION_TIME = @@session.long_query_time; + +select @EXECUTION_TIME; + +--error ER_UNKNOWN_SYSTEM_VARIABLE +set EXECUTION_TIME = 5; + +--error ER_UNKNOWN_SYSTEM_VARIABLE +set global EXECUTION_TIME = 5; + +--error ER_UNKNOWN_SYSTEM_VARIABLE +set session EXECUTION_TIME = 5; + +--echo ############################################################ +--echo CASE 16: test keywords as event name +--echo ############################################################ + +--disable_warnings +drop event if exists EXECUTION_TIME; +--enable_warnings + +create event EXECUTION_TIME on schedule every 1 second starts now() ends date_add(now(), interval 2 second) do insert into t1 values(3,3); + +select sleep(3); + +select * from t1; + +--echo ############################################################ +--echo CASE 17: test keywords as prepare object name +--echo ############################################################ +prepare EXECUTION_TIME from 'select ?'; + +set @a = 20; + +execute EXECUTION_TIME using @a; + +--echo ############################################################ +--echo CASE 18: clean up +--echo ############################################################ + +drop tablespace EXECUTION_TIME; + +drop database EXECUTION_TIME; +