dbi-users  

varchar error not reported with mysql

Morfys
Tue, 12 Jan 2010 17:31:36 -0800

Hi,

A mysql error does not seem to be reported when inserting a string
longer than the maximum VARCHAR length.

For example,
if I set mysql to do strict checking with:

SET SESSION sql_mode='STRICT_ALL_TABLES';

and I have the following field in my mysql table:
    s_val VARCHAR(1),

executing
insert into event_state values ('123456789')

with DBI and PrintError => 1, RaiseError => 1,
doesn't report any problem.

If I do the insertion manually in mysql, I get an error
ERROR 1406 (22001): Data too long for column 's_val' at row 1

Any possible solutions?  Thanks in advance.

  • varchar error not reported with mysql Morfys