mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / r / trigger-compat.result
blobd456ce8253fc0dfc487fd6270bc2d167bb68affc
1 DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%';
2 DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%';
3 DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%';
4 DELETE FROM mysql.columns_priv WHERE User LIKE 'mysqltest_%';
5 FLUSH PRIVILEGES;
6 DROP DATABASE IF EXISTS mysqltest_db1;
7 CREATE DATABASE mysqltest_db1;
8 CREATE USER mysqltest_dfn@localhost;
9 CREATE USER mysqltest_inv@localhost;
10 GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
12 ---> connection: wl2818_definer_con
13 CREATE TABLE t1(num_value INT);
14 CREATE TABLE t2(user_str TEXT);
15 CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
17 ---> patching t1.TRG...
19 CREATE TRIGGER wl2818_trg2 AFTER INSERT ON t1
20 FOR EACH ROW
21 INSERT INTO t2 VALUES(CURRENT_USER());
22 Warnings:
23 Warning 1454    No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
25 SELECT trigger_name, definer FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
26 trigger_name    definer
27 wl2818_trg1     
28 wl2818_trg2     mysqltest_dfn@localhost
29 Warnings:
30 Warning 1454    No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
32 SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
33 TRIGGER_CATALOG TRIGGER_SCHEMA  TRIGGER_NAME    EVENT_MANIPULATION      EVENT_OBJECT_CATALOG    EVENT_OBJECT_SCHEMA     EVENT_OBJECT_TABLE      ACTION_ORDER    ACTION_CONDITION        ACTION_STATEMENT        ACTION_ORIENTATION      ACTION_TIMING   ACTION_REFERENCE_OLD_TABLE      ACTION_REFERENCE_NEW_TABLE      ACTION_REFERENCE_OLD_ROW        ACTION_REFERENCE_NEW_ROW        CREATED SQL_MODE        DEFINER CHARACTER_SET_CLIENT    COLLATION_CONNECTION    DATABASE_COLLATION
34 NULL    mysqltest_db1   wl2818_trg1     INSERT  NULL    mysqltest_db1   t1      0       NULL    INSERT INTO t2 VALUES(CURRENT_USER())   ROW     BEFORE  NULL    NULL    OLD     NEW     NULL                    latin1  latin1_swedish_ci       latin1_swedish_ci
35 NULL    mysqltest_db1   wl2818_trg2     INSERT  NULL    mysqltest_db1   t1      0       NULL    INSERT INTO t2 VALUES(CURRENT_USER())   ROW     AFTER   NULL    NULL    OLD     NEW     NULL            mysqltest_dfn@localhost latin1  latin1_swedish_ci       latin1_swedish_ci
36 DROP TRIGGER wl2818_trg1;
37 Warnings:
38 Warning 1454    No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
39 DROP TRIGGER wl2818_trg2;
40 use mysqltest_db1;
41 DROP TABLE t1;
42 DROP TABLE t2;
43 DROP USER mysqltest_dfn@localhost;
44 DROP USER mysqltest_inv@localhost;
45 DROP DATABASE mysqltest_db1;
46 USE test;
48 # Bug#45235: 5.1 does not support 5.0-only syntax triggers in any way
50 DROP TABLE IF EXISTS t1, t2, t3;
51 CREATE TABLE t1 ( a INT );
52 CREATE TABLE t2 ( a INT );
53 CREATE TABLE t3 ( a INT );
54 INSERT INTO t1 VALUES (1), (2), (3);
55 INSERT INTO t2 VALUES (1), (2), (3);
56 INSERT INTO t3 VALUES (1), (2), (3);
57 # We simulate importing a trigger from 5.0 by writing a .TRN file for
58 # each trigger plus a .TRG file the way MySQL 5.0 would have done it, 
59 # with syntax allowed in 5.0 only.
61 # Note that in 5.0 the following lines are missing from t1.TRG:
63 # client_cs_names='latin1'
64 # connection_cl_names='latin1_swedish_ci'
65 # db_cl_names='latin1_swedish_ci'
66 # We will get parse errors for most DDL and DML statements when the table
67 # has broken triggers. The parse error refers to the first broken 
68 # trigger.
69 CREATE TRIGGER tr16 AFTER UPDATE ON t1 FOR EACH ROW INSERT INTO t1 VALUES (1);
70 ERROR 42000: Trigger 'tr13' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a USING t1 a' at line 1'
71 CREATE TRIGGER tr22 BEFORE INSERT ON t2 FOR EACH ROW DELETE FROM non_existing_table;
72 ERROR 42000: Unknown trigger has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Not allowed syntax here, and trigger name cant be extracted either.' at line 1'
73 SHOW TRIGGERS;
74 Trigger Event   Table   Statement       Timing  Created sql_mode        Definer character_set_client    collation_connection    Database Collation
75 tr11    INSERT  t1      DELETE FROM t3  BEFORE  NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
76 tr12    INSERT  t1      DELETE FROM t3  AFTER   NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
77 tr14    DELETE  t1      DELETE FROM non_existing_table  AFTER   NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
78 Warnings:
79 Warning 1603    Triggers for table `test`.`t1` have no creation context
80 Warning 1603    Triggers for table `test`.`t2` have no creation context
81 INSERT INTO t1 VALUES (1);
82 ERROR 42000: Trigger 'tr13' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a USING t1 a' at line 1'
83 INSERT INTO t2 VALUES (1);
84 ERROR 42000: Unknown trigger has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Not allowed syntax here, and trigger name cant be extracted either.' at line 1'
85 DELETE FROM t1;
86 ERROR 42000: Trigger 'tr13' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a USING t1 a' at line 1'
87 UPDATE t1 SET a = 1 WHERE a = 1;
88 ERROR 42000: Trigger 'tr13' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a USING t1 a' at line 1'
89 SELECT * FROM t1;
94 RENAME TABLE t1 TO t1_2;
95 ERROR 42000: Trigger 'tr13' has an error in its body: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a USING t1 a' at line 1'
96 SHOW TRIGGERS;
97 Trigger Event   Table   Statement       Timing  Created sql_mode        Definer character_set_client    collation_connection    Database Collation
98 tr11    INSERT  t1      DELETE FROM t3  BEFORE  NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
99 tr12    INSERT  t1      DELETE FROM t3  AFTER   NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
100 tr14    DELETE  t1      DELETE FROM non_existing_table  AFTER   NULL            root@localhost  latin1  latin1_swedish_ci       latin1_swedish_ci
101 Warnings:
102 Warning 1603    Triggers for table `test`.`t1` have no creation context
103 DROP TRIGGER tr11;
104 Warnings:
105 Warning 1603    Triggers for table `test`.`t1` have no creation context
106 DROP TRIGGER tr12;
107 DROP TRIGGER tr13;
108 DROP TRIGGER tr14;
109 DROP TRIGGER tr15;
110 SHOW TRIGGERS;
111 Trigger Event   Table   Statement       Timing  Created sql_mode        Definer character_set_client    collation_connection    Database Collation
112 # Make sure there is no trigger file left.
113 # We write the same trigger files one more time to test DROP TABLE.
114 DROP TABLE t1;
115 Warnings:
116 Warning 1603    Triggers for table `test`.`t1` have no creation context
117 DROP TABLE t2;
118 Warnings:
119 Warning 1603    Triggers for table `test`.`t2` have no creation context
120 DROP TABLE t3;
121 # Make sure there is no trigger file left.
122 CREATE TABLE t1 ( a INT );
123 CREATE TABLE t2 ( a INT );
124 INSERT INTO t1 VALUES (1), (2), (3);
125 INSERT INTO t2 VALUES (1), (2), (3);
126 # We write three trigger files. First trigger is syntaxically incorrect, next trigger is correct
127 # and last trigger is broken.
128 # Next we try to execute SHOW CREATE TRGGIR command for broken trigger and then try to drop one.
129 FLUSH TABLE t1;
130 SHOW CREATE TRIGGER tr12;
131 Trigger sql_mode        SQL Original Statement  character_set_client    collation_connection    Database Collation
132 tr12            CREATE DEFINER=`root`@`localhost` TRIGGER tr12 BEFORE INSERT ON t1 FOR EACH ROW DELETE FROM t2  latin1  latin1_swedish_ci       latin1_swedish_ci
133 Warnings:
134 Warning 1603    Triggers for table `test`.`t1` have no creation context
135 SHOW CREATE TRIGGER tr11;
136 Trigger sql_mode        SQL Original Statement  character_set_client    collation_connection    Database Collation
137 tr11            CREATE DEFINER=`root`@`localhost` TRIGGER tr11 BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t1 a USING t1 a     latin1  latin1_swedish_ci       latin1_swedish_ci
138 DROP TRIGGER tr12;
139 Warnings:
140 Warning 1603    Triggers for table `test`.`t1` have no creation context
141 DROP TRIGGER tr11;
142 DROP TABLE t1;
143 DROP TABLE t2;