 create trigger `User_Delete_Tri` before delete on `UserInfo`
 for each row
 begin
+    declare msg varchar(200);
     if old.`UId` = 1
     then
         set msg = "禁止删除超级管理员用户!\nForbid deleting the super user!";
-        signal SQLSTATE 'HY0000' set message_txt = msg;
-    end if;
+        signal SQLSTATE 'HY000' set message_text = msg;
+    end if;
+
     delete from `UserStatistics` where `UserStatistics`.`UId` = old.`UId`;
 end$$
 
 /*
  * 限制trust在0到10之间，其中Uid为1的用户不可更改
  */
-create trigger `User_Update_On_Trust_Tri` before insert update on `UserInfo`
-for each row
-begin
-    if (new.`UId` == 1)
+create trigger `User_Update_On_Trust_Tri` before update on `UserInfo`
+for each row
+begin
+    if (new.`UId` = 1)
     then
         set new.`Trust` = 10;
     elseif ((new.`Trust` > 10) or (new.`Trust` < 0))

    `Extra`       varchar(200)    null,
    primary key (`UId`),
    unique index `nickname_Unique` (`Nickname` asc),
    unique index `email_Unique` (`Email` asc)
    check (`Trust` >= 0 and `Trust` <= 10)
    check (`Status` == 0 or `Status` == 1)
);

/*

create trigger `User_Insert_Tri` after insert on `UserInfo`
for each row
begin
    if ((new.`Status` != 0 ) or (new.`Status` != 1))
    then
        update `UserInfo` set `Status` = 0 where `UId` = new.`UId`;
    end if;

    insert into UserStatistics (`UId`) values(new.`UId`);
end$$

