Commit d7e6ba47 authored by mleich@five.local.lan's avatar mleich@five.local.lan

Post fix for

WL#4203 Reorganize and fix the data dictionary tests of
        testsuite funcs_1
because the goal to fix
Bug#34532 Some funcs_1 tests do not clean up at end of testing
was partially missed.
Some minor additional modifications are for
   WL#4304 Cleanup in funcs_1 tests
parent 3f6e20a0
#### suite/funcs_1/cursors/cursors_master.test
let $message= NOT YET IMPLEMENTED: cursor tests;
--source include/show_msg80.inc
......@@ -67,56 +67,40 @@ let $engine_myisam= `SELECT @ENGINE_MYISAM = 1`;
let $engine_innodb= `SELECT @ENGINE_INNODB = 1`;
let $engine_memory= `SELECT @ENGINE_MEMORY = 1`;
# Decide, if the objects are to be (re)created
#
# - once at the beginning of a set of testcases ('$NO_REFRESH' <> '' --> TRUE)
# That means the current script must not (re)create any object.
# It can expect, that the objects already exist.
#
# - per every testscript/case ('$NO_REFRESH' = '' --> FALSE)
# That means all objects have to be (re)created within the current script.
#
eval SET @NO_REFRESH = IF( '$NO_REFRESH' = '', 0, 1);
let $run= `SELECT @NO_REFRESH = 0`;
if ($run)
{
--disable_warnings
DROP DATABASE IF EXISTS test1;
--enable_warnings
CREATE DATABASE test1;
USE test;
--disable_warnings
DROP DATABASE IF EXISTS test1;
--enable_warnings
CREATE DATABASE test1;
USE test;
# until a statement 'eval --source suite/funcs_1/include/$var_tb1.inc
# works we need to have similar statements for each $engine
if ($engine_innodb)
{
if ($engine_innodb)
{
--source suite/funcs_1/include/innodb_tb1.inc
--source suite/funcs_1/include/innodb_tb2.inc
--source suite/funcs_1/include/innodb_tb3.inc
--source suite/funcs_1/include/innodb_tb4.inc
USE test1;
--source suite/funcs_1/include/innodb_tb2.inc
}
}
if ($engine_memory)
{
if ($engine_memory)
{
--source suite/funcs_1/include/memory_tb1.inc
--source suite/funcs_1/include/memory_tb2.inc
--source suite/funcs_1/include/memory_tb3.inc
--source suite/funcs_1/include/memory_tb4.inc
USE test1;
--source suite/funcs_1/include/memory_tb2.inc
}
}
if ($engine_myisam)
{
if ($engine_myisam)
{
--source suite/funcs_1/include/myisam_tb1.inc
--source suite/funcs_1/include/myisam_tb2.inc
--source suite/funcs_1/include/myisam_tb3.inc
--source suite/funcs_1/include/myisam_tb4.inc
USE test1;
--source suite/funcs_1/include/myisam_tb2.inc
}
USE test;
--source suite/funcs_1/include/sp_tb.inc
}
USE test;
--source suite/funcs_1/include/sp_tb.inc
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
SET @NO_REFRESH = IF( '' = '', 0, 1);
USE test;
drop table if exists tb3 ;
create table tb3 (
f118 char not null DEFAULT 'a',
f119 char binary not null DEFAULT b'101',
f120 char ascii not null DEFAULT b'101',
f121 tinytext,
f122 text,
f123 mediumtext,
f124 longtext unicode,
f125 tinyblob,
f126 blob,
f127 mediumblob,
f128 longblob,
f129 binary not null DEFAULT b'101',
f130 tinyint not null DEFAULT 99,
f131 tinyint unsigned not null DEFAULT 99,
f132 tinyint zerofill not null DEFAULT 99,
f133 tinyint unsigned zerofill not null DEFAULT 99,
f134 smallint not null DEFAULT 999,
f135 smallint unsigned not null DEFAULT 999,
f136 smallint zerofill not null DEFAULT 999,
f137 smallint unsigned zerofill not null DEFAULT 999,
f138 mediumint not null DEFAULT 9999,
f139 mediumint unsigned not null DEFAULT 9999,
f140 mediumint zerofill not null DEFAULT 9999,
f141 mediumint unsigned zerofill not null DEFAULT 9999,
f142 int not null DEFAULT 99999,
f143 int unsigned not null DEFAULT 99999,
f144 int zerofill not null DEFAULT 99999,
f145 int unsigned zerofill not null DEFAULT 99999,
f146 bigint not null DEFAULT 999999,
f147 bigint unsigned not null DEFAULT 999999,
f148 bigint zerofill not null DEFAULT 999999,
f149 bigint unsigned zerofill not null DEFAULT 999999,
f150 decimal not null DEFAULT 999.999,
f151 decimal unsigned not null DEFAULT 999.17,
f152 decimal zerofill not null DEFAULT 999.999,
f153 decimal unsigned zerofill,
f154 decimal (0),
f155 decimal (64),
f156 decimal (0) unsigned,
f157 decimal (64) unsigned,
f158 decimal (0) zerofill,
f159 decimal (64) zerofill,
f160 decimal (0) unsigned zerofill,
f161 decimal (64) unsigned zerofill,
f162 decimal (0,0),
f163 decimal (63,30),
f164 decimal (0,0) unsigned,
f165 decimal (63,30) unsigned,
f166 decimal (0,0) zerofill,
f167 decimal (63,30) zerofill,
f168 decimal (0,0) unsigned zerofill,
f169 decimal (63,30) unsigned zerofill,
f170 numeric,
f171 numeric unsigned,
f172 numeric zerofill,
f173 numeric unsigned zerofill,
f174 numeric (0),
f175 numeric (64)
) engine = innodb;
Warnings:
Note 1265 Data truncated for column 'f150' at row 1
Note 1265 Data truncated for column 'f151' at row 1
Note 1265 Data truncated for column 'f152' at row 1
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/innodb_tb3.txt' into table tb3 ;
Testcase: 3.5:
--------------
create User test_general@localhost;
set password for test_general@localhost = password('PWD');
revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost;
create User test_super@localhost;
set password for test_super@localhost = password('PWD');
grant ALL on *.* to test_super@localhost with grant OPTION;
connect(localhost,test_general,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_super,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase: 3.5.1.1:
------------------
use test;
Create trigger trg1_1 BEFORE INSERT
on tb3 for each row set @test_before = 2, new.f142 = @test_before;
Create trigger trg1_2 AFTER INSERT
on tb3 for each row set @test_after = 6;
Create trigger trg1_4 BEFORE UPDATE
on tb3 for each row set @test_before = 27,
new.f142 = @test_before,
new.f122 = 'Before Update Trigger';
Create trigger trg1_3 AFTER UPDATE
on tb3 for each row set @test_after = '15';
Create trigger trg1_5 BEFORE DELETE on tb3 for each row
select count(*) into @test_before from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
Create trigger trg1_6 AFTER DELETE on tb3 for each row
select count(*) into @test_after from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
set @test_before = 1;
set @test_after = 5;
select @test_before, @test_after;
@test_before @test_after
1 5
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'First Row', @test_before, @test_after, 1);
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 First Row 2 0000000005 1
select @test_before, @test_after;
@test_before @test_after
2 6
set @test_before = 18;
set @test_after = 8;
select @test_before, @test_after;
@test_before @test_after
18 8
Update tb3 set tb3.f122 = 'Update',
tb3.f142 = @test_before,
tb3.f144 = @test_after
where tb3.f121 = 'Test 3.5.1.1';
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
27 15
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'Second Row', 5, 6, 2);
set @test_before = 0;
set @test_after = 0;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
Test 3.5.1.1 Second Row 2 0000000006 2
select @test_before, @test_after;
@test_before @test_after
0 0
Delete from tb3 where f121 = 'Test 3.5.1.1' and f134 = 2;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
2 1
drop trigger trg1_1;
drop trigger trg1_2;
drop trigger trg1_3;
drop trigger trg1_4;
drop trigger trg1_5;
drop trigger trg1_6;
delete from tb3 where f121='Test 3.5.1.1';
Testcase: 3.5.1.2:
------------------
Create trigger trg_1 after insert
on tb3 for each statement set @x= 1;
ERROR 42000: 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 'statement set @x= 1' at line 2
drop trigger trg_1;
Testcase 3.5.1.3:
-----------------
CREATE TRIGGER trg3_1 on tb3 BEFORE INSERT for each row set new.f120 = 't';
ERROR 42000: 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 'on tb3 BEFORE INSERT for each row set new.f120 = 't'' at line 1
CREATE trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's';
ERROR 42000: 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 'trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's'' at line 1
CREATE TRIGGER trg3_3 Before DELETE on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'set @ret1 = 'test' for each row' at line 1
CREATE TRIGGER trg3_4 DELETE AFTER on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'DELETE AFTER on tb3 set @ret1 = 'test' for each row' at line 1
CREATE for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test';
ERROR 42000: 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 'for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test'' at line 1
drop trigger trg3_1;
drop trigger trg3_2;
drop trigger trg3_3;
drop trigger trg3_4;
drop trigger trg3_5;
Testcase: 3.5.1.5:
------------------
CREATE TRIGGER trg4_1 AFTER on tb3 for each row set new.f120 = 'e';
ERROR 42000: 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 'on tb3 for each row set new.f120 = 'e'' at line 1
CREATE TRIGGER trg4_2 INSERT on tb3 for each set row new.f120 = 'f';
ERROR 42000: 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 'INSERT on tb3 for each set row new.f120 = 'f'' at line 1
CREATE TRIGGER trg4_3 BEFORE INSERT tb3 for each row set new.f120 = 'g';
ERROR 42000: 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 'tb3 for each row set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_4 AFTER UPDATE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'set new.f120 = 'g'' at line 1
CREATE trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_6 BEFORE DELETE for each row set new.f120 = 'g';
ERROR 42000: 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 'for each row set new.f120 = 'g'' at line 1
drop trigger trg4_1;
drop trigger trg4_2;
drop trigger trg4_3;
drop trigger trg4_4;
drop trigger trg4_5;
drop trigger trg4_6;
Testcase 3.5.1.6: - Need to fix
-------------------------------
Testcase 3.5.1.7: - need to fix
-------------------------------
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (f1 int, f2 char(25),f3 int) engine=innodb;
CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
for each row set new.f3 = '14';
CREATE TRIGGER trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
BEFORE UPDATE on test.t1 for each row set new.f3 = '42';
insert into t1 (f2) values ('insert 3.5.1.7');
select * from t1;
f1 f2 f3
NULL insert 3.5.1.7 14
update t1 set f2='update 3.5.1.7';
select * from t1;
f1 f2 f3
NULL update 3.5.1.7 42
select trigger_name from information_schema.triggers;
trigger_name
trg5_1
trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWX
drop trigger trg5_1;
drop trigger trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ;
drop table t1;
Testcase 3.5.1.8:
-----------------
CREATE TRIGGER trg12* before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '* before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER trigger before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 'trigger before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER 100 before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '100 before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @@view before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@@view before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @name before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@name before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER tb3.trg6_1 BEFORE INSERT on test.tb3
for each row set new.f120 ='X';
ERROR HY000: Trigger in wrong schema
drop database if exists trig_db;
create database trig_db;
use trig_db;
create table t1 (f1 integer) engine = innodb;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
ERROR HY000: Trigger in wrong schema
use test;
drop database trig_db;
drop trigger trg6_1;
drop trigger trg6_3;
Testcase 3.5.1.9:(cannot be inplemented at this point)
------------------------------------------------------
Testcase 3.5.1.10:
------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X';
CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger already exists
drop trigger trg7_1;
Testcase 3.5.1.?:
-----------------
drop table if exists t1;
drop table if exists t2;
create table t1 (f1 char(50), f2 integer) engine = innodb;
create table t2 (f1 char(50), f2 integer) engine = innodb;
create trigger trig before insert on t1
for each row set new.f1 ='trig t1';
create trigger trig before update on t2
for each row set new.f1 ='trig t2';
ERROR HY000: Trigger already exists
insert into t1 value ('insert to t1',1);
select * from t1;
f1 f2
trig t1 1
update t1 set f1='update to t1';
select * from t1;
f1 f2
update to t1 1
insert into t2 value ('insert to t2',2);
update t2 set f1='update to t1';
select * from t2;
f1 f2
update to t1 2
drop table t1;
drop table t2;
drop trigger trig;
Testcase 3.5.1.11:
------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
drop database if exists trig_db3;
create database trig_db1;
create database trig_db2;
create database trig_db3;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = innodb;
create trigger trig before insert on t1
for each row set new.f1 ='trig1', @test_var1='trig1';
use trig_db2;
create table t2 (f1 char(50), f2 integer) engine = innodb;
create trigger trig before insert on t2
for each row set new.f1 ='trig2', @test_var2='trig2';
use trig_db3;
create table t1 (f1 char(50), f2 integer) engine = innodb;
create trigger trig before insert on t1
for each row set new.f1 ='trig3', @test_var3='trig3';
set @test_var1= '', @test_var2= '', @test_var3= '';
use trig_db1;
insert into t1 (f1,f2) values ('insert to db1 t1',1);
insert into trig_db1.t1 (f1,f2) values ('insert to db1 t1 from db1',2);
insert into trig_db2.t2 (f1,f2) values ('insert to db2 t2 from db1',3);
insert into trig_db3.t1 (f1,f2) values ('insert to db3 t1 from db1',4);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1 trig2 trig3
select * from t1;
f1 f2
trig1 1
trig1 2
select * from trig_db2.t2;
f1 f2
trig2 3
select * from trig_db3.t1;
f1 f2
trig3 4
select * from t1;
f1 f2
trig1 1
trig1 2
use test;
drop database trig_db1;
drop database trig_db2;
drop database trig_db3;
Testcase 3.5.2.1/2/3:
---------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
create database trig_db1;
create database trig_db2;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = innodb;
create table trig_db2.t1 (f1 char(50), f2 integer) engine = innodb;
create trigger trig1_b before insert on t1
for each row set @test_var1='trig1_b';
create trigger trig_db1.trig1_a after insert on t1
for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
trig_db1 trig1_b t1
trig_db1 trig1_a t1
trig_db2 trig2 t1
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1_b trig1_a trig2
drop database trig_db1;
drop database trig_db2;
Testcase 3.5.3:
---------------
drop database if exists priv_db;
create database priv_db;
use priv_db;
create table t1 (f1 char(20));
create User test_noprivs@localhost;
set password for test_noprivs@localhost = password('PWD');
create User test_yesprivs@localhost;
set password for test_yesprivs@localhost = password('PWD');
Testcase 3.5.3.2/6:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SUPER on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase 3.5.3.2:
-----------------
select current_user;
current_user
test_noprivs@localhost
use priv_db;
create trigger trg1_1 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_1-no';
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-no');
select f1 from t1;
f1
insert 3.5.3.2-no
select current_user;
current_user
test_yesprivs@localhost
use priv_db;
create trigger trg1_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_2-yes';
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
Testcase 3.5.3.6:
-----------------
use priv_db;
drop trigger trg1_2;
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
use priv_db;
drop trigger trg1_2;
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-no');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
drop trigger trg1_2;
Testcase 3.5.3.7a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke UPDATE on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, UPDATE on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1a');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
drop trigger trg4a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg4a_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2a';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
drop trigger trg4a_2;
Testcase 3.5.3.7b:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke UPDATE on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
insert 3.5.3.7-1b
update t1 set f1 = 'update 3.5.3.7-1b' where f1 = 'insert 3.5.3.7-1b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
drop trigger trg4b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4b_2 before UPDATE on t1 for each row
set new.f1 = 'trig 3.5.3.7-2b';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
insert 3.5.3.7-2b
update t1 set f1 = 'update 3.5.3.7-2b' where f1 = 'insert 3.5.3.7-2b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
drop trigger trg4b_2;
Testcase 3.5.3.7c
-----------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke UPDATE on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
drop trigger trg4c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4c_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2c';
insert into t1 (f1) values ('insert 3.5.3.7-2c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
drop trigger trg4c_2;
Testcase 3.5.3.7d:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant SELECT (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1), INSERT (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
drop trigger trg4d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4d_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2d';
insert into t1 (f1) values ('insert 3.5.3.7-2d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
trig 3.5.3.7-2d
drop trigger trg4d_2;
Testcase 3.5.3.8a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SELECT on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, SELECT on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var = 'before trig 3.5.3.8-1a';
select @test_var;
@test_var
before trig 3.5.3.8-1a
insert into t1 (f1) values ('insert 3.5.3.8-1a');
select @test_var;
@test_var
before trig 3.5.3.8-1a
drop trigger trg5a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg5a_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2a';
select @test_var;
@test_var
before trig 3.5.3.8-2a
insert into t1 (f1) values ('insert 3.5.3.8-2a');
select @test_var;
@test_var
insert 3.5.3.8-2a
drop trigger trg5a_2;
Testcase: 3.5.3.8b
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke SELECT on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1b';
insert into t1 (f1) values ('insert 3.5.3.8-1b');
select @test_var;
@test_var
before trig 3.5.3.8-1b
update t1 set f1= 'update 3.5.3.8-1b' where f1 = 'insert 3.5.3.8-1b';
select @test_var;
@test_var
before trig 3.5.3.8-1b
drop trigger trg5b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5b_2 before UPDATE on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2b';
insert into t1 (f1) values ('insert 3.5.3.8-2b');
select @test_var;
@test_var
before trig 3.5.3.8-2b
update t1 set f1= 'update 3.5.3.8-2b' where f1 = 'insert 3.5.3.8-2b';
select @test_var;
@test_var
update 3.5.3.8-2b
drop trigger trg5b_2;
Testcase 3.5.3.8c:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke SELECT on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1c';
insert into t1 (f1) values ('insert 3.5.3.8-1c');
select @test_var;
@test_var
before trig 3.5.3.8-1c
drop trigger trg5c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5c_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2c';
insert into t1 (f1) values ('insert 3.5.3.8-2c');
select @test_var;
@test_var
insert 3.5.3.8-2c
drop trigger trg5c_2;
Testcase: 3.5.3.8d:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant UPDATE (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var='before trig 3.5.3.8-1d';
insert into t1 (f1) values ('insert 3.5.3.8-1d');
select @test_var;
@test_var
before trig 3.5.3.8-1d
drop trigger trg5d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5d_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2d';
insert into t1 (f1) values ('insert 3.5.3.8-2d');
select @test_var;
@test_var
insert 3.5.3.8-2d
drop trigger trg5d_2;
drop database if exists priv_db;
drop user test_yesprivs@localhost;
drop user test_noprivs@localhost;
drop user test_noprivs;
Testcase 3.5.4:
---------------
use test;
Testcase 3.5.4.1:
-----------------
create database db_drop;
Use db_drop;
create table t1 (f1 char(30)) engine=innodb;
grant INSERT, SELECT on db_drop.t1 to test_general;
Use db_drop;
Create trigger trg1 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.1';
Use db_drop;
Insert into t1 values ('Insert error 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
Insert no trigger 3.5.4.1
drop trigger trg1;
drop database if exists db_drop;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.2:
-----------------
create database db_drop2;
Use db_drop2;
drop table if exists t1_432 ;
create table t1_432 (f1 char (30)) engine=innodb;
Drop trigger tr_does_not_exit;
ERROR HY000: Trigger does not exist
drop table if exists t1_432 ;
drop database if exists db_drop2;
Testcase 3.5.4.3:
-----------------
create database db_drop3;
Use db_drop3;
drop table if exists t1_433 ;
drop table if exists t1_433a ;
create table t1_433 (f1 char (30)) engine=innodb;
create table t1_433a (f1a char (5)) engine=innodb;
CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row
set new.f1 = 'Trigger 3.5.4.3';
Drop trigger t1.433.trg3;
ERROR 42000: 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 '.trg3' at line 1
Drop trigger db_drop3.t1.433.trg3;
ERROR 42000: 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 '.433.trg3' at line 1
Drop trigger mysql.trg3;
ERROR HY000: Trigger does not exist
Drop trigger tbx.trg3;
ERROR HY000: Trigger does not exist
Drop trigger db_drop3.trg3;
drop table if exists t1_433;
drop table if exists t1_433a;
drop database if exists db_drop3;
Testcase 3.5.4.4:
-----------------
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=innodb;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Create trigger trg4 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.4';
Use db_drop4;
Insert into t1 values ('Insert 3.5.4.4');
Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
Show databases;
Database
information_schema
mysql
test
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
trigger_schema trigger_name event_object_table
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=innodb;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.4');
Select * from t1;
f1
2nd Insert 3.5.4.4
drop trigger trg4;
ERROR HY000: Trigger does not exist
drop database if exists db_drop4;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.5:
-----------------
create database db_drop5;
Use db_drop5;
create table t1 (f1 char(50)) engine=innodb;
grant INSERT, SELECT on t1 to test_general;
Create trigger trg5 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.5';
Use db_drop5;
Insert into t1 values ('Insert 3.5.4.5');
Select * from t1;
f1
Trigger 3.5.4.5
Drop table t1;
Show tables;
Tables_in_db_drop5
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg5';
trigger_schema trigger_name event_object_table
create table t1 (f1 char(50)) engine=innodb;
grant INSERT, SELECT on t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.5');
Select * from t1;
f1
2nd Insert 3.5.4.5
drop trigger trg5;
ERROR HY000: Trigger does not exist
drop database if exists db_drop5;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.5:
---------------
use test;
Testcase 3.5.5.1:
-----------------
Create trigger trg1 before INSERT on t100 for each row set new.f2=1000;
ERROR 42S02: Table 'test.t100' doesn't exist
Testcase 3.5.5.2:
-----------------
Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned);
Create trigger trg2 before INSERT
on t1_temp for each row set new.f2=9999;
ERROR HY000: Trigger's 't1_temp' is view or temporary table
drop table t1_temp;
Testcase 3.5.5.3:
-----------------
Create view vw3 as select f118 from tb3;
Create trigger trg3 before INSERT
on vw3 for each row set new.f118='s';
ERROR HY000: 'test.vw3' is not BASE TABLE
drop view vw3;
Testcase 3.5.5.4:
-----------------
create database dbtest_one;
create database dbtest_two;
use dbtest_two;
create table t2 (f1 char(15));
use dbtest_one;
create trigger trg4 before INSERT
on dbtest_two.t2 for each row set new.f1='trig 3.5.5.4';
ERROR HY000: Trigger in wrong schema
grant INSERT, SELECT on dbtest_two.t2 to test_general;
grant SELECT on dbtest_one.* to test_general;
use dbtest_two;
Insert into t2 values ('1st Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from t2;
f1
1st Insert 3.5.
use dbtest_one;
Insert into dbtest_two.t2 values ('2nd Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from dbtest_two.t2;
f1
1st Insert 3.5.
2nd Insert 3.5.
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
DROP DATABASE if exists dbtest_one;
drop database if EXISTS dbtest_two;
Testcase 3.5.6:
---------------
use test;
Testcase 3.5.6.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.3:
-----------------
Create trigger trg3_1 DURING UPDATE on tb3 for each row set new.f132=25;
ERROR 42000: 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 'DURING UPDATE on tb3 for each row set new.f132=25' at line 1
Create trigger trg3_2 TIME INSERT on tb3 for each row set new.f132=15;
ERROR 42000: 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 'TIME INSERT on tb3 for each row set new.f132=15' at line 1
drop trigger tb3.trg3_1;
drop trigger tb3.trg3_2;
Testcase 3.5.6.4 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.5 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.3 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.4:
-----------------
Create trigger trg4_1 BEFORE SELECT on tb3 for each row set new.f132=5;
ERROR 42000: 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 'SELECT on tb3 for each row set new.f132=5' at line 1
Create trigger trg4_2 AFTER VALUE on tb3 for each row set new.f132=1;
ERROR 42000: 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 'VALUE on tb3 for each row set new.f132=1' at line 1
drop trigger tb3.trg4_1;
drop trigger tb3.trg4_2;
Testcase 3.5.7.5 / 3.5.7.6:
---------------------------
Create trigger trg5_1 BEFORE INSERT
on tb3 for each row set new.f122='Trigger1 3.5.7.5/6';
Create trigger trg5_2 BEFORE INSERT
on tb3 for each row set new.f122='Trigger2 3.5.7.5';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.5/6','Insert 3.5.7.5');
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Trigger1 3.5.7.5/6
update tb3 set f122='Update 3.5.7.6' where f121= 'Test 3.5.7.5/6';
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Update 3.5.7.6
drop trigger trg5_1;
drop trigger trg5_2;
delete from tb3 where f121='Test 3.5.7.5/6';
Testcase 3.5.7.7 / 3.5.7.8:
---------------------------
set @test_var='Before trig 3.5.7.7';
Create trigger trg6_1 AFTER INSERT
on tb3 for each row set @test_var='Trigger1 3.5.7.7/8';
Create trigger trg6_2 AFTER INSERT
on tb3 for each row set @test_var='Trigger2 3.5.7.7';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.7
Insert into tb3 (f121,f122) values ('Test 3.5.7.7/8','Insert 3.5.7.7');
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Insert 3.5.7.7
select @test_var;
@test_var
Trigger1 3.5.7.7/8
update tb3 set f122='Update 3.5.7.8' where f121= 'Test 3.5.7.7/8';
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Update 3.5.7.8
select @test_var;
@test_var
Trigger1 3.5.7.7/8
drop trigger trg6_1;
drop trigger trg6_2;
delete from tb3 where f121='Test 3.5.7.7/8';
Testcase 3.5.7.9/10:
--------------------
Create trigger trg7_1 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger1 3.5.7.9/10';
Create trigger trg7_2 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger2 3.5.7.9';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.9/10','Insert 3.5.7.9');
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Insert 3.5.7.9
update tb3 set f122='update 3.5.7.10' where f121='Test 3.5.7.9/10';
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Trigger1 3.5.7.9/10
drop trigger trg7_1;
drop trigger trg7_2;
delete from tb3 where f121='Test 3.5.7.9/10';
Testcase 3.5.7.11/12:
---------------------
set @test_var='Before trig 3.5.7.11';
Create trigger trg8_1 AFTER UPDATE
on tb3 for each row set @test_var='Trigger 3.5.7.11/12';
Create trigger trg8_2 AFTER UPDATE
on tb3 for each row set @test_var='Trigger2 3.5.7.11';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.11
Insert into tb3 (f121,f122) values ('Test 3.5.7.11/12','Insert 3.5.7.11/12');
select @test_var;
@test_var
Before trig 3.5.7.11
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 Insert 3.5.7.11/12
update tb3 set f122='update 3.5.7.12' where f121='Test 3.5.7.11/12';
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 update 3.5.7.12
select @test_var;
@test_var
Trigger 3.5.7.11/12
delete from tb3 where f121='Test 3.5.7.11/12';
drop trigger trg8_1;
drop trigger trg8_2;
delete from tb3 where f121='Test 3.5.7.11/12';
Testcase 3.5.7.13/14:
---------------------
set @test_var=1;
Create trigger trg9_1 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+1;
Create trigger trg9_2 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+10;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.13/14','Insert 3.5.7.13');
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
Test 3.5.7.13/14 Insert 3.5.7.13
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.13/14';
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
select @test_var;
@test_var
2
delete from tb3 where f121='Test 3.5.7.13/14';
select @test_var;
@test_var
2
drop trigger trg9_1;
drop trigger trg9_2;
delete from tb3 where f121='Test 3.5.7.13/14';
Testcase 3.5.7.15/16:
---------------------
set @test_var=1;
Create trigger trg_3_406010_1 AFTER DELETE
on tb3 for each row set @test_var=@test_var+5;
Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50;
ERROR HY000: Trigger already exists
Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.15/16','Insert 3.5.7.15/16');
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
Test 3.5.7.15/16 Insert 3.5.7.15/16
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.15/16';
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
select @test_var;
@test_var
6
delete from tb3 where f121='Test 3.5.7.15/16';
select @test_var;
@test_var
6
drop trigger trg_3_406010_1;
drop trigger trg_3_406010_2;
delete from tb3 where f121='Test 3.5.7.15/16';
Testcase 3.5.7.17 (see Testcase 3.5.1.1)
----------------------------------------
Testcase 3.5.8.1: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.2: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.3/4:
-------------------
create database db_test;
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
grant LOCK TABLES on db_test.* to test_general;
Use db_test;
create table t1_i (
i120 char ascii not null DEFAULT b'101',
i136 smallint zerofill not null DEFAULT 999,
i144 int zerofill not null DEFAULT 99999,
i163 decimal (63,30)) engine=innodb;
create table t1_u (
u120 char ascii not null DEFAULT b'101',
u136 smallint zerofill not null DEFAULT 999,
u144 int zerofill not null DEFAULT 99999,
u163 decimal (63,30)) engine=innodb;
create table t1_d (
d120 char ascii not null DEFAULT b'101',
d136 smallint zerofill not null DEFAULT 999,
d144 int zerofill not null DEFAULT 99999,
d163 decimal (63,30)) engine=innodb;
Insert into t1_u values ('a',111,99999,999.99);
Insert into t1_u values ('b',222,99999,999.99);
Insert into t1_u values ('c',333,99999,999.99);
Insert into t1_u values ('d',222,99999,999.99);
Insert into t1_u values ('e',222,99999,999.99);
Insert into t1_u values ('f',333,99999,999.99);
Insert into t1_d values ('a',111,99999,999.99);
Insert into t1_d values ('b',222,99999,999.99);
Insert into t1_d values ('c',333,99999,999.99);
Insert into t1_d values ('d',444,99999,999.99);
Insert into t1_d values ('e',222,99999,999.99);
Insert into t1_d values ('f',222,99999,999.99);
3.5.8.4 - multiple SQL
----------------------
use test;
Create trigger trg1 AFTER INSERT on tb3 for each row
BEGIN
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update db_test.t1_u
set u144=new.f144, u163=new.f163
where u136=new.f136;
delete from db_test.t1_d where d136= new.f136;
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
END//
Use test;
set @test_var=0;
Insert into tb3 (f120, f122, f136, f144, f163)
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
f120 f122 f136 f144 f163
1 Test 3.5.8.4 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
b 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00222 0000023456 1.050000000000000000000000000000
e 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00444 0000099999 999.990000000000000000000000000000
select @test_var;
@test_var
3.150000000000000000000000000000
3.5.8.4 - single SQL - insert
-----------------------------
Create trigger trg2 BEFORE UPDATE on tb3 for each row
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update tb3 set f120='I', f122='Test 3.5.8.4-Single Insert'
where f122='Test 3.5.8.4';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
I Test 3.5.8.4-Single Insert 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
I 00222 0000023456 1.050000000000000000000000000000
3.5.8.4 - single SQL - update
-----------------------------
drop trigger trg2;
Create trigger trg3 BEFORE UPDATE on tb3 for each row
update db_test.t1_u
set u120=new.f120
where u136=new.f136;
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
where f122='Test 3.5.8.4-Single Insert';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
U Test 3.5.8.4-Single Update 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - delete
-------------------------------
drop trigger trg3;
Create trigger trg4 AFTER UPDATE on tb3 for each row
delete from db_test.t1_d where d136= new.f136;
update tb3 set f120='D', f136=444,
f122='Test 3.5.8.4-Single Delete'
where f122='Test 3.5.8.4-Single Update';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
D Test 3.5.8.4-Single Delete 00444 0000023456 1.050000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - select
-------------------------------
drop trigger trg4;
Create trigger trg5 AFTER UPDATE on tb3 for each row
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
set @test_var=0;
update tb3 set f120='S', f136=111,
f122='Test 3.5.8.4-Single Select'
where f122='Test 3.5.8.4-Single Delete';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
S Test 3.5.8.4-Single Select 00111 0000023456 1.050000000000000000000000000000
select @test_var;
@test_var
999.990000000000000000000000000000
drop trigger trg1;
drop trigger trg5;
drop database if exists db_test;
delete from tb3 where f122 like 'Test 3.5.8.4%';
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.8.5 (IF):
----------------------
create trigger trg2 before insert on tb3 for each row
BEGIN
IF new.f120='1' then
set @test_var='one', new.f120='2';
ELSEIF new.f120='2' then
set @test_var='two', new.f120='3';
ELSEIF new.f120='3' then
set @test_var='three', new.f120='4';
END IF;
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END IF;
END//
set @test_var='Empty', @test_var2=0;
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 one 2nd else
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 two 2nd else
D Test 3.5.8.5-if 00102 two 2nd else
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd if
D Test 3.5.8.5-if 00102 three 2nd if
d Test 3.5.8.5-if 00010 three 2nd if
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd else
D Test 3.5.8.5-if 00102 three 2nd else
d Test 3.5.8.5-if 00010 three 2nd else
D Test 3.5.8.5-if 00103 three 2nd else
create trigger trg3 before update on tb3 for each row
BEGIN
ELSEIF new.f120='2' then
END IF;
END//
ERROR 42000: 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 'ELSEIF new.f120='2' then
END IF;
END' at line 3
drop trigger trg3//
create trigger trg4 before update on tb3 for each row
BEGIN
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END//
ERROR 42000: 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 '' at line 7
drop trigger trg4;
drop trigger trg2;
delete from tb3 where f121='Test 3.5.8.5-if';
Testcase 3.5.8.5-case:
----------------------
create trigger trg3 before insert on tb3 for each row
BEGIN
SET new.f120=char(ascii(new.f120)-32);
CASE
when new.f136<100 then set new.f136=new.f136+120;
when new.f136<10 then set new.f144=777;
when new.f136>100 then set new.f120=new.f136-1;
END case;
CASE
when new.f136=200 then set @test_var=CONCAT(new.f120, '=');
ELSE set @test_var=concat(new.f120, '*');
END case;
CASE new.f144
when 1 then set @test_var=concat(@test_var, 'one');
when 2 then set @test_var=concat(@test_var, 'two');
when 3 then set @test_var=concat(@test_var, 'three');
when 4 then set @test_var=concat(@test_var, 'four');
when 5 then set @test_var=concat(@test_var, 'five');
when 6 then set @test_var=concat(@test_var, 'six');
when 7 then set @test_var=concat(@test_var, 'seven');
when 8 then set @test_var=concat(@test_var, 'eight');
when 9 then set @test_var=concat(@test_var, 'nine');
when 10 then set @test_var=concat(@test_var, 'ten');
when 11 then set @test_var=concat(@test_var, 'eleven');
when 12 then set @test_var=concat(@test_var, 'twelve');
when 13 then set @test_var=concat(@test_var, 'thirteen');
when 14 then set @test_var=concat(@test_var, 'fourteen');
when 15 then set @test_var=concat(@test_var, 'fifteen');
ELSE set @test_var=CONCAT(new.f120, '*', new.f144);
END case;
END//
set @test_var='Empty';
Insert into tb3 (f120, f122, f136, f144)
values ('a', 'Test 3.5.8.5-case', 5, 7);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 A*seven
Insert into tb3 (f120, f122, f136, f144)
values ('b', 'Test 3.5.8.5-case', 71,16);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 B*0000000016
B Test 3.5.8.5-case 00191 0000000016 B*0000000016
Insert into tb3 (f120, f122, f136, f144)
values ('c', 'Test 3.5.8.5-case', 80,1);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 C=one
B Test 3.5.8.5-case 00191 0000000016 C=one
C Test 3.5.8.5-case 00200 0000000001 C=one
Insert into tb3 (f120, f122, f136)
values ('d', 'Test 3.5.8.5-case', 152);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1*0000099999
B Test 3.5.8.5-case 00191 0000000016 1*0000099999
C Test 3.5.8.5-case 00200 0000000001 1*0000099999
1 Test 3.5.8.5-case 00152 0000099999 1*0000099999
Insert into tb3 (f120, f122, f136, f144)
values ('e', 'Test 3.5.8.5-case', 200, 8);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
Insert into tb3 (f120, f122, f136, f144)
values ('f', 'Test 3.5.8.5-case', 100, 8);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
create trigger trg3a before update on tb3 for each row
BEGIN
CASE
when new.f136<100 then set new.f120='p';
END//
ERROR 42000: 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 '' at line 5
drop trigger trg3a;
drop trigger trg3;
delete from tb3 where f121='Test 3.5.8.5-case';
Testcase 3.5.8.5-loop/leave:
----------------------------
Create trigger trg4 after insert on tb3 for each row
BEGIN
set @counter=0, @flag='Initial';
Label1: loop
if new.f136<new.f144 then
set @counter='Nothing to loop';
leave Label1;
else
set @counter=@counter+1;
if new.f136=new.f144+@counter then
set @counter=concat(@counter, ' loops');
leave Label1;
end if;
end if;
iterate label1;
set @flag='Final';
END loop Label1;
END//
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 2, 8);
select @counter, @flag;
@counter @flag
Nothing to loop Initial
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 11, 8);
select @counter, @flag;
@counter @flag
3 loops Initial
Create trigger trg4_2 after update on tb3 for each row
BEGIN
Label1: loop
set @counter=@counter+1;
END;
END//
ERROR 42000: 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 ';
END' at line 5
drop trigger trg4_2;
drop trigger trg4;
delete from tb3 where f122='Test 3.5.8.5-loop';
Testcase 3.5.8.5-repeat:
------------------------
Create trigger trg6 after insert on tb3 for each row
BEGIN
rp_label: REPEAT
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label;
END IF;
SET @counter2 = @counter2 + 1;
UNTIL @counter1> new.f136 END REPEAT rp_label;
END//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-repeat', 13);
select @counter1, @counter2;
@counter1 @counter2
15 8
Create trigger trg6_2 after update on tb3 for each row
BEGIN
REPEAT
SET @counter2 = @counter2 + 1;
END//
ERROR 42000: 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 'END' at line 5
drop trigger trg6;
delete from tb3 where f122='Test 3.5.8.5-repeat';
Testcase 3.5.8.5-while:
-----------------------
Create trigger trg7 after insert on tb3 for each row
wl_label: WHILE @counter1 < new.f136 DO
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label;
END IF;
SET @counter2 = @counter2 + 1;
END WHILE wl_label//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-while', 7);
select @counter1, @counter2;
@counter1 @counter2
7 4
Create trigger trg7_2 after update on tb3 for each row
BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: 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 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
Testcase 3.5.8.6: (requirement void)
------------------------------------
Testcase 3.5.8.7: (Disabled as a result of bug _____)
-----------------------------------------------------
Testcase 3.5.9.1/2:
-------------------
Create trigger trg1 BEFORE UPDATE on tb3 for each row
set new.f142 = 94087, @counter=@counter+1;
TotalRows
19
Affected
17
NotAffected
2
NewValuew
0
set @counter=0;
Update tb3 Set f142='1' where f130<100;
select count(*) as ExpectedChanged, @counter as TrigCounter
from tb3 where f142=94087;
ExpectedChanged TrigCounter
17 17
select count(*) as ExpectedNotChange from tb3
where f130<100 and f142<>94087;
ExpectedNotChange
0
select count(*) as NonExpectedChanged from tb3
where f130>=130 and f142=94087;
NonExpectedChanged
0
drop trigger trg1;
Testcase 3.5.9.3:
-----------------
Create trigger trg2_a before update on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_b after update on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
Create trigger trg2_c before delete on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_d after delete on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
Insert into tb3 (f122, f136, f163)
values ('Test 3.5.9.3', 7, 123.17);
Update tb3 Set f136=8 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
a NULL Test 3.5.9.3 00008 123.170000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
delete from tb3 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
drop trigger trg2_a;
drop trigger trg2_b;
drop trigger trg2_c;
drop trigger trg2_d;
Testcase 3.5.9.4:
-----------------
Create trigger trg3_a before insert on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_b after insert on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
Create trigger trg3_c before update on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_d after update on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Insert into tb3 (f122, f136, f151, f163)
values ('Test 3.5.9.4', 7, DEFAULT, 995.24);
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4%';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4 00007 999 995.240000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'f136' at row 20
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4-trig 00000 999 NULL
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4-trig 0 999 NULL
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4-trig 0 999 NULL
drop trigger trg3_a;
drop trigger trg3_b;
drop trigger trg3_c;
drop trigger trg3_d;
delete from tb3 where f122='Test 3.5.9.4-trig';
Testcase 3.5.9.5: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.6:
-----------------
create trigger trg4a before insert on tb3 for each row
set @temp1= old.f120;
ERROR HY000: There is no OLD row in on INSERT trigger
create trigger trg4b after insert on tb3 for each row
set old.f120= 'test';
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg4a;
drop trigger trg4b;
Testcase 3.5.9.7: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.8: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.9:
-----------------
create trigger trg5a before DELETE on tb3 for each row
set @temp1=new.f122;
ERROR HY000: There is no NEW row in on DELETE trigger
create trigger trg5b after DELETE on tb3 for each row
set new.f122='test';
ERROR HY000: There is no NEW row in on DELETE trigger
drop trigger trg5a;
drop trigger trg5b;
Testcase 3.5.9.10: (implied in previous tests)
----------------------------------------------
Testcase 3.5.9.11: covered by 3.5.9.9
-------------------------------------
Testcase 3.5.9.12: covered by 3.5.9.6
-------------------------------------
Testcase 3.5.9.13:
------------------
create trigger trg6a before UPDATE on tb3 for each row
set old.f118='C', new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6b after INSERT on tb3 for each row
set old.f136=163, new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6c after UPDATE on tb3 for each row
set old.f136=NULL;
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg6a;
drop trigger trg6b;
drop trigger trg6c;
Testcase 3.5.9.14: (implied in previous tests)
----------------------------------------------
Testcase 3.5.10.1/2/3:
----------------------
Create view vw11 as select * from tb3
where f122 like 'Test 3.5.10.1/2/3%';
Create trigger trg1a before insert on tb3
for each row set new.f163=111.11;
Create trigger trg1b after insert on tb3
for each row set @test_var='After Insert';
Create trigger trg1c before update on tb3
for each row set new.f121='Y', new.f122='Test 3.5.10.1/2/3-Update';
Create trigger trg1d after update on tb3
for each row set @test_var='After Update';
Create trigger trg1e before delete on tb3
for each row set @test_var=5;
Create trigger trg1f after delete on tb3
for each row set @test_var= 2* @test_var+7;
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 1);
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 2);
Insert into vw11 (f122, f151) values ('Not in View', 3);
select f121, f122, f151, f163
from tb3 where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
select f121, f122, f151, f163
from tb3 where f122 like 'Not in View';
f121 f122 f151 f163
NULL Not in View 3 111.110000000000000000000000000000
Update vw11 set f163=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
set @test_var=0;
Select @test_var as 'before delete';
before delete
0
delete from vw11 where f151=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Select @test_var as 'after delete';
after delete
17
drop view vw11;
drop trigger trg1a;
drop trigger trg1b;
drop trigger trg1c;
drop trigger trg1d;
drop trigger trg1e;
drop trigger trg1f;
delete from tb3 where f122 like 'Test 3.5.10.1/2/3%';
Testcase 3.5.10.4:
------------------
create table tb_load (f1 int, f2 char(25),f3 int) engine=innodb;
Create trigger trg4 before insert on tb_load
for each row set new.f3=-(new.f1 div 5), @counter= @counter+1;
set @counter= 0;
select @counter as 'Rows Loaded Before';
Rows Loaded Before
0
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table tb_load;
select @counter as 'Rows Loaded After';
Rows Loaded After
10
Select * from tb_load limit 10;
f1 f2 f3
-5000 a` 1000
-4999 aaa 999
-4998 abaa 999
-4997 acaaa 999
-4996 adaaaa 999
-4995 aeaaaaa 999
-4994 afaaaaaa 998
-4993 agaaaaaaa 998
-4992 a^aaaaaaaa 998
-4991 a_aaaaaaaaa 998
drop trigger trg4;
drop table tb_load;
Testcase 3.5.10.5: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.6: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.extra:
----------------------
create table t1_sp (var136 tinyint, var151 decimal) engine=innodb;
create trigger trg before insert on t1_sp
for each row set @counter=@counter+1;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR 02000: No data to FETCH
select @counter;
@counter
20
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
20
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase 3.5.11.1 (implemented in trig_perf.test)
-------------------------------------------------
drop user test_general@localhost;
drop user test_general;
drop user test_super@localhost;
Testcase y.y.y.2: Check for triggers starting triggers
------------------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2_1;
drop table if exists t2_2;
drop table if exists t2_3;
drop table if exists t2_4;
drop table if exists t3;
create table t1 (f1 integer);
create table t2_1 (f1 integer);
create table t2_2 (f1 integer);
create table t2_3 (f1 integer);
create table t2_4 (f1 integer);
create table t3 (f1 integer);
insert into t1 values (1);
create trigger tr1 after insert on t1 for each row
BEGIN
insert into t2_1 (f1) values (new.f1+1);
insert into t2_2 (f1) values (new.f1+1);
insert into t2_3 (f1) values (new.f1+1);
insert into t2_4 (f1) values (new.f1+1);
END//
create trigger tr2_1 after insert on t2_1 for each row
insert into t3 (f1) values (new.f1+10);
create trigger tr2_2 after insert on t2_2 for each row
insert into t3 (f1) values (new.f1+100);
create trigger tr2_3 after insert on t2_3 for each row
insert into t3 (f1) values (new.f1+1000);
create trigger tr2_4 after insert on t2_4 for each row
insert into t3 (f1) values (new.f1+10000);
insert into t1 values (1);
select * from t3;
f1
12
102
1002
10002
drop trigger tr1;
drop trigger tr2_1;
drop trigger tr2_2;
drop trigger tr2_3;
drop trigger tr2_4;
drop table t1, t2_1, t2_2, t2_3, t2_4, t3;
Testcase y.y.y.3: Circular trigger reference
--------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = innodb;
create table t2 (f2 integer) engine = innodb;
create table t3 (f3 integer) engine = innodb;
create table t4 (f4 integer) engine = innodb;
insert into t1 values (0);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1);
create trigger tr4 after insert on t4
for each row insert into t1 (f1) values (new.f4+1);
insert into t1 values (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
select * from t1;
f1
0
select * from t2;
f2
select * from t3;
f3
select * from t4;
f4
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop trigger tr4;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
Testcase y.y.y.4: Recursive trigger/SP references (disabled bug 11889)
----------------------------------------------------------------------
set @sql_mode='traditional';
create table t1_sp (
count integer,
var136 tinyint,
var151 decimal) engine=innodb;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
set @counter= @counter+1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (@counter, var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
create trigger trg before insert on t1_sp
for each row call trig_sp();
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR HY000: Recursive stored routines are not allowed.
select @counter;
@counter
1
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
0
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase y.y.y.5: Roleback of nested trigger references
-------------------------------------------------------
set @@sql_mode='traditional';
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = innodb;
create table t2 (f2 integer) engine = innodb;
create table t3 (f3 integer) engine = innodb;
create table t4 (f4 tinyint) engine = innodb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values (1);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1000);
set autocommit=0;
start transaction;
insert into t1 values (1);
ERROR 22003: Out of range value adjusted for column 'f4' at row 1
commit;
select * from t1;
f1
1
select * from t2;
f2
select * from t3;
f3
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
Testcase x.x.x.1:
-----------------
DROP TABLE IF EXISTS t0, t1, t2;
CREATE TABLE t0 (col1 char(50)) ENGINE=innodb;
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
PRIMARY KEY (id)) ENGINE=innodb;
CREATE TABLE t2 (id INT PRIMARY KEY, f_id INT,
INDEX par_ind (f_id), col1 char(50),
FOREIGN KEY (f_id) REFERENCES t1(id)
ON DELETE SET NULL) ENGINE=innodb;
insert into t1 values (1,'Department A');
insert into t1 values (2,'Department B');
insert into t1 values (3,'Department C');
insert into t2 values (1,2,'Emp 1');
insert into t2 values (2,2,'Emp 2');
insert into t2 values (3,2,'Emp 3');
create trigger trig after insert on t0 for each row
delete from t1 where col1=new.col1;
select * from t2;
id f_id col1
1 2 Emp 1
2 2 Emp 2
3 2 Emp 3
lock tables t0 write, t1 write;
insert into t0 values ('Department B');
unlock tables;
select * from t2;
id f_id col1
1 NULL Emp 1
2 NULL Emp 2
3 NULL Emp 3
drop trigger trig;
drop table t2, t1;
Testcase x.x.x.2:
-----------------
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
PRIMARY KEY (id)) ENGINE=innodb;
CREATE TABLE t2 (id INT PRIMARY KEY, f_id INT,
INDEX par_ind (f_id), col1 char(50),
FOREIGN KEY (f_id) REFERENCES t1(id)
ON UPDATE CASCADE) ENGINE=innodb;
insert into t1 values (1,'Department A');
insert into t1 values (2,'Department B');
insert into t1 values (3,'Department C');
insert into t2 values (1,2,'Emp 1');
insert into t2 values (2,3,'Emp 2');
insert into t2 values (3,4,'Emp 3');
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `t1` (`id`) ON UPDATE CASCADE)
create trigger tr_t2 before insert on t2 for each row
insert into t1 values(new.f_id, concat('New Department ', new.f_id));
lock tables t1 write, t2 write;
insert into t2 values (3,4,'Emp 3');
unlock tables;
select * from t1;
id col1
1 Department A
2 Department B
3 Department C
4 New Department 4
select * from t2;
id f_id col1
1 2 Emp 1
2 3 Emp 2
3 4 Emp 3
drop trigger tr_t2;
drop table t2, t1;
Foreign Key tests disabled (bug 11472 - stored in trig_frkey2.test)
-------------------------------------------------------------------
This source diff could not be displayed because it is too large. You can view the blob instead.
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
SET @NO_REFRESH = IF( '' = '', 0, 1);
DROP DATABASE IF EXISTS test1;
CREATE DATABASE test1;
USE test;
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
SET @NO_REFRESH = IF( '' = '', 0, 1);
USE test;
set @@global.max_heap_table_size = 4294967295;
set @@session.max_heap_table_size = 4294967295;
drop table if exists tb3;
create table tb3 (
f118 char not null DEFAULT 'a',
f119 char binary not null DEFAULT b'101',
f120 char ascii not null DEFAULT b'101',
f121 char(50),
f122 char(50),
f129 binary not null DEFAULT b'101',
f130 tinyint not null DEFAULT 99,
f131 tinyint unsigned not null DEFAULT 99,
f132 tinyint zerofill not null DEFAULT 99,
f133 tinyint unsigned zerofill not null DEFAULT 99,
f134 smallint not null DEFAULT 999,
f135 smallint unsigned not null DEFAULT 999,
f136 smallint zerofill not null DEFAULT 999,
f137 smallint unsigned zerofill not null DEFAULT 999,
f138 mediumint not null DEFAULT 9999,
f139 mediumint unsigned not null DEFAULT 9999,
f140 mediumint zerofill not null DEFAULT 9999,
f141 mediumint unsigned zerofill not null DEFAULT 9999,
f142 int not null DEFAULT 99999,
f143 int unsigned not null DEFAULT 99999,
f144 int zerofill not null DEFAULT 99999,
f145 int unsigned zerofill not null DEFAULT 99999,
f146 bigint not null DEFAULT 999999,
f147 bigint unsigned not null DEFAULT 999999,
f148 bigint zerofill not null DEFAULT 999999,
f149 bigint unsigned zerofill not null DEFAULT 999999,
f150 decimal not null DEFAULT 999.999,
f151 decimal unsigned not null DEFAULT 999.17,
f152 decimal zerofill not null DEFAULT 999.999,
f153 decimal unsigned zerofill,
f154 decimal (0),
f155 decimal (64),
f156 decimal (0) unsigned,
f157 decimal (64) unsigned,
f158 decimal (0) zerofill,
f159 decimal (64) zerofill,
f160 decimal (0) unsigned zerofill,
f161 decimal (64) unsigned zerofill,
f162 decimal (0,0),
f163 decimal (63,30),
f164 decimal (0,0) unsigned,
f165 decimal (63,30) unsigned,
f166 decimal (0,0) zerofill,
f167 decimal (63,30) zerofill,
f168 decimal (0,0) unsigned zerofill,
f169 decimal (63,30) unsigned zerofill,
f170 numeric,
f171 numeric unsigned,
f172 numeric zerofill,
f173 numeric unsigned zerofill,
f174 numeric (0),
f175 numeric (64)
) engine = memory;
Warnings:
Note 1265 Data truncated for column 'f150' at row 1
Note 1265 Data truncated for column 'f151' at row 1
Note 1265 Data truncated for column 'f152' at row 1
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/memory_tb3.txt' into table tb3 ;
Testcase: 3.5:
--------------
create User test_general@localhost;
set password for test_general@localhost = password('PWD');
revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost;
create User test_super@localhost;
set password for test_super@localhost = password('PWD');
grant ALL on *.* to test_super@localhost with grant OPTION;
connect(localhost,test_general,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_super,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase: 3.5.1.1:
------------------
use test;
Create trigger trg1_1 BEFORE INSERT
on tb3 for each row set @test_before = 2, new.f142 = @test_before;
Create trigger trg1_2 AFTER INSERT
on tb3 for each row set @test_after = 6;
Create trigger trg1_4 BEFORE UPDATE
on tb3 for each row set @test_before = 27,
new.f142 = @test_before,
new.f122 = 'Before Update Trigger';
Create trigger trg1_3 AFTER UPDATE
on tb3 for each row set @test_after = '15';
Create trigger trg1_5 BEFORE DELETE on tb3 for each row
select count(*) into @test_before from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
Create trigger trg1_6 AFTER DELETE on tb3 for each row
select count(*) into @test_after from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
set @test_before = 1;
set @test_after = 5;
select @test_before, @test_after;
@test_before @test_after
1 5
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'First Row', @test_before, @test_after, 1);
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 First Row 2 0000000005 1
select @test_before, @test_after;
@test_before @test_after
2 6
set @test_before = 18;
set @test_after = 8;
select @test_before, @test_after;
@test_before @test_after
18 8
Update tb3 set tb3.f122 = 'Update',
tb3.f142 = @test_before,
tb3.f144 = @test_after
where tb3.f121 = 'Test 3.5.1.1';
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
27 15
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'Second Row', 5, 6, 2);
set @test_before = 0;
set @test_after = 0;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
Test 3.5.1.1 Second Row 2 0000000006 2
select @test_before, @test_after;
@test_before @test_after
0 0
Delete from tb3 where f121 = 'Test 3.5.1.1' and f134 = 2;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
2 1
drop trigger trg1_1;
drop trigger trg1_2;
drop trigger trg1_3;
drop trigger trg1_4;
drop trigger trg1_5;
drop trigger trg1_6;
delete from tb3 where f121='Test 3.5.1.1';
Testcase: 3.5.1.2:
------------------
Create trigger trg_1 after insert
on tb3 for each statement set @x= 1;
ERROR 42000: 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 'statement set @x= 1' at line 2
drop trigger trg_1;
Testcase 3.5.1.3:
-----------------
CREATE TRIGGER trg3_1 on tb3 BEFORE INSERT for each row set new.f120 = 't';
ERROR 42000: 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 'on tb3 BEFORE INSERT for each row set new.f120 = 't'' at line 1
CREATE trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's';
ERROR 42000: 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 'trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's'' at line 1
CREATE TRIGGER trg3_3 Before DELETE on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'set @ret1 = 'test' for each row' at line 1
CREATE TRIGGER trg3_4 DELETE AFTER on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'DELETE AFTER on tb3 set @ret1 = 'test' for each row' at line 1
CREATE for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test';
ERROR 42000: 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 'for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test'' at line 1
drop trigger trg3_1;
drop trigger trg3_2;
drop trigger trg3_3;
drop trigger trg3_4;
drop trigger trg3_5;
Testcase: 3.5.1.5:
------------------
CREATE TRIGGER trg4_1 AFTER on tb3 for each row set new.f120 = 'e';
ERROR 42000: 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 'on tb3 for each row set new.f120 = 'e'' at line 1
CREATE TRIGGER trg4_2 INSERT on tb3 for each set row new.f120 = 'f';
ERROR 42000: 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 'INSERT on tb3 for each set row new.f120 = 'f'' at line 1
CREATE TRIGGER trg4_3 BEFORE INSERT tb3 for each row set new.f120 = 'g';
ERROR 42000: 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 'tb3 for each row set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_4 AFTER UPDATE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'set new.f120 = 'g'' at line 1
CREATE trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_6 BEFORE DELETE for each row set new.f120 = 'g';
ERROR 42000: 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 'for each row set new.f120 = 'g'' at line 1
drop trigger trg4_1;
drop trigger trg4_2;
drop trigger trg4_3;
drop trigger trg4_4;
drop trigger trg4_5;
drop trigger trg4_6;
Testcase 3.5.1.6: - Need to fix
-------------------------------
Testcase 3.5.1.7: - need to fix
-------------------------------
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (f1 int, f2 char(25),f3 int) engine=memory;
CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
for each row set new.f3 = '14';
CREATE TRIGGER trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
BEFORE UPDATE on test.t1 for each row set new.f3 = '42';
insert into t1 (f2) values ('insert 3.5.1.7');
select * from t1;
f1 f2 f3
NULL insert 3.5.1.7 14
update t1 set f2='update 3.5.1.7';
select * from t1;
f1 f2 f3
NULL update 3.5.1.7 42
select trigger_name from information_schema.triggers;
trigger_name
trg5_1
trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWX
drop trigger trg5_1;
drop trigger trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ;
drop table t1;
Testcase 3.5.1.8:
-----------------
CREATE TRIGGER trg12* before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '* before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER trigger before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 'trigger before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER 100 before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '100 before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @@view before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@@view before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @name before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@name before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER tb3.trg6_1 BEFORE INSERT on test.tb3
for each row set new.f120 ='X';
ERROR HY000: Trigger in wrong schema
drop database if exists trig_db;
create database trig_db;
use trig_db;
create table t1 (f1 integer) engine = memory;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
ERROR HY000: Trigger in wrong schema
use test;
drop database trig_db;
drop trigger trg6_1;
drop trigger trg6_3;
Testcase 3.5.1.9:(cannot be inplemented at this point)
------------------------------------------------------
Testcase 3.5.1.10:
------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X';
CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger already exists
drop trigger trg7_1;
Testcase 3.5.1.?:
-----------------
drop table if exists t1;
drop table if exists t2;
create table t1 (f1 char(50), f2 integer) engine = memory;
create table t2 (f1 char(50), f2 integer) engine = memory;
create trigger trig before insert on t1
for each row set new.f1 ='trig t1';
create trigger trig before update on t2
for each row set new.f1 ='trig t2';
ERROR HY000: Trigger already exists
insert into t1 value ('insert to t1',1);
select * from t1;
f1 f2
trig t1 1
update t1 set f1='update to t1';
select * from t1;
f1 f2
update to t1 1
insert into t2 value ('insert to t2',2);
update t2 set f1='update to t1';
select * from t2;
f1 f2
update to t1 2
drop table t1;
drop table t2;
drop trigger trig;
Testcase 3.5.1.11:
------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
drop database if exists trig_db3;
create database trig_db1;
create database trig_db2;
create database trig_db3;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = memory;
create trigger trig before insert on t1
for each row set new.f1 ='trig1', @test_var1='trig1';
use trig_db2;
create table t2 (f1 char(50), f2 integer) engine = memory;
create trigger trig before insert on t2
for each row set new.f1 ='trig2', @test_var2='trig2';
use trig_db3;
create table t1 (f1 char(50), f2 integer) engine = memory;
create trigger trig before insert on t1
for each row set new.f1 ='trig3', @test_var3='trig3';
set @test_var1= '', @test_var2= '', @test_var3= '';
use trig_db1;
insert into t1 (f1,f2) values ('insert to db1 t1',1);
insert into trig_db1.t1 (f1,f2) values ('insert to db1 t1 from db1',2);
insert into trig_db2.t2 (f1,f2) values ('insert to db2 t2 from db1',3);
insert into trig_db3.t1 (f1,f2) values ('insert to db3 t1 from db1',4);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1 trig2 trig3
select * from t1;
f1 f2
trig1 1
trig1 2
select * from trig_db2.t2;
f1 f2
trig2 3
select * from trig_db3.t1;
f1 f2
trig3 4
select * from t1;
f1 f2
trig1 1
trig1 2
use test;
drop database trig_db1;
drop database trig_db2;
drop database trig_db3;
Testcase 3.5.2.1/2/3:
---------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
create database trig_db1;
create database trig_db2;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = memory;
create table trig_db2.t1 (f1 char(50), f2 integer) engine = memory;
create trigger trig1_b before insert on t1
for each row set @test_var1='trig1_b';
create trigger trig_db1.trig1_a after insert on t1
for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
trig_db1 trig1_b t1
trig_db1 trig1_a t1
trig_db2 trig2 t1
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1_b trig1_a trig2
drop database trig_db1;
drop database trig_db2;
Testcase 3.5.3:
---------------
drop database if exists priv_db;
create database priv_db;
use priv_db;
create table t1 (f1 char(20));
create User test_noprivs@localhost;
set password for test_noprivs@localhost = password('PWD');
create User test_yesprivs@localhost;
set password for test_yesprivs@localhost = password('PWD');
Testcase 3.5.3.2/6:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SUPER on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase 3.5.3.2:
-----------------
select current_user;
current_user
test_noprivs@localhost
use priv_db;
create trigger trg1_1 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_1-no';
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-no');
select f1 from t1;
f1
insert 3.5.3.2-no
select current_user;
current_user
test_yesprivs@localhost
use priv_db;
create trigger trg1_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_2-yes';
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
Testcase 3.5.3.6:
-----------------
use priv_db;
drop trigger trg1_2;
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
use priv_db;
drop trigger trg1_2;
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-no');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
drop trigger trg1_2;
Testcase 3.5.3.7a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke UPDATE on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, UPDATE on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1a');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
drop trigger trg4a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg4a_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2a';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
drop trigger trg4a_2;
Testcase 3.5.3.7b:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke UPDATE on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
insert 3.5.3.7-1b
update t1 set f1 = 'update 3.5.3.7-1b' where f1 = 'insert 3.5.3.7-1b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
drop trigger trg4b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4b_2 before UPDATE on t1 for each row
set new.f1 = 'trig 3.5.3.7-2b';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
insert 3.5.3.7-2b
update t1 set f1 = 'update 3.5.3.7-2b' where f1 = 'insert 3.5.3.7-2b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
drop trigger trg4b_2;
Testcase 3.5.3.7c
-----------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke UPDATE on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
drop trigger trg4c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4c_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2c';
insert into t1 (f1) values ('insert 3.5.3.7-2c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
drop trigger trg4c_2;
Testcase 3.5.3.7d:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant SELECT (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1), INSERT (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
drop trigger trg4d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4d_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2d';
insert into t1 (f1) values ('insert 3.5.3.7-2d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
trig 3.5.3.7-2d
drop trigger trg4d_2;
Testcase 3.5.3.8a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SELECT on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, SELECT on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var = 'before trig 3.5.3.8-1a';
select @test_var;
@test_var
before trig 3.5.3.8-1a
insert into t1 (f1) values ('insert 3.5.3.8-1a');
select @test_var;
@test_var
before trig 3.5.3.8-1a
drop trigger trg5a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg5a_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2a';
select @test_var;
@test_var
before trig 3.5.3.8-2a
insert into t1 (f1) values ('insert 3.5.3.8-2a');
select @test_var;
@test_var
insert 3.5.3.8-2a
drop trigger trg5a_2;
Testcase: 3.5.3.8b
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke SELECT on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1b';
insert into t1 (f1) values ('insert 3.5.3.8-1b');
select @test_var;
@test_var
before trig 3.5.3.8-1b
update t1 set f1= 'update 3.5.3.8-1b' where f1 = 'insert 3.5.3.8-1b';
select @test_var;
@test_var
before trig 3.5.3.8-1b
drop trigger trg5b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5b_2 before UPDATE on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2b';
insert into t1 (f1) values ('insert 3.5.3.8-2b');
select @test_var;
@test_var
before trig 3.5.3.8-2b
update t1 set f1= 'update 3.5.3.8-2b' where f1 = 'insert 3.5.3.8-2b';
select @test_var;
@test_var
update 3.5.3.8-2b
drop trigger trg5b_2;
Testcase 3.5.3.8c:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke SELECT on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1c';
insert into t1 (f1) values ('insert 3.5.3.8-1c');
select @test_var;
@test_var
before trig 3.5.3.8-1c
drop trigger trg5c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5c_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2c';
insert into t1 (f1) values ('insert 3.5.3.8-2c');
select @test_var;
@test_var
insert 3.5.3.8-2c
drop trigger trg5c_2;
Testcase: 3.5.3.8d:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant UPDATE (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var='before trig 3.5.3.8-1d';
insert into t1 (f1) values ('insert 3.5.3.8-1d');
select @test_var;
@test_var
before trig 3.5.3.8-1d
drop trigger trg5d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5d_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2d';
insert into t1 (f1) values ('insert 3.5.3.8-2d');
select @test_var;
@test_var
insert 3.5.3.8-2d
drop trigger trg5d_2;
drop database if exists priv_db;
drop user test_yesprivs@localhost;
drop user test_noprivs@localhost;
drop user test_noprivs;
Testcase 3.5.4:
---------------
use test;
Testcase 3.5.4.1:
-----------------
create database db_drop;
Use db_drop;
create table t1 (f1 char(30)) engine=memory;
grant INSERT, SELECT on db_drop.t1 to test_general;
Use db_drop;
Create trigger trg1 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.1';
Use db_drop;
Insert into t1 values ('Insert error 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
Insert no trigger 3.5.4.1
drop trigger trg1;
drop database if exists db_drop;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.2:
-----------------
create database db_drop2;
Use db_drop2;
drop table if exists t1_432 ;
create table t1_432 (f1 char (30)) engine=memory;
Drop trigger tr_does_not_exit;
ERROR HY000: Trigger does not exist
drop table if exists t1_432 ;
drop database if exists db_drop2;
Testcase 3.5.4.3:
-----------------
create database db_drop3;
Use db_drop3;
drop table if exists t1_433 ;
drop table if exists t1_433a ;
create table t1_433 (f1 char (30)) engine=memory;
create table t1_433a (f1a char (5)) engine=memory;
CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row
set new.f1 = 'Trigger 3.5.4.3';
Drop trigger t1.433.trg3;
ERROR 42000: 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 '.trg3' at line 1
Drop trigger db_drop3.t1.433.trg3;
ERROR 42000: 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 '.433.trg3' at line 1
Drop trigger mysql.trg3;
ERROR HY000: Trigger does not exist
Drop trigger tbx.trg3;
ERROR HY000: Trigger does not exist
Drop trigger db_drop3.trg3;
drop table if exists t1_433;
drop table if exists t1_433a;
drop database if exists db_drop3;
Testcase 3.5.4.4:
-----------------
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=memory;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Create trigger trg4 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.4';
Use db_drop4;
Insert into t1 values ('Insert 3.5.4.4');
Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
Show databases;
Database
information_schema
mysql
test
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
trigger_schema trigger_name event_object_table
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=memory;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.4');
Select * from t1;
f1
2nd Insert 3.5.4.4
drop trigger trg4;
ERROR HY000: Trigger does not exist
drop database if exists db_drop4;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.5:
-----------------
create database db_drop5;
Use db_drop5;
create table t1 (f1 char(50)) engine=memory;
grant INSERT, SELECT on t1 to test_general;
Create trigger trg5 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.5';
Use db_drop5;
Insert into t1 values ('Insert 3.5.4.5');
Select * from t1;
f1
Trigger 3.5.4.5
Drop table t1;
Show tables;
Tables_in_db_drop5
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg5';
trigger_schema trigger_name event_object_table
create table t1 (f1 char(50)) engine=memory;
grant INSERT, SELECT on t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.5');
Select * from t1;
f1
2nd Insert 3.5.4.5
drop trigger trg5;
ERROR HY000: Trigger does not exist
drop database if exists db_drop5;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.5:
---------------
use test;
Testcase 3.5.5.1:
-----------------
Create trigger trg1 before INSERT on t100 for each row set new.f2=1000;
ERROR 42S02: Table 'test.t100' doesn't exist
Testcase 3.5.5.2:
-----------------
Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned);
Create trigger trg2 before INSERT
on t1_temp for each row set new.f2=9999;
ERROR HY000: Trigger's 't1_temp' is view or temporary table
drop table t1_temp;
Testcase 3.5.5.3:
-----------------
Create view vw3 as select f118 from tb3;
Create trigger trg3 before INSERT
on vw3 for each row set new.f118='s';
ERROR HY000: 'test.vw3' is not BASE TABLE
drop view vw3;
Testcase 3.5.5.4:
-----------------
create database dbtest_one;
create database dbtest_two;
use dbtest_two;
create table t2 (f1 char(15));
use dbtest_one;
create trigger trg4 before INSERT
on dbtest_two.t2 for each row set new.f1='trig 3.5.5.4';
ERROR HY000: Trigger in wrong schema
grant INSERT, SELECT on dbtest_two.t2 to test_general;
grant SELECT on dbtest_one.* to test_general;
use dbtest_two;
Insert into t2 values ('1st Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from t2;
f1
1st Insert 3.5.
use dbtest_one;
Insert into dbtest_two.t2 values ('2nd Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from dbtest_two.t2;
f1
1st Insert 3.5.
2nd Insert 3.5.
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
DROP DATABASE if exists dbtest_one;
drop database if EXISTS dbtest_two;
Testcase 3.5.6:
---------------
use test;
Testcase 3.5.6.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.3:
-----------------
Create trigger trg3_1 DURING UPDATE on tb3 for each row set new.f132=25;
ERROR 42000: 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 'DURING UPDATE on tb3 for each row set new.f132=25' at line 1
Create trigger trg3_2 TIME INSERT on tb3 for each row set new.f132=15;
ERROR 42000: 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 'TIME INSERT on tb3 for each row set new.f132=15' at line 1
drop trigger tb3.trg3_1;
drop trigger tb3.trg3_2;
Testcase 3.5.6.4 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.5 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.3 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.4:
-----------------
Create trigger trg4_1 BEFORE SELECT on tb3 for each row set new.f132=5;
ERROR 42000: 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 'SELECT on tb3 for each row set new.f132=5' at line 1
Create trigger trg4_2 AFTER VALUE on tb3 for each row set new.f132=1;
ERROR 42000: 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 'VALUE on tb3 for each row set new.f132=1' at line 1
drop trigger tb3.trg4_1;
drop trigger tb3.trg4_2;
Testcase 3.5.7.5 / 3.5.7.6:
---------------------------
Create trigger trg5_1 BEFORE INSERT
on tb3 for each row set new.f122='Trigger1 3.5.7.5/6';
Create trigger trg5_2 BEFORE INSERT
on tb3 for each row set new.f122='Trigger2 3.5.7.5';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.5/6','Insert 3.5.7.5');
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Trigger1 3.5.7.5/6
update tb3 set f122='Update 3.5.7.6' where f121= 'Test 3.5.7.5/6';
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Update 3.5.7.6
drop trigger trg5_1;
drop trigger trg5_2;
delete from tb3 where f121='Test 3.5.7.5/6';
Testcase 3.5.7.7 / 3.5.7.8:
---------------------------
set @test_var='Before trig 3.5.7.7';
Create trigger trg6_1 AFTER INSERT
on tb3 for each row set @test_var='Trigger1 3.5.7.7/8';
Create trigger trg6_2 AFTER INSERT
on tb3 for each row set @test_var='Trigger2 3.5.7.7';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.7
Insert into tb3 (f121,f122) values ('Test 3.5.7.7/8','Insert 3.5.7.7');
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Insert 3.5.7.7
select @test_var;
@test_var
Trigger1 3.5.7.7/8
update tb3 set f122='Update 3.5.7.8' where f121= 'Test 3.5.7.7/8';
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Update 3.5.7.8
select @test_var;
@test_var
Trigger1 3.5.7.7/8
drop trigger trg6_1;
drop trigger trg6_2;
delete from tb3 where f121='Test 3.5.7.7/8';
Testcase 3.5.7.9/10:
--------------------
Create trigger trg7_1 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger1 3.5.7.9/10';
Create trigger trg7_2 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger2 3.5.7.9';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.9/10','Insert 3.5.7.9');
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Insert 3.5.7.9
update tb3 set f122='update 3.5.7.10' where f121='Test 3.5.7.9/10';
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Trigger1 3.5.7.9/10
drop trigger trg7_1;
drop trigger trg7_2;
delete from tb3 where f121='Test 3.5.7.9/10';
Testcase 3.5.7.11/12:
---------------------
set @test_var='Before trig 3.5.7.11';
Create trigger trg8_1 AFTER UPDATE
on tb3 for each row set @test_var='Trigger 3.5.7.11/12';
Create trigger trg8_2 AFTER UPDATE
on tb3 for each row set @test_var='Trigger2 3.5.7.11';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.11
Insert into tb3 (f121,f122) values ('Test 3.5.7.11/12','Insert 3.5.7.11/12');
select @test_var;
@test_var
Before trig 3.5.7.11
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 Insert 3.5.7.11/12
update tb3 set f122='update 3.5.7.12' where f121='Test 3.5.7.11/12';
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 update 3.5.7.12
select @test_var;
@test_var
Trigger 3.5.7.11/12
delete from tb3 where f121='Test 3.5.7.11/12';
drop trigger trg8_1;
drop trigger trg8_2;
delete from tb3 where f121='Test 3.5.7.11/12';
Testcase 3.5.7.13/14:
---------------------
set @test_var=1;
Create trigger trg9_1 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+1;
Create trigger trg9_2 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+10;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.13/14','Insert 3.5.7.13');
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
Test 3.5.7.13/14 Insert 3.5.7.13
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.13/14';
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
select @test_var;
@test_var
2
delete from tb3 where f121='Test 3.5.7.13/14';
select @test_var;
@test_var
2
drop trigger trg9_1;
drop trigger trg9_2;
delete from tb3 where f121='Test 3.5.7.13/14';
Testcase 3.5.7.15/16:
---------------------
set @test_var=1;
Create trigger trg_3_406010_1 AFTER DELETE
on tb3 for each row set @test_var=@test_var+5;
Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50;
ERROR HY000: Trigger already exists
Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.15/16','Insert 3.5.7.15/16');
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
Test 3.5.7.15/16 Insert 3.5.7.15/16
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.15/16';
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
select @test_var;
@test_var
6
delete from tb3 where f121='Test 3.5.7.15/16';
select @test_var;
@test_var
6
drop trigger trg_3_406010_1;
drop trigger trg_3_406010_2;
delete from tb3 where f121='Test 3.5.7.15/16';
Testcase 3.5.7.17 (see Testcase 3.5.1.1)
----------------------------------------
Testcase 3.5.8.1: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.2: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.3/4:
-------------------
create database db_test;
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
grant LOCK TABLES on db_test.* to test_general;
Use db_test;
create table t1_i (
i120 char ascii not null DEFAULT b'101',
i136 smallint zerofill not null DEFAULT 999,
i144 int zerofill not null DEFAULT 99999,
i163 decimal (63,30)) engine=memory;
create table t1_u (
u120 char ascii not null DEFAULT b'101',
u136 smallint zerofill not null DEFAULT 999,
u144 int zerofill not null DEFAULT 99999,
u163 decimal (63,30)) engine=memory;
create table t1_d (
d120 char ascii not null DEFAULT b'101',
d136 smallint zerofill not null DEFAULT 999,
d144 int zerofill not null DEFAULT 99999,
d163 decimal (63,30)) engine=memory;
Insert into t1_u values ('a',111,99999,999.99);
Insert into t1_u values ('b',222,99999,999.99);
Insert into t1_u values ('c',333,99999,999.99);
Insert into t1_u values ('d',222,99999,999.99);
Insert into t1_u values ('e',222,99999,999.99);
Insert into t1_u values ('f',333,99999,999.99);
Insert into t1_d values ('a',111,99999,999.99);
Insert into t1_d values ('b',222,99999,999.99);
Insert into t1_d values ('c',333,99999,999.99);
Insert into t1_d values ('d',444,99999,999.99);
Insert into t1_d values ('e',222,99999,999.99);
Insert into t1_d values ('f',222,99999,999.99);
3.5.8.4 - multiple SQL
----------------------
use test;
Create trigger trg1 AFTER INSERT on tb3 for each row
BEGIN
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update db_test.t1_u
set u144=new.f144, u163=new.f163
where u136=new.f136;
delete from db_test.t1_d where d136= new.f136;
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
END//
Use test;
set @test_var=0;
Insert into tb3 (f120, f122, f136, f144, f163)
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
f120 f122 f136 f144 f163
1 Test 3.5.8.4 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
b 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00222 0000023456 1.050000000000000000000000000000
e 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00444 0000099999 999.990000000000000000000000000000
select @test_var;
@test_var
3.150000000000000000000000000000
3.5.8.4 - single SQL - insert
-----------------------------
Create trigger trg2 BEFORE UPDATE on tb3 for each row
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update tb3 set f120='I', f122='Test 3.5.8.4-Single Insert'
where f122='Test 3.5.8.4';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
I Test 3.5.8.4-Single Insert 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
I 00222 0000023456 1.050000000000000000000000000000
3.5.8.4 - single SQL - update
-----------------------------
drop trigger trg2;
Create trigger trg3 BEFORE UPDATE on tb3 for each row
update db_test.t1_u
set u120=new.f120
where u136=new.f136;
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
where f122='Test 3.5.8.4-Single Insert';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
U Test 3.5.8.4-Single Update 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - delete
-------------------------------
drop trigger trg3;
Create trigger trg4 AFTER UPDATE on tb3 for each row
delete from db_test.t1_d where d136= new.f136;
update tb3 set f120='D', f136=444,
f122='Test 3.5.8.4-Single Delete'
where f122='Test 3.5.8.4-Single Update';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
D Test 3.5.8.4-Single Delete 00444 0000023456 1.050000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - select
-------------------------------
drop trigger trg4;
Create trigger trg5 AFTER UPDATE on tb3 for each row
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
set @test_var=0;
update tb3 set f120='S', f136=111,
f122='Test 3.5.8.4-Single Select'
where f122='Test 3.5.8.4-Single Delete';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
S Test 3.5.8.4-Single Select 00111 0000023456 1.050000000000000000000000000000
select @test_var;
@test_var
999.990000000000000000000000000000
drop trigger trg1;
drop trigger trg5;
drop database if exists db_test;
delete from tb3 where f122 like 'Test 3.5.8.4%';
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.8.5 (IF):
----------------------
create trigger trg2 before insert on tb3 for each row
BEGIN
IF new.f120='1' then
set @test_var='one', new.f120='2';
ELSEIF new.f120='2' then
set @test_var='two', new.f120='3';
ELSEIF new.f120='3' then
set @test_var='three', new.f120='4';
END IF;
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END IF;
END//
set @test_var='Empty', @test_var2=0;
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 one 2nd else
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 two 2nd else
D Test 3.5.8.5-if 00102 two 2nd else
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd if
D Test 3.5.8.5-if 00102 three 2nd if
d Test 3.5.8.5-if 00010 three 2nd if
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd else
D Test 3.5.8.5-if 00102 three 2nd else
d Test 3.5.8.5-if 00010 three 2nd else
D Test 3.5.8.5-if 00103 three 2nd else
create trigger trg3 before update on tb3 for each row
BEGIN
ELSEIF new.f120='2' then
END IF;
END//
ERROR 42000: 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 'ELSEIF new.f120='2' then
END IF;
END' at line 3
drop trigger trg3//
create trigger trg4 before update on tb3 for each row
BEGIN
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END//
ERROR 42000: 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 '' at line 7
drop trigger trg4;
drop trigger trg2;
delete from tb3 where f121='Test 3.5.8.5-if';
Testcase 3.5.8.5-case:
----------------------
create trigger trg3 before insert on tb3 for each row
BEGIN
SET new.f120=char(ascii(new.f120)-32);
CASE
when new.f136<100 then set new.f136=new.f136+120;
when new.f136<10 then set new.f144=777;
when new.f136>100 then set new.f120=new.f136-1;
END case;
CASE
when new.f136=200 then set @test_var=CONCAT(new.f120, '=');
ELSE set @test_var=concat(new.f120, '*');
END case;
CASE new.f144
when 1 then set @test_var=concat(@test_var, 'one');
when 2 then set @test_var=concat(@test_var, 'two');
when 3 then set @test_var=concat(@test_var, 'three');
when 4 then set @test_var=concat(@test_var, 'four');
when 5 then set @test_var=concat(@test_var, 'five');
when 6 then set @test_var=concat(@test_var, 'six');
when 7 then set @test_var=concat(@test_var, 'seven');
when 8 then set @test_var=concat(@test_var, 'eight');
when 9 then set @test_var=concat(@test_var, 'nine');
when 10 then set @test_var=concat(@test_var, 'ten');
when 11 then set @test_var=concat(@test_var, 'eleven');
when 12 then set @test_var=concat(@test_var, 'twelve');
when 13 then set @test_var=concat(@test_var, 'thirteen');
when 14 then set @test_var=concat(@test_var, 'fourteen');
when 15 then set @test_var=concat(@test_var, 'fifteen');
ELSE set @test_var=CONCAT(new.f120, '*', new.f144);
END case;
END//
set @test_var='Empty';
Insert into tb3 (f120, f122, f136, f144)
values ('a', 'Test 3.5.8.5-case', 5, 7);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 A*seven
Insert into tb3 (f120, f122, f136, f144)
values ('b', 'Test 3.5.8.5-case', 71,16);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 B*0000000016
B Test 3.5.8.5-case 00191 0000000016 B*0000000016
Insert into tb3 (f120, f122, f136, f144)
values ('c', 'Test 3.5.8.5-case', 80,1);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 C=one
B Test 3.5.8.5-case 00191 0000000016 C=one
C Test 3.5.8.5-case 00200 0000000001 C=one
Insert into tb3 (f120, f122, f136)
values ('d', 'Test 3.5.8.5-case', 152);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1*0000099999
B Test 3.5.8.5-case 00191 0000000016 1*0000099999
C Test 3.5.8.5-case 00200 0000000001 1*0000099999
1 Test 3.5.8.5-case 00152 0000099999 1*0000099999
Insert into tb3 (f120, f122, f136, f144)
values ('e', 'Test 3.5.8.5-case', 200, 8);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
Insert into tb3 (f120, f122, f136, f144)
values ('f', 'Test 3.5.8.5-case', 100, 8);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
create trigger trg3a before update on tb3 for each row
BEGIN
CASE
when new.f136<100 then set new.f120='p';
END//
ERROR 42000: 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 '' at line 5
drop trigger trg3a;
drop trigger trg3;
delete from tb3 where f121='Test 3.5.8.5-case';
Testcase 3.5.8.5-loop/leave:
----------------------------
Create trigger trg4 after insert on tb3 for each row
BEGIN
set @counter=0, @flag='Initial';
Label1: loop
if new.f136<new.f144 then
set @counter='Nothing to loop';
leave Label1;
else
set @counter=@counter+1;
if new.f136=new.f144+@counter then
set @counter=concat(@counter, ' loops');
leave Label1;
end if;
end if;
iterate label1;
set @flag='Final';
END loop Label1;
END//
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 2, 8);
select @counter, @flag;
@counter @flag
Nothing to loop Initial
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 11, 8);
select @counter, @flag;
@counter @flag
3 loops Initial
Create trigger trg4_2 after update on tb3 for each row
BEGIN
Label1: loop
set @counter=@counter+1;
END;
END//
ERROR 42000: 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 ';
END' at line 5
drop trigger trg4_2;
drop trigger trg4;
delete from tb3 where f122='Test 3.5.8.5-loop';
Testcase 3.5.8.5-repeat:
------------------------
Create trigger trg6 after insert on tb3 for each row
BEGIN
rp_label: REPEAT
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label;
END IF;
SET @counter2 = @counter2 + 1;
UNTIL @counter1> new.f136 END REPEAT rp_label;
END//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-repeat', 13);
select @counter1, @counter2;
@counter1 @counter2
15 8
Create trigger trg6_2 after update on tb3 for each row
BEGIN
REPEAT
SET @counter2 = @counter2 + 1;
END//
ERROR 42000: 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 'END' at line 5
drop trigger trg6;
delete from tb3 where f122='Test 3.5.8.5-repeat';
Testcase 3.5.8.5-while:
-----------------------
Create trigger trg7 after insert on tb3 for each row
wl_label: WHILE @counter1 < new.f136 DO
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label;
END IF;
SET @counter2 = @counter2 + 1;
END WHILE wl_label//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-while', 7);
select @counter1, @counter2;
@counter1 @counter2
7 4
Create trigger trg7_2 after update on tb3 for each row
BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: 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 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
Testcase 3.5.8.6: (requirement void)
------------------------------------
Testcase 3.5.8.7: (Disabled as a result of bug _____)
-----------------------------------------------------
Testcase 3.5.9.1/2:
-------------------
Create trigger trg1 BEFORE UPDATE on tb3 for each row
set new.f142 = 94087, @counter=@counter+1;
TotalRows
19
Affected
18
NotAffected
1
NewValuew
0
set @counter=0;
Update tb3 Set f142='1' where f130<100;
select count(*) as ExpectedChanged, @counter as TrigCounter
from tb3 where f142=94087;
ExpectedChanged TrigCounter
18 18
select count(*) as ExpectedNotChange from tb3
where f130<100 and f142<>94087;
ExpectedNotChange
0
select count(*) as NonExpectedChanged from tb3
where f130>=130 and f142=94087;
NonExpectedChanged
0
drop trigger trg1;
Testcase 3.5.9.3:
-----------------
Create trigger trg2_a before update on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_b after update on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
Create trigger trg2_c before delete on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_d after delete on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
Insert into tb3 (f122, f136, f163)
values ('Test 3.5.9.3', 7, 123.17);
Update tb3 Set f136=8 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
a NULL Test 3.5.9.3 00008 123.170000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
delete from tb3 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
drop trigger trg2_a;
drop trigger trg2_b;
drop trigger trg2_c;
drop trigger trg2_d;
Testcase 3.5.9.4:
-----------------
Create trigger trg3_a before insert on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_b after insert on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
Create trigger trg3_c before update on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_d after update on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Insert into tb3 (f122, f136, f151, f163)
values ('Test 3.5.9.4', 7, DEFAULT, 995.24);
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4%';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4 00007 999 995.240000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'f136' at row 20
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4-trig 00000 999 NULL
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4-trig 0 999 NULL
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4-trig 0 999 NULL
drop trigger trg3_a;
drop trigger trg3_b;
drop trigger trg3_c;
drop trigger trg3_d;
delete from tb3 where f122='Test 3.5.9.4-trig';
Testcase 3.5.9.5: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.6:
-----------------
create trigger trg4a before insert on tb3 for each row
set @temp1= old.f120;
ERROR HY000: There is no OLD row in on INSERT trigger
create trigger trg4b after insert on tb3 for each row
set old.f120= 'test';
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg4a;
drop trigger trg4b;
Testcase 3.5.9.7: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.8: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.9:
-----------------
create trigger trg5a before DELETE on tb3 for each row
set @temp1=new.f122;
ERROR HY000: There is no NEW row in on DELETE trigger
create trigger trg5b after DELETE on tb3 for each row
set new.f122='test';
ERROR HY000: There is no NEW row in on DELETE trigger
drop trigger trg5a;
drop trigger trg5b;
Testcase 3.5.9.10: (implied in previous tests)
----------------------------------------------
Testcase 3.5.9.11: covered by 3.5.9.9
-------------------------------------
Testcase 3.5.9.12: covered by 3.5.9.6
-------------------------------------
Testcase 3.5.9.13:
------------------
create trigger trg6a before UPDATE on tb3 for each row
set old.f118='C', new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6b after INSERT on tb3 for each row
set old.f136=163, new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6c after UPDATE on tb3 for each row
set old.f136=NULL;
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg6a;
drop trigger trg6b;
drop trigger trg6c;
Testcase 3.5.9.14: (implied in previous tests)
----------------------------------------------
Testcase 3.5.10.1/2/3:
----------------------
Create view vw11 as select * from tb3
where f122 like 'Test 3.5.10.1/2/3%';
Create trigger trg1a before insert on tb3
for each row set new.f163=111.11;
Create trigger trg1b after insert on tb3
for each row set @test_var='After Insert';
Create trigger trg1c before update on tb3
for each row set new.f121='Y', new.f122='Test 3.5.10.1/2/3-Update';
Create trigger trg1d after update on tb3
for each row set @test_var='After Update';
Create trigger trg1e before delete on tb3
for each row set @test_var=5;
Create trigger trg1f after delete on tb3
for each row set @test_var= 2* @test_var+7;
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 1);
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 2);
Insert into vw11 (f122, f151) values ('Not in View', 3);
select f121, f122, f151, f163
from tb3 where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
select f121, f122, f151, f163
from tb3 where f122 like 'Not in View';
f121 f122 f151 f163
NULL Not in View 3 111.110000000000000000000000000000
Update vw11 set f163=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
set @test_var=0;
Select @test_var as 'before delete';
before delete
0
delete from vw11 where f151=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Select @test_var as 'after delete';
after delete
17
drop view vw11;
drop trigger trg1a;
drop trigger trg1b;
drop trigger trg1c;
drop trigger trg1d;
drop trigger trg1e;
drop trigger trg1f;
delete from tb3 where f122 like 'Test 3.5.10.1/2/3%';
Testcase 3.5.10.4:
------------------
create table tb_load (f1 int, f2 char(25),f3 int) engine=memory;
Create trigger trg4 before insert on tb_load
for each row set new.f3=-(new.f1 div 5), @counter= @counter+1;
set @counter= 0;
select @counter as 'Rows Loaded Before';
Rows Loaded Before
0
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table tb_load;
select @counter as 'Rows Loaded After';
Rows Loaded After
10
Select * from tb_load limit 10;
f1 f2 f3
-5000 a` 1000
-4999 aaa 999
-4998 abaa 999
-4997 acaaa 999
-4996 adaaaa 999
-4995 aeaaaaa 999
-4994 afaaaaaa 998
-4993 agaaaaaaa 998
-4992 a^aaaaaaaa 998
-4991 a_aaaaaaaaa 998
drop trigger trg4;
drop table tb_load;
Testcase 3.5.10.5: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.6: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.extra:
----------------------
create table t1_sp (var136 tinyint, var151 decimal) engine=memory;
create trigger trg before insert on t1_sp
for each row set @counter=@counter+1;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR 02000: No data to FETCH
select @counter;
@counter
20
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
20
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase 3.5.11.1 (implemented in trig_perf.test)
-------------------------------------------------
drop user test_general@localhost;
drop user test_general;
drop user test_super@localhost;
Testcase y.y.y.2: Check for triggers starting triggers
------------------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2_1;
drop table if exists t2_2;
drop table if exists t2_3;
drop table if exists t2_4;
drop table if exists t3;
create table t1 (f1 integer);
create table t2_1 (f1 integer);
create table t2_2 (f1 integer);
create table t2_3 (f1 integer);
create table t2_4 (f1 integer);
create table t3 (f1 integer);
insert into t1 values (1);
create trigger tr1 after insert on t1 for each row
BEGIN
insert into t2_1 (f1) values (new.f1+1);
insert into t2_2 (f1) values (new.f1+1);
insert into t2_3 (f1) values (new.f1+1);
insert into t2_4 (f1) values (new.f1+1);
END//
create trigger tr2_1 after insert on t2_1 for each row
insert into t3 (f1) values (new.f1+10);
create trigger tr2_2 after insert on t2_2 for each row
insert into t3 (f1) values (new.f1+100);
create trigger tr2_3 after insert on t2_3 for each row
insert into t3 (f1) values (new.f1+1000);
create trigger tr2_4 after insert on t2_4 for each row
insert into t3 (f1) values (new.f1+10000);
insert into t1 values (1);
select * from t3;
f1
12
102
1002
10002
drop trigger tr1;
drop trigger tr2_1;
drop trigger tr2_2;
drop trigger tr2_3;
drop trigger tr2_4;
drop table t1, t2_1, t2_2, t2_3, t2_4, t3;
Testcase y.y.y.3: Circular trigger reference
--------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = memory;
create table t2 (f2 integer) engine = memory;
create table t3 (f3 integer) engine = memory;
create table t4 (f4 integer) engine = memory;
insert into t1 values (0);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1);
create trigger tr4 after insert on t4
for each row insert into t1 (f1) values (new.f4+1);
insert into t1 values (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
select * from t1;
f1
0
1
select * from t2;
f2
2
select * from t3;
f3
3
select * from t4;
f4
4
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop trigger tr4;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
Testcase y.y.y.4: Recursive trigger/SP references (disabled bug 11889)
----------------------------------------------------------------------
set @sql_mode='traditional';
create table t1_sp (
count integer,
var136 tinyint,
var151 decimal) engine=memory;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
set @counter= @counter+1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (@counter, var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
create trigger trg before insert on t1_sp
for each row call trig_sp();
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR HY000: Recursive stored routines are not allowed.
select @counter;
@counter
1
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
0
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase y.y.y.5: Roleback of nested trigger references
-------------------------------------------------------
set @@sql_mode='traditional';
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = memory;
create table t2 (f2 integer) engine = memory;
create table t3 (f3 integer) engine = memory;
create table t4 (f4 tinyint) engine = memory;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
insert into t1 values (1);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1000);
set autocommit=0;
start transaction;
insert into t1 values (1);
ERROR 22003: Out of range value adjusted for column 'f4' at row 1
commit;
select * from t1;
f1
1
1
select * from t2;
f2
2
select * from t3;
f3
3
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
This source diff could not be displayed because it is too large. You can view the blob instead.
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
SET @NO_REFRESH = IF( '' = '', 0, 1);
USE test;
drop table if exists tb3 ;
create table tb3 (
f118 char not null DEFAULT 'a',
f119 char binary not null DEFAULT b'101',
f120 char ascii not null DEFAULT b'101',
f121 tinytext,
f122 text,
f123 mediumtext,
f124 longtext unicode,
f125 tinyblob,
f126 blob,
f127 mediumblob,
f128 longblob,
f129 binary not null DEFAULT b'101',
f130 tinyint not null DEFAULT 99,
f131 tinyint unsigned not null DEFAULT 99,
f132 tinyint zerofill not null DEFAULT 99,
f133 tinyint unsigned zerofill not null DEFAULT 99,
f134 smallint not null DEFAULT 999,
f135 smallint unsigned not null DEFAULT 999,
f136 smallint zerofill not null DEFAULT 999,
f137 smallint unsigned zerofill not null DEFAULT 999,
f138 mediumint not null DEFAULT 9999,
f139 mediumint unsigned not null DEFAULT 9999,
f140 mediumint zerofill not null DEFAULT 9999,
f141 mediumint unsigned zerofill not null DEFAULT 9999,
f142 int not null DEFAULT 99999,
f143 int unsigned not null DEFAULT 99999,
f144 int zerofill not null DEFAULT 99999,
f145 int unsigned zerofill not null DEFAULT 99999,
f146 bigint not null DEFAULT 999999,
f147 bigint unsigned not null DEFAULT 999999,
f148 bigint zerofill not null DEFAULT 999999,
f149 bigint unsigned zerofill not null DEFAULT 999999,
f150 decimal not null DEFAULT 999.999,
f151 decimal unsigned not null DEFAULT 999.17,
f152 decimal zerofill not null DEFAULT 999.999,
f153 decimal unsigned zerofill,
f154 decimal (0),
f155 decimal (64),
f156 decimal (0) unsigned,
f157 decimal (64) unsigned,
f158 decimal (0) zerofill,
f159 decimal (64) zerofill,
f160 decimal (0) unsigned zerofill,
f161 decimal (64) unsigned zerofill,
f162 decimal (0,0),
f163 decimal (63,30),
f164 decimal (0,0) unsigned,
f165 decimal (63,30) unsigned,
f166 decimal (0,0) zerofill,
f167 decimal (63,30) zerofill,
f168 decimal (0,0) unsigned zerofill,
f169 decimal (63,30) unsigned zerofill,
f170 numeric,
f171 numeric unsigned,
f172 numeric zerofill,
f173 numeric unsigned zerofill,
f174 numeric (0),
f175 numeric (64)
) Engine = myisam;
Warnings:
Note 1265 Data truncated for column 'f150' at row 1
Note 1265 Data truncated for column 'f151' at row 1
Note 1265 Data truncated for column 'f152' at row 1
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/myisam_tb3.txt' into table tb3 ;
Testcase: 3.5:
--------------
create User test_general@localhost;
set password for test_general@localhost = password('PWD');
revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost;
create User test_super@localhost;
set password for test_super@localhost = password('PWD');
grant ALL on *.* to test_super@localhost with grant OPTION;
connect(localhost,test_general,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_super,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase: 3.5.1.1:
------------------
use test;
Create trigger trg1_1 BEFORE INSERT
on tb3 for each row set @test_before = 2, new.f142 = @test_before;
Create trigger trg1_2 AFTER INSERT
on tb3 for each row set @test_after = 6;
Create trigger trg1_4 BEFORE UPDATE
on tb3 for each row set @test_before = 27,
new.f142 = @test_before,
new.f122 = 'Before Update Trigger';
Create trigger trg1_3 AFTER UPDATE
on tb3 for each row set @test_after = '15';
Create trigger trg1_5 BEFORE DELETE on tb3 for each row
select count(*) into @test_before from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
Create trigger trg1_6 AFTER DELETE on tb3 for each row
select count(*) into @test_after from tb3 as tr_tb3
where f121 = 'Test 3.5.1.1';
set @test_before = 1;
set @test_after = 5;
select @test_before, @test_after;
@test_before @test_after
1 5
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'First Row', @test_before, @test_after, 1);
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 First Row 2 0000000005 1
select @test_before, @test_after;
@test_before @test_after
2 6
set @test_before = 18;
set @test_after = 8;
select @test_before, @test_after;
@test_before @test_after
18 8
Update tb3 set tb3.f122 = 'Update',
tb3.f142 = @test_before,
tb3.f144 = @test_after
where tb3.f121 = 'Test 3.5.1.1';
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
27 15
Insert into tb3 (f121, f122, f142, f144, f134)
values ('Test 3.5.1.1', 'Second Row', 5, 6, 2);
set @test_before = 0;
set @test_after = 0;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
Test 3.5.1.1 Second Row 2 0000000006 2
select @test_before, @test_after;
@test_before @test_after
0 0
Delete from tb3 where f121 = 'Test 3.5.1.1' and f134 = 2;
select f121, f122, f142, f144, f134 from tb3 where f121 = 'Test 3.5.1.1';
f121 f122 f142 f144 f134
Test 3.5.1.1 Before Update Trigger 27 0000000008 1
select @test_before, @test_after;
@test_before @test_after
2 1
drop trigger trg1_1;
drop trigger trg1_2;
drop trigger trg1_3;
drop trigger trg1_4;
drop trigger trg1_5;
drop trigger trg1_6;
delete from tb3 where f121='Test 3.5.1.1';
Testcase: 3.5.1.2:
------------------
Create trigger trg_1 after insert
on tb3 for each statement set @x= 1;
ERROR 42000: 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 'statement set @x= 1' at line 2
drop trigger trg_1;
Testcase 3.5.1.3:
-----------------
CREATE TRIGGER trg3_1 on tb3 BEFORE INSERT for each row set new.f120 = 't';
ERROR 42000: 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 'on tb3 BEFORE INSERT for each row set new.f120 = 't'' at line 1
CREATE trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's';
ERROR 42000: 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 'trg3_2 TRIGGER AFTER INSERT on tb3 for each row set new.f120 = 's'' at line 1
CREATE TRIGGER trg3_3 Before DELETE on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'set @ret1 = 'test' for each row' at line 1
CREATE TRIGGER trg3_4 DELETE AFTER on tb3 set @ret1 = 'test' for each row;
ERROR 42000: 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 'DELETE AFTER on tb3 set @ret1 = 'test' for each row' at line 1
CREATE for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test';
ERROR 42000: 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 'for each row TRIGGER trg3_5 AFTER UPDATE on tb3 set @ret1 = 'test'' at line 1
drop trigger trg3_1;
drop trigger trg3_2;
drop trigger trg3_3;
drop trigger trg3_4;
drop trigger trg3_5;
Testcase: 3.5.1.5:
------------------
CREATE TRIGGER trg4_1 AFTER on tb3 for each row set new.f120 = 'e';
ERROR 42000: 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 'on tb3 for each row set new.f120 = 'e'' at line 1
CREATE TRIGGER trg4_2 INSERT on tb3 for each set row new.f120 = 'f';
ERROR 42000: 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 'INSERT on tb3 for each set row new.f120 = 'f'' at line 1
CREATE TRIGGER trg4_3 BEFORE INSERT tb3 for each row set new.f120 = 'g';
ERROR 42000: 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 'tb3 for each row set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_4 AFTER UPDATE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'set new.f120 = 'g'' at line 1
CREATE trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g';
ERROR 42000: 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 'trg4_5 AFTER DELETE on tb3 for each set new.f120 = 'g'' at line 1
CREATE TRIGGER trg4_6 BEFORE DELETE for each row set new.f120 = 'g';
ERROR 42000: 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 'for each row set new.f120 = 'g'' at line 1
drop trigger trg4_1;
drop trigger trg4_2;
drop trigger trg4_3;
drop trigger trg4_4;
drop trigger trg4_5;
drop trigger trg4_6;
Testcase 3.5.1.6: - Need to fix
-------------------------------
Testcase 3.5.1.7: - need to fix
-------------------------------
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (f1 int, f2 char(25),f3 int) engine=myisam;
CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
for each row set new.f3 = '14';
CREATE TRIGGER trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
BEFORE UPDATE on test.t1 for each row set new.f3 = '42';
insert into t1 (f2) values ('insert 3.5.1.7');
select * from t1;
f1 f2 f3
NULL insert 3.5.1.7 14
update t1 set f2='update 3.5.1.7';
select * from t1;
f1 f2 f3
NULL update 3.5.1.7 42
select trigger_name from information_schema.triggers;
trigger_name
trg5_1
trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWX
drop trigger trg5_1;
drop trigger trg_abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ;
drop table t1;
Testcase 3.5.1.8:
-----------------
CREATE TRIGGER trg12* before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '* before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER trigger before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 'trigger before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER 100 before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '100 before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @@view before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@@view before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER @name before insert on tb3 for each row set new.f120 = 't';
ERROR 42000: 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 '@name before insert on tb3 for each row set new.f120 = 't'' at line 1
CREATE TRIGGER tb3.trg6_1 BEFORE INSERT on test.tb3
for each row set new.f120 ='X';
ERROR HY000: Trigger in wrong schema
drop database if exists trig_db;
create database trig_db;
use trig_db;
create table t1 (f1 integer) engine = myisam;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
ERROR HY000: Trigger in wrong schema
use test;
drop database trig_db;
drop trigger trg6_1;
drop trigger trg6_3;
Testcase 3.5.1.9:(cannot be inplemented at this point)
------------------------------------------------------
Testcase 3.5.1.10:
------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X';
CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger already exists
drop trigger trg7_1;
Testcase 3.5.1.?:
-----------------
drop table if exists t1;
drop table if exists t2;
create table t1 (f1 char(50), f2 integer) engine = myisam;
create table t2 (f1 char(50), f2 integer) engine = myisam;
create trigger trig before insert on t1
for each row set new.f1 ='trig t1';
create trigger trig before update on t2
for each row set new.f1 ='trig t2';
ERROR HY000: Trigger already exists
insert into t1 value ('insert to t1',1);
select * from t1;
f1 f2
trig t1 1
update t1 set f1='update to t1';
select * from t1;
f1 f2
update to t1 1
insert into t2 value ('insert to t2',2);
update t2 set f1='update to t1';
select * from t2;
f1 f2
update to t1 2
drop table t1;
drop table t2;
drop trigger trig;
Testcase 3.5.1.11:
------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
drop database if exists trig_db3;
create database trig_db1;
create database trig_db2;
create database trig_db3;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = myisam;
create trigger trig before insert on t1
for each row set new.f1 ='trig1', @test_var1='trig1';
use trig_db2;
create table t2 (f1 char(50), f2 integer) engine = myisam;
create trigger trig before insert on t2
for each row set new.f1 ='trig2', @test_var2='trig2';
use trig_db3;
create table t1 (f1 char(50), f2 integer) engine = myisam;
create trigger trig before insert on t1
for each row set new.f1 ='trig3', @test_var3='trig3';
set @test_var1= '', @test_var2= '', @test_var3= '';
use trig_db1;
insert into t1 (f1,f2) values ('insert to db1 t1',1);
insert into trig_db1.t1 (f1,f2) values ('insert to db1 t1 from db1',2);
insert into trig_db2.t2 (f1,f2) values ('insert to db2 t2 from db1',3);
insert into trig_db3.t1 (f1,f2) values ('insert to db3 t1 from db1',4);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1 trig2 trig3
select * from t1;
f1 f2
trig1 1
trig1 2
select * from trig_db2.t2;
f1 f2
trig2 3
select * from trig_db3.t1;
f1 f2
trig3 4
select * from t1;
f1 f2
trig1 1
trig1 2
use test;
drop database trig_db1;
drop database trig_db2;
drop database trig_db3;
Testcase 3.5.2.1/2/3:
---------------------
drop database if exists trig_db1;
drop database if exists trig_db2;
create database trig_db1;
create database trig_db2;
use trig_db1;
create table t1 (f1 char(50), f2 integer) engine = myisam;
create table trig_db2.t1 (f1 char(50), f2 integer) engine = myisam;
create trigger trig1_b before insert on t1
for each row set @test_var1='trig1_b';
create trigger trig_db1.trig1_a after insert on t1
for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
trig_db1 trig1_b t1
trig_db1 trig1_a t1
trig_db2 trig2 t1
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
select @test_var1, @test_var2, @test_var3;
@test_var1 @test_var2 @test_var3
trig1_b trig1_a trig2
drop database trig_db1;
drop database trig_db2;
Testcase 3.5.3:
---------------
drop database if exists priv_db;
create database priv_db;
use priv_db;
create table t1 (f1 char(20));
create User test_noprivs@localhost;
set password for test_noprivs@localhost = password('PWD');
create User test_yesprivs@localhost;
set password for test_yesprivs@localhost = password('PWD');
Testcase 3.5.3.2/6:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SUPER on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
Testcase 3.5.3.2:
-----------------
select current_user;
current_user
test_noprivs@localhost
use priv_db;
create trigger trg1_1 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_1-no';
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-no');
select f1 from t1;
f1
insert 3.5.3.2-no
select current_user;
current_user
test_yesprivs@localhost
use priv_db;
create trigger trg1_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.2_2-yes';
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.2-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
Testcase 3.5.3.6:
-----------------
use priv_db;
drop trigger trg1_2;
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-yes');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
use priv_db;
drop trigger trg1_2;
use priv_db;
insert into t1 (f1) values ('insert 3.5.3.6-no');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
drop trigger trg1_2;
Testcase 3.5.3.7a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke UPDATE on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, UPDATE on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1a');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
drop trigger trg4a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT UPDATE, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg4a_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2a';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
drop trigger trg4a_2;
Testcase 3.5.3.7b:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke UPDATE on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
insert 3.5.3.7-1b
update t1 set f1 = 'update 3.5.3.7-1b' where f1 = 'insert 3.5.3.7-1b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
drop trigger trg4b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4b_2 before UPDATE on t1 for each row
set new.f1 = 'trig 3.5.3.7-2b';
insert into t1 (f1) values ('insert 3.5.3.7-2b');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
insert 3.5.3.7-2b
update t1 set f1 = 'update 3.5.3.7-2b' where f1 = 'insert 3.5.3.7-2b';
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
drop trigger trg4b_2;
Testcase 3.5.3.7c
-----------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke UPDATE on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
drop trigger trg4c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4c_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2c';
insert into t1 (f1) values ('insert 3.5.3.7-2c');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
drop trigger trg4c_2;
Testcase 3.5.3.7d:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant SELECT (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant UPDATE (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs;
Grants for test_noprivs@%
GRANT SUPER ON *.* TO 'test_noprivs'@'%'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1), INSERT (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8884
------------------------------------------------
insert into t1 (f1) values ('insert 3.5.3.7-1d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
drop trigger trg4d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT UPDATE (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg4d_2 before INSERT on t1 for each row
set new.f1 = 'trig 3.5.3.7-2d';
insert into t1 (f1) values ('insert 3.5.3.7-2d');
select f1 from t1;
f1
insert 3.5.3.2-no
trig 3.5.3.2_2-yes
trig 3.5.3.2_2-yes
insert 3.5.3.6-no
insert 3.5.3.7-1a
trig 3.5.3.7-2a
update 3.5.3.7-1b
trig 3.5.3.7-2b
insert 3.5.3.7-1c
trig 3.5.3.7-2c
insert 3.5.3.7-1d
trig 3.5.3.7-2d
drop trigger trg4d_2;
Testcase 3.5.3.8a:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant ALL on *.* to test_noprivs@localhost;
revoke SELECT on *.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER, SELECT on *.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
select current_user;
current_user
test_noprivs@localhost
use priv_db;
show grants;
Grants for test_noprivs@localhost
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var = 'before trig 3.5.3.8-1a';
select @test_var;
@test_var
before trig 3.5.3.8-1a
insert into t1 (f1) values ('insert 3.5.3.8-1a');
select @test_var;
@test_var
before trig 3.5.3.8-1a
drop trigger trg5a_1;
use priv_db;
select current_user;
current_user
test_yesprivs@localhost
show grants;
Grants for test_yesprivs@localhost
GRANT SELECT, SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
create trigger trg5a_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2a';
select @test_var;
@test_var
before trig 3.5.3.8-2a
insert into t1 (f1) values ('insert 3.5.3.8-2a');
select @test_var;
@test_var
insert 3.5.3.8-2a
drop trigger trg5a_2;
Testcase: 3.5.3.8b
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.* to test_noprivs@localhost;
revoke SELECT on priv_db.* from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.* to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `priv_db`.* TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1b';
insert into t1 (f1) values ('insert 3.5.3.8-1b');
select @test_var;
@test_var
before trig 3.5.3.8-1b
update t1 set f1= 'update 3.5.3.8-1b' where f1 = 'insert 3.5.3.8-1b';
select @test_var;
@test_var
before trig 3.5.3.8-1b
drop trigger trg5b_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5b_2 before UPDATE on t1 for each row
set @test_var= new.f1;
set @test_var= 'before trig 3.5.3.8-2b';
insert into t1 (f1) values ('insert 3.5.3.8-2b');
select @test_var;
@test_var
before trig 3.5.3.8-2b
update t1 set f1= 'update 3.5.3.8-2b' where f1 = 'insert 3.5.3.8-2b';
select @test_var;
@test_var
update 3.5.3.8-2b
drop trigger trg5b_2;
Testcase 3.5.3.8c:
------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant ALL on priv_db.t1 to test_noprivs@localhost;
revoke SELECT on priv_db.t1 from test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
show grants for test_yesprivs@localhost;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var= 'before trig 3.5.3.8-1c';
insert into t1 (f1) values ('insert 3.5.3.8-1c');
select @test_var;
@test_var
before trig 3.5.3.8-1c
drop trigger trg5c_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5c_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2c';
insert into t1 (f1) values ('insert 3.5.3.8-2c');
select @test_var;
@test_var
insert 3.5.3.8-2c
drop trigger trg5c_2;
Testcase: 3.5.3.8d:
-------------------
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
grant SUPER on *.* to test_noprivs@localhost;
grant UPDATE (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
grant SUPER on *.* to test_yesprivs@localhost;
grant SELECT (f1) on priv_db.t1 to test_yesprivs@localhost;
show grants for test_noprivs@localhost;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
show grants;
Grants for test_noprivs@localhost
GRANT SUPER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
use priv_db;
Trigger create disabled - should fail - Bug 8887
------------------------------------------------
set @test_var='before trig 3.5.3.8-1d';
insert into t1 (f1) values ('insert 3.5.3.8-1d');
select @test_var;
@test_var
before trig 3.5.3.8-1d
drop trigger trg5d_1;
show grants;
Grants for test_yesprivs@localhost
GRANT SUPER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
GRANT SELECT (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
use priv_db;
create trigger trg5d_2 before INSERT on t1 for each row
set @test_var= new.f1;
set @test_var='before trig 3.5.3.8-2d';
insert into t1 (f1) values ('insert 3.5.3.8-2d');
select @test_var;
@test_var
insert 3.5.3.8-2d
drop trigger trg5d_2;
drop database if exists priv_db;
drop user test_yesprivs@localhost;
drop user test_noprivs@localhost;
drop user test_noprivs;
Testcase 3.5.4:
---------------
use test;
Testcase 3.5.4.1:
-----------------
create database db_drop;
Use db_drop;
create table t1 (f1 char(30)) engine=myisam;
grant INSERT, SELECT on db_drop.t1 to test_general;
Use db_drop;
Create trigger trg1 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.1';
Use db_drop;
Insert into t1 values ('Insert error 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers;
trigger_schema trigger_name event_object_table
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1;
f1
Trigger 3.5.4.1
Insert no trigger 3.5.4.1
drop trigger trg1;
drop database if exists db_drop;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.2:
-----------------
create database db_drop2;
Use db_drop2;
drop table if exists t1_432 ;
create table t1_432 (f1 char (30)) engine=myisam;
Drop trigger tr_does_not_exit;
ERROR HY000: Trigger does not exist
drop table if exists t1_432 ;
drop database if exists db_drop2;
Testcase 3.5.4.3:
-----------------
create database db_drop3;
Use db_drop3;
drop table if exists t1_433 ;
drop table if exists t1_433a ;
create table t1_433 (f1 char (30)) engine=myisam;
create table t1_433a (f1a char (5)) engine=myisam;
CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row
set new.f1 = 'Trigger 3.5.4.3';
Drop trigger t1.433.trg3;
ERROR 42000: 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 '.trg3' at line 1
Drop trigger db_drop3.t1.433.trg3;
ERROR 42000: 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 '.433.trg3' at line 1
Drop trigger mysql.trg3;
ERROR HY000: Trigger does not exist
Drop trigger tbx.trg3;
ERROR HY000: Trigger does not exist
Drop trigger db_drop3.trg3;
drop table if exists t1_433;
drop table if exists t1_433a;
drop database if exists db_drop3;
Testcase 3.5.4.4:
-----------------
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=myisam;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Create trigger trg4 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.4';
Use db_drop4;
Insert into t1 values ('Insert 3.5.4.4');
Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
Show databases;
Database
information_schema
mysql
test
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
trigger_schema trigger_name event_object_table
create database db_drop4;
Use db_drop4;
create table t1 (f1 char(30)) engine=myisam;
grant INSERT, SELECT on db_drop4.t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.4');
Select * from t1;
f1
2nd Insert 3.5.4.4
drop trigger trg4;
ERROR HY000: Trigger does not exist
drop database if exists db_drop4;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.4.5:
-----------------
create database db_drop5;
Use db_drop5;
create table t1 (f1 char(50)) engine=myisam;
grant INSERT, SELECT on t1 to test_general;
Create trigger trg5 BEFORE INSERT on t1
for each row set new.f1='Trigger 3.5.4.5';
Use db_drop5;
Insert into t1 values ('Insert 3.5.4.5');
Select * from t1;
f1
Trigger 3.5.4.5
Drop table t1;
Show tables;
Tables_in_db_drop5
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg5';
trigger_schema trigger_name event_object_table
create table t1 (f1 char(50)) engine=myisam;
grant INSERT, SELECT on t1 to test_general;
Insert into t1 values ('2nd Insert 3.5.4.5');
Select * from t1;
f1
2nd Insert 3.5.4.5
drop trigger trg5;
ERROR HY000: Trigger does not exist
drop database if exists db_drop5;
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.5:
---------------
use test;
Testcase 3.5.5.1:
-----------------
Create trigger trg1 before INSERT on t100 for each row set new.f2=1000;
ERROR 42S02: Table 'test.t100' doesn't exist
Testcase 3.5.5.2:
-----------------
Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned);
Create trigger trg2 before INSERT
on t1_temp for each row set new.f2=9999;
ERROR HY000: Trigger's 't1_temp' is view or temporary table
drop table t1_temp;
Testcase 3.5.5.3:
-----------------
Create view vw3 as select f118 from tb3;
Create trigger trg3 before INSERT
on vw3 for each row set new.f118='s';
ERROR HY000: 'test.vw3' is not BASE TABLE
drop view vw3;
Testcase 3.5.5.4:
-----------------
create database dbtest_one;
create database dbtest_two;
use dbtest_two;
create table t2 (f1 char(15));
use dbtest_one;
create trigger trg4 before INSERT
on dbtest_two.t2 for each row set new.f1='trig 3.5.5.4';
ERROR HY000: Trigger in wrong schema
grant INSERT, SELECT on dbtest_two.t2 to test_general;
grant SELECT on dbtest_one.* to test_general;
use dbtest_two;
Insert into t2 values ('1st Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from t2;
f1
1st Insert 3.5.
use dbtest_one;
Insert into dbtest_two.t2 values ('2nd Insert 3.5.5.4');
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
Select * from dbtest_two.t2;
f1
1st Insert 3.5.
2nd Insert 3.5.
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
DROP DATABASE if exists dbtest_one;
drop database if EXISTS dbtest_two;
Testcase 3.5.6:
---------------
use test;
Testcase 3.5.6.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.3:
-----------------
Create trigger trg3_1 DURING UPDATE on tb3 for each row set new.f132=25;
ERROR 42000: 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 'DURING UPDATE on tb3 for each row set new.f132=25' at line 1
Create trigger trg3_2 TIME INSERT on tb3 for each row set new.f132=15;
ERROR 42000: 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 'TIME INSERT on tb3 for each row set new.f132=15' at line 1
drop trigger tb3.trg3_1;
drop trigger tb3.trg3_2;
Testcase 3.5.6.4 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.6.5 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.1 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.2 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.3 (see Testcase 3.5.1.1)
---------------------------------------
Testcase 3.5.7.4:
-----------------
Create trigger trg4_1 BEFORE SELECT on tb3 for each row set new.f132=5;
ERROR 42000: 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 'SELECT on tb3 for each row set new.f132=5' at line 1
Create trigger trg4_2 AFTER VALUE on tb3 for each row set new.f132=1;
ERROR 42000: 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 'VALUE on tb3 for each row set new.f132=1' at line 1
drop trigger tb3.trg4_1;
drop trigger tb3.trg4_2;
Testcase 3.5.7.5 / 3.5.7.6:
---------------------------
Create trigger trg5_1 BEFORE INSERT
on tb3 for each row set new.f122='Trigger1 3.5.7.5/6';
Create trigger trg5_2 BEFORE INSERT
on tb3 for each row set new.f122='Trigger2 3.5.7.5';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.5/6','Insert 3.5.7.5');
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Trigger1 3.5.7.5/6
update tb3 set f122='Update 3.5.7.6' where f121= 'Test 3.5.7.5/6';
Select f121,f122 from tb3 where f121='Test 3.5.7.5/6';
f121 f122
Test 3.5.7.5/6 Update 3.5.7.6
drop trigger trg5_1;
drop trigger trg5_2;
delete from tb3 where f121='Test 3.5.7.5/6';
Testcase 3.5.7.7 / 3.5.7.8:
---------------------------
set @test_var='Before trig 3.5.7.7';
Create trigger trg6_1 AFTER INSERT
on tb3 for each row set @test_var='Trigger1 3.5.7.7/8';
Create trigger trg6_2 AFTER INSERT
on tb3 for each row set @test_var='Trigger2 3.5.7.7';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.7
Insert into tb3 (f121,f122) values ('Test 3.5.7.7/8','Insert 3.5.7.7');
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Insert 3.5.7.7
select @test_var;
@test_var
Trigger1 3.5.7.7/8
update tb3 set f122='Update 3.5.7.8' where f121= 'Test 3.5.7.7/8';
Select f121,f122 from tb3 where f121='Test 3.5.7.7/8';
f121 f122
Test 3.5.7.7/8 Update 3.5.7.8
select @test_var;
@test_var
Trigger1 3.5.7.7/8
drop trigger trg6_1;
drop trigger trg6_2;
delete from tb3 where f121='Test 3.5.7.7/8';
Testcase 3.5.7.9/10:
--------------------
Create trigger trg7_1 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger1 3.5.7.9/10';
Create trigger trg7_2 BEFORE UPDATE
on tb3 for each row set new.f122='Trigger2 3.5.7.9';
ERROR HY000: Trigger already exists
Insert into tb3 (f121,f122) values ('Test 3.5.7.9/10','Insert 3.5.7.9');
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Insert 3.5.7.9
update tb3 set f122='update 3.5.7.10' where f121='Test 3.5.7.9/10';
Select f121,f122 from tb3 where f121='Test 3.5.7.9/10';
f121 f122
Test 3.5.7.9/10 Trigger1 3.5.7.9/10
drop trigger trg7_1;
drop trigger trg7_2;
delete from tb3 where f121='Test 3.5.7.9/10';
Testcase 3.5.7.11/12:
---------------------
set @test_var='Before trig 3.5.7.11';
Create trigger trg8_1 AFTER UPDATE
on tb3 for each row set @test_var='Trigger 3.5.7.11/12';
Create trigger trg8_2 AFTER UPDATE
on tb3 for each row set @test_var='Trigger2 3.5.7.11';
ERROR HY000: Trigger already exists
select @test_var;
@test_var
Before trig 3.5.7.11
Insert into tb3 (f121,f122) values ('Test 3.5.7.11/12','Insert 3.5.7.11/12');
select @test_var;
@test_var
Before trig 3.5.7.11
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 Insert 3.5.7.11/12
update tb3 set f122='update 3.5.7.12' where f121='Test 3.5.7.11/12';
Select f121,f122 from tb3 where f121='Test 3.5.7.11/12';
f121 f122
Test 3.5.7.11/12 update 3.5.7.12
select @test_var;
@test_var
Trigger 3.5.7.11/12
delete from tb3 where f121='Test 3.5.7.11/12';
drop trigger trg8_1;
drop trigger trg8_2;
delete from tb3 where f121='Test 3.5.7.11/12';
Testcase 3.5.7.13/14:
---------------------
set @test_var=1;
Create trigger trg9_1 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+1;
Create trigger trg9_2 BEFORE DELETE
on tb3 for each row set @test_var=@test_var+10;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.13/14','Insert 3.5.7.13');
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
Test 3.5.7.13/14 Insert 3.5.7.13
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.13/14';
Select f121,f122 from tb3 where f121='Test 3.5.7.13/14';
f121 f122
select @test_var;
@test_var
2
delete from tb3 where f121='Test 3.5.7.13/14';
select @test_var;
@test_var
2
drop trigger trg9_1;
drop trigger trg9_2;
delete from tb3 where f121='Test 3.5.7.13/14';
Testcase 3.5.7.15/16:
---------------------
set @test_var=1;
Create trigger trg_3_406010_1 AFTER DELETE
on tb3 for each row set @test_var=@test_var+5;
Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50;
ERROR HY000: Trigger already exists
Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger already exists
select @test_var;
@test_var
1
Insert into tb3 (f121,f122) values ('Test 3.5.7.15/16','Insert 3.5.7.15/16');
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
Test 3.5.7.15/16 Insert 3.5.7.15/16
select @test_var;
@test_var
1
delete from tb3 where f121='Test 3.5.7.15/16';
Select f121,f122 from tb3 where f121='Test 3.5.7.15/16';
f121 f122
select @test_var;
@test_var
6
delete from tb3 where f121='Test 3.5.7.15/16';
select @test_var;
@test_var
6
drop trigger trg_3_406010_1;
drop trigger trg_3_406010_2;
delete from tb3 where f121='Test 3.5.7.15/16';
Testcase 3.5.7.17 (see Testcase 3.5.1.1)
----------------------------------------
Testcase 3.5.8.1: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.2: (implied in previous tests)
---------------------------------------------
Testcase 3.5.8.3/4:
-------------------
create database db_test;
grant SELECT, INSERT, UPDATE, DELETE on db_test.* to test_general;
grant LOCK TABLES on db_test.* to test_general;
Use db_test;
create table t1_i (
i120 char ascii not null DEFAULT b'101',
i136 smallint zerofill not null DEFAULT 999,
i144 int zerofill not null DEFAULT 99999,
i163 decimal (63,30)) engine=myisam;
create table t1_u (
u120 char ascii not null DEFAULT b'101',
u136 smallint zerofill not null DEFAULT 999,
u144 int zerofill not null DEFAULT 99999,
u163 decimal (63,30)) engine=myisam;
create table t1_d (
d120 char ascii not null DEFAULT b'101',
d136 smallint zerofill not null DEFAULT 999,
d144 int zerofill not null DEFAULT 99999,
d163 decimal (63,30)) engine=myisam;
Insert into t1_u values ('a',111,99999,999.99);
Insert into t1_u values ('b',222,99999,999.99);
Insert into t1_u values ('c',333,99999,999.99);
Insert into t1_u values ('d',222,99999,999.99);
Insert into t1_u values ('e',222,99999,999.99);
Insert into t1_u values ('f',333,99999,999.99);
Insert into t1_d values ('a',111,99999,999.99);
Insert into t1_d values ('b',222,99999,999.99);
Insert into t1_d values ('c',333,99999,999.99);
Insert into t1_d values ('d',444,99999,999.99);
Insert into t1_d values ('e',222,99999,999.99);
Insert into t1_d values ('f',222,99999,999.99);
3.5.8.4 - multiple SQL
----------------------
use test;
Create trigger trg1 AFTER INSERT on tb3 for each row
BEGIN
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update db_test.t1_u
set u144=new.f144, u163=new.f163
where u136=new.f136;
delete from db_test.t1_d where d136= new.f136;
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
END//
Use test;
set @test_var=0;
Insert into tb3 (f120, f122, f136, f144, f163)
values ('1', 'Test 3.5.8.4', 222, 23456, 1.05);
Select f120, f122, f136, f144, f163 from tb3 where f122= 'Test 3.5.8.4';
f120 f122 f136 f144 f163
1 Test 3.5.8.4 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
b 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00222 0000023456 1.050000000000000000000000000000
e 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
d 00444 0000099999 999.990000000000000000000000000000
select @test_var;
@test_var
3.150000000000000000000000000000
3.5.8.4 - single SQL - insert
-----------------------------
Create trigger trg2 BEFORE UPDATE on tb3 for each row
insert into db_test.t1_i
values (new.f120, new.f136, new.f144, new.f163);
update tb3 set f120='I', f122='Test 3.5.8.4-Single Insert'
where f122='Test 3.5.8.4';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
I Test 3.5.8.4-Single Insert 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_i;
i120 i136 i144 i163
1 00222 0000023456 1.050000000000000000000000000000
I 00222 0000023456 1.050000000000000000000000000000
3.5.8.4 - single SQL - update
-----------------------------
drop trigger trg2;
Create trigger trg3 BEFORE UPDATE on tb3 for each row
update db_test.t1_u
set u120=new.f120
where u136=new.f136;
update tb3 set f120='U', f122='Test 3.5.8.4-Single Update'
where f122='Test 3.5.8.4-Single Insert';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
U Test 3.5.8.4-Single Update 00222 0000023456 1.050000000000000000000000000000
select * from db_test.t1_u;
u120 u136 u144 u163
a 00111 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
U 00222 0000023456 1.050000000000000000000000000000
f 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - delete
-------------------------------
drop trigger trg3;
Create trigger trg4 AFTER UPDATE on tb3 for each row
delete from db_test.t1_d where d136= new.f136;
update tb3 set f120='D', f136=444,
f122='Test 3.5.8.4-Single Delete'
where f122='Test 3.5.8.4-Single Update';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
D Test 3.5.8.4-Single Delete 00444 0000023456 1.050000000000000000000000000000
select * from db_test.t1_d;
d120 d136 d144 d163
a 00111 0000099999 999.990000000000000000000000000000
c 00333 0000099999 999.990000000000000000000000000000
3.5.8.3/4 - single SQL - select
-------------------------------
drop trigger trg4;
Create trigger trg5 AFTER UPDATE on tb3 for each row
select sum(db_test.t1_u.u163) into @test_var from db_test.t1_u
where u136= new.f136;
set @test_var=0;
update tb3 set f120='S', f136=111,
f122='Test 3.5.8.4-Single Select'
where f122='Test 3.5.8.4-Single Delete';
Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%';
f120 f122 f136 f144 f163
S Test 3.5.8.4-Single Select 00111 0000023456 1.050000000000000000000000000000
select @test_var;
@test_var
999.990000000000000000000000000000
drop trigger trg1;
drop trigger trg5;
drop database if exists db_test;
delete from tb3 where f122 like 'Test 3.5.8.4%';
revoke ALL PRIVILEGES, GRANT OPTION FROM 'test_general'@'localhost';
Testcase 3.5.8.5 (IF):
----------------------
create trigger trg2 before insert on tb3 for each row
BEGIN
IF new.f120='1' then
set @test_var='one', new.f120='2';
ELSEIF new.f120='2' then
set @test_var='two', new.f120='3';
ELSEIF new.f120='3' then
set @test_var='three', new.f120='4';
END IF;
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END IF;
END//
set @test_var='Empty', @test_var2=0;
Insert into tb3 (f120, f122, f136) values ('1', 'Test 3.5.8.5-if', 101);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 one 2nd else
Insert into tb3 (f120, f122, f136) values ('2', 'Test 3.5.8.5-if', 102);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 two 2nd else
D Test 3.5.8.5-if 00102 two 2nd else
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 10);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd if
D Test 3.5.8.5-if 00102 three 2nd if
d Test 3.5.8.5-if 00010 three 2nd if
Insert into tb3 (f120, f122, f136) values ('3', 'Test 3.5.8.5-if', 103);
select f120, f122, f136, @test_var, @test_var2
from tb3 where f122 = 'Test 3.5.8.5-if';
f120 f122 f136 @test_var @test_var2
D Test 3.5.8.5-if 00101 three 2nd else
D Test 3.5.8.5-if 00102 three 2nd else
d Test 3.5.8.5-if 00010 three 2nd else
D Test 3.5.8.5-if 00103 three 2nd else
create trigger trg3 before update on tb3 for each row
BEGIN
ELSEIF new.f120='2' then
END IF;
END//
ERROR 42000: 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 'ELSEIF new.f120='2' then
END IF;
END' at line 3
drop trigger trg3//
create trigger trg4 before update on tb3 for each row
BEGIN
IF (new.f120='4') and (new.f136=10) then
set @test_var2='2nd if', new.f120='d';
ELSE
set @test_var2='2nd else', new.f120='D';
END//
ERROR 42000: 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 '' at line 7
drop trigger trg4;
drop trigger trg2;
delete from tb3 where f121='Test 3.5.8.5-if';
Testcase 3.5.8.5-case:
----------------------
create trigger trg3 before insert on tb3 for each row
BEGIN
SET new.f120=char(ascii(new.f120)-32);
CASE
when new.f136<100 then set new.f136=new.f136+120;
when new.f136<10 then set new.f144=777;
when new.f136>100 then set new.f120=new.f136-1;
END case;
CASE
when new.f136=200 then set @test_var=CONCAT(new.f120, '=');
ELSE set @test_var=concat(new.f120, '*');
END case;
CASE new.f144
when 1 then set @test_var=concat(@test_var, 'one');
when 2 then set @test_var=concat(@test_var, 'two');
when 3 then set @test_var=concat(@test_var, 'three');
when 4 then set @test_var=concat(@test_var, 'four');
when 5 then set @test_var=concat(@test_var, 'five');
when 6 then set @test_var=concat(@test_var, 'six');
when 7 then set @test_var=concat(@test_var, 'seven');
when 8 then set @test_var=concat(@test_var, 'eight');
when 9 then set @test_var=concat(@test_var, 'nine');
when 10 then set @test_var=concat(@test_var, 'ten');
when 11 then set @test_var=concat(@test_var, 'eleven');
when 12 then set @test_var=concat(@test_var, 'twelve');
when 13 then set @test_var=concat(@test_var, 'thirteen');
when 14 then set @test_var=concat(@test_var, 'fourteen');
when 15 then set @test_var=concat(@test_var, 'fifteen');
ELSE set @test_var=CONCAT(new.f120, '*', new.f144);
END case;
END//
set @test_var='Empty';
Insert into tb3 (f120, f122, f136, f144)
values ('a', 'Test 3.5.8.5-case', 5, 7);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 A*seven
Insert into tb3 (f120, f122, f136, f144)
values ('b', 'Test 3.5.8.5-case', 71,16);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 B*0000000016
B Test 3.5.8.5-case 00191 0000000016 B*0000000016
Insert into tb3 (f120, f122, f136, f144)
values ('c', 'Test 3.5.8.5-case', 80,1);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 C=one
B Test 3.5.8.5-case 00191 0000000016 C=one
C Test 3.5.8.5-case 00200 0000000001 C=one
Insert into tb3 (f120, f122, f136)
values ('d', 'Test 3.5.8.5-case', 152);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1*0000099999
B Test 3.5.8.5-case 00191 0000000016 1*0000099999
C Test 3.5.8.5-case 00200 0000000001 1*0000099999
1 Test 3.5.8.5-case 00152 0000099999 1*0000099999
Insert into tb3 (f120, f122, f136, f144)
values ('e', 'Test 3.5.8.5-case', 200, 8);
Warnings:
Warning 1265 Data truncated for column 'f120' at row 1
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
Insert into tb3 (f120, f122, f136, f144)
values ('f', 'Test 3.5.8.5-case', 100, 8);
select f120, f122, f136, f144, @test_var
from tb3 where f122 = 'Test 3.5.8.5-case';
f120 f122 f136 f144 @test_var
A Test 3.5.8.5-case 00125 0000000007 1=eight
B Test 3.5.8.5-case 00191 0000000016 1=eight
C Test 3.5.8.5-case 00200 0000000001 1=eight
1 Test 3.5.8.5-case 00152 0000099999 1=eight
1 Test 3.5.8.5-case 00200 0000000008 1=eight
create trigger trg3a before update on tb3 for each row
BEGIN
CASE
when new.f136<100 then set new.f120='p';
END//
ERROR 42000: 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 '' at line 5
drop trigger trg3a;
drop trigger trg3;
delete from tb3 where f121='Test 3.5.8.5-case';
Testcase 3.5.8.5-loop/leave:
----------------------------
Create trigger trg4 after insert on tb3 for each row
BEGIN
set @counter=0, @flag='Initial';
Label1: loop
if new.f136<new.f144 then
set @counter='Nothing to loop';
leave Label1;
else
set @counter=@counter+1;
if new.f136=new.f144+@counter then
set @counter=concat(@counter, ' loops');
leave Label1;
end if;
end if;
iterate label1;
set @flag='Final';
END loop Label1;
END//
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 2, 8);
select @counter, @flag;
@counter @flag
Nothing to loop Initial
Insert into tb3 (f122, f136, f144)
values ('Test 3.5.8.5-loop', 11, 8);
select @counter, @flag;
@counter @flag
3 loops Initial
Create trigger trg4_2 after update on tb3 for each row
BEGIN
Label1: loop
set @counter=@counter+1;
END;
END//
ERROR 42000: 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 ';
END' at line 5
drop trigger trg4_2;
drop trigger trg4;
delete from tb3 where f122='Test 3.5.8.5-loop';
Testcase 3.5.8.5-repeat:
------------------------
Create trigger trg6 after insert on tb3 for each row
BEGIN
rp_label: REPEAT
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE rp_label;
END IF;
SET @counter2 = @counter2 + 1;
UNTIL @counter1> new.f136 END REPEAT rp_label;
END//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-repeat', 13);
select @counter1, @counter2;
@counter1 @counter2
15 8
Create trigger trg6_2 after update on tb3 for each row
BEGIN
REPEAT
SET @counter2 = @counter2 + 1;
END//
ERROR 42000: 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 'END' at line 5
drop trigger trg6;
delete from tb3 where f122='Test 3.5.8.5-repeat';
Testcase 3.5.8.5-while:
-----------------------
Create trigger trg7 after insert on tb3 for each row
wl_label: WHILE @counter1 < new.f136 DO
SET @counter1 = @counter1 + 1;
IF (@counter1 MOD 2 = 0) THEN ITERATE wl_label;
END IF;
SET @counter2 = @counter2 + 1;
END WHILE wl_label//
set @counter1= 0, @counter2= 0;
Insert into tb3 (f122, f136)
values ('Test 3.5.8.5-while', 7);
select @counter1, @counter2;
@counter1 @counter2
7 4
Create trigger trg7_2 after update on tb3 for each row
BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: 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 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
Testcase 3.5.8.6: (requirement void)
------------------------------------
Testcase 3.5.8.7: (Disabled as a result of bug _____)
-----------------------------------------------------
Testcase 3.5.9.1/2:
-------------------
Create trigger trg1 BEFORE UPDATE on tb3 for each row
set new.f142 = 94087, @counter=@counter+1;
TotalRows
19
Affected
17
NotAffected
2
NewValuew
0
set @counter=0;
Update tb3 Set f142='1' where f130<100;
select count(*) as ExpectedChanged, @counter as TrigCounter
from tb3 where f142=94087;
ExpectedChanged TrigCounter
17 17
select count(*) as ExpectedNotChange from tb3
where f130<100 and f142<>94087;
ExpectedNotChange
0
select count(*) as NonExpectedChanged from tb3
where f130>=130 and f142=94087;
NonExpectedChanged
0
drop trigger trg1;
Testcase 3.5.9.3:
-----------------
Create trigger trg2_a before update on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_b after update on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
Create trigger trg2_c before delete on tb3 for each row
set @tr_var_b4_118=old.f118, @tr_var_b4_121=old.f121,
@tr_var_b4_122=old.f122, @tr_var_b4_136=old.f136,
@tr_var_b4_163=old.f163;
Create trigger trg2_d after delete on tb3 for each row
set @tr_var_af_118=old.f118, @tr_var_af_121=old.f121,
@tr_var_af_122=old.f122, @tr_var_af_136=old.f136,
@tr_var_af_163=old.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
Insert into tb3 (f122, f136, f163)
values ('Test 3.5.9.3', 7, 123.17);
Update tb3 Set f136=8 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
a NULL Test 3.5.9.3 00008 123.170000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 7 123.170000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
0 0 0 0 0
delete from tb3 where f122='Test 3.5.9.3';
select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3';
f118 f121 f122 f136 f163
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_163
a NULL Test 3.5.9.3 8 123.170000000000000000000000000000
drop trigger trg2_a;
drop trigger trg2_b;
drop trigger trg2_c;
drop trigger trg2_d;
Testcase 3.5.9.4:
-----------------
Create trigger trg3_a before insert on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_b after insert on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
Create trigger trg3_c before update on tb3 for each row
set @tr_var_b4_118=new.f118, @tr_var_b4_121=new.f121,
@tr_var_b4_122=new.f122, @tr_var_b4_136=new.f136,
@tr_var_b4_151=new.f151, @tr_var_b4_163=new.f163;
Create trigger trg3_d after update on tb3 for each row
set @tr_var_af_118=new.f118, @tr_var_af_121=new.f121,
@tr_var_af_122=new.f122, @tr_var_af_136=new.f136,
@tr_var_af_151=new.f151, @tr_var_af_163=new.f163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Insert into tb3 (f122, f136, f151, f163)
values ('Test 3.5.9.4', 7, DEFAULT, 995.24);
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4%';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4 00007 999 995.240000000000000000000000000000
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
0 0 0 0 0 0
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'f136' at row 20
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
a NULL Test 3.5.9.4-trig 00000 999 NULL
select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122,
@tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163;
@tr_var_b4_118 @tr_var_b4_121 @tr_var_b4_122 @tr_var_b4_136 @tr_var_b4_151 @tr_var_b4_163
a NULL Test 3.5.9.4-trig 0 999 NULL
select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122,
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
@tr_var_af_118 @tr_var_af_121 @tr_var_af_122 @tr_var_af_136 @tr_var_af_151 @tr_var_af_163
a NULL Test 3.5.9.4-trig 0 999 NULL
drop trigger trg3_a;
drop trigger trg3_b;
drop trigger trg3_c;
drop trigger trg3_d;
delete from tb3 where f122='Test 3.5.9.4-trig';
Testcase 3.5.9.5: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.6:
-----------------
create trigger trg4a before insert on tb3 for each row
set @temp1= old.f120;
ERROR HY000: There is no OLD row in on INSERT trigger
create trigger trg4b after insert on tb3 for each row
set old.f120= 'test';
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg4a;
drop trigger trg4b;
Testcase 3.5.9.7: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.8: (implied in previous tests)
---------------------------------------------
Testcase 3.5.9.9:
-----------------
create trigger trg5a before DELETE on tb3 for each row
set @temp1=new.f122;
ERROR HY000: There is no NEW row in on DELETE trigger
create trigger trg5b after DELETE on tb3 for each row
set new.f122='test';
ERROR HY000: There is no NEW row in on DELETE trigger
drop trigger trg5a;
drop trigger trg5b;
Testcase 3.5.9.10: (implied in previous tests)
----------------------------------------------
Testcase 3.5.9.11: covered by 3.5.9.9
-------------------------------------
Testcase 3.5.9.12: covered by 3.5.9.6
-------------------------------------
Testcase 3.5.9.13:
------------------
create trigger trg6a before UPDATE on tb3 for each row
set old.f118='C', new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6b after INSERT on tb3 for each row
set old.f136=163, new.f118='U';
ERROR HY000: Updating of OLD row is not allowed in trigger
create trigger trg6c after UPDATE on tb3 for each row
set old.f136=NULL;
ERROR HY000: Updating of OLD row is not allowed in trigger
drop trigger trg6a;
drop trigger trg6b;
drop trigger trg6c;
Testcase 3.5.9.14: (implied in previous tests)
----------------------------------------------
Testcase 3.5.10.1/2/3:
----------------------
Create view vw11 as select * from tb3
where f122 like 'Test 3.5.10.1/2/3%';
Create trigger trg1a before insert on tb3
for each row set new.f163=111.11;
Create trigger trg1b after insert on tb3
for each row set @test_var='After Insert';
Create trigger trg1c before update on tb3
for each row set new.f121='Y', new.f122='Test 3.5.10.1/2/3-Update';
Create trigger trg1d after update on tb3
for each row set @test_var='After Update';
Create trigger trg1e before delete on tb3
for each row set @test_var=5;
Create trigger trg1f after delete on tb3
for each row set @test_var= 2* @test_var+7;
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 1);
Insert into vw11 (f122, f151) values ('Test 3.5.10.1/2/3', 2);
Insert into vw11 (f122, f151) values ('Not in View', 3);
select f121, f122, f151, f163
from tb3 where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
NULL Test 3.5.10.1/2/3 2 111.110000000000000000000000000000
NULL Test 3.5.10.1/2/3 1 111.110000000000000000000000000000
select f121, f122, f151, f163
from tb3 where f122 like 'Not in View';
f121 f122 f151 f163
NULL Not in View 3 111.110000000000000000000000000000
Update vw11 set f163=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Y Test 3.5.10.1/2/3-Update 1 1.000000000000000000000000000000
set @test_var=0;
Select @test_var as 'before delete';
before delete
0
delete from vw11 where f151=1;
select f121, f122, f151, f163 from tb3
where f122 like 'Test 3.5.10.1/2/3%';
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
select f121, f122, f151, f163 from vw11;
f121 f122 f151 f163
Y Test 3.5.10.1/2/3-Update 2 1.000000000000000000000000000000
Select @test_var as 'after delete';
after delete
17
drop view vw11;
drop trigger trg1a;
drop trigger trg1b;
drop trigger trg1c;
drop trigger trg1d;
drop trigger trg1e;
drop trigger trg1f;
delete from tb3 where f122 like 'Test 3.5.10.1/2/3%';
Testcase 3.5.10.4:
------------------
create table tb_load (f1 int, f2 char(25),f3 int) engine=myisam;
Create trigger trg4 before insert on tb_load
for each row set new.f3=-(new.f1 div 5), @counter= @counter+1;
set @counter= 0;
select @counter as 'Rows Loaded Before';
Rows Loaded Before
0
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table tb_load;
select @counter as 'Rows Loaded After';
Rows Loaded After
10
Select * from tb_load limit 10;
f1 f2 f3
-5000 a` 1000
-4999 aaa 999
-4998 abaa 999
-4997 acaaa 999
-4996 adaaaa 999
-4995 aeaaaaa 999
-4994 afaaaaaa 998
-4993 agaaaaaaa 998
-4992 a^aaaaaaaa 998
-4991 a_aaaaaaaaa 998
drop trigger trg4;
drop table tb_load;
Testcase 3.5.10.5: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.6: (implemented in trig_frkey.test)
---------------------------------------------------
Testcase 3.5.10.extra:
----------------------
create table t1_sp (var136 tinyint, var151 decimal) engine=myisam;
create trigger trg before insert on t1_sp
for each row set @counter=@counter+1;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR 02000: No data to FETCH
select @counter;
@counter
20
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
20
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase 3.5.11.1 (implemented in trig_perf.test)
-------------------------------------------------
drop user test_general@localhost;
drop user test_general;
drop user test_super@localhost;
Testcase y.y.y.2: Check for triggers starting triggers
------------------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2_1;
drop table if exists t2_2;
drop table if exists t2_3;
drop table if exists t2_4;
drop table if exists t3;
create table t1 (f1 integer);
create table t2_1 (f1 integer);
create table t2_2 (f1 integer);
create table t2_3 (f1 integer);
create table t2_4 (f1 integer);
create table t3 (f1 integer);
insert into t1 values (1);
create trigger tr1 after insert on t1 for each row
BEGIN
insert into t2_1 (f1) values (new.f1+1);
insert into t2_2 (f1) values (new.f1+1);
insert into t2_3 (f1) values (new.f1+1);
insert into t2_4 (f1) values (new.f1+1);
END//
create trigger tr2_1 after insert on t2_1 for each row
insert into t3 (f1) values (new.f1+10);
create trigger tr2_2 after insert on t2_2 for each row
insert into t3 (f1) values (new.f1+100);
create trigger tr2_3 after insert on t2_3 for each row
insert into t3 (f1) values (new.f1+1000);
create trigger tr2_4 after insert on t2_4 for each row
insert into t3 (f1) values (new.f1+10000);
insert into t1 values (1);
select * from t3;
f1
12
102
1002
10002
drop trigger tr1;
drop trigger tr2_1;
drop trigger tr2_2;
drop trigger tr2_3;
drop trigger tr2_4;
drop table t1, t2_1, t2_2, t2_3, t2_4, t3;
Testcase y.y.y.3: Circular trigger reference
--------------------------------------------
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = myisam;
create table t2 (f2 integer) engine = myisam;
create table t3 (f3 integer) engine = myisam;
create table t4 (f4 integer) engine = myisam;
insert into t1 values (0);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1);
create trigger tr4 after insert on t4
for each row insert into t1 (f1) values (new.f4+1);
insert into t1 values (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
select * from t1;
f1
0
1
select * from t2;
f2
2
select * from t3;
f3
3
select * from t4;
f4
4
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop trigger tr4;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
Testcase y.y.y.4: Recursive trigger/SP references (disabled bug 11889)
----------------------------------------------------------------------
set @sql_mode='traditional';
create table t1_sp (
count integer,
var136 tinyint,
var151 decimal) engine=myisam;
create procedure trig_sp()
begin
declare done int default 0;
declare var151 decimal;
declare var136 tinyint;
declare cur1 cursor for select f136, f151 from tb3;
declare continue handler for sqlstate '01000' set done = 1;
set @counter= @counter+1;
open cur1;
fetch cur1 into var136, var151;
wl_loop: WHILE NOT done DO
insert into t1_sp values (@counter, var136, var151);
fetch cur1 into var136, var151;
END WHILE wl_loop;
close cur1;
end//
create trigger trg before insert on t1_sp
for each row call trig_sp();
set @counter=0;
select @counter;
@counter
0
call trig_sp();
ERROR HY000: Recursive stored routines are not allowed.
select @counter;
@counter
1
select count(*) from tb3;
count(*)
20
select count(*) from t1_sp;
count(*)
0
drop procedure trig_sp;
drop trigger trg;
drop table t1_sp;
Testcase y.y.y.5: Roleback of nested trigger references
-------------------------------------------------------
set @@sql_mode='traditional';
use test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
create table t1 (f1 integer) engine = myisam;
create table t2 (f2 integer) engine = myisam;
create table t3 (f3 integer) engine = myisam;
create table t4 (f4 tinyint) engine = myisam;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1);
create trigger tr1 after insert on t1
for each row insert into t2 (f2) values (new.f1+1);
create trigger tr2 after insert on t2
for each row insert into t3 (f3) values (new.f2+1);
create trigger tr3 after insert on t3
for each row insert into t4 (f4) values (new.f3+1000);
set autocommit=0;
start transaction;
insert into t1 values (1);
ERROR 22003: Out of range value adjusted for column 'f4' at row 1
commit;
select * from t1;
f1
1
1
select * from t2;
f2
2
select * from t3;
f3
3
drop trigger tr1;
drop trigger tr2;
drop trigger tr3;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
This source diff could not be displayed because it is too large. You can view the blob instead.
#### suite/funcs_1/t/innodb_storedproc.test
#
--source include/have_innodb.inc
let $engine_type= innodb;
--source suite/funcs_1/storedproc/load_sp_tb.inc
--source suite/funcs_1/storedproc/storedproc_master.inc
......@@ -3,4 +3,6 @@
let $engine_type= memory;
--source suite/funcs_1/storedproc/load_sp_tb.inc
--source suite/funcs_1/storedproc/storedproc_master.inc
......@@ -3,4 +3,6 @@
let $engine_type= myisam;
--source suite/funcs_1/storedproc/load_sp_tb.inc
--source suite/funcs_1/storedproc/storedproc_master.inc
......@@ -5,15 +5,6 @@
# Set $engine_type
let $engine_type= myisam;
# Decide, if the objects are to be (re)created
#
# - once at the beginning of a set of testcases ('$NO_REFRESH' <> '' --> TRUE)
# That means the current script must not (re)create any object.
# It can expect, that the objects already exist.
#
# - per every testscript/case ('$NO_REFRESH' = '' --> FALSE)
# That means all objects have to be (re)created within the current script.
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/myisam_tb3.inc
......
#### suite/funcs_1/views/views_master.test
#
# Last Change:
# 2007-10-05 mleich
# 1. Fix for Bug#31237 Test "ndb_views" fails because of differing order ...
# 2. Cleanup of test
# 2007-11-15 hhunger WL#4084: Review and fix all disabled tests ...
let $message= ! Attention: The file with the expected results is not
| thoroughly checked.
......@@ -8,25 +14,20 @@ let $message= ! Attention: The file with the expected results is not
--source include/show_msg80.inc
# As long as
# Bug#11589: mysqltest, --ps-protocol, strange output, float/double/real with zerofill
# is not fixed, we must switch the ps-protocol for some statements off.
# Bug#32285: mysqltest, --ps-protocol, strange output, float/double/real with zerofill
# is not fixed, we must switch the ps-protocol for some statements off (formerly bug#11589).
# If this bug is fixed, please
# 1. set the following variable to 0
# 2. check, if the test passes
# 3. remove the workarounds
let $have_bug_11589= 1;
if ($have_bug_11589)
let $have_bug_32285= 1;
if ($have_bug_32285)
{
let $message= There are some statements where the ps-protocol is switched off.
Bug#11589: mysqltest, --ps-protocol, strange output, float/double/real with zerofill;
Bug#32285: mysqltest, --ps-protocol, strange output, float/double/real with zerofill;
--source include/show_msg80.inc
}
let $message= ! Attention: The file with the expected results suffers from
Bug#10713: mysqldump includes database in create view and referenced tables;
--source include/show_msg80.inc
# The sub testcases are nearly independend. That is the reason why
# we do not want to abort after the first error.
--disable_abort_on_error
......@@ -42,7 +43,7 @@ Bug#10713: mysqldump includes database in create view and referenced tables;
# MySQL has also added some vendor-specific enhancements to the standard
# SQL requirements.
# FIXME (ML)
# FIXME (mleich)
# - Alter all object names so that they follow the v/t/..<number> scheme or
# apply another method which prevents that customer data might be
# accidently modified
......@@ -107,6 +108,12 @@ insert into tb2 (f59,f60,f61) values (109,108,104);
INSERT INTO tb2 (f59,f60) VALUES( 299,899 );
INSERT INTO tb2 (f59,f60) VALUES( 242,79 );
INSERT INTO tb2 (f59,f60) VALUES( 424,89 );
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM tb2 ORDER BY f59, f60, f61;
--enable_ps_protocol
#
#
Use test;
......@@ -145,99 +152,101 @@ Insert into t1 values (500,9866);
--enable_warnings
CREATE VIEW v1 AS select f59,f60,f61
FROM test.tb2 where f59=250;
select * FROM v1 limit 0,10;
select * FROM v1 order by f60,f61 limit 0,10;
#(02)
Drop view if exists v1 ;
CREATE VIEW v1 AS select f59,f60,f61
FROM test.tb2 limit 100;
select * FROM v1 limit 0,10;
select * FROM v1 order by f59,f60,f61 limit 0,10;
#(03)
CREATE or REPLACE VIEW v1 AS select f59,f60,f61
FROM test.tb2 limit 4,3;
select * FROM v1 limit 0,10;
FROM test.tb2;
select * FROM v1 order by f59,f60,f61 limit 4,3;
#(04)
CREATE or REPLACE VIEW v1 AS select distinct f59
FROM test.tb2 limit 4,3;
select * FROM v1 limit 0,10;
FROM test.tb2;
select * FROM v1 order by f59 limit 4,3;
#(05)
ALTER VIEW v1 AS select f59
FROM test.tb2 limit 6,2;
select * FROM v1 limit 0,10;
FROM test.tb2;
select * FROM v1 order by f59 limit 6,2;
#(06)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 order by f59 limit 100;
select * FROM v1 limit 0,10;
from tb2 order by f59;
select * FROM v1 order by f59 limit 0,10;
#(07)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 order by f59 asc limit 100;
from tb2 order by f59 asc;
select * FROM v1 limit 0,10;
#(08)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 order by f59 desc limit 100;
from tb2 order by f59 desc;
select * FROM v1 limit 0,10;
#(09)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 group by f59 limit 100;
select * FROM v1 limit 0,10;
from tb2 group by f59;
select * FROM v1 order by f59 limit 0,10;
#(10)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 group by f59 asc limit 100;
select * FROM v1 limit 0,10;
from tb2 group by f59 asc;
select * FROM v1 order by f59 limit 0,10;
#(11)
CREATE or REPLACE VIEW v1 AS select f59
from tb2 group by f59 desc limit 100;
select * FROM v1 limit 0,10;
from tb2 group by f59 desc;
select * FROM v1 order by f59 limit 0,10;
#(12)
CREATE or REPLACE VIEW v1 AS (select f59 from tb2)
union (select f59 from t1) limit 100;
select * FROM v1 limit 0,10;
union (select f59 from t1);
select * FROM v1 order by f59 limit 0,10;
#(13)
CREATE or REPLACE VIEW v1 AS (select f59 FROM tb2)
UNION DISTINCT(select f59 FROM t1) ;
select * FROM v1 limit 0,10;
select * FROM v1 order by f59 limit 0,10;
#(14)
CREATE or REPLACE VIEW v1 AS (select f59 FROM tb2)
UNION ALL(select f59 FROM t1) ;
select * FROM v1 limit 0,10;
select * FROM v1 order by f59 limit 0,10;
#(15)
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
CREATE or REPLACE VIEW v1 AS select *
FROM test.tb2 WITH LOCAL CHECK OPTION ;
select * FROM v1 limit 0,50;
select * FROM v1 order by f59,f60,f61,f62,f63,f64 limit 0,50;
#(16)
CREATE or REPLACE VIEW v1 AS select *
FROM test.tb2 WITH CASCADED CHECK OPTION ;
select * FROM v1 limit 0,10;
select * FROM v1 order by f59,f60,f61,f62,f63,f64 limit 0,10;
--horizontal_results
--enable_ps_protocol
#(17)
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 WITH CASCADED CHECK OPTION;
SELECT * FROM v1 limit 0,10;
SELECT * FROM v1 order by f59,f60 limit 0,10;
#(18)
CREATE or REPLACE VIEW v1 AS select f59, f60
from test.tb2 where f59=3330 ;
select * FROM v1 limit 0,10;
select * FROM v1 order by f60 limit 0,10;
DROP VIEW v1 ;
DROP TABLE t1 ;
......@@ -260,12 +269,12 @@ CREATE TABLE t1 (f1 BIGINT) ;
# SELECT INTO is illegal
SET @x=0;
--error 1350
--error ER_VIEW_SELECT_CLAUSE
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
Select @x;
# Subquery in the FROM clause is illegal
--error 1349
--error ER_VIEW_SELECT_DERIVED
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
......@@ -282,23 +291,16 @@ SELECT @a ;
SELECT * FROM t1;
DROP TRIGGER tr1 ;
SET @a:=0 ;
--error 1347
--error ER_WRONG_OBJECT
CREATE TRIGGER tr1 BEFORE INSERT ON v1 FOR EACH ROW SET @a:=1 ;
# RENAME VIEW is not available even when we try it via rename table.
# FIXME: Write a bug report for the ugly error message
# 1017: Can't find file: './test/v1.frm' (errno: 2),
# because the much more beautiful
# 1347: 'test.v1' is not BASE TABLE
# exists.
--replace_result '\\' '/'
# MLML --error 1017
RENAME TABLE v1 TO v2;
--error 1064
# RENAME VIEW is not available even when we try it via rename table.
--error ER_PARSE_ERROR
RENAME VIEW v2 TO v1;
#--error 1347
#--error ER_WRONG_OBJECT
ALTER TABLE v2 RENAME AS v1;
--error 1064
--error ER_PARSE_ERROR
ALTER VIEW v1 RENAME AS v2;
# VIEWs cannot contain a PRIMARY KEY or have an Index.
......@@ -310,12 +312,12 @@ DROP VIEW IF EXISTS v2 ;
CREATE TABLE t1 ( f1 DATE, f2 BLOB, f3 DOUBLE );
CREATE VIEW v1 AS SELECT f1, f2, f3 FROM t1;
ALTER TABLE t1 ADD PRIMARY KEY(f1);
--error 1347
--error ER_WRONG_OBJECT
ALTER TABLE v1 ADD PRIMARY KEY(f1);
--error 1064
--error ER_PARSE_ERROR
ALTER VIEW v1 ADD PRIMARY KEY(f1);
CREATE INDEX t1_idx ON t1(f3);
--error 1347
--error ER_WRONG_OBJECT
CREATE INDEX v1_idx ON v1(f3);
DROP TABLE t1;
DROP VIEW v1;
......@@ -333,21 +335,21 @@ let $message= Testcase 3.3.1.3 + 3.1.1.4 ;
DROP VIEW IF EXISTS v1 ;
--enable_warnings
# REPLACE after VIEW name
--error 1064
CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table limit 50;
--error ER_PARSE_ERROR
CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table;
# CHECK OPTION before AS SELECT
--error 1064
--error ER_PARSE_ERROR
CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50;
# CHECK OPTION before AS SELECT
--error 1064
--error ER_PARSE_ERROR
CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50;
# CREATE after SELECT
--error 1064
SELECT * FROM tb2 my_table CREATE VIEW As v1 limit 100 ;
--error ER_PARSE_ERROR
SELECT * FROM tb2 my_table CREATE VIEW As v1;
# AS forgotten
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE VIEW v1 Select f59, f60
from test.tb2 my_table where f59 = 250 ;
# positive case
......@@ -355,60 +357,60 @@ CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table WITH CASCADED CHECK OPTION;
DROP VIEW v1;
# REPLACE OR CREATE instead of CREATE OR REPLACE
--error 1064
--error ER_PARSE_ERROR
REPLACE OR CREATE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table WITH CASCADED CHECK OPTION;
# AS after SELECT
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 SELECT AS F59, F60
FROM test.tb2 my_table WITH CASCADED CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table CASCADED WITH CHECK OPTION;
# OPTION CHECK instead of CHECK OPTION
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table WITH CASCADED OPTION CHECK;
# CHECK OPTION before WITH
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table CHECK OPTION WITH CASCADED;
# CHECK OPTION before AS SELECT
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
# VIEW <viewname> after AS SELECT
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION;
# VIEW <viewname> after CHECK OPTION
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table WITH CASCADED CHECK OPTION VIEW v1;
# Variants with LOCAL CHECK OPTION
--error 1064
--error ER_PARSE_ERROR
REPLACE OR CREATE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table WITH LOCAL CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 SELECT AS F59, F60
FROM test.tb2 my_table WITH LOCAL CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table LOCAL WITH CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table WITH LOCAL OPTION CHECK;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 AS SELECT F59, F60
FROM test.tb2 my_table CHECK OPTION WITH LOCAL;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table WITH LOCAL CHECK OPTION VIEW v1;
......@@ -419,15 +421,15 @@ CREATE table t1 (f1 int ,f2 int) ;
INSERT INTO t1 values (235, 22);
INSERT INTO t1 values (554, 11);
# SELECTs of UNION in braces
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE view v1 as (Select from f59 tb2)
Union ALL (Select from f1 t1);
# by before order
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by order f59 limit 100 ;
from tb2 by order f59;
# by before group
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
......@@ -442,24 +444,24 @@ let $message= Testcase 3.3.1.5 ;
--disable_warnings
DROP VIEW IF EXISTS v1 ;
--enable_warnings
--error 1064
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
--error 1064
CREATE v1 AS SELECT * FROM tb2 limit 100 ;
--error 1064
VIEW v1 AS SELECT * FROM tb2 limit 100 ;
--error ER_PARSE_ERROR
CREATE VIEW v1 SELECT * FROM tb2;
--error ER_PARSE_ERROR
CREATE v1 AS SELECT * FROM tb2;
--error ER_PARSE_ERROR
VIEW v1 AS SELECT * FROM tb2;
# positive case
CREATE VIEW v1 AS SELECT 1;
DROP VIEW v1;
--error 1064
--error ER_PARSE_ERROR
VIEW v1 AS SELECT 1;
--error 1064
--error ER_PARSE_ERROR
CREATE v1 AS SELECT 1;
--error 1064
--error ER_PARSE_ERROR
CREATE VIEW AS SELECT 1;
--error 1064
--error ER_PARSE_ERROR
CREATE VIEW v1 SELECT 1;
--error 1064
--error ER_PARSE_ERROR
CREATE VIEW v1 AS ;
......@@ -480,37 +482,37 @@ let $message= Testcase 3.3.1.6 ;
DROP VIEW IF EXISTS v1 ;
--enable_warnings
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
CREATE or REPLACE ALGORITHM = UNDEFINED VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
CREATE or REPLACE ALGORITHM = MERGE VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
CREATE or REPLACE ALGORITHM = TEMPTABLE VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
CREATE or REPLACE ALGORITHM = TEMPTABLE VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
# negative test cases
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE = TEMPTABLE VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE ALGORITHM TEMPTABLE VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE ALGORITHM = VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE TEMPTABLE = ALGORITHM VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE TEMPTABLE - ALGORITHM VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE GARBAGE = TEMPTABLE VIEW v1
as SELECT * from tb2 limit 100 ;
--error 1064
as SELECT * from tb2;
--error ER_PARSE_ERROR
CREATE or REPLACE ALGORITHM = GARBAGE VIEW v1
as SELECT * from tb2 limit 100 ;
as SELECT * from tb2;
Drop view if exists v1 ;
CREATE or REPLACE VIEW v1
......@@ -522,16 +524,16 @@ AS SELECT * from tb2 where f59 < 1 WITH CASCADED CHECK OPTION;
CREATE or REPLACE VIEW v1
AS SELECT * from tb2 where f59 < 1 WITH LOCAL CHECK OPTION;
# negative test cases
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE VIEW v1
AS SELECT * from tb2 where f59 < 1 WITH NO CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE VIEW v1
AS SELECT * from tb2 where f59 < 1 CASCADED CHECK OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE VIEW v1
AS SELECT * from tb2 where f59 < 1 WITH CASCADED OPTION;
--error 1064
--error ER_PARSE_ERROR
CREATE or REPLACE VIEW v1
AS SELECT * from tb2 where f59 < 1 WITH CASCADED CHECK ;
......@@ -543,12 +545,12 @@ let $message= Testcase 3.3.1.7 ;
# view names are accepted, at creation time, alteration time,
# and drop time.
###############################################################################
# Note(ML): non-qualified view name means a view name without preceeding
# Note(mleich): non-qualified view name means a view name without preceeding
# database name
--disable_warnings
DROP VIEW IF EXISTS v1 ;
--enable_warnings
Create view test.v1 AS Select * from test.tb2 limit 100 ;
Create view test.v1 AS Select * from test.tb2;
Alter view test.v1 AS Select F59 from test. tb2 limit 100 ;
Drop view test.v1 ;
Create view v1 AS Select * from test.tb2 limit 100 ;
......@@ -561,7 +563,7 @@ let $message= Testcase 3.3.1.A0 ;
###############################################################################
# Testcase 3.3.1.A0: Ensure that view names are treated case sensitive.
###############################################################################
# Note(ML): Maybe this test produces portability problems on Windows.
# Note(mleich): Maybe this test produces portability problems on Windows.
# FIXME There should be a test outside this one checking the
# creation of objects with cases sensitive names.
# If we have this test the following sub testcase should
......@@ -576,8 +578,8 @@ INSERT INTO t1 VALUES(1111), (2222);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1 = 1111;
# We get here the sql code
# - 0 on OS with cases sensitive view names (Example: UNIX)
# - 1050 on OS without cases sensitive view names (Example: WINDOWS)
--error 0,1050
# - ER_TABLE_EXISTS_ERROR on OS without cases sensitive view names (Example: WINDOWS)
--error 0,ER_TABLE_EXISTS_ERROR
CREATE VIEW V1 AS SELECT * FROM t1 WHERE f1 = 2222;
SELECT * FROM v1;
# SELECT * FROM V1;
......@@ -595,20 +597,20 @@ let $message= Testcase 3.3.1.8 ;
# that an appropriate error message is returned when the name
# is rejected.
###############################################################################
# Note(ML): There could be more negative tests here, but I assume that the
# server routines checking if a table or view name is acceptable are
# heavily tested in tests checking the creation of tables.
--error 1064
# Note(mleich): There could be more negative tests here, but I assume that the
# server routines checking if a table or view name is acceptable
# are heavily tested in tests checking the creation of tables.
--error ER_PARSE_ERROR
Create view select AS Select * from test.tb2 limit 100;
--error 1064
--error ER_PARSE_ERROR
Create view as AS Select * from test.tb2 limit 100;
--error 1064
--error ER_PARSE_ERROR
Create view where AS Select * from test.tb2 limit 100;
--error 1064
--error ER_PARSE_ERROR
Create view from AS Select * from test.tb2 limit 100;
--error 1064
--error ER_PARSE_ERROR
Create view while AS Select * from test.tb2 limit 100;
--error 1064
--error ER_PARSE_ERROR
Create view asdkj*(&*&&^ as Select * from test.tb2 limit 100 ;
--disable_warnings
Drop view if exists test.procedure ;
......@@ -623,9 +625,10 @@ let $message= Testcase 3.3.1.9 ;
# Testcase 3.3.1.9: Ensure that a reference to a non-existent view is rejected
# with an appropriate error message
###############################################################################
# Note(ML): The SELECT statement syntax does not contain any functionality to
# claim, that the object after FROM must be a VIEW. SHOW's will be
# checked in 3.3.11 Checks on SHOW, EXPLAIN, and DESCRIBE statements.
# Note(mleich): The SELECT statement syntax does not contain any functionality
# to claim, that the object after FROM must be a VIEW. SHOW's will
# be checked in
# 3.3.11 Checks on SHOW, EXPLAIN, and DESCRIBE statements.
# Let's check here a view based on a dropped view or table.
--disable_warnings
Drop TABLE IF EXISTS t1 ;
......@@ -640,32 +643,32 @@ CREATE VIEW v2 AS SELECT * FROM v1;
# Only negative cases, positive cases will be checked later:
DROP TABLE t1;
--error 1356
--error ER_VIEW_INVALID
SELECT * FROM v1;
--error 1356
--error ER_VIEW_INVALID
DELETE FROM v1;
--error 1356
--error ER_VIEW_INVALID
UPDATE v1 SET f1 = 'aaaaa';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v1 SET f1 = "fffff";
# v2 is based on v1, which is now invalid
--error 1356
--error ER_VIEW_INVALID
SELECT * FROM v2;
--error 1356
--error ER_VIEW_INVALID
DELETE FROM v2;
--error 1356
--error ER_VIEW_INVALID
UPDATE v2 SET f1 = 'aaaaa';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v2 SET f1 = "fffff";
DROP VIEW v1;
# v2 is based on v1, which is now dropped
--error 1356
--error ER_VIEW_INVALID
SELECT * FROM v2;
--error 1356
--error ER_VIEW_INVALID
DELETE FROM v2;
--error 1356
--error ER_VIEW_INVALID
UPDATE v2 SET f1 = 'aaaaa';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v2 SET f1 = "fffff";
DROP VIEW v2;
......@@ -677,11 +680,11 @@ DROP VIEW IF EXISTS v1 ;
--enable_warnings
CREATE TABLE t1 (f1 FLOAT);
# Create a new VIEW based on itself
--error 1146
--error ER_NO_SUCH_TABLE
CREATE VIEW v1 AS SELECT * FROM v1;
# Replace a valid VIEW with one new based on itself
CREATE VIEW v1 AS SELECT * FROM t1;
--error 1146
--error ER_NO_SUCH_TABLE
CREATE or REPLACE VIEW v1 AS SELECT * FROM v1;
DROP VIEW v1;
......@@ -697,9 +700,9 @@ let $message= Testcase 3.3.1.10 ;
Drop view if exists test.v1 ;
--enable_warnings
Create view test.v1 AS Select * from test.tb2 ;
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create view test.v1 AS Select F59 from test.tb2 ;
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create view v1 AS Select F59 from test.tb2 ;
......@@ -710,18 +713,18 @@ let $message= Testcase 3.3.1.11 ;
# table with the same name in the same database.
###############################################################################
# The VIEW should get the same name like an already existing TABLE.
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create view test.tb2 AS Select f59,f60 from test.tb2 limit 100 ;
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create view tb2 AS Select f59,f60 from test.tb2 limit 100 ;
# The TABLE should get the same name like an already existing VIEW.
--disable_warnings
Drop view if exists test.v111 ;
--enable_warnings
Create view test.v111 as select * from tb2 limit 50;
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create table test.v111(f1 int );
--error 1050
--error ER_TABLE_EXISTS_ERROR
Create table v111(f1 int );
DROP VIEW test.v111;
......@@ -809,25 +812,29 @@ CREATE TABLE t1 (f1 BIGINT);
INSERT INTO t1 VALUES(1);
CREATE VIEW test.v1 AS SELECT * FROM t1 limit 2;
SHOW CREATE VIEW test.v1;
--sorted_result
SELECT * FROM test.v1;
# Switch the algorithm
CREATE OR REPLACE ALGORITHM = TEMPTABLE VIEW test.v1
AS SELECT * FROM t1 limit 2;
SHOW CREATE VIEW test.v1;
--sorted_result
SELECT * FROM test.v1;
# Switch the base table
CREATE OR REPLACE VIEW test.v1 AS SELECT * FROM tb2 limit 2;
CREATE OR REPLACE VIEW test.v1 AS SELECT * FROM tb2 order by f59 limit 2;
SHOW CREATE VIEW test.v1;
if ($have_bug_11589)
{
--disable_ps_protocol
}
SELECT * FROM test.v1 ;
--vertical_results
SELECT * FROM test.v1 order by f59,f60,f61,f62,f63,f64,f65;
--horizontal_results
--enable_ps_protocol
# Switch the SELECT but not the base table
CREATE OR REPLACE VIEW test.v1 AS SELECT F59 FROM tb2 limit 10,100;
CREATE OR REPLACE VIEW test.v1 AS SELECT F59 FROM tb2;
SHOW CREATE VIEW test.v1;
SELECT * FROM test.v1;
SELECT * FROM test.v1 order by F59 limit 10,100;
Drop table test.t1 ;
Drop view test.v1 ;
......@@ -839,9 +846,9 @@ let $message= Testcase 3.3.1.14 ;
# used to create a view using the name of an existing base
# table, it fails with an appropriate error message.
###############################################################################
--error 1347
--error ER_WRONG_OBJECT
CREATE OR REPLACE VIEW test.tb2 AS SELECT * From tb2 LIMIT 2;
--error 1347
--error ER_WRONG_OBJECT
CREATE OR REPLACE VIEW tb2 AS SELECT * From tb2 LIMIT 2;
......@@ -856,11 +863,12 @@ let $message= Testcase 3.3.1.15 ;
--disable_warnings
Drop table if exists test.v1 ;
--enable_warnings
CREATE OR REPLACE view test.v1 as select * from tb2 LIMIT 2;
if ($have_bug_11589)
CREATE OR REPLACE view test.v1 as select * from tb2;
if ($have_bug_32285)
{
--disable_ps_protocol
}
--sorted_result
SELECT * FROM test.v1;
--enable_ps_protocol
Drop view test.v1 ;
......@@ -880,8 +888,8 @@ let $message= Testcase 3.3.1.16 + 3.3.1.17 ;
Drop table if exists test.v1 ;
--enable_warnings
CREATE OR REPLACE VIEW v1 AS SELECT * From tb2;
# Note(ML): The empty result is intended, because I want to compare
# column names only
# Note(mleich): The empty result is intended, because I want to compare
# column names only.
SELECT * FROM tb2 WHERE 1 = 2;
SELECT * FROM v1 WHERE 1 = 2;
Drop view v1;
......@@ -924,7 +932,7 @@ let $message= Testcase 3.3.1.18 ;
# from the underlying base table(s) rather than the view
# column names.
###############################################################################
# Note(ML): The goal is to check the merge algorithm.
# Note(mleich): The goal is to check the merge algorithm.
--disable_warnings
Drop view if exists v1 ;
Drop view if exists v1_1 ;
......@@ -935,14 +943,14 @@ from test.tb2 limit 0,100 ;
Create view v1_1
as Select test.tb2.f59 as NewNameF1, test.tb2.f60 as NewNameF2
from tb2 limit 0,100 ;
--error 1054
--error ER_BAD_FIELD_ERROR
SELECT NewNameF1,f60 FROM test.v1_1 ;
--error 1054
--error ER_BAD_FIELD_ERROR
SELECT NewNameF1, v1_1.f60 FROM test.v1_1 ;
--error 1054
--error ER_BAD_FIELD_ERROR
SELECT f59, f60 FROM test.v1 ;
Use test ;
--error 1054
--error ER_BAD_FIELD_ERROR
SELECT F59 FROM v1 ;
......@@ -974,14 +982,14 @@ SELECT * FROM v1;
# negative testcases (sometimes including the underlying SELECT)
# duplicate via alias in SELECT
SELECT f1, f2 AS f1 FROM t1;
--error 1060
--error ER_DUP_FIELDNAME
CREATE OR REPLACE VIEW v1 AS SELECT f1, f2 AS f1 FROM t1;
# duplicate via JOIN SELECT
SELECT t1.f1, t2.f1 AS f1 FROM t1, t2;
--error 1060
--error ER_DUP_FIELDNAME
CREATE OR REPLACE VIEW v1 AS SELECT t1.f1, t2.f1 AS f1 FROM t1, t2;
# duplicate via VIEW definition
--error 1060
--error ER_DUP_FIELDNAME
CREATE OR REPLACE VIEW v1 (my_col, my_col) AS SELECT * FROM t1;
......@@ -1000,13 +1008,13 @@ CREATE TABLE t1( f1 BIGINT, f2 DECIMAL(5,2));
CREATE OR REPLACE VIEW v1 (my_f1, my_f2) AS SELECT * FROM t1;
CREATE OR REPLACE VIEW v1 (my_f1, my_f2) AS SELECT f1, f2 FROM t1;
# negative cases, where we assign a wrong number of column names
--error 1353
--error ER_VIEW_WRONG_LIST
CREATE OR REPLACE VIEW v1 (my_f1 ) AS SELECT * FROM t1;
--error 1353
--error ER_VIEW_WRONG_LIST
CREATE OR REPLACE VIEW v1 (my_f1 ) AS SELECT f1, f2 FROM t1;
--error 1353
--error ER_VIEW_WRONG_LIST
CREATE OR REPLACE VIEW v1 (my_f1, my_f2, my_f3) AS SELECT * FROM t1;
--error 1353
--error ER_VIEW_WRONG_LIST
CREATE OR REPLACE VIEW v1 (my_f1, my_f2, my_f3) AS SELECT f1, f2 FROM t1;
......@@ -1019,8 +1027,8 @@ let $message= Testcase 3.3.1.21 ;
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
CREATE VIEW test.v1( F59, F60 ) AS SELECT F59, F60 From tb2 LIMIT 2;
SELECT * FROM test.v1;
CREATE VIEW test.v1( F59, F60 ) AS SELECT F59, F60 From tb2;
SELECT * FROM test.v1 order by F59, F60 desc LIMIT 2;
Drop view if exists test.v1 ;
......@@ -1034,11 +1042,14 @@ let $message= Testcase 3.3.1.22 ;
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
CREATE VIEW test.v1( product ) AS SELECT f59*f60 From tb2 LIMIT 2;
CREATE VIEW test.v1( product ) AS SELECT f59*f60 From tb2 WHERE f59 < 3;
--sorted_result
SELECT * FROM test.v1;
CREATE OR REPLACE VIEW test.v1( product ) AS SELECT 1*2;
--sorted_result
SELECT * FROM test.v1;
CREATE OR REPLACE VIEW test.v1( product ) AS SELECT USER();
--sorted_result
SELECT * FROM test.v1;
Drop view if exists test.v1 ;
......@@ -1053,8 +1064,8 @@ let $message= Testcase 3.3.1.23 + 3.3.1.24 ;
# a non-existent view fails, with an appropriate error
# message, at creation time.
###############################################################################
# Note(ML): The SELECT statement syntax does not contain any functionality to
# claim, that the object after FROM must be a VIEW.
# Note(mleich): The SELECT statement syntax does not contain any functionality
# to claim, that the object after FROM must be a VIEW.
# Testcase 3.3.1.24 should be deleted.
USE test;
--disable_warnings
......@@ -1062,9 +1073,9 @@ DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v2;
--enable_warnings
--error 1146
--error ER_NO_SUCH_TABLE
CREATE VIEW test.v2 AS SELECT * FROM test.t1;
--error 1146
--error ER_NO_SUCH_TABLE
CREATE VIEW v2 AS Select * from test.v1;
DROP VIEW IF EXISTS v2;
......@@ -1075,8 +1086,8 @@ let $message= Testcase 3.3.1.25 ;
# Testcase 3.3.1.25: Ensure that a view cannot be based on one or more
# temporary tables.
###############################################################################
# Note(ML): A temporary table hides permanent tables which have the same name.
# So do not forget to drop the temporary table.
# Note(mleich): A temporary table hides permanent tables which have the same
# name. So do not forget to drop the temporary table.
--disable_warnings
DROP TABLE IF EXISTS t1_temp;
DROP TABLE IF EXISTS t2_temp;
......@@ -1086,13 +1097,13 @@ Create table t1_temp(f59 char(10),f60 int) ;
Create temporary table t1_temp(f59 char(10),f60 int) ;
Insert into t1_temp values('FER',90);
Insert into t1_temp values('CAR',27);
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
Create view v1 as select * from t1_temp ;
Create temporary table t2_temp(f59 char(10),f60 int) ;
Insert into t2_temp values('AAA',11);
Insert into t2_temp values('BBB',22);
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
Create or replace view v1
as select t1_temp.f59,t2_temp.f59 from t1_temp,t2_temp ;
DROP temporary table t1_temp;
......@@ -1110,34 +1121,34 @@ INSERT INTO t1 VALUES('A');
INSERT INTO t2 VALUES('t2');
INSERT INTO t2 VALUES('B');
# simple SELECT
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT f2 FROM t2;
# JOIN - temporary table first
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t2, t1;
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT f2, f1 FROM t2, t1;
# JOIN - temporary table last
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1, t2;
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT f1, f2 FROM t1, t2;
# UNION - temporary table first
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t2 UNION SELECT * FROM t1;
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT f2 FROM t2 UNION SELECT f1 FROM t1;
# UNION - temporary table last
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 UNION SELECT * FROM t2;
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT f1 FROM t1 UNION SELECT f2 FROM t2;
# SUBQUERY - temporary table first
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2
WHERE f2 = ( SELECT f1 FROM t1 );
# SUBQUERY - temporary table last
--error 1352
--error ER_VIEW_SELECT_TMPTABLE
CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t1
WHERE f1 = ( SELECT f2 FROM t2 );
DROP TABLE t1;
......@@ -1153,11 +1164,12 @@ let $message= Testcase 3.3.1.26 ;
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
Create view test.v1 AS Select * from test.tb2 limit 2 ;
Create view test.v1 AS Select * from test.tb2;
if ($have_bug_11589)
{
--disable_ps_protocol
}
--sorted_result
Select * from test.v1;
--enable_ps_protocol
Drop view test.v1 ;
......@@ -1173,9 +1185,9 @@ let $message= Testcase 3.3.1.27 ;
DROP VIEW IF EXISTS test.v1;
Drop VIEW IF EXISTS test.v1_1 ;
--enable_warnings
Create view test.v1 AS Select * from test.tb2 limit 2 ;
Create view test.v1 AS Select * from test.tb2;
Create view test.v1_1 AS Select F59 from test.v1 ;
Select * from test.v1_1 limit 20 ;
Select * from test.v1_1 order by F59 limit 2;
Drop view test.v1 ;
Drop view test.v1_1 ;
......@@ -1193,12 +1205,15 @@ create database test2 ;
Create view test2.v2 AS Select * from test.tb2 limit 50,50;
use test2 ;
Create view v1 AS Select * from test.tb2 limit 50 ;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
Select * from v1 ;
--vertical_results
Select * from v1 order by f59,f60,f61,f62,f63,f64,f65;
--horizontal_results
--enable_ps_protocol
--sorted_result
Select * from test2.v2 ;
Drop view if exists test2.v1 ;
Drop view if exists test2.v2 ;
......@@ -1223,7 +1238,8 @@ Create view test2.v2 AS Select F59 from test.v1 ;
Drop view if exists test.v1 ;
Drop view if exists test2.v2 ;
# Note(ML): Testcase 3.3.1.30 (identical requirements like 3.3.1.26) omitted
# Note(mleich): Testcase 3.3.1.30 (identical requirements like 3.3.1.26)
# --> omitted
let $message= Testcase 3.3.1.31 ;
--source include/show_msg80.inc
......@@ -1241,6 +1257,7 @@ INSERT INTO test.t1 VALUES( 445, 765 );
Create or replace view test.v1
AS SELECT test.t1.F59, test.tb2.F60
FROM test.tb2 JOIN test.t1 ON test.tb2.F59 = test.t1.F59 ;
--sorted_result
Select * from test.v1;
Drop view test.v1 ;
......@@ -1265,6 +1282,7 @@ INSERT INTO t1 VALUES( 445, 765 );
CREATE VIEW test2.v1
AS SELECT test.tb2.F59, test.tb2.F60
FROM test.tb2 INNER JOIN test2.t1 ON tb2.f59 = t1.f59;
--sorted_result
Select * from test2.v1;
Use test;
......@@ -1287,7 +1305,7 @@ CREATE VIEW test.v1
AS SELECT test.v1_firstview.f59, test.v1_firstview.f60
FROM test.v1_firstview INNER JOIN test.v1_secondview
ON test.v1_firstview.f59 = test.v1_secondview.f59 ;
SELECT * FROM test.v1 limit 0,10;
SELECT * FROM test.v1 order by f59,f60 limit 0,10;
Drop view if exists test.v1_firstview ;
Drop view if exists test.v1_secondview ;
Drop view if exists test.v1 ;
......@@ -1314,7 +1332,7 @@ CREATE VIEW v1
AS SELECT test.v1_firstview.F59, test.v1_firstview.F60
FROM test.v1_firstview INNER JOIN test.v1_secondview
ON test.v1_firstview.f59 = test.v1_secondview.f59 ;
SELECT * FROM v1 limit 0,10;
SELECT * FROM v1 order by f59,f60 limit 0,10;
Drop view v1 ;
Drop view test.v1_firstview ;
Drop view test.v1_secondview ;
......@@ -1339,7 +1357,7 @@ CREATE VIEW test.v1
AS SELECT test.v1_firstview.f59, test.v1_firstview.f60
FROM test.v1_firstview INNER JOIN test.tb2
ON test.v1_firstview.f59 = test.tb2.f59;
SELECT * FROM test.v1 limit 0,10;
SELECT * FROM test.v1 order by f59,f60 limit 0,10;
Drop view test.v1 ;
Drop view test.v1_firstview;
......@@ -1360,7 +1378,7 @@ CREATE VIEW v1_firstview AS SELECT * FROM test.tb2 ;
CREATE VIEW v1
AS SELECT v1_firstview.f59, v1_firstview.f60
FROM v1_firstview INNER JOIN test.tb2 ON v1_firstview.f59 = test.tb2.f59 ;
SELECT * FROM v1 limit 0,10;
SELECT * FROM v1 order by f59,f60 limit 0,10;
Drop database test2 ;
......@@ -1372,10 +1390,6 @@ let $message= Testcase 3.3.1.37 ;
# tables and/or views, some of which reside in the same
# database and some of which reside in one other database.
###############################################################################
# (Bug Associated)
# FIXME: ??? Bug number
# FIXME: reimplement this test
use test;
--disable_warnings
Drop table if exists t1;
......@@ -1385,7 +1399,7 @@ Drop view if exists test.v1_1 ;
Drop view if exists test.v1_main ;
--enable_warnings
Create view test.v1 as Select f59, f60 FROM test.tb2;
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59,f60 limit 0,10;
Create table t1(f59 int, f60 int);
Insert into t1 values (90,507) ;
......@@ -1396,7 +1410,7 @@ Select * from v1_1 ;
Create view v1_main
as SELECT test.tb2.f59 FROM test.tb2 JOIN test.v1
ON test.tb2.f59 = test.v1.f59;
Select * from v1_main limit 0,10;
Select * from v1_main order by f59 limit 0,10;
Drop table t1;
Drop view test.v1 ;
......@@ -1407,7 +1421,7 @@ Drop view test.v1_main ;
let $message= Testcase 3.3.1.31 - 3.3.1.37 New Implementation ;
--source include/show_msg80.inc
###############################################################################
# ML: The testcases 3.3.1.31 - 3.3.1.37 should be tested more systematic.
# mleich: The testcases 3.3.1.31 - 3.3.1.37 should be tested more systematic.
# Ensure that a view can be based on a join of multiple
# Testcase 3.3.1.31: tables within the same database
# Testcase 3.3.1.32: tables from another database.
......@@ -1504,8 +1518,8 @@ Drop view if exists test.v1_main;
Drop view if exists test1.v1_1 ;
Drop database if exists test3 ;
--enable_warnings
Create view test.v1 as Select f59, f60 FROM test.tb2 limit 20 ;
Select * from test.v1 ;
Create view test.v1 as Select f59, f60 FROM test.tb2;
Select * from test.v1 order by f59,f60 limit 20;
Create table test1.t1 (f59 int,f60 int) ;
Insert into test1.t1 values (199,507) ;
......@@ -1522,7 +1536,7 @@ Create view test3.v1_2 as Select f59,f60 from test3.t1 ;
Select * from test3.v1_2 ;
use test ;
# ML: FIXME The SELECT should deliver at least one row.
# mleich: FIXME The SELECT should deliver at least one row.
Create view v1_main
as SELECT test.tb2.f59 as f1, test1.v1_1.f59 as f2,
test3.v1_2.f59 as f3
......@@ -1546,11 +1560,11 @@ let $message= Testcase 3.3.1.39 ;
--disable_warnings
Drop view if exists test.v1 ;
--enable_warnings
--error 1349
--error ER_VIEW_SELECT_DERIVED
CREATE VIEW test.v1
AS Select f59 from (Select * FROM tb2 limit 20) tx ;
--error 1146
SELECT * FROM test.v1 ;
--error ER_NO_SUCH_TABLE
SELECT * FROM test.v1 order by f59 ;
--disable_warnings
Drop view if exists test.v1 ;
--enable_warnings
......@@ -1568,10 +1582,10 @@ Drop view if exists test.v1 ;
--enable_warnings
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
--error 1351
--error ER_VIEW_SELECT_VARIABLE
CREATE VIEW test.v1 AS SELECT @var1, @var2 ;
# System variables (name starts with '@@') are also not allowed
--error 1351
--error ER_VIEW_SELECT_VARIABLE
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
--disable_warnings
Drop view if exists test.v1 ;
......@@ -1583,7 +1597,7 @@ let $message= Testcase 3.3.1.41 ;
###############################################################################
# Testcase 3.3.1.41: Ensure that a view definition within a stored procedure
# definition cannot include references to any of the stored
# procedures parameters.
# procedures parameters.
###############################################################################
--disable_warnings
Drop view if exists test.v1 ;
......@@ -1616,11 +1630,11 @@ let $message= Testcase 3.3.1.42 ;
--disable_warnings
Drop VIEW if exists test.v1 ;
--enable_warnings
--error 1064
--error ER_PARSE_ERROR
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
#(02)
--error 1064
--error ER_PARSE_ERROR
CREATE OR REPLACE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
......@@ -1646,20 +1660,24 @@ CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM test.tb2 where f59 = 122 and f60 = 432 limit 0,20;
--horizontal_results
--enable_ps_protocol
UPDATE test.v1 SET f59 = 3000 WHERE test.v1.f59 = 122 ;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM test.tb2 where f59 = 3000 limit 0,20;
--horizontal_results
--enable_ps_protocol
DELETE FROM test.v1
......@@ -1677,12 +1695,12 @@ let $message= Testcase 3.3.1.44 ;
# with an appropriate error message and do not affect the
# data in the underlying tables(s).
###############################################################################
# ML: Maybe we need some more tests here.
# mleich: Maybe we need some more tests here.
--disable_warnings
Drop view if exists test.v1 ;
--enable_warnings
# Note(ML): The modification will fail, because the VIEW contains 'limit'
# Note(mleich): The modification will fail, because the VIEW contains 'limit'
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2 limit 100;
--error ER_NON_INSERTABLE_TABLE
......@@ -1709,24 +1727,28 @@ CREATE VIEW test.v1 AS SELECT * FROM test.tb2 where f59 = 04;
--enable_info
UPDATE test.v1 SET f59 = 30 where F59 = 04 ;
--disable_info
SELECT * FROM test.v1 where f59 = 30 ;
if ($have_bug_11589)
SELECT * FROM test.v1 where f59 = 30 order by f59;
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM test.tb2 where f59 = 30 ;
--horizontal_results
--enable_ps_protocol
--enable_info
UPDATE tb2 SET f59 = 100 where f59 = 30 ;
--disable_info
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM tb2 where f59 = 100 ;
--horizontal_results
--enable_ps_protocol
SELECT * FROM test.v1 ;
SELECT * FROM test.v1 order by f59 ;
drop view if exists test.v1 ;
......@@ -1772,7 +1794,8 @@ SELECT * FROM v1 ORDER BY f1;
--enable_info
# 1. The record to be inserted will be within the scope of the view.
# But there is already a record with the PRIMARY KEY f1 = 2 .
--error 1062
# OBN change for 5.1.21 --error ER_DUP_ENTRY_WITH_KEY_NAME
--error ER_DUP_ENTRY
INSERT INTO v1 VALUES(2,'two');
# 2. The record to be inserted will be within the scope of the view.
# There is no already existing record with the PRIMARY KEY f1 = 3 .
......@@ -1789,7 +1812,8 @@ SELECT * FROM v1 ORDER BY f1;
# 1. The record to be updated is within the scope of the view
# and will stay inside the scope.
# But there is already a record with the PRIMARY KEY f1 = 2 .
--error 1062
# OBN change for 5.1.21 --error ER_DUP_ENTRY_WITH_KEY_NAME
--error ER_DUP_ENTRY
UPDATE v1 SET f1 = 2 WHERE f1 = 3;
# 2. The record to be updated is within the scope of the view
# and will stay inside the scope.
......@@ -1817,9 +1841,9 @@ Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60
FROM test.tb2 where f59 = 195 WITH CHECK OPTION ;
--error 1369
--error ER_VIEW_CHECK_FAILED
UPDATE test.v1 SET f59 = 198 where f59=195 ;
SELECT * FROM test.v1 ;
SELECT * FROM test.v1 order by f59 ;
drop view if exists test.v1 ;
......@@ -1842,11 +1866,11 @@ FROM test.tb2 where F59 = 0987 WITH LOCAL CHECK OPTION ;
CREATE VIEW test.v2 as SELECT * FROM test.v1 ;
# This UPDATE violates the definition of VIEW test.v1.
--error 1369
--error ER_VIEW_CHECK_FAILED
UPDATE test.v1 SET F59 = 919 where f59 = 0987 ;
SELECT * FROM test.v1 ;
SELECT * FROM test.v1 order by f59 ;
# ML: This UPDATE violates the definition of VIEW test.v1, but this
# mleich: This UPDATE violates the definition of VIEW test.v1, but this
# does not count, because the UPDATE runs on test.v2, which
# is defined without any CHECK OPTION.
# FIXME Does this testcase fit to 3.3.1.47 ?
......@@ -1873,11 +1897,11 @@ DROP VIEW IF EXISTS test.v1;
eval CREATE TABLE t1 (f1 ENUM('A', 'B', 'C') NOT NULL, f2 INTEGER)
ENGINE = $engine_type;
INSERT INTO t1 VALUES ('A', 1);
SELECT * FROM t1;
SELECT * FROM t1 order by f1, f2;
CREATE VIEW v1 AS SELECT * FROM t1 WHERE f2 BETWEEN 1 AND 2
WITH CASCADED CHECK OPTION ;
SELECT * FROM v1;
SELECT * FROM v1 order by f1, f2;
--enable_info
# positive cases
UPDATE v1 SET f2 = 2 WHERE f2 = 1;
......@@ -1885,17 +1909,17 @@ INSERT INTO v1 VALUES('B',2);
--disable_info
# Bug#11771: View over InnoDB table, wrong result SELECT on VIEW,
# field->query_id wrong
SELECT * FROM v1;
SELECT * FROM v1 order by f1, f2;
# negative cases
--enable_info
--error 1369
--error ER_VIEW_CHECK_FAILED
UPDATE v1 SET f2 = 4;
--error 1369
--error ER_VIEW_CHECK_FAILED
INSERT INTO v1 VALUES('B',3);
--disable_info
# Bug#11771: View over InnoDB table, wrong result SELECT on VIEW,
# field->query_id wrong
SELECT * FROM v1;
SELECT * FROM v1 order by f1, f2;
let $message= Testcase 3.3.1.49 ;
......@@ -1980,10 +2004,10 @@ let $message= Testcase 3.3.1.49A ;
# The annoying redundant
# eval INSERT INTO t1_results VALUES (@v3_to_v1_options,@statement,
# @v3_to_v1_violation,$mysql_errno);
# could not be put into a file to be sourced because of
# could not be put into a file to be sourced because of the closed
# Bug#10267 mysqltest, wrong number of loops when a script is sourced
# within a loop
#
# To be implemented later.
USE test;
--disable_warnings
......@@ -2270,7 +2294,8 @@ SELECT * FROM t1_results
WHERE v3_to_v1_options LIKE 'WITH %' AND v3_to_v1_options NOT LIKE 'WITH LOCAL %'
AND v3_to_v1_violation NOT LIKE ' _ _ ' AND errno = 0
ORDER BY v3_to_v1_options;
# 5. There must be NO failing INSERT/UPDATE getting a sql_errno <> 1369.
# 5. There must be NO failing INSERT/UPDATE getting a
# sql_errno <> 1369 (ER_VIEW_CHECK_FAILED).
SELECT * FROM t1_results
WHERE errno <> 0 AND errno <> 1369
ORDER BY v3_to_v1_options;
......@@ -2292,12 +2317,14 @@ DROP VIEW IF EXISTS test.v1;
# that is semantically equivalent to CREATE VIEW <view name>
# AS SELECT * FROM <table name>.
###############################################################################
CREATE VIEW test.v1 AS SELECT * FROM test.tb2 limit 5 ;
if ($have_bug_11589)
CREATE VIEW test.v1 AS SELECT * FROM test.tb2;
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM test.v1 ;
--vertical_results
SELECT * FROM test.v1 order by f59,f60,f61 ;
--horizontal_results
--enable_ps_protocol
drop view test.v1 ;
###############################################################################
......@@ -2307,8 +2334,8 @@ drop view test.v1 ;
# that is semantically equivalent to CREATE VIEW <view name>
# AS SELECT col1, col3 FROM <table name>.
###############################################################################
CREATE VIEW test.v1 AS SELECT F59,F61 FROM test.tb2 limit 50 ;
SELECT * FROM test.v1 ;
CREATE VIEW test.v1 AS SELECT F59,F61 FROM test.tb2;
SELECT * FROM test.v1 order by F59, F61 limit 50;
drop view test.v1 ;
###############################################################################
# Testcase 3.3.1.52: Ensure that a view that is a subset of every column and
......@@ -2317,12 +2344,14 @@ drop view test.v1 ;
# that is semantically equivalent to CREATE VIEW <view name>
# AS SELECT * FROM <table name> WHERE ....
###############################################################################
CREATE VIEW test.v1 AS SELECT * FROM test.tb2 limit 20 ;
CREATE VIEW test.v1 AS SELECT * FROM test.tb2 order by f59, f60, f61;
if ($have_bug_11589)
{
--disable_ps_protocol
}
SELECT * FROM test.v1;
--vertical_results
SELECT * FROM test.v1 order by f59,f60,f61 ;
--horizontal_results
--enable_ps_protocol
drop view test.v1 ;
###############################################################################
......@@ -2332,8 +2361,8 @@ drop view test.v1 ;
# definition that is semantically equivalent to CREATE VIEW
# <view name> AS SELECT col1, col3 FROM <table name> WHERE ..
###############################################################################
CREATE VIEW test.v1 AS SELECT F59,f61 FROM test.tb2 limit 20 ;
SELECT * FROM test.v1 limit 50;
CREATE VIEW test.v1 AS SELECT F59,f61 FROM test.tb2;
SELECT * FROM test.v1 order by f59,f61 desc limit 20;
drop view test.v1 ;
......@@ -2361,14 +2390,14 @@ Insert into t2 values (2,2000) ;
Insert into t2 values (31,97) ;
Create view test.v1 as select t1.f59, t1.f60
from t1,t2 where t1.f59=t2.f59 ;
Select * from test.v1 limit 50 ;
Select * from test.v1 order by f59 limit 50 ;
drop table test.t1 ;
drop table test.t2 ;
drop view test.v1 ;
# FIXME(ML): Implement an automatic check for 3.3.1.50 - 3.3.1.54
# FIXME(mleich): Implement an automatic check for 3.3.1.50 - 3.3.1.54
# CREATE VIEW ... AS <SELECT ... FROM tb2 ...>
# CREATE TEMPORARY TABLE ... AS <SELECT ... FROM tb2 ...>
# Comparison of the VIEW with the temporary table
......@@ -2464,7 +2493,7 @@ create or replace view test.v1 as
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
from t1 inner join t2 where t1.f59 = t2.f59 ;
select * from test.v1;
select * from test.v1 order by t1_f59 ;
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
from t1 inner join t2 where t1.f59 = t2.f59;
......@@ -2473,7 +2502,7 @@ from t1 inner join t2 where t1.f59 = t2.f59;
Create or replace view test.v1 as
Select t1.f59 AS t1_f59, t2.f59 AS t2_f59
FROM t2 cross join t1;
Select * from v1;
Select * from v1 order by t1_f59,t2_f59;
Select t1.f59 AS t1_f59, t2.f59 AS t2_f59
FROM t2 cross join t1;
......@@ -2481,7 +2510,7 @@ FROM t2 cross join t1;
Create or replace view test.v1 as
Select straight_join t1.f59 AS t1_f59, t2.f59 AS t2_f59
FROM t2,t1;
Select * from v1;
Select * from v1 order by t1_f59,t2_f59;
Select straight_join t1.f59 AS t1_f59, t2.f59 AS t2_f59
FROM t2,t1;
......@@ -2489,7 +2518,7 @@ FROM t2,t1;
Create or replace view test.v1 as
Select f59, f60, f61, a, b
FROM t2 natural join t1;
Select * from v1;
Select * from v1 order by f59;
Select f59, f60, f61, a, b
FROM t2 natural join t1;
......@@ -2498,7 +2527,7 @@ Create or replace view test.v1 as
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
FROM t2 left outer join t1 on t2.f59=t1.f59;
Select * from v1;
Select * from v1 order by t1_f59;
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
FROM t2 left outer join t1 on t2.f59=t1.f59;
......@@ -2507,7 +2536,7 @@ FROM t2 left outer join t1 on t2.f59=t1.f59;
Create or replace view test.v1 as
Select f59, f60, f61, t1.a, t2.b
FROM t2 natural left outer join t1;
Select * from v1;
Select * from v1 order by f59;
Select f59, f60, f61, t1.a, t2.b
FROM t2 natural left outer join t1;
......@@ -2516,7 +2545,7 @@ Create or replace view test.v1 as
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
FROM t2 right outer join t1 on t2.f59=t1.f59;
Select * from v1;
Select * from v1 order by t1_f59;
Select t1.f59 t1_f59, t2.f59 t2_f59, t1.f60 t1_f60, t2.f60 t2_f60,
t1.f61 t1_f61, t2.f61 t2_f61
FROM t2 right outer join t1 on t2.f59=t1.f59;
......@@ -2525,7 +2554,7 @@ FROM t2 right outer join t1 on t2.f59=t1.f59;
Create or replace view test.v1 as
Select f59, f60, a, b
FROM t2 natural right outer join t1;
Select * from v1;
Select * from v1 order by f59 desc;
Select f59, f60, a, b
FROM t2 natural right outer join t1;
......@@ -2558,7 +2587,7 @@ Insert into t1 values (901,801,401) ;
Create or replace view test.v1 as
Select tb2.f59 FROM tb2 LEFT JOIN t1 on tb2.f59 = t1.f59 ;
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Drop view if exists test.v1 ;
# Testcase 3.3.1.A2 ;
......@@ -2573,7 +2602,7 @@ Insert into t1 values (201,201,201) ;
Create or replace view test.v1
as Select tb2.f59 FROM tb2 INNER JOIN t1 on tb2.f59 = t1.f59 ;
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Drop view if exists test.v1 ;
# Testcase 3.3.1.A3 ;
......@@ -2588,7 +2617,7 @@ Insert into t1 values (21,21,21) ;
Create or replace view test.v1
as Select tb2.f59 FROM tb2 CROSS JOIN t1 on tb2.f59 = t1.f59 ;
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Drop view test.v1 ;
......@@ -2614,15 +2643,15 @@ Insert into t1 values (91,81,41) ;
Create or replace view test.v1 as (Select f59 FROM tb2 where f59=17 )
Union ALL (Select f59 from t1 where f59=17 );
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Create or replace view test.v1 as (Select f59 FROM tb2 where f59=17 )
Union (Select f59 from t1 where f59=17 );
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Create or replace view test.v1 as (Select f59 FROM tb2 where f59=17 )
Union Distinct (Select f59 from t1 where f60=17 );
Select * from test.v1 limit 0,10;
Select * from test.v1 order by f59 limit 0,10;
Drop view test.v1 ;
......@@ -2638,25 +2667,25 @@ insert into t1 values (901,801,401);
create or replace view test.v1 as
select tb2.f59 from tb2 join t1 on tb2.f59 = t1.f59;
select * from test.v1 limit 0,10;
select * from test.v1 order by f59 limit 0,10;
create or replace view test.v1 as
(select f59 from tb2 where f59=107 )
union all
(select f59 from t1 where f59=107 );
select * from test.v1 limit 0,10;
select * from test.v1 order by f59 limit 0,10;
create or replace view test.v1 as
(select f59 from tb2 where f59=107 )
union
(select f59 from t1 where f59=107 );
select * from test.v1 limit 0,10;
select * from test.v1 order by f59 limit 0,10;
create or replace view test.v1 as
(select f59 from tb2 where f59=107 )
union distinct
(select f59 from t1 where f59=107 );
select * from test.v1 limit 0,10;
select * from test.v1 order by f59 limit 0,10;
drop view if exists test.v1 ;
drop table t1;
......@@ -2675,15 +2704,17 @@ Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT F59
FROM test.tb2 where test.tb2.F59 = 109;
SELECT * FROM test.v1 limit 0,10;
SELECT * FROM test.v1 order by f59 limit 0,10;
ALTER VIEW test.v1 AS SELECT *
FROM test.tb2 WHERE test.tb2.f59 = 242 ;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM test.v1 limit 0,10;
--vertical_results
SELECT * FROM test.v1 order by f59 limit 0,10;
--horizontal_results
--enable_ps_protocol
Drop view test.v1 ;
......@@ -2711,7 +2742,7 @@ CREATE VIEW v1 AS SELECT f1 FROM t1;
# DROP VIEW
DROP VIEW v1;
--error 1051
--error ER_BAD_TABLE_ERROR
DROP VIEW v1;
CREATE VIEW v1 AS SELECT f1 FROM t1;
......@@ -2758,7 +2789,7 @@ while ($num1)
# DROP VIEW v1_top < |RESTRICD|CASCADE> must be successful.
eval $aux1 ;
# Check, that v1_top really no more exists + cleanup for the second sub test
--error 1051
--error ER_BAD_TABLE_ERROR
DROP VIEW v1_top;
CREATE VIEW v1_top AS SELECT * FROM v1_base;
......@@ -2788,7 +2819,7 @@ let $message= Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 ;
# 3.3.1.A5 SHOW COLUMNS, SHOW FIELDS, DESCRIBE, EXPLAIN
# statement is executed
###############################################################################
# Note(ML): There will be no non failing sub testcases with SHOW here.
# Note(mleich): There will be no non failing sub testcases with SHOW here.
# They will be done in 3.3.11 ff.
--disable_warnings
DROP TABLE IF EXISTS t1 ;
......@@ -2800,24 +2831,24 @@ DROP VIEW v1 ;
# The negative tests:
# SELECT
--error 1146
--error ER_NO_SUCH_TABLE
SELECT * FROM v1 ;
#
--error 1146
--error ER_NO_SUCH_TABLE
SHOW CREATE VIEW v1 ;
--error 1146
--error ER_NO_SUCH_TABLE
SHOW CREATE TABLE v1 ;
# Attention: Like is a filter. So we will get an empty result set here.
SHOW TABLE STATUS like 'v1' ;
SHOW TABLES LIKE 'v1';
--error 1146
--error ER_NO_SUCH_TABLE
SHOW COLUMNS FROM v1;
--error 1146
--error ER_NO_SUCH_TABLE
SHOW FIELDS FROM v1;
CHECK TABLE v1;
--error 1146
--error ER_NO_SUCH_TABLE
DESCRIBE v1;
--error 1146
--error ER_NO_SUCH_TABLE
EXPLAIN SELECT * FROM v1;
Use test;
......@@ -2886,9 +2917,9 @@ eval EXPLAIN SELECT * FROM test3.v$toplevel;
# 1.2 Check the top level view when a base VIEW is dropped
DROP VIEW test3.v0;
eval SHOW CREATE VIEW test3.v$toplevel;
--error 1356
--error ER_VIEW_INVALID
eval SELECT * FROM test3.v$toplevel;
--error 1356
--error ER_VIEW_INVALID
eval EXPLAIN SELECT * FROM test3.v$toplevel;
......@@ -2901,15 +2932,19 @@ eval EXPLAIN SELECT * FROM test3.v$toplevel;
#++++++++++++++++++++++++++++++++++++++++++++++
# OBN - Reduced the value of join limit to 30
# Above seems to hang - FIXME
# ML - Reason unclear why it hangs for OBN on innodb and memory.
# mleich - Reason unclear why it hangs for OBN on innodb and memory.
# Hypothesis: Maybe the consumption of virtual memory is high
# and OBN's box performs excessive paging.
# (RAM: OBN ~384MB RAM, ML 1 GB)
# (RAM: OBN ~384MB RAM, mleich 1 GB)
#++++++++++++++++++++++++++++++++++++++++++++++
let $message= FIXME - Setting join_limit to 30 - hangs for higher values;
let $message= FIXME - Setting join_limit to 28 - hangs for higher values;
--source include/show_msg.inc
# OBN - Reduced from 30 in 5.1.21 to avoid hitting the ndbcluster limit
# of "ERROR HY000: Got temporary error 4006 'Connect failure
# - out of connection objects (increase MaxNoOfConcurrentTransactions)'
# from NDBCLUSTER " to early;
#SET @join_limit = 61;
SET @join_limit = 30;
SET @join_limit = 28; # OBN - see above
SET @max_level = @join_limit - 1;
--enable_query_log
......@@ -3045,9 +3080,9 @@ let $sublevel= `SELECT @max_level`;
eval CREATE VIEW test1.v$level AS SELECT f1, f2
FROM test3.t1 tab1 NATURAL JOIN test1.v$sublevel tab2;
eval SHOW CREATE VIEW test1.v$level;
# the following line as written as '--eror 1116' and the command
# the following line as written as '--eror ER_TOO_MANY_TABLES' and the command
# is successful so assuming no expected error was intended
# --error 1116
# --error ER_TOO_MANY_TABLES
eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
let $message= The output of following EXPLAIN is deactivated, because the result
......@@ -3058,9 +3093,9 @@ if (1)
{
--disable_result_log
}
# the following line as written as '--eror 1116' and the command
# the following line as written as '--eror ER_TOO_MANY_TABLES' and the command
# is successful so assuming no expected error was intended
# --error 1116
# --error ER_TOO_MANY_TABLES
eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
if (1)
......@@ -3156,11 +3191,13 @@ Create view test.v1 AS SELECT f59,f60,f61 FROM tb2 ;
INSERT INTO test.v1 ( f59 , f60 ) values (2005,0101) ;
--disable_info
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM tb2 where f59 = 2005 and f60 = 0101 ;
--horizontal_results
--enable_ps_protocol
SELECT f59,f60 FROM test.v1 where f59 = 2005 and f60 = 0101 ;
DELETE FROM tb2 where f59 = 2005 and f60 = 0101 ;
......@@ -3185,13 +3222,15 @@ CREATE VIEW test.v1 AS SELECT f59,f60,f61 FROM tb2 ;
UPDATE test.v1 SET f59 = 8 WHERE f59 = 780 and f60 = 105;
--disable_info
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM tb2 where f59 = 8 and f60 = 105;
--horizontal_results
--enable_ps_protocol
SELECT f59,f60 FROM test.v1 where f59 = 8 and f60 = 105;
SELECT f59,f60 FROM test.v1 where f59 = 8 and f60 = 105 ;
Drop view test.v1 ;
......@@ -3213,13 +3252,15 @@ CREATE VIEW test.v1 AS SELECT f59,f60,f61 FROM tb2 ;
UPDATE test.v1 SET f59 = 891 WHERE f60 = 105 ;
--disable_info
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
--vertical_results
SELECT * FROM tb2 where f59 = 891 and f60 = 105;
--horizontal_results
--enable_ps_protocol
SELECT f59,f60 FROM test.v1 where f59 = 891 and f60 = 105;
SELECT f59,f60 FROM test.v1 where f59 = 891 and f60 = 105 ;
Drop view test.v1 ;
......@@ -3240,7 +3281,7 @@ CREATE VIEW test.v1 AS SELECT f59,f60,f61 FROM tb2 where f59 = 789 ;
DELETE FROM test.v1 where f59 = 789 ;
--disable_info
SELECT * FROM tb2 where f59 = 789 ;
SELECT f59,f60 FROM test.v1 where f59 = 789;
SELECT f59,f60 FROM test.v1 where f59 = 789 order by f60 ;
Drop view test.v1 ;
......@@ -3263,7 +3304,7 @@ DELETE FROM test.v1 where f59 = 711 ;
--disable_info
SELECT * FROM tb2 where f59 = 711 ;
SELECT f59,f60 FROM test.v1 where f59 = 711;
SELECT f59,f60 FROM test.v1 where f59 = 711 order by f60 ;
Drop view test.v1 ;
......@@ -3296,7 +3337,8 @@ DELETE FROM t1;
# f1 gets the default 0, because we are in the native sql_mode
INSERT INTO v1 SET f2 = 'ABC';
# f1 gets the default 0, but this value is already exists
--error 1062
# OBN change for 5.1.21 --error ER_DUP_ENTRY_WITH_KEY_NAME
--error ER_DUP_ENTRY
INSERT INTO v1 SET f2 = 'ABC';
SELECT * from t1;
DELETE FROM t1;
......@@ -3384,7 +3426,8 @@ CREATE VIEW v1 AS SELECT f2, f3 FROM t1;
# f1 gets the default 0, because we are in the native sql_mode
INSERT INTO v1 SET f2 = 'ABC';
# f1 gets the default 0 and this value is already exists
--error 1062
# OBN change for 5.1.21 --error ER_DUP_ENTRY_WITH_KEY_NAME
--error ER_DUP_ENTRY
INSERT INTO v1 SET f2 = 'ABC';
SELECT * from t1;
DELETE FROM t1;
......@@ -3537,25 +3580,25 @@ DELETE FROM t1;
#------------------------------------------------
INSERT INTO t1 VALUES(1, 'ABC', -1.2E-3, 'X');
# UPDATE my_greeting - f1
--error 1348
--error ER_NONUPDATEABLE_COLUMN
UPDATE v1 SET my_greeting = 'Hej' WHERE f1 = 1;
SELECT * from t1;
DELETE FROM t1;
INSERT INTO t1 VALUES(1, 'ABC', -1.2E-3, 'X');
# UPDATE my_greeting - f2
--error 1348
--error ER_NONUPDATEABLE_COLUMN
UPDATE v1 SET my_greeting = 'Hej' WHERE f2 = 'ABC';
SELECT * from t1;
DELETE FROM t1;
INSERT INTO t1 VALUES(1, 'ABC', -1.2E-3, 'X');
# UPDATE my_greeting - my_greeting
--error 1348
--error ER_NONUPDATEABLE_COLUMN
UPDATE v1 SET my_greeting = 'Hej' WHERE my_greeting = 'HELLO';
SELECT * from t1;
DELETE FROM t1;
INSERT INTO t1 VALUES(1, 'ABC', -1.2E-3, 'X');
# UPDATE my_greeting - none
--error 1348
--error ER_NONUPDATEABLE_COLUMN
UPDATE v1 SET my_greeting = 'Hej';
SELECT * from t1;
DELETE FROM t1;
......@@ -3578,7 +3621,7 @@ DROP VIEW v1;
CREATE VIEW v1 AS SELECT f1, f2, f4 FROM t1;
# This INSERT must fail
--error 1423
--error ER_NO_DEFAULT_FOR_VIEW_FIELD
INSERT INTO v1 SET f1 = 1;
SELECT * from t1;
DELETE FROM t1;
......@@ -3634,7 +3677,7 @@ let $message= Testcases 3.3.2.7 - 3.3.2.9,
# rejects any INSERT or UPDATE or DELETE statement with an
# appropriate error message
#
# ML: I assume the type of the storage engine does not play any role.
# mleich: I assume the type of the storage engine does not play any role.
###############################################################################
INSERT INTO tb2 (f59,f60,f61) VALUES (77,185,126) ;
INSERT INTO tb2 (f59,f60,f61) VALUES (59,58,54) ;
......@@ -3669,9 +3712,9 @@ while ($num)
eval $aux;
--error ER_NON_INSERTABLE_TABLE
INSERT INTO v1 VALUES (3000);
--error 1288
--error ER_NON_UPDATABLE_TABLE
UPDATE v1 SET f61 = 100 WHERE f61 = 32;
--error 1288
--error ER_NON_UPDATABLE_TABLE
DELETE FROM v1;
DROP VIEW v1 ;
......@@ -3768,19 +3811,6 @@ SET @variant6= 'CREATE VIEW v1 AS SELECT (SELECT f60 FROM t2 WHERE f59=19) AS f6
# For a WHERE clause sub query that refers to a table also referenced in a
# FROM clause 3.3.2.18
SET @variant7= 'CREATE VIEW v1 AS SELECT f61 FROM v2';
# Attention: The attempt to UPDATE the next VIEW fails like expected,
# but the error message
# ERROR 1093 (HY000) : You can't specify target table 'v1' for
# update in FORM clause"
# is wrong. The server must deliver ERROR 1288.
# Bug#10773 Incorrect message is displayed while updating a view
# ML FIXME (remove the comment above, replace --error 1288,1093 with
# --error 1288 and update the file with expected results)
# when Bug#10773 is solved
# For a reference to a non-updateable view 3.3.2.19
let $message= Some server responses suffer from
Bug#10773 Incorrect message is displayed while updating a view;
--source include/show_msg80.inc
SET @variant8= 'CREATE VIEW v1 AS SELECT f59 AS f61 FROM t1 WHERE f60 IN (SELECT f59 FROM t1)';
# For ALGORITHM = TEMPTABLE 3.3.2.20
SET @variant9= 'CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1';
......@@ -3799,17 +3829,12 @@ while ($num)
--error ER_NON_INSERTABLE_TABLE
INSERT INTO v1 VALUES (1002);
--error 1288, 1093
# --error ER_NON_UPDATABLE_TABLE, ER_UPDATE_TABLE_USED
--error ER_NON_UPDATABLE_TABLE
UPDATE v1 SET f61=1007;
--error 1288
--error ER_NON_UPDATABLE_TABLE
DELETE FROM v1;
# The following "--error 0" will be no more needed, when
# Bug#12471: mysqltest, --error within loop affects wrong statement
# is fixed.
--error 0
DROP VIEW v1;
dec $num;
}
......@@ -3847,25 +3872,25 @@ INSERT INTO v1 SET f1 = -1, f4 = 'ABC', report = 'v1 0';
# 0. Initial state
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 1. Name of one base table column is altered
ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5);
INSERT INTO t1 SET f1 = 0, f4x = 'ABC', report = 't1 1';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v1 SET f1 = 0, f4 = 'ABC', report = 'v1 1';
--error 1054
--error ER_BAD_FIELD_ERROR
INSERT INTO v1 SET f1 = 0, f4x = 'ABC', report = 'v1 1a';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v1 SET f1 = 0, report = 'v1 1b';
DESCRIBE t1;
# Bug#12533 crash on DESCRIBE <view> after renaming base table column;
--error 1356
--error ER_VIEW_INVALID
DESCRIBE v1;
SELECT * FROM t1;
--error 1356
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
--error ER_VIEW_INVALID
SELECT * FROM v1 order by f1, report;
ALTER TABLE t1 CHANGE COLUMN f4x f4 CHAR(5);
#
# 2. Length of one base table column is increased
......@@ -3874,8 +3899,8 @@ INSERT INTO t1 SET f1 = 2, f4 = '<-- 10 -->', report = 't1 2';
INSERT INTO v1 SET f1 = 2, f4 = '<-- 10 -->', report = 'v1 2';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 3. Length of one base table column is reduced
ALTER TABLE t1 CHANGE COLUMN f4 f4 CHAR(8);
......@@ -3883,8 +3908,8 @@ INSERT INTO t1 SET f1 = 3, f4 = '<-- 10 -->', report = 't1 3';
INSERT INTO v1 SET f1 = 3, f4 = '<-- 10 -->', report = 'v1 3';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 4. Type of one base table column is altered string -> string
ALTER TABLE t1 CHANGE COLUMN f4 f4 VARCHAR(20);
......@@ -3892,8 +3917,8 @@ INSERT INTO t1 SET f1 = 4, f4 = '<------ 20 -------->', report = 't1 4';
INSERT INTO v1 SET f1 = 4, f4 = '<------ 20 -------->', report = 'v1 4';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 5. Type of one base table column altered numeric -> string
ALTER TABLE t1 CHANGE COLUMN f1 f1 VARCHAR(30);
......@@ -3903,20 +3928,20 @@ INSERT INTO v1 SET f1 = '<------------- 30 ----------->',
f4 = '<------ 20 -------->', report = 'v1 5';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 6. DROP of one base table column
ALTER TABLE t1 DROP COLUMN f2;
INSERT INTO t1 SET f1 = 'ABC', f4 = '<------ 20 -------->', report = 't1 6';
--error 1356
--error ER_VIEW_INVALID
INSERT INTO v1 SET f1 = 'ABC', f4 = '<------ 20 -------->', report = 'v1 6';
DESCRIBE t1;
--error 1356
--error ER_VIEW_INVALID
DESCRIBE v1;
SELECT * FROM t1;
--error 1356
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
--error ER_VIEW_INVALID
SELECT * FROM v1 order by f1, report;
#
# 7. Recreation of dropped base table column with the same data type like before
ALTER TABLE t1 ADD COLUMN f2 DATE DEFAULT NULL;
......@@ -3926,8 +3951,8 @@ INSERT INTO v1 SET f1 = 'ABC', f2 = '1500-12-04',
f4 = '<------ 20 -------->', report = 'v1 7';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 8. Recreation of dropped base table column with a different data type
# like before
......@@ -3939,22 +3964,22 @@ INSERT INTO v1 SET f1 = 'ABC', f2 = -3.3E-4,
f4 = '<------ 20 -------->', report = 'v1 8';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 9. Add a column to the base table
ALTER TABLE t1 ADD COLUMN f3 NUMERIC(7,2);
INSERT INTO t1 SET f1 = 'ABC', f2 = -3.3E-4,
f3 = -2.2, f4 = '<------ 20 -------->', report = 't1 9';
--error 1054
--error ER_BAD_FIELD_ERROR
INSERT INTO v1 SET f1 = 'ABC', f2 = -3.3E-4,
f3 = -2.2, f4 = '<------ 20 -------->', report = 'v1 9';
INSERT INTO v1 SET f1 = 'ABC', f2 = -3.3E-4,
f4 = '<------ 20 -------->', report = 'v1 9a';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, report;
SELECT * FROM v1 order by f1, report;
#
# 10. VIEW with numeric function is "victim" of data type change
DROP TABLE t1;
......@@ -3964,48 +3989,54 @@ INSERT INTO t1 SET f1 = 'ABC', f2 = 3;
CREATE VIEW v1 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, f2;
SELECT * FROM v1 order by 2;
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
DESCRIBE v1;
SELECT * FROM t1;
SELECT * FROM v1;
SELECT * FROM t1 order by f1, f2;
SELECT * FROM v1 order by 2;
# Some statements for comparison
# - the ugly SQRT('DEF) as constant
SELECT SQRT('DEF');
# - Will a VIEW based on the same definition show the same result ?
CREATE VIEW v2 AS SELECT SQRT('DEF');
SELECT * FROM v2;
SELECT * FROM v2 order by 1;
# - Will a VIEW v2 created after the base table column recreation show the same
# result set like v1 ?
CREATE OR REPLACE VIEW v2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
DESCRIBE v2;
SELECT * FROM v2;
SELECT * FROM v2 order by 2;
# - What will be the content of base table created with AS SELECT ?
CREATE TABLE t2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM t2;
--vertical_results
SELECT * FROM t2 order by 2;
--horizontal_results
--enable_ps_protocol
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v1;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM t2;
--vertical_results
SELECT * FROM t2 order by 2;
--horizontal_results
--enable_ps_protocol
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v2;
if ($have_bug_11589)
if ($have_bug_32285)
{
--disable_ps_protocol
}
SELECT * FROM t2;
--vertical_results
SELECT * FROM t2 order by 2;
--horizontal_results
--enable_ps_protocol
#
DROP TABLE t1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment