mysql - 什么是 MySQL 中的注释级警告?

标签 mysql

好的,我明白什么是 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/

相关文章:

php - 随机(有权重偏差)从数据库中选择行?

php - 获取选中和未选中的复选框值

python - 如何解决这个 Django/MySQL 设置灾难?

php - 在同一页面上显示 MySQL 查询

mysql - 当使用 AJAX 以 JSON 格式从 MySQL 获取 2000 行时,TTFB 花费的时间太长

mysql - AgentID 位置的 Sql 动态列

php - 如何提高mysql查询处理速度

php - 登录时验证用户并授予他们有限的数据库权限

php - 如何使用 mysqli_fetch_array() 两次?

javascript - 在 OSX Lion 下的 SilkJS 上使用 MySQL