Bug #77883 | Only able to get ZERO from warning_count. | ||
---|---|---|---|
Submitted: | 30 Jul 2015 12:30 | Modified: | 25 Oct 2018 8:21 |
Reporter: | Peter Laursen (Basic Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Errors | Severity: | S3 (Non-critical) |
Version: | 5.6.25 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[30 Jul 2015 12:30]
Peter Laursen
[30 Jul 2015 12:31]
Peter Laursen
Sorry - first line should have read like "I am not able to get anything else than "0" returned from warning_count."
[30 Jul 2015 12:49]
Peter Laursen
The warning_count in the C-API (https://dev.mysql.com/doc/refman/5.6/en/mysql-warning-count.html) it seems to work (with the C-API from MariaDB at least). If the server variable and API function do not return the same, differences should be elaborated somewhere in docs.
[3 May 2018 6:31]
Chiranjeevi Battula
Hello Peter, Thank you for the bug report. Thanks, Chiranjeevi.
[25 Oct 2018 8:21]
Erlend Dahl
Posted by developer - Jens Even Blomsoy: Update: Using; SHOW COUNT(*) WARNINGS; or SELECT @@warning_count; Produces the wanted and expected result. By doing SHOW VARIABLES LIKE 'warning_count'; one touches a table in the query and the warning_count is reset to take into account the errors that may occur according to the documentation. The warning_count from this query is in a way correct in the sense that it counts the number of warnings produced by the same query. This is although confusing. So the question is if this should be changed to view the warning_count of the previous query. As mentioned in the last comment, this is not a bug. /* If we encounter a diagnostics statement (GET DIAGNOSTICS, or e.g. the old SHOW WARNINGS|ERRORS, or "diagnostics variables" such as @@warning_count | @@error_count, we'll set some hints so this information is not lost. DA_KEEP_UNSPECIFIED is used in LEX constructor to avoid leaving variables uninitialized. */ enum enum_keep_diagnostics { DA_KEEP_NOTHING = 0, /**< keep nothing */ DA_KEEP_DIAGNOSTICS, /**< keep the diagnostics area */ DA_KEEP_COUNTS, /**< keep \@warning_count / \@error_count */ DA_KEEP_PARSE_ERROR, /**< keep diagnostics area after parse error */ DA_KEEP_UNSPECIFIED /**< keep semantics is unspecified */ }; SHOW VARIABLES is not a "diagnostics statement". Thus so in alignment with the SQL-standard, the diagnostics area will be emptied. The query "SELECT @@warning_count;" does use the DA_KEEP_COUNTS and will give the wanted result. While the query "SHOW VARIABLES LIKE 'warning_count';" is valid, it will not produce anything useful. https://dev.mysql.com/doc/refman/5.7/en/diagnostics-area.html