Commit f8221294 authored by Alexander Barkov's avatar Alexander Barkov

Fixing a bug in the recent commit that added trigger names into error messages

Trigger names were erroneously cut to 8 or 4 bytes (on 64 and 32 bit machines).
Recording correct tests results.
parent 65808255
...@@ -10,7 +10,7 @@ SELECT @sum; ...@@ -10,7 +10,7 @@ SELECT @sum;
CREATE TRIGGER IF NOT EXISTS val_sum_new BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val; CREATE TRIGGER IF NOT EXISTS val_sum_new BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val;
CREATE TRIGGER IF NOT EXISTS val_sum AFTER INSERT ON t1 FOR EACH ROW SET @sum = @sum + 1 + NEW.val; CREATE TRIGGER IF NOT EXISTS val_sum AFTER INSERT ON t1 FOR EACH ROW SET @sum = @sum + 1 + NEW.val;
Warnings: Warnings:
Note 1359 Trigger 'db1.val_' already exists Note 1359 Trigger 'db1.val_sum' already exists
CREATE OR REPLACE TRIGGER IF NOT EXISTS val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + 2 + NEW.val; CREATE OR REPLACE TRIGGER IF NOT EXISTS val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + 2 + NEW.val;
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum'; SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
...@@ -21,7 +21,7 @@ SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val ...@@ -21,7 +21,7 @@ SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val
ACTION_STATEMENT ACTION_STATEMENT
SET @sum = @sum + 3 + NEW.val SET @sum = @sum + 3 + NEW.val
CREATE TRIGGER val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + 4 + NEW.val; CREATE TRIGGER val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + 4 + NEW.val;
ERROR HY000: Trigger 'db1.val_' already exists ERROR HY000: Trigger 'db1.val_sum' already exists
SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum'; SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT ACTION_STATEMENT
SET @sum = @sum + 3 + NEW.val SET @sum = @sum + 3 + NEW.val
......
...@@ -1986,7 +1986,7 @@ drop table if exists t1; ...@@ -1986,7 +1986,7 @@ drop table if exists t1;
create table t1 (i int, j int); create table t1 (i int, j int);
create trigger t1_bi before insert on t1 for each row begin end; create trigger t1_bi before insert on t1 for each row begin end;
create trigger t1_bi before insert on t1 for each row begin end; create trigger t1_bi before insert on t1 for each row begin end;
ERROR HY000: Trigger 'test.t1_' already exists ERROR HY000: Trigger 'test.t1_bi' already exists
create trigger t1_bi2 before insert on t1 for each row begin end; create trigger t1_bi2 before insert on t1 for each row begin end;
drop trigger t1_bi; drop trigger t1_bi;
drop trigger t1_bi2; drop trigger t1_bi2;
......
...@@ -253,7 +253,7 @@ Testcase 3.5.1.10: ...@@ -253,7 +253,7 @@ Testcase 3.5.1.10:
------------------ ------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X'; 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'; CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg7_1' already exists
drop trigger trg7_1; drop trigger trg7_1;
Testcase 3.5.1.?: Testcase 3.5.1.?:
...@@ -266,7 +266,7 @@ create trigger trig before insert on t1 ...@@ -266,7 +266,7 @@ create trigger trig before insert on t1
for each row set new.f1 ='trig t1'; for each row set new.f1 ='trig t1';
create trigger trig before update on t2 create trigger trig before update on t2
for each row set new.f1 ='trig t2'; for each row set new.f1 ='trig t2';
ERROR HY000: Trigger 'test.tri' already exists ERROR HY000: Trigger 'test.trig' already exists
insert into t1 value ('insert to t1',1); insert into t1 value ('insert to t1',1);
select * from t1; select * from t1;
f1 f2 f1 f2
......
...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE ...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50; on tb3 for each row set @test_var=@test_var+50;
Create trigger trg_3_406010_1 AFTER INSERT Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1; on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg_3_406010_1' already exists
select @test_var; select @test_var;
@test_var @test_var
1 1
......
...@@ -254,7 +254,7 @@ Testcase 3.5.1.10: ...@@ -254,7 +254,7 @@ Testcase 3.5.1.10:
------------------ ------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X'; 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'; CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg7_1' already exists
drop trigger trg7_1; drop trigger trg7_1;
Testcase 3.5.1.?: Testcase 3.5.1.?:
...@@ -267,7 +267,7 @@ create trigger trig before insert on t1 ...@@ -267,7 +267,7 @@ create trigger trig before insert on t1
for each row set new.f1 ='trig t1'; for each row set new.f1 ='trig t1';
create trigger trig before update on t2 create trigger trig before update on t2
for each row set new.f1 ='trig t2'; for each row set new.f1 ='trig t2';
ERROR HY000: Trigger 'test.tri' already exists ERROR HY000: Trigger 'test.trig' already exists
insert into t1 value ('insert to t1',1); insert into t1 value ('insert to t1',1);
select * from t1; select * from t1;
f1 f2 f1 f2
......
...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE ...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50; on tb3 for each row set @test_var=@test_var+50;
Create trigger trg_3_406010_1 AFTER INSERT Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1; on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg_3_406010_1' already exists
select @test_var; select @test_var;
@test_var @test_var
1 1
......
...@@ -254,7 +254,7 @@ Testcase 3.5.1.10: ...@@ -254,7 +254,7 @@ Testcase 3.5.1.10:
------------------ ------------------
CREATE TRIGGER trg7_1 BEFORE UPDATE on tb3 for each row set new.f120 ='X'; 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'; CREATE TRIGGER trg7_1 AFTER INSERT on tb3 for each row set @x ='Y';
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg7_1' already exists
drop trigger trg7_1; drop trigger trg7_1;
Testcase 3.5.1.?: Testcase 3.5.1.?:
...@@ -267,7 +267,7 @@ create trigger trig before insert on t1 ...@@ -267,7 +267,7 @@ create trigger trig before insert on t1
for each row set new.f1 ='trig t1'; for each row set new.f1 ='trig t1';
create trigger trig before update on t2 create trigger trig before update on t2
for each row set new.f1 ='trig t2'; for each row set new.f1 ='trig t2';
ERROR HY000: Trigger 'test.tri' already exists ERROR HY000: Trigger 'test.trig' already exists
insert into t1 value ('insert to t1',1); insert into t1 value ('insert to t1',1);
select * from t1; select * from t1;
f1 f2 f1 f2
......
...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE ...@@ -459,7 +459,7 @@ Create trigger trg_3_406010_2 AFTER DELETE
on tb3 for each row set @test_var=@test_var+50; on tb3 for each row set @test_var=@test_var+50;
Create trigger trg_3_406010_1 AFTER INSERT Create trigger trg_3_406010_1 AFTER INSERT
on tb3 for each row set @test_var=@test_var+1; on tb3 for each row set @test_var=@test_var+1;
ERROR HY000: Trigger 'test.trg' already exists ERROR HY000: Trigger 'test.trg_3_406010_1' already exists
select @test_var; select @test_var;
@test_var @test_var
1 1
......
...@@ -19,7 +19,7 @@ SET @sum = @sum + NEW.val + 1 ...@@ -19,7 +19,7 @@ SET @sum = @sum + NEW.val + 1
connection master; connection master;
CREATE TRIGGER IF NOT EXISTS val_sum AFTER INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val + 2; CREATE TRIGGER IF NOT EXISTS val_sum AFTER INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val + 2;
Warnings: Warnings:
Note 1359 Trigger 'db1.val_' already exists Note 1359 Trigger 'db1.val_sum' already exists
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Master FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum'; SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Master FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Master ACTION_STATEMENT_Master
SET @sum = @sum + NEW.val + 1 SET @sum = @sum + NEW.val + 1
......
...@@ -833,7 +833,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, ...@@ -833,7 +833,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
} }
else if (lex->create_info.if_not_exists()) else if (lex->create_info.if_not_exists())
{ {
strxnmov(trigname_buff, sizeof(trigname_buff-1), tables->db, ".", strxnmov(trigname_buff, sizeof(trigname_buff) - 1, tables->db, ".",
lex->spname->m_name.str, NullS); lex->spname->m_name.str, NullS);
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_TRG_ALREADY_EXISTS, ER_TRG_ALREADY_EXISTS,
...@@ -852,7 +852,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, ...@@ -852,7 +852,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
} }
else else
{ {
strxnmov(trigname_buff, sizeof(trigname_buff-1), tables->db, ".", strxnmov(trigname_buff, sizeof(trigname_buff) - 1, tables->db, ".",
lex->spname->m_name.str, NullS); lex->spname->m_name.str, NullS);
my_error(ER_TRG_ALREADY_EXISTS, MYF(0), trigname_buff); my_error(ER_TRG_ALREADY_EXISTS, MYF(0), trigname_buff);
DBUG_RETURN(true); DBUG_RETURN(true);
......
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