2005-11-10 20:25:03 +01:00
|
|
|
# Test case(s) in this file contain(s) GRANT/REVOKE statements, which are not
|
|
|
|
# supported in embedded server. So, this test should not be run on embedded
|
|
|
|
# server.
|
|
|
|
|
|
|
|
-- source include/not_embedded.inc
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
#
|
|
|
|
# Tests for WL#2818:
|
|
|
|
# - Check that triggers created w/o DEFINER information work well:
|
|
|
|
# - create the first trigger;
|
|
|
|
# - manually remove definer information from corresponding TRG file;
|
|
|
|
# - create the second trigger (the first trigger will be reloaded; check
|
|
|
|
# that we receive a warning);
|
|
|
|
# - check that the triggers loaded correctly;
|
|
|
|
#
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Prepare environment.
|
|
|
|
#
|
|
|
|
|
|
|
|
DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%';
|
|
|
|
DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%';
|
|
|
|
DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%';
|
|
|
|
DELETE FROM mysql.columns_priv WHERE User LIKE 'mysqltest_%';
|
|
|
|
FLUSH PRIVILEGES;
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP DATABASE IF EXISTS mysqltest_db1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE DATABASE mysqltest_db1;
|
|
|
|
|
|
|
|
CREATE USER mysqltest_dfn@localhost;
|
|
|
|
CREATE USER mysqltest_inv@localhost;
|
|
|
|
|
2006-02-01 11:28:45 +01:00
|
|
|
GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
|
2005-11-10 20:25:03 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create a table and the first trigger.
|
|
|
|
#
|
|
|
|
|
|
|
|
--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
|
|
|
|
--connection wl2818_definer_con
|
|
|
|
--echo
|
|
|
|
--echo ---> connection: wl2818_definer_con
|
|
|
|
|
|
|
|
CREATE TABLE t1(num_value INT);
|
|
|
|
CREATE TABLE t2(user_str TEXT);
|
|
|
|
|
2009-02-19 21:37:40 +01:00
|
|
|
CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
|
2005-11-10 20:25:03 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Remove definers from TRG file.
|
|
|
|
#
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo ---> patching t1.TRG...
|
|
|
|
|
2009-02-19 21:37:40 +01:00
|
|
|
# Here we remove definers. This is somewhat complex than the original test
|
|
|
|
# Previously, the test only used grep -v 'definers=' t1.TRG, but grep is not
|
|
|
|
# portable and we have to load the file into a table, exclude the definers line,
|
|
|
|
# then load the data to an outfile to accomplish the same effect
|
|
|
|
|
|
|
|
--disable_query_log
|
|
|
|
--connection default
|
|
|
|
CREATE TABLE patch (a blob);
|
2009-02-20 00:24:25 +01:00
|
|
|
let $MYSQLD_DATADIR = `select @@datadir`;
|
|
|
|
eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' INTO TABLE patch;
|
2009-02-19 21:37:40 +01:00
|
|
|
# remove original t1.TRG file so SELECT INTO OUTFILE won't fail
|
2009-02-20 00:24:25 +01:00
|
|
|
--remove_file $MYSQLD_DATADIR/mysqltest_db1/t1.TRG
|
2009-02-19 21:37:40 +01:00
|
|
|
eval SELECT SUBSTRING_INDEX(a,'definers=',1) INTO OUTFILE
|
2009-02-20 00:24:25 +01:00
|
|
|
'$MYSQLD_DATADIR/mysqltest_db1/t1.TRG'
|
2009-02-19 21:37:40 +01:00
|
|
|
FROM patch;
|
|
|
|
DROP TABLE patch;
|
|
|
|
--connection wl2818_definer_con
|
|
|
|
--enable_query_log
|
2005-11-10 20:25:03 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create a new trigger.
|
|
|
|
#
|
|
|
|
|
|
|
|
--echo
|
|
|
|
|
|
|
|
CREATE TRIGGER wl2818_trg2 AFTER INSERT ON t1
|
|
|
|
FOR EACH ROW
|
|
|
|
INSERT INTO t2 VALUES(CURRENT_USER());
|
|
|
|
|
|
|
|
--echo
|
|
|
|
|
|
|
|
SELECT trigger_name, definer FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
|
|
|
|
|
|
|
|
--echo
|
|
|
|
|
|
|
|
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
|
Add new option "check-testcases" to mysql-test-run.pl
Cleanup the sideeffects from most of the testcases with sideeffects.
mysql-test/mysql-test-run.pl:
Add option "check-testcases" to mysql-test-run.pl
Will execute "include/check-testcase.test" once before each tescase and record the output into "var/tmp/check-testcase.result"
After the teastcase it will run again and this time compare the output with previously recorded file.
mysql-test/r/analyze.result:
Drop table t1 at end of test
mysql-test/r/create_select_tmp.result:
Drop table t1 at end of test
mysql-test/r/ctype_cp932.result:
Drop table t1 at end of test
mysql-test/r/ctype_recoding.result:
Drop table t1 at end of test
mysql-test/r/grant2.result:
Drop user mysqltest_2 and mysqltest_A@'%'
mysql-test/r/join_outer.result:
Drop view v1 to cleanup
mysql-test/r/ps_1general.result:
Drop table t1 at end of test
mysql-test/r/query_cache.result:
Drop function "f1"
mysql-test/r/read_only.result:
Reset the "read_only" flag
mysql-test/r/rpl000001.result:
Remove user "blafasel2"
mysql-test/r/rpl000017.result:
Remove user "replicate"
mysql-test/r/rpl_failed_optimize.result:
Drop table t1 to cleanup
mysql-test/r/rpl_flush_tables.result:
Drop tables t3, t4, t5
mysql-test/r/rpl_ignore_revoke.result:
Delete user "user_foo"
mysql-test/r/rpl_insert_id.result:
Drop table t1 to cleanup
mysql-test/r/rpl_loaddata.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_loaddata_rule_m.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_loaddata_rule_s.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_misc_functions.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_multi_update3.result:
Drop tyable t1 and t2 to cleanup
mysql-test/r/rpl_replicate_do.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_skip_error.result:
Drop tyable t1 to cleanup
mysql-test/r/rpl_slave_status.result:
Drop tyable t1 to cleanup
mysql-test/r/sp-prelocking.result:
Drop view v1 and tables t1, t2, t3 and t4 to cleanup
mysql-test/r/sp-security.result:
Delete users to cleanup
Delete remaining traces in tables_priv and procs_priv
mysql-test/r/subselect_innodb.result:
Drop procedure p1 to cleanup
mysql-test/r/trigger-compat.result:
Drop trigger wl2818_trg1 and wl2818_trg2.
Drop table t1, t2
Drop database mysqltest_db1
And the users "mysqltest_dfn@localhost" and "mysqltest_inv@localhost"
mysql-test/r/type_bit.result:
Drop tables t1 and t2 to cleanup
mysql-test/r/variables.result:
Set GLOBAL max_join_size to 10 as it originally was in variables-master.opt
mysql-test/r/view_grant.result:
Dop user "test@localhost" to cleanup
mysql-test/t/analyze.test:
Drop table t1 to cleanup
mysql-test/t/create_select_tmp.test:
Drop table t1 to cleanup
mysql-test/t/ctype_cp932.test:
Drop table t1 to cleanup
mysql-test/t/ctype_recoding.test:
Drop table t1 to cleanup
mysql-test/t/fulltext_var.test:
Restore the original ft_boolean_syntax
mysql-test/t/grant2.test:
Drop users "mysqltest_2" and "mysqltest_A@'%'" to cleanup
mysql-test/t/innodb_cache.test:
Reset query_cache_size to original value
mysql-test/t/join_outer.test:
Drop view v1 to cleanup
mysql-test/t/ps_1general.test:
Drop table t1 to cleanup
mysql-test/t/query_cache.test:
Drop function "f1" to cleanup
mysql-test/t/read_only.test:
Reset the readonly flag
mysql-test/t/rpl000001.test:
Delete user "blafasel2" to cleanup
mysql-test/t/rpl000017.test:
Delete user "replicate" to cleanup
mysql-test/t/rpl_failed_optimize.test:
Drop table t1 to cleanup
mysql-test/t/rpl_flush_tables.test:
Droip table t3, t4 and t5 to cleanup
mysql-test/t/rpl_ignore_revoke.test:
Delet user "user_foo" to cleanup
mysql-test/t/rpl_insert_id.test:
drop table t1 to cleanup
mysql-test/t/rpl_loaddata.test:
Drop table t1 to cleanup
mysql-test/t/rpl_loaddata_rule_m.test:
Drop table t1 to cleanup
mysql-test/t/rpl_loaddata_rule_s.test:
Drop table t1 to cleanup
mysql-test/t/rpl_misc_functions.test:
Drop table t1 to cleanup
mysql-test/t/rpl_multi_update3.test:
Drop table t1 and t2 to cleanup
mysql-test/t/rpl_replicate_do.test:
Drop table t1 to cleanup
mysql-test/t/rpl_skip_error.test:
Drop table t1 to cleanup
mysql-test/t/rpl_slave_status.test:
Drop table t1 to cleanup
mysql-test/t/sp-prelocking.test:
Drop table t1, t2 t3 and t4 to cleanup
Drop view v1
mysql-test/t/sp-security.test:
Delete test users from mysql.user, mysql.db, mysql.procs_priv and mysql.tables_priv
Drop table t1 to cleanup
mysql-test/t/subselect_innodb.test:
Drop procedure p1 to cleanup
mysql-test/t/trigger-compat.test:
Drop trigger wl2818_trg1 and wl2818_trg2 to cleanup
Drop table t1, t2
Drop users
drop database mysqltest_db1
mysql-test/t/type_bit.test:
drop table t1 and t2 to cleanup
mysql-test/t/variables-master.opt:
Increase max_join_size to 100.
mysql-test/t/variables.test:
Set max_join_size to 10, which was the original value in variables-master.opt
mysql-test/t/view_grant.test:
Drop the user "test@localhost"
mysql-test/include/check-testcase.test:
New BitKeeper file ``mysql-test/include/check-testcase.test''
2006-01-26 17:54:34 +01:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
DROP TRIGGER wl2818_trg1;
|
|
|
|
DROP TRIGGER wl2818_trg2;
|
|
|
|
disconnect wl2818_definer_con;
|
|
|
|
connection default;
|
|
|
|
use mysqltest_db1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP USER mysqltest_dfn@localhost;
|
|
|
|
DROP USER mysqltest_inv@localhost;
|
|
|
|
DROP DATABASE mysqltest_db1;
|
|
|
|
|