Recently we got request from our customer that something is going
wrong with their database and they’re are getting strange errors
after each insert or update to specific table. The strangeness
caused by “Unknown column ‘column-name’ in ‘field list'” message
while this column was existing in this table. Our investigation
shown that this was caused by trigger on the table they were
trying to do the insert/update. This trigger did the insert to
another table where the mentioned column didn’t exist.
Let me show you example:
create test DB and 2 test tables:
create database test;
use test;
create table t1 (field1 int auto_increment not null, field2 varchar(10), field3 varchar(10), primary key(field1)) engine=innodb;
create table t2 (field1 int, field2 varchar(10)) engine=innodb;
Then create a new insert trigger on t1 table:
delimiter ##
create trigger insert_on_t1_to_t2
after insert
on t1 for each …
[Read more]