Is there a way to detect overflow in mysql?

After some time, trying to kill this error, I directly tested the SQL query:

UPDATE noticias SET
    data_destaque_ini='2013-12-03', data_destaque_fim='',
    fotoDestaque_x=-3, fotoDestaque_y=-102,
    fotoDestaque_escala=154, destacar=1
WHERE idNoticia=3

But it fotoDestaque_escalaretains the same meaning as before: 127. Hum, this is a round number, right? Therefore, even without any sql error message, I opened the structure and that it: the column was set to TINYINT(from 127 to 127), and changing it to SMALLINTsolved the problem.

But, thinking about the future, I am alarmed by this behavior of MySQL: I passed too much value to the column, MySQL saved what was possible, cut everything else and said nothing about - the client remains in the dark!

So, is there a way to configure or detect, somehow, an overflow? If not, I'm going to do a php level test in my library ...

+3
2

11.2.6 MySQL:

MySQL , , SQL, :

  • SQL, MySQL , SQL.
  • , MySQL .

, , MySQL SQL. 5.1.7 SQL.

+3

( ) MySQL , /:

mysql> CREATE TABLE t (i TINYINT);
Query OK, 0 rows affected (0.11 sec)

mysql> INSERT INTO t VALUES (128);
Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------+
| Level   | Code | Message                                    |
+---------+------+--------------------------------------------+
| Warning | 1264 | Out of range value for column 'i' at row 1 |
+---------+------+--------------------------------------------+
1 row in set (0.00 sec)


"Query OK, 1 row affected, 1 warning" № 2.

SHOW WARNINGS; SQL- , .

, .

+4

All Articles