Description:
I found a server-side assertion failure while testing MySQL prepared statements through the classic MySQL protocol.
The reproducer first authenticates normally, then sends the trigger packets directly to the authenticated socket. It does not use a client library prepared-statement API for the trigger path.
The trigger sequence is:
1. Raw `COM_STMT_PREPARE` for:
```sql
EXPLAIN FORMAT=JSON SELECT ? + COUNT(*) FROM information_schema.engines
```
2. Raw `COM_STMT_EXECUTE` for the prepared statement. The execute packet uses `CLIENT_QUERY_ATTRIBUTES` semantics and supplies one parameter.
I expected the server either to execute the statement or to reject the packet with a normal error response. Instead, the server aborted with an assertion failure.
The saved server error log starts with:
```text
Invalid previous diagnostics area status 'eof' when attempting to report status 'eof'. This is a bug and the server will now abort.
mysqld: /home/fhb/mysql-server/sql/sql_error.cc:422: void Diagnostics_area::assert_not_set(...): Assertion `!invalid_da_status__check_error_log' failed.
```
Backtrace excerpt:
```text
#10 Diagnostics_area::assert_not_set at /home/fhb/mysql-server/sql/sql_error.cc:422
#11 Diagnostics_area::set_eof_status at /home/fhb/mysql-server/sql/sql_error.cc:454
#12 my_eof at /home/fhb/mysql-server/sql/sql_class.cc:3853
#13 send_eof at /home/fhb/mysql-server/sql/sql_prepare.cc:2165
#14 Materialized_cursor::open at /home/fhb/mysql-server/sql/sql_cursor.cc:382
#15 Prepared_statement::execute at /home/fhb/mysql-server/sql/sql_prepare.cc:3820
#16 Prepared_statement::execute_loop at /home/fhb/mysql-server/sql/sql_prepare.cc:3161
#17 mysqld_stmt_execute at /home/fhb/mysql-server/sql/sql_prepare.cc:1902
```
How to repeat:
1. Start a debug/ASan MySQL server build.
2. Install Python dependencies:
```bash
pip install pymysql mysql-connector-python
```
3. Run the attached reproducer against the test server:
```bash
python3 bug_reproduce_0.py -h <host> -P <port> -u <user> -p <password> -d bug0_repro
```
4. The script sends the raw `COM_STMT_PREPARE` and `COM_STMT_EXECUTE` packets directly through the socket.
Observed output:
```text
Raw send packet_1_stmt2.bin: COM_STMT_EXECUTE payload_len=24
Connection lost while waiting for packet_1_stmt2.bin: server closed the connection
BUG CONFIRMED: server appears to be down
```