Instead of checking lex->sql_command which does not corect in case of triggers mark tables for insert.
Attach a file by drag & drop or click to upload