升级的MySQL 5.0 Linux - > MySQL 5.1 Windows和现在的查询不起作用

时间:2021-11-22 07:17:33

First of all, I know this SHOULDN'T work. We're using a very old DAL/ORM (Pear/DB/GenericDao based) layer that incorrectly surmises that id is not an autoincrement/integer field.

首先,我知道这不应该工作。我们正在使用一个非常古老的DAL / ORM(基于Pear / DB / GenericDao)层,错误地推测该id不是自动增量/整数字段。

This statement DOES work in 5.0 Linux, DOES NOT work in 5.1 Windows. Is there a setting that could be different in my ini (ignore_type_errors="yes":))? I really don't want to add rewriting/upgrading this DAL/ORM (which predates me at the company) to the server upgrade tasks.

此声明适用于5.0 Linux,不适用于5.1 Windows。在我的ini中是否存在可能不同的设置(ignore_type_errors =“yes”:))?我真的不想在服务器升级任务中添加重写/升级这个DAL / ORM(在我公司之前)。

Statement

声明

INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';

Error

错误

Error Code: 1366
Incorrect integer value: '' for column 'id' at row 1)

DDL for Table

表的DDL

CREATE TABLE `Party` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `partyTypeID` varchar(32) NOT NULL DEFAULT '',
  `comment` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `partyTypeID` (`partyTypeID`)
) ENGINE=MyISAM AUTO_INCREMENT=1017793 DEFAULT CHARSET=latin1;

1 个解决方案

#1


4  

You are probably using a more strict SQL_MODE in 5.1 than you were using in 5.0, thus what used to be a warning is now an error.

您可能在5.1中使用比在5.0中使用的更严格的SQL_MODE,因此过去的警告现在是一个错误。

What SQL_MODE are you using?

你使用什么SQL_MODE?

SELECT @@GLOBAL.sql_mode;

Here's an example to show how to get rid of the error:

这是一个示例,说明如何摆脱错误:

mysql> set sql_mode = 'STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
ERROR 1366 (HY000): Incorrect integer value: '' for column 'id' at row 1
mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level   | Code | Message                                              |
+---------+------+------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: '' for column 'id' at row 1 |
+---------+------+------------------------------------------------------+
1 row in set (0.00 sec)

#1


4  

You are probably using a more strict SQL_MODE in 5.1 than you were using in 5.0, thus what used to be a warning is now an error.

您可能在5.1中使用比在5.0中使用的更严格的SQL_MODE,因此过去的警告现在是一个错误。

What SQL_MODE are you using?

你使用什么SQL_MODE?

SELECT @@GLOBAL.sql_mode;

Here's an example to show how to get rid of the error:

这是一个示例,说明如何摆脱错误:

mysql> set sql_mode = 'STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
ERROR 1366 (HY000): Incorrect integer value: '' for column 'id' at row 1
mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level   | Code | Message                                              |
+---------+------+------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: '' for column 'id' at row 1 |
+---------+------+------------------------------------------------------+
1 row in set (0.00 sec)