Re: Not solved - mysql data truncation does not cause an error to be thrown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 9, 2007 8:34 PM, Andrew Blake <a.blake@xxxxxxxxxxxxx> wrote:
> Hello
>
> It seems that the normal mysql_query doesn't error when an sql command
> forces the server to truncate the data. The mysql server executes the
> sql and provides a warning but it still executes the sql so allowing php
> to ignore the fact that there is a warning. You can run another sql
> command "SHOW COUNT(*) WARNINGS" after your insert command to check if
> there is a warning and roll back the changes - similar to the java mysql
> interface. I haven't used mysqli and perhaps this is addressed in that ?

I doubt it.

> Using sqlyog (3rd party mysql gui) to run the sql also provides no
> warning message but running it on the command line provides the "1 row
> affected, 1 warning message" With data validation and check this data
> too large situation should never happen but surely php should pay
> attention to the warnings too ?

It's not a php problem. Mysql should throw proper errors instead of a 'warning'.

http://dev.mysql.com/doc/refman/4.1/en/blob.html
If you assign a value to a BLOB or TEXT column that exceeds the data
type's maximum length, the value is truncated to fit and a warning is
generated.

Same for char/varchar & binary fields
(http://dev.mysql.com/doc/refman/4.1/en/binary-varbinary.html and
http://dev.mysql.com/doc/refman/4.1/en/char.html).

You will get the same "problem" in other languages I'm sure (try it in
python, perl, ruby).

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux