mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
7dbea7df27
checks on trigger activation) mysql-test/r/information_schema.result: Update result file: a new column DEFINER has been added to INFORMATION_SCHEMA.TRIGGERS. mysql-test/r/mysqldump.result: Update result file: a new column DEFINER has been added to INFORMATION_SCHEMA.TRIGGERS. mysql-test/r/rpl_ddl.result: Update result file: a new column DEFINER has been added to INFORMATION_SCHEMA.TRIGGERS. mysql-test/r/rpl_sp.result: Update result file: a new clause DEFINER has been added to CREATE TRIGGER statement. mysql-test/r/rpl_trigger.result: Results for new test cases were added. mysql-test/r/skip_grants.result: Error message has been changed. mysql-test/r/trigger.result: Added DEFINER column. mysql-test/r/view.result: Error messages have been changed. mysql-test/r/view_grant.result: Error messages have been changed. mysql-test/t/mysqldump.test: Drop created procedure to not affect further tests. mysql-test/t/rpl_trigger.test: Add tests for new column in information schema. mysql-test/t/skip_grants.test: Error tag has been renamed. mysql-test/t/view.test: Error tag has been renamed. mysql-test/t/view_grant.test: Error tag has been changed. sql/item_func.cc: Fix typo in comments. sql/mysql_priv.h: A try to minimize copy&paste: - introduce operations to be used from sql_yacc.yy; - introduce an operation to be used from trigger and view processing code. sql/share/errmsg.txt: - Rename ER_NO_VIEW_USER to ER_MALFORMED_DEFINER in order to be shared for view and trigger implementations; - Fix a typo; - Add a new error code for trigger warning. sql/sp.cc: set_info() was split into set_info() and set_definer(). sql/sp_head.cc: set_info() was split into set_info() and set_definer(). sql/sp_head.h: set_info() was split into set_info() and set_definer(). sql/sql_acl.cc: Add a new check: exit from the cycle if the table is NULL. sql/sql_lex.h: - Rename create_view_definer to definer, since it is used for views and triggers; - Change st_lex_user to LEX_USER, since st_lex_user is a structure. So, formally, it should be "struct st_lex_user", which is longer than just LEX_USER; - Add trigger_definition_begin. sql/sql_parse.cc: - Add a new check: exit from the cycle if the table is NULL; - Implement definer-related functions. sql/sql_show.cc: Add DEFINER column. sql/sql_trigger.cc: Add DEFINER support for triggers. sql/sql_trigger.h: Add DEFINER support for triggers. sql/sql_view.cc: Rename create_view_definer to definer. sql/sql_yacc.yy: Add support for DEFINER-clause in CREATE TRIGGER statement. Since CREATE TRIGGER and CREATE VIEW can be similar at the start, yacc is unable to distinguish between them. So, had to modify both statements in order to make it parsable by yacc. mysql-test/r/trigger-compat.result: Result file for triggers backward compatibility test. mysql-test/r/trigger-grant.result: Result file of the test for WL#2818. mysql-test/t/trigger-compat.test: Triggers backward compatibility test: check that the server still can load triggers w/o definer attribute and modify tables with such triggers (add a new trigger, etc). mysql-test/t/trigger-grant.test: Test for WL#2818 -- check that DEFINER support in triggers works properly
124 lines
2.9 KiB
Text
124 lines
2.9 KiB
Text
stop slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
reset master;
|
|
reset slave;
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
start slave;
|
|
create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
|
|
create table t2 (a int auto_increment, primary key (a), b int);
|
|
create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null);
|
|
create trigger t1 before insert on t1 for each row
|
|
begin
|
|
insert into t3 values (NULL, "t1", new.a, new.b, rand());
|
|
end|
|
|
create trigger t2 after insert on t2 for each row
|
|
begin
|
|
insert into t3 values (NULL, "t2", new.a, new.b, rand());
|
|
end|
|
|
insert into t3 values(100,"log",0,0,0);
|
|
SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
|
|
insert into t1 values(1,1,rand()),(NULL,2,rand());
|
|
insert into t2 (b) values(last_insert_id());
|
|
insert into t2 values(3,0),(NULL,0);
|
|
insert into t2 values(NULL,0),(500,0);
|
|
select a,b, truncate(rand_value,4) from t1;
|
|
a b truncate(rand_value,4)
|
|
1 1 0.4320
|
|
2 2 0.3055
|
|
select * from t2;
|
|
a b
|
|
1 2
|
|
3 0
|
|
4 0
|
|
5 0
|
|
500 0
|
|
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
|
|
a name old_a old_b truncate(rand_value,4)
|
|
100 log 0 0 0.0000
|
|
101 t1 1 1 0.3203
|
|
102 t1 0 2 0.5666
|
|
103 t2 1 2 0.9164
|
|
104 t2 3 0 0.8826
|
|
105 t2 4 0 0.6635
|
|
106 t2 5 0 0.6699
|
|
107 t2 500 0 0.3593
|
|
|
|
--- On slave --
|
|
select a,b, truncate(rand_value,4) from t1;
|
|
a b truncate(rand_value,4)
|
|
1 1 0.4320
|
|
2 2 0.3055
|
|
select * from t2;
|
|
a b
|
|
1 2
|
|
3 0
|
|
4 0
|
|
5 0
|
|
500 0
|
|
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
|
|
a name old_a old_b truncate(rand_value,4)
|
|
100 log 0 0 0.0000
|
|
101 t1 1 1 0.3203
|
|
102 t1 0 2 0.5666
|
|
103 t2 1 2 0.9164
|
|
104 t2 3 0 0.8826
|
|
105 t2 4 0 0.6635
|
|
106 t2 5 0 0.6699
|
|
107 t2 500 0 0.3593
|
|
drop table t1,t2,t3;
|
|
select get_lock("bug12480",2);
|
|
get_lock("bug12480",2)
|
|
1
|
|
create table t1 (a datetime,b datetime, c datetime);
|
|
drop function if exists bug12480;
|
|
Warnings:
|
|
Note 1305 FUNCTION bug12480 does not exist
|
|
create function bug12480() returns datetime
|
|
begin
|
|
set @a=get_lock("bug12480",2);
|
|
return now();
|
|
end|
|
|
create trigger t1_first before insert on t1
|
|
for each row begin
|
|
set @a=get_lock("bug12480",2);
|
|
set new.b= now();
|
|
set new.c= bug12480();
|
|
end
|
|
|
|
|
insert into t1 set a = now();
|
|
select a=b && a=c from t1;
|
|
a=b && a=c
|
|
1
|
|
SELECT routine_name, definer
|
|
FROM information_schema.routines;
|
|
routine_name definer
|
|
bug12480 root@localhost
|
|
SELECT trigger_name, definer
|
|
FROM information_schema.triggers;
|
|
trigger_name definer
|
|
t1_first root@localhost
|
|
|
|
--- On slave --
|
|
SELECT routine_name, definer
|
|
FROM information_schema.routines;
|
|
routine_name definer
|
|
bug12480 @
|
|
SELECT trigger_name, definer
|
|
FROM information_schema.triggers;
|
|
trigger_name definer
|
|
t1_first root@localhost
|
|
select a=b && a=c from t1;
|
|
a=b && a=c
|
|
1
|
|
test
|
|
1
|
|
truncate table t1;
|
|
drop trigger t1_first;
|
|
insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now());
|
|
select a=b && a=c from t1;
|
|
a=b && a=c
|
|
1
|
|
1
|
|
1
|
|
drop function bug12480;
|
|
drop table t1;
|