错误代码:1264。列' XXX'超出范围值在第1行

时间:2016-05-31 08:15:01

标签: mysql linux windows ubuntu centos

我的存储过程有页码的IN参数(IN page INT) 一切都适用于任何值<= 2147483647。 如果值为> 2147483647,则会收到错误1264。 所有这些都发生在5.6.26 Community Server compiled for Linux (x86_64)上,而5.6.24 Community Server compiled for Win64 (x86_64)则相同 以上所有都很好,我理解错误。

但是,在服务器5.6.30-1+deb.sury.org~xenial+2 (Ubuntu) compiled for debian-linux-gnu (x86_64)上,这不会被复制。无论我通过什么值,输入值都会减少到2147483647。

这个&#34;自动最大值上限&#34;是什么设置?如何在不重新安装的情况下同步不同环境中的设置以具有相同的行为?

谢谢!

1 个答案:

答案 0 :(得分:0)

检查5.1.7 Server SQL Modes

mysql> SELECT @@GLOBAL.SQL_MODE, @@SESSION.SQL_MODE;
+--------------------------------------------+--------------------------------------------+
| @@GLOBAL.SQL_MODE                          | @@SESSION.SQL_MODE                         |
+--------------------------------------------+--------------------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+--------------------------------------------+
1 row in set (0.00 sec)

mysql> DELIMITER //

mysql> DROP PROCEDURE IF EXISTS `sp_test`//
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE PROCEDURE `sp_test`(IN `page` INT)
    -> BEGIN
    ->   SELECT `page`;
    -> END//
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;

mysql> CALL `sp_test`(2147483647);
+------------+
| `page`     |
+------------+
| 2147483647 |
+------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> CALL `sp_test`(2147483648);
ERROR 1264 (22003): Out of range value for column 'page' at row 1

mysql> SET @@SESSION.SQL_MODE = 'NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

mysql> select @@GLOBAL.SQL_MODE, @@SESSION.SQL_MODE;
+--------------------------------------------+------------------------+
| @@GLOBAL.SQL_MODE                          | @@SESSION.SQL_MODE     |
+--------------------------------------------+------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+------------------------+
1 row in set (0.00 sec)

mysql> CALL `sp_test`(2147483648);
+------------+
| `page`     |
+------------+
| 2147483647 |
+------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

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