pingcap / parser

A MySQL Compatible SQL Parser
Apache License 2.0
1.41k stars 489 forks source link

Incorrect increase in warning count for error 1068 #1268

Closed dveeden closed 3 years ago

dveeden commented 3 years ago

Bug Report

tidbTestSuite.TestClientErrors in pingcap/tidb found this.

1. Minimal reproduce step (Required)

$ mysqlsh mysql://root@127.0.0.1:4000/test -i -e 'SELECT * FROM information_schema.client_errors_summary_global WHERE error_number=1068; CREATE TABLE test_client_errors2 (a int primary key, b int primary key); SELECT * FROM information_schema.client_errors_summary_global WHERE error_number=1068;'
MySQL Shell 8.0.25

Copyright (c) 2016, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.

Type '\help' or '\?' for help; '\quit' to exit.
Creating a Classic session to 'root@127.0.0.1:4000/test'
Fetching schema names for autocompletion... Press ^C to stop.
Fetching table and column names from `test` for auto-completion... Press ^C to stop.
Your MySQL connection id is 5
Server version: 5.7.25-TiDB-v5.2.0-alpha-222-g297a90dde-dirty TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
Default schema set to `test`.
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
| ERROR_NUMBER | ERROR_MESSAGE                | ERROR_COUNT | WARNING_COUNT | FIRST_SEEN          | LAST_SEEN           |
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
|         1068 | Multiple primary key defined |           1 |             0 | 2021-07-07 08:09:08 | 2021-07-07 08:09:08 |
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
1 row in set (0.0003 sec)
ERROR: 1068 (42000): Multiple primary key defined
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
| ERROR_NUMBER | ERROR_MESSAGE                | ERROR_COUNT | WARNING_COUNT | FIRST_SEEN          | LAST_SEEN           |
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
|         1068 | Multiple primary key defined |           2 |             0 | 2021-07-07 08:09:08 | 2021-07-07 08:09:11 |
+--------------+------------------------------+-------------+---------------+---------------------+---------------------+
1 row in set (0.0002 sec)

2. What did you expect to see? (Required)

CREATE TABLE test_client_errors2 (a int primary key, b int primary key) is expected to only increase the ERROR_COUNT and not the WARNING_COUNT.

3. What did you see instead (Required)

WARNING_COUNT increases.

4. What is your TiDB version? (Required)

5.7.25-TiDB-v5.2.0-alpha-222-g297a90dde-dirty 127.0.0.1:4000  test  SQL  select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.2.0-alpha-222-g297a90dde-dirty
Edition: Community
Git Commit Hash: 297a90dde2018c53bc38b08605c4460ce4ccdbc6
Git Branch: master
UTC Build Time: 2021-07-07 06:11:19
GoVersion: go1.16.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.0008 sec)

This happens when pingcap/parser is updated to https://github.com/pingcap/parser/commit/8d6fe8127e60cc5e7b51637f6ccd63506bf764e2 or later. This in turn seem to be caused by https://github.com/pingcap/errors/commit/40f9a1999b3bce21f1603b268f262a14bca7f74b from https://github.com/pingcap/errors/pull/35

dveeden commented 3 years ago

/cc @disksing