Bug #94366 show errors from previous MySQL operation
Submitted: 16 Feb 20:22 Modified: 17 Feb 17:00
Reporter: PRABHU R Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0 OS:Microsoft Windows
Assigned to: CPU Architecture:Other
Tags: Errors Messages

[16 Feb 20:22] PRABHU R
Description:
I did,
       SELECT * FROM unknown_table;
       SELECT @@error_count;

       --Returns Error
       --Returns Errorcount as 1
       
       SELECT 1;
       SELECT @@error_count;

       --Returns 1
       --Returns Errorcount as 1

I expected,

       SELECT * FROM unknown_table;
       SELECT @@error_count;

       --Returns Error
       --Returns Errorcount as 1

       SELECT 1;
       SELECT @@error_count;

       --Returns 1
       --Returns Errorcount as 0

It happens,

           show errors from previous MySQL operation

How to repeat:
I did,
       SELECT * FROM unknown_table;
       SELECT @@error_count;

       --Returns Error
       --Returns Errorcount as 1
       
       SELECT 1;
       SELECT @@error_count;

       --Returns 1
       --Returns Errorcount as 1

I expected,

       SELECT * FROM unknown_table;
       SELECT @@error_count;

       --Returns Error
       --Returns Errorcount as 1

       SELECT 1;
       SELECT @@error_count;

       --Returns 1
       --Returns Errorcount as 0

It happens,

           show errors from previous MySQL operation
[17 Feb 17:00] Miguel Solorzano
Thank you for the bug report. Behavior according documented on Manual:
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html

error_count

The number of errors that resulted from the last statement that generated messages. This variable is read only. See Section 13.7.6.17, “SHOW ERRORS Syntax”. 

Your example the last statement with generated messages continues to be:
SELECT * FROM unknown_table; and SELECT 1; doesn't generates error message,
[18 Feb 9:35] Umesh Shastry
Bug #94368 marked as duplicate of this one