Intro
Almost any of you got such an error when you tried to import your own mysql backups via .sql, at least, once in your lifetime, instead of using mysqldump.
Anyway, you can get this weird error on tables such as player.mob_proto and player.skill_proto.
Why
Since mysql5, there's a flag called STRICT_TRANS_TABLES that forbids you to set a wrong field into enum fields returning an error.
Usually, you should not have '' as an enum value because it's the result of a bad flag value set in it.
To be more precise:
The 0 element of an enum is interpreted as '', but '' is not the 0 element.
If you have an enum such as ('A', 'B', 'C'): A is 1, B is 2, C is 3, and everything else not in the enum is truncated as 0.
The STRICT_TRANS_TABLES won't truncate the value to 0, but it will generate an error.
If you run a query like this, you could see their positions very easily:
Result: [Only registered and activated users can see links. Click Here To Register...]
Your aim is to either remove the STRICT_TRANS_TABLES flag or the truncated '' fields to NULL.
How-To-Fix
You have many solutions to fix this awful error:
What-To-Know
Almost any of you got such an error when you tried to import your own mysql backups via .sql, at least, once in your lifetime, instead of using mysqldump.
Anyway, you can get this weird error on tables such as player.mob_proto and player.skill_proto.
Code:
#skill_proto 1265 - Data truncated for column 'setAffectFlag' at row 1 1265 - Data truncated for column 'setFlag' at row 1 #mob_proto 1265 - Data truncated for column 'size' at row 1 #and so on
Since mysql5, there's a flag called STRICT_TRANS_TABLES that forbids you to set a wrong field into enum fields returning an error.
Usually, you should not have '' as an enum value because it's the result of a bad flag value set in it.
To be more precise:
The 0 element of an enum is interpreted as '', but '' is not the 0 element.
If you have an enum such as ('A', 'B', 'C'): A is 1, B is 2, C is 3, and everything else not in the enum is truncated as 0.
The STRICT_TRANS_TABLES won't truncate the value to 0, but it will generate an error.
If you run a query like this, you could see their positions very easily:
Code:
select apply, apply+0 from player.item_attr;
Your aim is to either remove the STRICT_TRANS_TABLES flag or the truncated '' fields to NULL.
How-To-Fix
You have many solutions to fix this awful error:
- Add the IGNORE parameter to your INSERT or UPDATE queries to consider this error just a warning.
Code:/* change this */ INSERT INTO smth ...therestofthequery...; /* to */ INSERT IGNORE INTO smth ...therestofthequery...;
- You should replace the empty string fields '' as NULL for the relative enum/set ones.
It could be boring, and db could not read such NULL fields at all causing a crash.
NB: You should also set the field NULLable. - Remove the STRICT_TRANS_TABLES flag from the sql_mode variable putting this at the beginning of the query:
Or just:Code:SET sql_mode=(SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES',''));
NB: mysqldump does such a thing automatically.Code:SET sql_mode = '';
What-To-Know
- [Only registered and activated users can see links. Click Here To Register...]
- [Only registered and activated users can see links. Click Here To Register...]
- [Only registered and activated users can see links. Click Here To Register...]
- [Only registered and activated users can see links. Click Here To Register...]