mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
c5a8245596
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT with locked tables" Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers" Bug #24738 "CREATE TABLE ... SELECT is not isolated properly" Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when temporary table exists" Deadlock occured when one tried to execute CREATE TABLE IF NOT EXISTS ... SELECT statement under LOCK TABLES which held read lock on target table. Attempt to execute the same statement for already existing target table with triggers caused server crashes. Also concurrent execution of CREATE TABLE ... SELECT statement and other statements involving target table suffered from various races (some of which might've led to deadlocks). Finally, attempt to execute CREATE TABLE ... SELECT in case when a temporary table with same name was already present led to the insertion of data into this temporary table and creation of empty non-temporary table. All above problems stemmed from the old implementation of CREATE TABLE ... SELECT in which we created, opened and locked target table without any special protection in a separate step and not with the rest of tables used by this statement. This underminded deadlock-avoidance approach used in server and created window for races. It also excluded target table from prelocking causing problems with trigger execution. The patch solves these problems by implementing new approach to handling of CREATE TABLE ... SELECT for base tables. We try to open and lock table to be created at the same time as the rest of tables used by this statement. If such table does not exist at this moment we create and place in the table cache special placeholder for it which prevents its creation or any other usage by other threads. We still use old approach for creation of temporary tables. Also note that we decided to postpone introduction of some tests for concurrent behaviour of CREATE TABLE ... SELECT till 5.1. The main reason for this is absence in 5.0 ability to set @@debug variable at runtime, which can be circumvented only by using several test files with individual .opt files. Since the latter is likely to slowdown test-suite unnecessary we chose not to push this tests into 5.0, but run them manually for this version and later push their optimized version into 5.1 mysql-test/r/create.result: Extended test coverage for CREATE TABLE ... SELECT. In particular added tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when temporary table exists" and bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT with locked tables". mysql-test/r/trigger.result: Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers" mysql-test/t/create.test: Extended test coverage for CREATE TABLE ... SELECT. In particular added tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when temporary table exists" and bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT with locked tables". mysql-test/t/trigger.test: Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers" sql/lock.cc: Now for creation of name-lock placeholder in lock_table_name() we use auxiliary function table_cache_insert_placeholder(). sql/mysql_priv.h: Made build_table_path() function available outside of sql_table.cc file. reopen_name_locked_table() now has 3rd argument which controls linking in of table being opened into THD::open_tables (this is useful in cases when placeholder used for name-locking is already linked into this list). Added declaration of auxiliary function table_cache_insert_placeholder() which is used for creation of table placeholders for name-locking. Added declaration of table_cache_has_open_placeholder() function which can be used for checking if table cache contains an open placeholder for the table and if this placeholder was created by another thread. (This function is needed only in 5.0 where we use it in various versions of CREATE TABLE in order to protect it from concurrent CREATE TABLE ... SELECT operations for the table. Starting from 5.1 we use different approach so it is going to be removed there). Made close_old_data_files() static within sql_base.cc file. Added auxiliary drop_open_table() routine. Moved declaration of refresh_version to table.h header to make it accessible from inline methods of TABLE class. MYSQL_OPEN_IGNORE_LOCKED_TABLES flag is no longer used. Instead MYSQL_OPEN_TEMPORARY_ONLY option was added. sql/sql_base.cc: Added support for the new approach to the handling of CREATE TABLE ... SELECT for base tables. Now we try to open and lock table to be created at the same time as the rest of tables used by this statement. If such table does not exist at this moment we create and place in the table cache special placeholder for it which prevents its creation or any other usage by other threads. Note significant distinctions of this placeholder from the placeholder used for normal name-lock: 1) It is treated like open table by other name-locks so it does not allow name-lock taking operations like DROP TABLE or RENAME TABLE to proceed. 2) it is linked into THD::open_tables list and automatically removed during close_thread_tables() call. open_tables(): Implemented logic described above. To do this added auxiliary check_if_table_exists() function. Removed support for MYSQL_OPEN_IGNORE_LOCKED_TABLES option which is no longer used. Added MYSQL_OPEN_TEMPORARY_ONLY which is used to restrict search for temporary tables only. close_cached_tables()/close_thread_table()/reopen_tables()/ close_old_data_files()/table_is_used()/remove_table_from_cache(): Added support for open placeholders (note that we also use them when we need to re-open tables during flush). Added auxiliary drop_open_table() routine. reopen_name_locked_table(): Now has 3rd argument which controls linking in of table being opened into THD::open_tables (this is useful in cases when placeholder used for name-locking is already linked into this list). Added auxiliary table_cache_insert_placeholder() routine which simplifies creation of placeholders used for name-locking. Added table_cache_has_open_placeholder() function which can be used for checking if table cache contains an open placeholder for the table and if this placeholder was created by another thread. (This function is needed only in 5.0 where we use it in various versions of CREATE TABLE in order to protect it from concurrent CREATE TABLE ... SELECT operations for the table. Starting from 5.1 we use different approach so it is going to be removed there). sql/sql_handler.cc: Adjusted mysql_ha_mark_tables_for_reopen() routine to properly handle placeholders which now can be linked into open tables list. sql/sql_insert.cc: Introduced new approach to handling of base tables in CREATE TABLE ... SELECT statement. Now we try to open and lock table to be created at the same time as the rest of tables used by this statement. If such table does not exist at this moment we create and place in the table cache special placeholder for it which prevents its creation or any other usage by other threads. By doing this we avoid races which existed with previous approach in which we created, opened and locked target in separate step without any special protection. This also allows properly calculate prelocking set in cases when target table already exists and has some on insert triggers. Note that we don't employ the same approach for temporary tables (this is okay as such tables are unaffected by other threads). Changed create_table_from_items() and select_create methods to implement this approach. sql/sql_parse.cc: The new approach to handling of CREATE TABLE ... SELECT for base tables assumes that all tables (including table to be created) are opened and (or) locked at the same time. So in cases when we create base table we have to pass to open_and_lock_tables() table list which includes target table. sql/sql_prepare.cc: The new approach to handling of CREATE TABLE ... SELECT for base tables assumes that all tables (including table to be created) are opened and (or) locked at the same time. So in cases when we create base table we have to pass to open_and_lock_tables() table list which includes target table. sql/sql_table.cc: Now mysql_create_table_internal(), mysql_create_like_table() and mysql_alter_table() not only check that destination table doesn't exist on disk but also check that there is no create placeholder in table cache for it (i.e. there is no CREATE TABLE ... SELECT operation in progress for it). Note that starting from 5.1 we use different approach in order to to protect CREATE TABLE ... SELECT from concurrent CREATE TABLE (ALTER TABLE ... RENAME) operations, the latter simply take name-locks on table before its creation (on target table name before renaming). Also made build_table_path() available from other files and asjusted calls to reopen_name_locked_table(), which now takes extra argument, which controls linking of open table into THD::open_tables list. sql/sql_trigger.cc: reopen_name_locked_tables() now has one more argument which controls linking of opened table into the THD::open_tables list. sql/sql_yacc.yy: The new approach to handling of CREATE TABLE ... SELECT statement for base tables assumes that all tables including table to be created are open and (or) locked at the same time. Therefore we need to set correct lock for target table. sql/table.h: Moved declaration of refresh_version variable from mysql_priv.h to make it accessible from inline methods of TABLE class. Renamed TABLE::locked_by_flush member to open_placeholder since now it is also used for taking exclusive name-lock and not only by flush. Introduced TABLE::is_name_opened() helper method which can be used to distinguish TABLE instances corresponding to open tables or placeholders for them from closed instances (e.g. due to their old version). Also introduced TABLE::needs_reopen_or_name_lock() helper which allows to check if TABLE instance corresponds to outdated version of table or to name-lock placeholder. Introduced TABLE_LIST::create member which marks elements of table list corresponds to the table to be created. Adjusted TABLE_LIST::placeholder() method to take into account name-lock placeholders for tables to be created (this, for example, allows to properly handle such placeholders in lock_tables()).
1452 lines
43 KiB
Text
1452 lines
43 KiB
Text
drop table if exists t1, t2, t3, t4;
|
|
drop view if exists v1;
|
|
drop database if exists mysqltest;
|
|
drop function if exists f1;
|
|
drop function if exists f2;
|
|
drop procedure if exists p1;
|
|
create table t1 (i int);
|
|
create trigger trg before insert on t1 for each row set @a:=1;
|
|
set @a:=0;
|
|
select @a;
|
|
@a
|
|
0
|
|
insert into t1 values (1);
|
|
select @a;
|
|
@a
|
|
1
|
|
drop trigger trg;
|
|
create trigger trg before insert on t1 for each row set @a:=new.i;
|
|
insert into t1 values (123);
|
|
select @a;
|
|
@a
|
|
123
|
|
drop trigger trg;
|
|
drop table t1;
|
|
create table t1 (i int not null, j int);
|
|
create trigger trg before insert on t1 for each row
|
|
begin
|
|
if isnull(new.j) then
|
|
set new.j:= new.i * 10;
|
|
end if;
|
|
end|
|
|
insert into t1 (i) values (1)|
|
|
insert into t1 (i,j) values (2, 3)|
|
|
select * from t1|
|
|
i j
|
|
1 10
|
|
2 3
|
|
drop trigger trg|
|
|
drop table t1|
|
|
create table t1 (i int not null primary key);
|
|
create trigger trg after insert on t1 for each row
|
|
set @a:= if(@a,concat(@a, ":", new.i), new.i);
|
|
set @a:="";
|
|
insert into t1 values (2),(3),(4),(5);
|
|
select @a;
|
|
@a
|
|
2:3:4:5
|
|
drop trigger trg;
|
|
drop table t1;
|
|
create table t1 (aid int not null primary key, balance int not null default 0);
|
|
insert into t1 values (1, 1000), (2,3000);
|
|
create trigger trg before update on t1 for each row
|
|
begin
|
|
declare loc_err varchar(255);
|
|
if abs(new.balance - old.balance) > 1000 then
|
|
set new.balance:= old.balance;
|
|
set loc_err := concat("Too big change for aid = ", new.aid);
|
|
set @update_failed:= if(@update_failed, concat(@a, ":", loc_err), loc_err);
|
|
end if;
|
|
end|
|
|
set @update_failed:=""|
|
|
update t1 set balance=1500|
|
|
select @update_failed;
|
|
select * from t1|
|
|
@update_failed
|
|
Too big change for aid = 2
|
|
aid balance
|
|
1 1500
|
|
2 3000
|
|
drop trigger trg|
|
|
drop table t1|
|
|
create table t1 (i int);
|
|
insert into t1 values (1),(2),(3),(4);
|
|
create trigger trg after update on t1 for each row
|
|
set @total_change:=@total_change + new.i - old.i;
|
|
set @total_change:=0;
|
|
update t1 set i=3;
|
|
select @total_change;
|
|
@total_change
|
|
2
|
|
drop trigger trg;
|
|
drop table t1;
|
|
create table t1 (i int);
|
|
insert into t1 values (1),(2),(3),(4);
|
|
create trigger trg before delete on t1 for each row
|
|
set @del_sum:= @del_sum + old.i;
|
|
set @del_sum:= 0;
|
|
delete from t1 where i <= 3;
|
|
select @del_sum;
|
|
@del_sum
|
|
6
|
|
drop trigger trg;
|
|
drop table t1;
|
|
create table t1 (i int);
|
|
insert into t1 values (1),(2),(3),(4);
|
|
create trigger trg after delete on t1 for each row set @del:= 1;
|
|
set @del:= 0;
|
|
delete from t1 where i <> 0;
|
|
select @del;
|
|
@del
|
|
1
|
|
drop trigger trg;
|
|
drop table t1;
|
|
create table t1 (i int, j int);
|
|
create trigger trg1 before insert on t1 for each row
|
|
begin
|
|
if new.j > 10 then
|
|
set new.j := 10;
|
|
end if;
|
|
end|
|
|
create trigger trg2 before update on t1 for each row
|
|
begin
|
|
if old.i % 2 = 0 then
|
|
set new.j := -1;
|
|
end if;
|
|
end|
|
|
create trigger trg3 after update on t1 for each row
|
|
begin
|
|
if new.j = -1 then
|
|
set @fired:= "Yes";
|
|
end if;
|
|
end|
|
|
set @fired:="";
|
|
insert into t1 values (1,2),(2,3),(3,14);
|
|
select @fired;
|
|
@fired
|
|
|
|
select * from t1;
|
|
i j
|
|
1 2
|
|
2 3
|
|
3 10
|
|
update t1 set j= 20;
|
|
select @fired;
|
|
@fired
|
|
Yes
|
|
select * from t1;
|
|
i j
|
|
1 20
|
|
2 -1
|
|
3 20
|
|
drop trigger trg1;
|
|
drop trigger trg2;
|
|
drop trigger trg3;
|
|
drop table t1;
|
|
create table t1 (id int not null primary key, data int);
|
|
create trigger t1_bi before insert on t1 for each row
|
|
set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))");
|
|
create trigger t1_ai after insert on t1 for each row
|
|
set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))");
|
|
create trigger t1_bu before update on t1 for each row
|
|
set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data,
|
|
") new=(id=", new.id, ", data=", new.data,"))");
|
|
create trigger t1_au after update on t1 for each row
|
|
set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data,
|
|
") new=(id=", new.id, ", data=", new.data,"))");
|
|
create trigger t1_bd before delete on t1 for each row
|
|
set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))");
|
|
create trigger t1_ad after delete on t1 for each row
|
|
set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))");
|
|
set @log:= "";
|
|
insert into t1 values (1, 1);
|
|
select @log;
|
|
@log
|
|
(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1))
|
|
set @log:= "";
|
|
insert ignore t1 values (1, 2);
|
|
select @log;
|
|
@log
|
|
(BEFORE_INSERT: new=(id=1, data=2))
|
|
set @log:= "";
|
|
insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
|
|
select @log;
|
|
@log
|
|
(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=2))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=2))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2))
|
|
set @log:= "";
|
|
replace t1 values (1, 4), (3, 3);
|
|
select @log;
|
|
@log
|
|
(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=2))(AFTER_DELETE: old=(id=1, data=2))(AFTER_INSERT: new=(id=1, data=4))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3))
|
|
drop trigger t1_bd;
|
|
drop trigger t1_ad;
|
|
set @log:= "";
|
|
replace t1 values (1, 5);
|
|
select @log;
|
|
@log
|
|
(BEFORE_INSERT: new=(id=1, data=5))(AFTER_INSERT: new=(id=1, data=5))
|
|
drop table t1;
|
|
create table t1 (id int primary key, data varchar(10), fk int);
|
|
create table t2 (event varchar(100));
|
|
create table t3 (id int primary key);
|
|
create trigger t1_ai after insert on t1 for each row
|
|
insert into t2 values (concat("INSERT INTO t1 id=", new.id, " data='", new.data, "'"));
|
|
insert into t1 (id, data) values (1, "one"), (2, "two");
|
|
select * from t1;
|
|
id data fk
|
|
1 one NULL
|
|
2 two NULL
|
|
select * from t2;
|
|
event
|
|
INSERT INTO t1 id=1 data='one'
|
|
INSERT INTO t1 id=2 data='two'
|
|
drop trigger t1_ai;
|
|
create trigger t1_bi before insert on t1 for each row
|
|
begin
|
|
if exists (select id from t3 where id=new.fk) then
|
|
insert into t2 values (concat("INSERT INTO t1 id=", new.id, " data='", new.data, "' fk=", new.fk));
|
|
else
|
|
insert into t2 values (concat("INSERT INTO t1 FAILED id=", new.id, " data='", new.data, "' fk=", new.fk));
|
|
set new.id= NULL;
|
|
end if;
|
|
end|
|
|
insert into t3 values (1);
|
|
insert into t1 values (4, "four", 1), (5, "five", 2);
|
|
ERROR 23000: Column 'id' cannot be null
|
|
select * from t1;
|
|
id data fk
|
|
1 one NULL
|
|
2 two NULL
|
|
4 four 1
|
|
select * from t2;
|
|
event
|
|
INSERT INTO t1 id=1 data='one'
|
|
INSERT INTO t1 id=2 data='two'
|
|
INSERT INTO t1 id=4 data='four' fk=1
|
|
INSERT INTO t1 FAILED id=5 data='five' fk=2
|
|
drop table t1, t2, t3;
|
|
create table t1 (id int primary key, data varchar(10));
|
|
create table t2 (seq int);
|
|
insert into t2 values (10);
|
|
create function f1 () returns int return (select max(seq) from t2);
|
|
create trigger t1_bi before insert on t1 for each row
|
|
begin
|
|
if new.id > f1() then
|
|
set new.id:= f1();
|
|
end if;
|
|
end|
|
|
insert into t1 values (1, "first");
|
|
insert into t1 values (f1(), "max");
|
|
select * from t1;
|
|
id data
|
|
1 first
|
|
10 max
|
|
drop table t1, t2;
|
|
drop function f1;
|
|
create table t1 (id int primary key, fk_t2 int);
|
|
create table t2 (id int primary key, fk_t3 int);
|
|
create table t3 (id int primary key);
|
|
insert into t1 values (1,1), (2,1), (3,2);
|
|
insert into t2 values (1,1), (2,2);
|
|
insert into t3 values (1), (2);
|
|
create trigger t3_ad after delete on t3 for each row
|
|
delete from t2 where fk_t3=old.id;
|
|
create trigger t2_ad after delete on t2 for each row
|
|
delete from t1 where fk_t2=old.id;
|
|
delete from t3 where id = 1;
|
|
select * from t1 left join (t2 left join t3 on t2.fk_t3 = t3.id) on t1.fk_t2 = t2.id;
|
|
id fk_t2 id fk_t3 id
|
|
3 2 2 2 2
|
|
drop table t1, t2, t3;
|
|
create table t1 (id int primary key, copy int);
|
|
create table t2 (id int primary key, data int);
|
|
insert into t2 values (1,1), (2,2);
|
|
create trigger t1_bi before insert on t1 for each row
|
|
set new.copy= (select data from t2 where id = new.id);
|
|
create trigger t1_bu before update on t1 for each row
|
|
set new.copy= (select data from t2 where id = new.id);
|
|
insert into t1 values (1,3), (2,4), (3,3);
|
|
update t1 set copy= 1 where id = 2;
|
|
select * from t1;
|
|
id copy
|
|
1 1
|
|
2 2
|
|
3 NULL
|
|
drop table t1, t2;
|
|
create table t1 (i int);
|
|
create table t3 (i int);
|
|
create trigger trg before insert on t1 for each row set @a:= old.i;
|
|
ERROR HY000: There is no OLD row in on INSERT trigger
|
|
create trigger trg before delete on t1 for each row set @a:= new.i;
|
|
ERROR HY000: There is no NEW row in on DELETE trigger
|
|
create trigger trg before update on t1 for each row set old.i:=1;
|
|
ERROR HY000: Updating of OLD row is not allowed in trigger
|
|
create trigger trg before delete on t1 for each row set new.i:=1;
|
|
ERROR HY000: There is no NEW row in on DELETE trigger
|
|
create trigger trg after update on t1 for each row set new.i:=1;
|
|
ERROR HY000: Updating of NEW row is not allowed in after trigger
|
|
create trigger trg before update on t1 for each row set new.j:=1;
|
|
ERROR 42S22: Unknown column 'j' in 'NEW'
|
|
create trigger trg before update on t1 for each row set @a:=old.j;
|
|
ERROR 42S22: Unknown column 'j' in 'OLD'
|
|
create trigger trg before insert on t2 for each row set @a:=1;
|
|
ERROR 42S02: Table 'test.t2' doesn't exist
|
|
create trigger trg before insert on t1 for each row set @a:=1;
|
|
create trigger trg after insert on t1 for each row set @a:=1;
|
|
ERROR HY000: Trigger already exists
|
|
create trigger trg2 before insert on t1 for each row set @a:=1;
|
|
ERROR 42000: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
|
|
create trigger trg before insert on t3 for each row set @a:=1;
|
|
ERROR HY000: Trigger already exists
|
|
create trigger trg2 before insert on t3 for each row set @a:=1;
|
|
drop trigger trg2;
|
|
drop trigger trg;
|
|
drop trigger trg;
|
|
ERROR HY000: Trigger does not exist
|
|
create view v1 as select * from t1;
|
|
create trigger trg before insert on v1 for each row set @a:=1;
|
|
ERROR HY000: 'test.v1' is not BASE TABLE
|
|
drop view v1;
|
|
drop table t1;
|
|
drop table t3;
|
|
create temporary table t1 (i int);
|
|
create trigger trg before insert on t1 for each row set @a:=1;
|
|
ERROR HY000: Trigger's 't1' is view or temporary table
|
|
drop table t1;
|
|
create table t1 (x1col char);
|
|
create trigger tx1 before insert on t1 for each row set new.x1col = 'x';
|
|
insert into t1 values ('y');
|
|
drop trigger tx1;
|
|
drop table t1;
|
|
create table t1 (i int) engine=myisam;
|
|
insert into t1 values (1), (2);
|
|
create trigger trg1 before delete on t1 for each row set @del_before:= @del_before + old.i;
|
|
create trigger trg2 after delete on t1 for each row set @del_after:= @del_after + old.i;
|
|
set @del_before:=0, @del_after:= 0;
|
|
delete from t1;
|
|
select @del_before, @del_after;
|
|
@del_before @del_after
|
|
3 3
|
|
drop trigger trg1;
|
|
drop trigger trg2;
|
|
drop table t1;
|
|
create table t1 (a int);
|
|
create trigger trg1 before insert on t1 for each row set new.a= 10;
|
|
drop table t1;
|
|
create table t1 (a int);
|
|
insert into t1 values ();
|
|
select * from t1;
|
|
a
|
|
NULL
|
|
drop table t1;
|
|
create database mysqltest;
|
|
use mysqltest;
|
|
create table t1 (i int);
|
|
create trigger trg1 before insert on t1 for each row set @a:= 1;
|
|
drop database mysqltest;
|
|
use test;
|
|
create database mysqltest;
|
|
create table mysqltest.t1 (i int);
|
|
create trigger trg1 before insert on mysqltest.t1 for each row set @a:= 1;
|
|
ERROR HY000: Trigger in wrong schema
|
|
use mysqltest;
|
|
create trigger test.trg1 before insert on t1 for each row set @a:= 1;
|
|
ERROR HY000: Trigger in wrong schema
|
|
drop database mysqltest;
|
|
use test;
|
|
create table t1 (i int, j int default 10, k int not null, key (k));
|
|
create table t2 (i int);
|
|
insert into t1 (i, k) values (1, 1);
|
|
insert into t2 values (1);
|
|
create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j;
|
|
create trigger trg2 after update on t1 for each row set @b:= "Fired";
|
|
set @a:= 0, @b:= "";
|
|
update t1, t2 set j = j + 10 where t1.i = t2.i;
|
|
select @a, @b;
|
|
@a @b
|
|
10 Fired
|
|
insert into t1 values (2, 13, 2);
|
|
insert into t2 values (2);
|
|
set @a:= 0, @b:= "";
|
|
update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2;
|
|
select @a, @b;
|
|
@a @b
|
|
15 Fired
|
|
create trigger trg3 before delete on t1 for each row set @c:= @c + old.j;
|
|
create trigger trg4 before delete on t2 for each row set @d:= @d + old.i;
|
|
create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired";
|
|
create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired";
|
|
set @c:= 0, @d:= 0, @e:= "", @f:= "";
|
|
delete t1, t2 from t1, t2 where t1.i = t2.i;
|
|
select @c, @d, @e, @f;
|
|
@c @d @e @f
|
|
48 3 After delete t1 fired After delete t2 fired
|
|
drop table t1, t2;
|
|
create table t1 (i int, j int default 10)|
|
|
create table t2 (i int)|
|
|
insert into t2 values (1), (2)|
|
|
create trigger trg1 before insert on t1 for each row
|
|
begin
|
|
if new.i = 1 then
|
|
set new.j := 1;
|
|
end if;
|
|
end|
|
|
create trigger trg2 after insert on t1 for each row set @a:= 1|
|
|
set @a:= 0|
|
|
insert into t1 (i) select * from t2|
|
|
select * from t1|
|
|
i j
|
|
1 1
|
|
2 10
|
|
select @a|
|
|
@a
|
|
1
|
|
drop table t1, t2|
|
|
create table t1 (i int, j int, k int);
|
|
create trigger trg1 before insert on t1 for each row set new.k = new.i;
|
|
create trigger trg2 after insert on t1 for each row set @b:= "Fired";
|
|
set @b:="";
|
|
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, i);
|
|
select *, @b from t1;
|
|
i j k @b
|
|
10 NULL 10 Fired
|
|
15 NULL 15 Fired
|
|
set @b:="";
|
|
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j);
|
|
select *, @b from t1;
|
|
i j k @b
|
|
10 NULL 10 Fired
|
|
15 NULL 15 Fired
|
|
1 2 1 Fired
|
|
3 4 3 Fired
|
|
5 6 5 Fired
|
|
drop table t1;
|
|
create table t1 (i int, at int, k int, key(k)) engine=myisam;
|
|
create table t2 (i int);
|
|
insert into t1 values (1, 1, 1);
|
|
insert into t2 values (1), (2), (3);
|
|
create trigger ai after insert on t1 for each row set @a:= new.at;
|
|
create trigger au after update on t1 for each row set @a:= new.at;
|
|
create trigger ad after delete on t1 for each row set @a:= old.at;
|
|
alter table t1 drop column at;
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
insert into t1 values (2, 1);
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 1
|
|
update t1 set k = 2 where i = 2;
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
delete from t1 where i = 2;
|
|
ERROR 42S22: Unknown column 'at' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k);
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
1 2
|
|
insert into t1 select 3, 3;
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
1 2
|
|
3 3
|
|
update t1, t2 set k = k + 10 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 11
|
|
1 2
|
|
3 3
|
|
update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3;
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 11
|
|
1 12
|
|
3 3
|
|
delete t1, t2 from t1 straight_join t2 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'at' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 12
|
|
3 3
|
|
delete t2, t1 from t2 straight_join t1 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'at' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
3 3
|
|
alter table t1 add primary key (i);
|
|
insert into t1 values (3, 4) on duplicate key update k= k + 10;
|
|
ERROR 42S22: Unknown column 'at' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
3 13
|
|
replace into t1 values (3, 3);
|
|
ERROR 42S22: Unknown column 'at' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
drop table t1, t2;
|
|
create table t1 (i int, bt int, k int, key(k)) engine=myisam;
|
|
create table t2 (i int);
|
|
insert into t1 values (1, 1, 1), (2, 2, 2);
|
|
insert into t2 values (1), (2), (3);
|
|
create trigger bi before insert on t1 for each row set @a:= new.bt;
|
|
create trigger bu before update on t1 for each row set @a:= new.bt;
|
|
create trigger bd before delete on t1 for each row set @a:= old.bt;
|
|
alter table t1 drop column bt;
|
|
insert into t1 values (3, 3);
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
update t1 set i = 2;
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
delete from t1;
|
|
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k);
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
insert into t1 select 3, 3;
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
update t1, t2 set k = k + 10 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2;
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
delete t1, t2 from t1 straight_join t2 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
delete t2, t1 from t2 straight_join t1 where t1.i = t2.i;
|
|
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
alter table t1 add primary key (i);
|
|
drop trigger bi;
|
|
insert into t1 values (2, 4) on duplicate key update k= k + 10;
|
|
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
replace into t1 values (2, 4);
|
|
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
|
select * from t1;
|
|
i k
|
|
1 1
|
|
2 2
|
|
drop table t1, t2;
|
|
drop function if exists bug5893;
|
|
create table t1 (col1 int, col2 int);
|
|
insert into t1 values (1, 2);
|
|
create function bug5893 () returns int return 5;
|
|
create trigger t1_bu before update on t1 for each row set new.col1= bug5893();
|
|
drop function bug5893;
|
|
update t1 set col2 = 4;
|
|
ERROR 42000: FUNCTION test.bug5893 does not exist
|
|
drop trigger t1_bu;
|
|
drop table t1;
|
|
set sql_mode='ansi';
|
|
create table t1 ("t1 column" int);
|
|
create trigger t1_bi before insert on t1 for each row set new."t1 column" = 5;
|
|
set sql_mode="";
|
|
insert into t1 values (0);
|
|
create trigger t1_af after insert on t1 for each row set @a=10;
|
|
insert into t1 values (0);
|
|
select * from t1;
|
|
t1 column
|
|
5
|
|
5
|
|
select @a;
|
|
@a
|
|
10
|
|
show triggers;
|
|
Trigger Event Table Statement Timing Created sql_mode Definer
|
|
t1_bi INSERT t1 set new."t1 column" = 5 BEFORE # REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI root@localhost
|
|
t1_af INSERT t1 set @a=10 AFTER # root@localhost
|
|
drop table t1;
|
|
set sql_mode="traditional";
|
|
create table t1 (a date);
|
|
insert into t1 values ('2004-01-00');
|
|
ERROR 22007: Incorrect date value: '2004-01-00' for column 'a' at row 1
|
|
set sql_mode="";
|
|
create trigger t1_bi before insert on t1 for each row set new.a = '2004-01-00';
|
|
set sql_mode="traditional";
|
|
insert into t1 values ('2004-01-01');
|
|
select * from t1;
|
|
a
|
|
2004-01-00
|
|
set sql_mode=default;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` date default NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
show triggers;
|
|
Trigger Event Table Statement Timing Created sql_mode Definer
|
|
t1_bi INSERT t1 set new.a = '2004-01-00' BEFORE # root@localhost
|
|
drop table t1;
|
|
create table t1 (id int);
|
|
create trigger t1_ai after insert on t1 for each row reset query cache;
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row reset master;
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row reset slave;
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush hosts;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush tables with read lock;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush logs;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush status;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush slave;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush master;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush des_key_file;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush user_resources;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush tables;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
create trigger t1_ai after insert on t1 for each row flush privileges;
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure if exists p1;
|
|
create trigger t1_ai after insert on t1 for each row call p1();
|
|
create procedure p1() flush tables;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() reset query cache;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() reset master;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() reset slave;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: RESET is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush hosts;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush privileges;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush tables with read lock;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush tables;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush logs;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush status;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush slave;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush master;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush des_key_file;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
create procedure p1() flush user_resources;
|
|
insert into t1 values (0);
|
|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
|
|
drop procedure p1;
|
|
drop table t1;
|
|
create table t1 (id int, data int, username varchar(16));
|
|
insert into t1 (id, data) values (1, 0);
|
|
create trigger t1_whoupdated before update on t1 for each row
|
|
begin
|
|
declare user varchar(32);
|
|
declare i int;
|
|
select user() into user;
|
|
set NEW.username = user;
|
|
select count(*) from ((select 1) union (select 2)) as d1 into i;
|
|
end|
|
|
update t1 set data = 1;
|
|
update t1 set data = 2;
|
|
drop table t1;
|
|
create table t1 (c1 int, c2 datetime);
|
|
create trigger tr1 before insert on t1 for each row
|
|
begin
|
|
set new.c2= '2004-04-01';
|
|
select 'hello';
|
|
end|
|
|
ERROR 0A000: Not allowed to return a result set from a trigger
|
|
insert into t1 (c1) values (1),(2),(3);
|
|
select * from t1;
|
|
c1 c2
|
|
1 NULL
|
|
2 NULL
|
|
3 NULL
|
|
drop procedure if exists bug11587;
|
|
create procedure bug11587(x char(16))
|
|
begin
|
|
select "hello";
|
|
select "hello again";
|
|
end|
|
|
create trigger tr1 before insert on t1 for each row
|
|
begin
|
|
call bug11587();
|
|
set new.c2= '2004-04-02';
|
|
end|
|
|
insert into t1 (c1) values (4),(5),(6);
|
|
ERROR 0A000: Not allowed to return a result set from a trigger
|
|
select * from t1;
|
|
c1 c2
|
|
1 NULL
|
|
2 NULL
|
|
3 NULL
|
|
drop procedure bug11587;
|
|
drop table t1;
|
|
create table t1 (f1 integer);
|
|
create table t2 (f2 integer);
|
|
create trigger t1_ai after insert on t1
|
|
for each row insert into t2 values (new.f1+1);
|
|
create trigger t2_ai after insert on t2
|
|
for each row insert into t1 values (new.f2+1);
|
|
set @SAVE_SP_RECURSION_LEVELS=@@max_sp_recursion_depth;
|
|
set @@max_sp_recursion_depth=100;
|
|
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.
|
|
set @@max_sp_recursion_depth=@SAVE_SP_RECURSION_LEVELS;
|
|
select * from t1;
|
|
f1
|
|
1
|
|
select * from t2;
|
|
f2
|
|
2
|
|
drop trigger t1_ai;
|
|
drop trigger t2_ai;
|
|
create trigger t1_bu before update on t1
|
|
for each row insert into t1 values (2);
|
|
update t1 set f1= 10;
|
|
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
|
|
1
|
|
drop trigger t1_bu;
|
|
create trigger t1_bu before update on t1
|
|
for each row delete from t1 where f1=new.f1;
|
|
update t1 set f1= 10;
|
|
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
|
|
1
|
|
drop trigger t1_bu;
|
|
create trigger t1_bi before insert on t1
|
|
for each row set new.f1=(select sum(f1) from t1);
|
|
insert into t1 values (3);
|
|
select * from t1;
|
|
f1
|
|
1
|
|
1
|
|
drop trigger t1_bi;
|
|
drop tables t1, t2;
|
|
create table t1 (id int);
|
|
create table t2 (id int);
|
|
create trigger t1_bi before insert on t1 for each row insert into t2 values (new.id);
|
|
prepare stmt1 from "insert into t1 values (10)";
|
|
create procedure p1() insert into t1 values (10);
|
|
call p1();
|
|
drop trigger t1_bi;
|
|
execute stmt1;
|
|
call p1();
|
|
deallocate prepare stmt1;
|
|
drop procedure p1;
|
|
create table t3 (id int);
|
|
create trigger t1_bi after insert on t1 for each row insert into t2 values (new.id);
|
|
prepare stmt1 from "insert into t1 values (10)";
|
|
create procedure p1() insert into t1 values (10);
|
|
call p1();
|
|
drop trigger t1_bi;
|
|
create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id);
|
|
execute stmt1;
|
|
ERROR HY000: Table 't3' was not locked with LOCK TABLES
|
|
call p1();
|
|
ERROR HY000: Table 't3' was not locked with LOCK TABLES
|
|
deallocate prepare stmt1;
|
|
drop procedure p1;
|
|
drop table t1, t2, t3;
|
|
create table t1 (a int);
|
|
CREATE PROCEDURE `p1`()
|
|
begin
|
|
insert into t1 values (1);
|
|
end//
|
|
create trigger trg before insert on t1 for each row
|
|
begin
|
|
declare done int default 0;
|
|
set done= not done;
|
|
end//
|
|
CALL p1();
|
|
drop procedure p1;
|
|
drop table t1;
|
|
create trigger t1_bi before insert on test.t1 for each row set @a:=0;
|
|
ERROR 3D000: No database selected
|
|
create trigger test.t1_bi before insert on t1 for each row set @a:=0;
|
|
ERROR 3D000: No database selected
|
|
drop trigger t1_bi;
|
|
ERROR 3D000: No database selected
|
|
create table t1 (id int);
|
|
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
|
|
create trigger t1_ai after insert on test.t1 for each row set @b:=new.id;
|
|
insert into t1 values (101);
|
|
select @a, @b;
|
|
@a @b
|
|
101 101
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t1 set @a:=new.id
|
|
test t1_ai test t1 set @b:=new.id
|
|
rename table t1 to t2;
|
|
insert into t2 values (102);
|
|
select @a, @b;
|
|
@a @b
|
|
102 102
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t2 set @a:=new.id
|
|
test t1_ai test t2 set @b:=new.id
|
|
alter table t2 rename to t3;
|
|
insert into t3 values (103);
|
|
select @a, @b;
|
|
@a @b
|
|
103 103
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t3 set @a:=new.id
|
|
test t1_ai test t3 set @b:=new.id
|
|
alter table t3 rename to t4, add column val int default 0;
|
|
insert into t4 values (104, 1);
|
|
select @a, @b;
|
|
@a @b
|
|
104 104
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t4 set @a:=new.id
|
|
test t1_ai test t4 set @b:=new.id
|
|
drop trigger t1_bi;
|
|
drop trigger t1_ai;
|
|
drop table t4;
|
|
create database mysqltest;
|
|
use mysqltest;
|
|
create table t1 (id int);
|
|
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
|
|
insert into t1 values (101);
|
|
select @a;
|
|
@a
|
|
101
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test' or event_object_schema = 'mysqltest';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
mysqltest t1_bi mysqltest t1 set @a:=new.id
|
|
rename table t1 to test.t2;
|
|
ERROR HY000: Trigger in wrong schema
|
|
insert into t1 values (102);
|
|
select @a;
|
|
@a
|
|
102
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test' or event_object_schema = 'mysqltest';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
mysqltest t1_bi mysqltest t1 set @a:=new.id
|
|
drop trigger test.t1_bi;
|
|
ERROR HY000: Trigger does not exist
|
|
alter table t1 rename to test.t1;
|
|
ERROR HY000: Trigger in wrong schema
|
|
insert into t1 values (103);
|
|
select @a;
|
|
@a
|
|
103
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test' or event_object_schema = 'mysqltest';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
mysqltest t1_bi mysqltest t1 set @a:=new.id
|
|
drop trigger test.t1_bi;
|
|
ERROR HY000: Trigger does not exist
|
|
alter table t1 rename to test.t1, add column val int default 0;
|
|
ERROR HY000: Trigger in wrong schema
|
|
insert into t1 values (104);
|
|
select @a;
|
|
@a
|
|
104
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test' or event_object_schema = 'mysqltest';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
mysqltest t1_bi mysqltest t1 set @a:=new.id
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`id` int(11) default NULL
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
drop trigger test.t1_bi;
|
|
ERROR HY000: Trigger does not exist
|
|
drop trigger t1_bi;
|
|
drop table t1;
|
|
drop database mysqltest;
|
|
use test;
|
|
create table t1 (id int);
|
|
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
|
|
create trigger t1_ai after insert on t1 for each row set @b:=new.id;
|
|
insert into t1 values (101);
|
|
select @a, @b;
|
|
@a @b
|
|
101 101
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t1 set @a:=new.id
|
|
test t1_ai test t1 set @b:=new.id
|
|
rename table t1 to t2;
|
|
ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 13)
|
|
insert into t1 values (102);
|
|
select @a, @b;
|
|
@a @b
|
|
102 102
|
|
select trigger_schema, trigger_name, event_object_schema,
|
|
event_object_table, action_statement from information_schema.triggers
|
|
where event_object_schema = 'test';
|
|
trigger_schema trigger_name event_object_schema event_object_table action_statement
|
|
test t1_bi test t1 set @a:=new.id
|
|
test t1_ai test t1 set @b:=new.id
|
|
drop trigger t1_bi;
|
|
drop trigger t1_ai;
|
|
drop table t1;
|
|
create table t1 (i int);
|
|
create trigger t1_bi before insert on t1 for each row return 0;
|
|
ERROR 42000: RETURN is only allowed in a FUNCTION
|
|
insert into t1 values (1);
|
|
drop table t1;
|
|
create table t1 (a varchar(64), b int);
|
|
create table t2 like t1;
|
|
create trigger t1_ai after insert on t1 for each row
|
|
set @a:= (select max(a) from t1);
|
|
insert into t1 (a) values
|
|
("Twas"),("brillig"),("and"),("the"),("slithy"),("toves"),
|
|
("Did"),("gyre"),("and"),("gimble"),("in"),("the"),("wabe");
|
|
create trigger t2_ai after insert on t2 for each row
|
|
set @a:= (select max(a) from t2);
|
|
insert into t2 select * from t1;
|
|
load data infile '../std_data_ln/words.dat' into table t1 (a);
|
|
drop trigger t1_ai;
|
|
drop trigger t2_ai;
|
|
create function f1() returns int return (select max(b) from t1);
|
|
insert into t1 values
|
|
("All",f1()),("mimsy",f1()),("were",f1()),("the",f1()),("borogoves",f1()),
|
|
("And",f1()),("the",f1()),("mome", f1()),("raths",f1()),("outgrabe",f1());
|
|
create function f2() returns int return (select max(b) from t2);
|
|
insert into t2 select a, f2() from t1;
|
|
load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1();
|
|
drop table t1, t2;
|
|
drop function f1;
|
|
drop function f2;
|
|
create table t1(i int not null, j int not null, n numeric(15,2), primary key(i,j));
|
|
create table t2(i int not null, n numeric(15,2), primary key(i));
|
|
create trigger t1_ai after insert on t1 for each row
|
|
begin
|
|
declare sn numeric(15,2);
|
|
select sum(n) into sn from t1 where i=new.i;
|
|
replace into t2 values(new.i, sn);
|
|
end|
|
|
insert into t1 values
|
|
(1,1,10.00),(1,2,10.00),(1,3,10.00),(1,4,10.00),(1,5,10.00),
|
|
(1,6,10.00),(1,7,10.00),(1,8,10.00),(1,9,10.00),(1,10,10.00),
|
|
(1,11,10.00),(1,12,10.00),(1,13,10.00),(1,14,10.00),(1,15,10.00);
|
|
select * from t1;
|
|
i j n
|
|
1 1 10.00
|
|
1 2 10.00
|
|
1 3 10.00
|
|
1 4 10.00
|
|
1 5 10.00
|
|
1 6 10.00
|
|
1 7 10.00
|
|
1 8 10.00
|
|
1 9 10.00
|
|
1 10 10.00
|
|
1 11 10.00
|
|
1 12 10.00
|
|
1 13 10.00
|
|
1 14 10.00
|
|
1 15 10.00
|
|
select * from t2;
|
|
i n
|
|
1 150.00
|
|
drop tables t1, t2;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (
|
|
conn_id INT,
|
|
trigger_conn_id INT
|
|
);
|
|
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
|
|
SET NEW.trigger_conn_id = CONNECTION_ID();
|
|
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
|
|
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
|
|
SELECT * FROM t1 WHERE conn_id != trigger_conn_id;
|
|
conn_id trigger_conn_id
|
|
DROP TRIGGER t1_bi;
|
|
DROP TABLE t1;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (i1 INT);
|
|
SET @save_sql_mode=@@sql_mode;
|
|
SET SQL_MODE='';
|
|
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
|
|
SET @x = 5/0;
|
|
SET SQL_MODE='traditional';
|
|
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
|
|
SET @x = 5/0;
|
|
SET @x=1;
|
|
INSERT INTO t1 VALUES (@x);
|
|
SELECT @x;
|
|
@x
|
|
NULL
|
|
SET @x=2;
|
|
UPDATE t1 SET i1 = @x;
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
SELECT @x;
|
|
@x
|
|
NULL
|
|
SET SQL_MODE='';
|
|
SET @x=3;
|
|
INSERT INTO t1 VALUES (@x);
|
|
SELECT @x;
|
|
@x
|
|
NULL
|
|
SET @x=4;
|
|
UPDATE t1 SET i1 = @x;
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
Error 1365 Division by 0
|
|
SELECT @x;
|
|
@x
|
|
NULL
|
|
SET @@sql_mode=@save_sql_mode;
|
|
DROP TRIGGER t1_ai;
|
|
DROP TRIGGER t1_au;
|
|
DROP TABLE t1;
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
DROP PROCEDURE IF EXISTS p2;
|
|
CREATE TABLE t1 (i1 INT);
|
|
INSERT INTO t1 VALUES (3);
|
|
CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET i1 = 5;
|
|
CREATE PROCEDURE p2(INOUT i1 INT) DETERMINISTIC NO SQL SET i1 = i1 * 7;
|
|
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
|
|
BEGIN
|
|
CALL p1(NEW.i1);
|
|
CALL p2(NEW.i1);
|
|
END//
|
|
UPDATE t1 SET i1 = 11 WHERE i1 = 3;
|
|
DROP TRIGGER t1_bu;
|
|
DROP PROCEDURE p2;
|
|
DROP PROCEDURE p1;
|
|
INSERT INTO t1 VALUES (13);
|
|
CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 17;
|
|
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
|
|
CALL p1(OLD.i1);
|
|
UPDATE t1 SET i1 = 19 WHERE i1 = 13;
|
|
ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
|
|
DROP TRIGGER t1_bu;
|
|
DROP PROCEDURE p1;
|
|
INSERT INTO t1 VALUES (23);
|
|
CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 29;
|
|
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
|
|
CALL p1(OLD.i1);
|
|
UPDATE t1 SET i1 = 31 WHERE i1 = 23;
|
|
ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
|
|
DROP TRIGGER t1_bu;
|
|
DROP PROCEDURE p1;
|
|
INSERT INTO t1 VALUES (37);
|
|
CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 41;
|
|
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
|
|
CALL p1(NEW.i1);
|
|
UPDATE t1 SET i1 = 43 WHERE i1 = 37;
|
|
ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
|
|
DROP TRIGGER t1_au;
|
|
DROP PROCEDURE p1;
|
|
INSERT INTO t1 VALUES (47);
|
|
CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 49;
|
|
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
|
|
CALL p1(NEW.i1);
|
|
UPDATE t1 SET i1 = 51 WHERE i1 = 47;
|
|
ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
|
|
DROP TRIGGER t1_au;
|
|
DROP PROCEDURE p1;
|
|
SELECT * FROM t1;
|
|
i1
|
|
35
|
|
13
|
|
23
|
|
43
|
|
51
|
|
DROP TABLE t1;
|
|
create trigger wont_work after update on mysql.user for each row
|
|
begin
|
|
set @a:= 1;
|
|
end|
|
|
ERROR HY000: Triggers can not be created on system tables
|
|
use mysql|
|
|
create trigger wont_work after update on event for each row
|
|
begin
|
|
set @a:= 1;
|
|
end|
|
|
ERROR HY000: Triggers can not be created on system tables
|
|
use test|
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
CREATE TABLE t1(c INT);
|
|
CREATE TABLE t2(c INT);
|
|
CREATE DEFINER=1234567890abcdefGHIKL@localhost
|
|
TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
|
|
ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
|
|
CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
|
|
TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2;
|
|
ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
drop table if exists t1;
|
|
drop table if exists t2;
|
|
drop table if exists t3;
|
|
drop table if exists t4;
|
|
SET @save_sql_mode=@@sql_mode;
|
|
SET sql_mode='TRADITIONAL'|
|
|
create table t1 (id int(10) not null primary key, v int(10) )|
|
|
create table t2 (id int(10) not null primary key, v int(10) )|
|
|
create table t3 (id int(10) not null primary key, v int(10) )|
|
|
create table t4 (c int)|
|
|
create trigger t4_bi before insert on t4 for each row set @t4_bi_called:=1|
|
|
create trigger t4_bu before update on t4 for each row set @t4_bu_called:=1|
|
|
insert into t1 values(10, 10)|
|
|
set @a:=1/0|
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
select 1/0 from t1|
|
|
1/0
|
|
NULL
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
create trigger t1_bi before insert on t1 for each row set @a:=1/0|
|
|
insert into t1 values(20, 20)|
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
drop trigger t1_bi|
|
|
create trigger t1_bi before insert on t1 for each row
|
|
begin
|
|
insert into t2 values (new.id, new.v);
|
|
update t2 set v=v+1 where id= new.id;
|
|
replace t3 values (new.id, 0);
|
|
update t2, t3 set t2.v=new.v, t3.v=new.v where t2.id=t3.id;
|
|
create temporary table t5 select * from t1;
|
|
delete from t5;
|
|
insert into t5 select * from t1;
|
|
insert into t4 values (0);
|
|
set @check= (select count(*) from t5);
|
|
update t4 set c= @check;
|
|
drop temporary table t5;
|
|
set @a:=1/0;
|
|
end|
|
|
set @check=0, @t4_bi_called=0, @t4_bu_called=0|
|
|
insert into t1 values(30, 30)|
|
|
Warnings:
|
|
Error 1365 Division by 0
|
|
select @check, @t4_bi_called, @t4_bu_called|
|
|
@check @t4_bi_called @t4_bu_called
|
|
2 1 1
|
|
SET @@sql_mode=@save_sql_mode;
|
|
drop table t1;
|
|
drop table t2;
|
|
drop table t3;
|
|
drop table t4;
|
|
drop table if exists t1;
|
|
create table t1 (i int, j int key);
|
|
insert into t1 values (1,1), (2,2), (3,3);
|
|
create trigger t1_bu before update on t1 for each row
|
|
set new.j = new.j + 10;
|
|
update t1 set i= i+ 10 where j > 2;
|
|
select * from t1;
|
|
i j
|
|
1 1
|
|
2 2
|
|
13 13
|
|
drop table t1;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY);
|
|
CREATE TABLE t2 (a INT PRIMARY KEY);
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
|
|
CREATE TRIGGER trg_t1 BEFORE DELETE on t1 FOR EACH ROW
|
|
INSERT INTO t2 VALUES (OLD.a);
|
|
FLUSH STATUS;
|
|
TRUNCATE t1;
|
|
SHOW STATUS LIKE 'handler_delete';
|
|
Variable_name Value
|
|
Handler_delete 0
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
0
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
|
|
DELETE FROM t2;
|
|
FLUSH STATUS;
|
|
DELETE FROM t1;
|
|
SHOW STATUS LIKE 'handler_delete';
|
|
Variable_name Value
|
|
Handler_delete 8
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
8
|
|
DROP TRIGGER trg_t1;
|
|
DROP TABLE t1,t2;
|
|
drop table if exists t1;
|
|
drop function if exists f1;
|
|
create table t1 (i int);
|
|
create function f1() returns int return 10;
|
|
create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10;
|
|
insert into t1 values ();
|
|
select @a;
|
|
@a
|
|
20
|
|
insert into t1 values ();
|
|
select @a;
|
|
@a
|
|
20
|
|
drop table t1;
|
|
drop function f1;
|
|
drop table if exists t1;
|
|
create table t1(a int, b varchar(50));
|
|
drop trigger not_a_trigger;
|
|
ERROR HY000: Trigger does not exist
|
|
drop trigger if exists not_a_trigger;
|
|
Warnings:
|
|
Note 1360 Trigger does not exist
|
|
create trigger t1_bi before insert on t1
|
|
for each row set NEW.b := "In trigger t1_bi";
|
|
insert into t1 values (1, "a");
|
|
drop trigger if exists t1_bi;
|
|
insert into t1 values (2, "b");
|
|
drop trigger if exists t1_bi;
|
|
Warnings:
|
|
Note 1360 Trigger does not exist
|
|
insert into t1 values (3, "c");
|
|
select * from t1;
|
|
a b
|
|
1 In trigger t1_bi
|
|
2 b
|
|
3 c
|
|
drop table t1;
|
|
CREATE TABLE t1 (
|
|
id int NOT NULL DEFAULT '0',
|
|
a varchar(10) NOT NULL,
|
|
b varchar(10),
|
|
c varchar(10),
|
|
d timestamp NOT NULL,
|
|
PRIMARY KEY (id, a)
|
|
);
|
|
CREATE TABLE t2 (
|
|
fubar_id int unsigned NOT NULL DEFAULT '0',
|
|
last_change_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
PRIMARY KEY (fubar_id)
|
|
);
|
|
CREATE TRIGGER fubar_change
|
|
AFTER UPDATE ON t1
|
|
FOR EACH ROW
|
|
BEGIN
|
|
INSERT INTO t2 (fubar_id, last_change_time)
|
|
SELECT DISTINCT NEW.id AS fubar_id, NOW() AS last_change_time
|
|
FROM t1 WHERE (id = NEW.id) AND (OLD.c != NEW.c)
|
|
ON DUPLICATE KEY UPDATE
|
|
last_change_time =
|
|
IF((fubar_id = NEW.id)AND(OLD.c != NEW.c),NOW(),last_change_time);
|
|
END
|
|
|
|
|
INSERT INTO t1 (id,a, b,c,d) VALUES
|
|
(1,'a','b','c',now()),(2,'a','b','c',now());
|
|
UPDATE t1 SET c='Bang!' WHERE id=1;
|
|
SELECT fubar_id FROM t2;
|
|
fubar_id
|
|
1
|
|
DROP TABLE t1,t2;
|
|
DROP TABLE IF EXISTS bug21825_A;
|
|
DROP TABLE IF EXISTS bug21825_B;
|
|
CREATE TABLE bug21825_A (id int(10));
|
|
CREATE TABLE bug21825_B (id int(10));
|
|
CREATE TRIGGER trgA AFTER INSERT ON bug21825_A
|
|
FOR EACH ROW
|
|
BEGIN
|
|
INSERT INTO bug21825_B (id) values (1);
|
|
END//
|
|
INSERT INTO bug21825_A (id) VALUES (10);
|
|
INSERT INTO bug21825_A (id) VALUES (20);
|
|
DROP TABLE bug21825_B;
|
|
DELETE FROM bug21825_A WHERE id = 20;
|
|
DROP TABLE bug21825_A;
|
|
DROP TABLE IF EXISTS bug22580_t1;
|
|
DROP PROCEDURE IF EXISTS bug22580_proc_1;
|
|
DROP PROCEDURE IF EXISTS bug22580_proc_2;
|
|
CREATE TABLE bug22580_t1 (a INT, b INT);
|
|
CREATE PROCEDURE bug22580_proc_2()
|
|
BEGIN
|
|
DROP TABLE IF EXISTS bug22580_tmp;
|
|
CREATE TEMPORARY TABLE bug22580_tmp (a INT);
|
|
DROP TABLE bug22580_tmp;
|
|
END||
|
|
CREATE PROCEDURE bug22580_proc_1()
|
|
BEGIN
|
|
CALL bug22580_proc_2();
|
|
END||
|
|
CREATE TRIGGER t1bu BEFORE UPDATE ON bug22580_t1
|
|
FOR EACH ROW
|
|
BEGIN
|
|
CALL bug22580_proc_1();
|
|
END||
|
|
INSERT INTO bug22580_t1 VALUES (1,1);
|
|
DROP TABLE bug22580_t1;
|
|
DROP PROCEDURE bug22580_proc_1;
|
|
DROP PROCEDURE bug22580_proc_2;
|
|
DROP TRIGGER IF EXISTS trg27006_a_update;
|
|
DROP TRIGGER IF EXISTS trg27006_a_insert;
|
|
CREATE TABLE t1 (
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
`val` varchar(10) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
CREATE TABLE t2 like t1;
|
|
CREATE TRIGGER trg27006_a_insert AFTER INSERT ON t1 FOR EACH ROW
|
|
BEGIN
|
|
insert into t2 values (NULL,new.val);
|
|
END |
|
|
CREATE TRIGGER trg27006_a_update AFTER UPDATE ON t1 FOR EACH ROW
|
|
BEGIN
|
|
insert into t2 values (NULL,new.val);
|
|
END |
|
|
INSERT INTO t1(val) VALUES ('test1'),('test2');
|
|
SELECT * FROM t1;
|
|
id val
|
|
1 test1
|
|
2 test2
|
|
SELECT * FROM t2;
|
|
id val
|
|
1 test1
|
|
2 test2
|
|
INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val);
|
|
INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val);
|
|
INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val);
|
|
SELECT * FROM t1;
|
|
id val
|
|
1 test1
|
|
2 test3
|
|
3 test4
|
|
SELECT * FROM t2;
|
|
id val
|
|
1 test1
|
|
2 test2
|
|
3 test3
|
|
4 test4
|
|
DROP TRIGGER trg27006_a_insert;
|
|
DROP TRIGGER trg27006_a_update;
|
|
drop table t1,t2;
|
|
drop table if exists t1, t2, t3;
|
|
create table t1 (i int);
|
|
create trigger t1_bi before insert on t1 for each row set new.i = 7;
|
|
create trigger t1_ai after insert on t1 for each row set @a := 7;
|
|
create table t2 (j int);
|
|
insert into t2 values (1), (2);
|
|
set @a:="";
|
|
create table if not exists t1 select * from t2;
|
|
Warnings:
|
|
Note 1050 Table 't1' already exists
|
|
select * from t1;
|
|
i
|
|
7
|
|
7
|
|
select @a;
|
|
@a
|
|
7
|
|
drop trigger t1_bi;
|
|
drop trigger t1_ai;
|
|
create table t3 (isave int);
|
|
create trigger t1_bi before insert on t1 for each row insert into t3 values (new.i);
|
|
create table if not exists t1 select * from t2;
|
|
Warnings:
|
|
Note 1050 Table 't1' already exists
|
|
select * from t1;
|
|
i
|
|
7
|
|
7
|
|
1
|
|
2
|
|
select * from t3;
|
|
isave
|
|
1
|
|
2
|
|
drop table t1, t2, t3;
|
|
End of 5.0 tests
|