表结构:
CREATE TABLE `setup_int` ( `key` VARCHAR(50) NOT NULL, `val` INT(11) NOT NULL, PRIMARY KEY (`key`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB如您所见,字段为NOT NULL -Fields且没有默认值。
我们更新到MariaDB 10.1.21并立即出现以下问题:以下查询失败,没有任何错误消息!
INSERT INTO `setup_int` (`key`) VALUES ('test');原因似乎是缺少默认值。
如果我向表中添加默认值,则插入成功。 如果我将NOT NULL更改为NULL ,则插入成功。 如果我在MariaDB 10.1.20上执行此操作,则插入是成功的。 如果我使用两个字段执行插入,则插入成功。这有效:
INSERT INTO `setup_int` (`key`,`val`) VALUES ('test',0);问题是:我可以做些什么(一些设置或其他东西)来使mariadb 10.1.21像以前一样处理这种情况。 我现在无法改变所有表格,现在我无法降级。
主要问题是PHP执行的查询返回true尽管插入失败!
Table Structure:
CREATE TABLE `setup_int` ( `key` VARCHAR(50) NOT NULL, `val` INT(11) NOT NULL, PRIMARY KEY (`key`) ) COLLATE='utf8_general_ci' ENGINE=InnoDBAs you can see the fields are NOT NULL-Fields and have no default value.
We updated to MariaDB 10.1.21 and have the following issue now: The following query fails without any error message!
INSERT INTO `setup_int` (`key`) VALUES ('test');The reason seems to be the missing default value.
If I add an default value to the table, the insert is successfull. If I change the NOT NULL to NULL, the insert is successfull. IF I do it on MariaDB 10.1.20, the insert is successfull. If I do the insert with both fields the insert is successfull.This works:
INSERT INTO `setup_int` (`key`,`val`) VALUES ('test',0);The question is: What can I do (some setting, or something else) to make mariadb 10.1.21 to handle this situation like before. I cannot alter all tables right now and i cannot downgrade right now.
The main issue is that the query executed by PHP returns true although the insert failed!
最满意答案
看看这里: https : //stackoverflow.com/a/2503938/1973205
然后你可以像这样设置变量: https : //mariadb.com/kb/en/mariadb/sql-mode/
作为一个纯粹的逻辑事实,查询失败是正确的。
Take a look here: https://stackoverflow.com/a/2503938/1973205
And then you can set the variables like this: https://mariadb.com/kb/en/mariadb/sql-mode/
As a pure logic fact, it's correct that the query fails.
更多推荐
发布评论