Commit 945ffb2f authored by Rich Prohaska's avatar Rich Prohaska

DB-504 test insert select with various triggers to make sure that bulk fetch will work

parent 56126798
set default_storage_engine='tokudb';
drop table if exists s,t;
create table s (id bigint not null primary key, x bigint);
insert into s values (1,0),(2,0),(3,0),(4,0);
create table t like s;
begin;
insert into t select * from s;
rollback;
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
drop table s,t;
set default_storage_engine='tokudb';
drop table if exists s,t;
create table s (id bigint not null primary key, x bigint);
insert into s values (1,0),(2,0),(3,0),(4,0);
create table t like s;
begin;
insert into t select * from s;
rollback;
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
truncate table t;
insert into t values (1,0);
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
truncate table t;
insert into t values (1,0);
create trigger t_trigger before update on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after update on t for each row insert into s values (1000000,0);
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before update on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after update on t for each row delete from s where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger before update on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
create trigger t_trigger after update on t for each row update s set x=x+1 where id=1000000;
begin;
insert into t select * from s on duplicate key update x=t.x+1;
ERROR HY000: Can't update table 's' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_trigger;
drop table s,t;
# verify that various insert triggers can not execute on the source table for an insert select statement
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists s,t;
enable_warnings;
create table s (id bigint not null primary key, x bigint);
insert into s values (1,0),(2,0),(3,0),(4,0);
create table t like s;
begin;
insert into t select * from s;
rollback;
# verify that before insert triggers can not insert into the source table
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not insert into the source table
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not delete from the source table
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not delete from the source table
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not update the source table
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not update the source table
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s;
rollback;
drop trigger t_trigger;
drop table s,t;
# verify that various insert triggers can not execute on the source table for an insert select statement
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists s,t;
enable_warnings;
create table s (id bigint not null primary key, x bigint);
insert into s values (1,0),(2,0),(3,0),(4,0);
create table t like s;
begin;
insert into t select * from s;
rollback;
# insert into t values (1,0);
# verify that before insert triggers can not insert into the source table
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not insert into the source table
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not delete from the source table
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not delete from the source table
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not update the source table
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not update the source table
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# force duplicate keys
truncate table t;
insert into t values (1,0);
# verify that before insert triggers can not insert into the source table
create trigger t_trigger before insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not insert into the source table
create trigger t_trigger after insert on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not delete from the source table
create trigger t_trigger before insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not delete from the source table
create trigger t_trigger after insert on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before insert triggers can not update the source table
create trigger t_trigger before insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not update the source table
create trigger t_trigger after insert on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# force duplicate keys
truncate table t;
insert into t values (1,0);
# verify that before insert triggers can not insert into the source table
create trigger t_trigger before update on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not insert into the source table
create trigger t_trigger after update on t for each row insert into s values (1000000,0);
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before update triggers can not delete from the source table
create trigger t_trigger before update on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not delete from the source table
create trigger t_trigger after update on t for each row delete from s where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that before update triggers can not update the source table
create trigger t_trigger before update on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
# verify that after insert triggers can not update the source table
create trigger t_trigger after update on t for each row update s set x=x+1 where id=1000000;
begin;
error 1442;
insert into t select * from s on duplicate key update x=t.x+1;
rollback;
drop trigger t_trigger;
drop table s,t;
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