好的,我明白什么是 MySQL 上下文中的错误和警告。但是有什么需要注意级别的警告呢?我已经搜索了 MySQL 文档,但没有找到任何相关内容。如果有人能阐明它们是什么以及它们为什么有用,那就更好了。
mysql> create database if not exists city;
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> show warnings
-> ;
+-------+------+------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------+
| Note | 1007 | Can't create database 'city'; database exists |
+-------+------+------------------------------------------------+
1 row in set (0.00 sec)
最佳答案
我一直认为 Note 就像一个“FYI”:发生或未发生的事情可能会引起人们的兴趣。我可以在 docs 中找到最接近的定义是:
... events that do not affect the integrity of the reload operation
它来自 sql_notes
服务器变量,可能在 mysqldump
之外不常使用。
拖网 MySQL source code ,看起来像 Sql_Condition::SL_NOTE
注释了这个级别的警告。有一些,但它们大多是您所期望的无影响信息:
- 事件已经存在
- 表已经存在
查询“%s”被查询重写插件重写为“%s”
- 密码设置
遗憾的是,我本以为代码文档 block 会提供一些关于它们的一点信息,但事实并非如此:
class Sql_condition {
public:
/**
Enumeration value describing the severity of the condition.
*/
enum enum_severity_level { SL_NOTE, SL_WARNING, SL_ERROR, SEVERITY_END };
这可能需要向 MySQL 团队报告文档错误。
有趣的是,MariaDB has this to say :
A note is different to a warning in that it only appears if the sql_notes variable is set to 1 (the default), and is not converted to an error if strict mode is enabled.
我从中得出的结论是,在 Maria 中以及可能通过扩展 MySQL:注释是警告,但是可以忽略的警告,因为没有描述数据丢失或副作用。
关于mysql - 什么是 MySQL 中的注释级警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52629437/