> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# SHOW WARNINGS

> SHOW WARNINGS and SHOW ERRORS return the diagnostics of the previous statement in the current session, such as rows an INSERT filtered or set to NULL.

`SHOW WARNINGS` displays the diagnostics (notes, warnings, and errors) generated by the most recently executed statement on the current session. `SHOW ERRORS` is the same statement but returns only the error-level diagnostics.

These statements implement the MySQL diagnostics area, so a MySQL client, or a JDBC driver through `Statement.getWarnings()`, can retrieve the diagnostics of the previous statement. Two things fill the buffer: an `INSERT` that filtered rows or substituted out-of-range values with `NULL` instead of failing, and the error of a statement that failed.

No privilege is required to perform this operation.

## Syntax

```SQL theme={null}
SHOW WARNINGS [LIMIT [offset,] row_count]
SHOW ERRORS [LIMIT [offset,] row_count]
```

## Parameters

`LIMIT [offset,] row_count`: returns at most `row_count` diagnostics, skipping the first `offset` ones. `offset` is optional and defaults to `0`.

## Return value

| Field | Description |
| - | - |
| Level | The severity of the diagnostic: `Note`, `Warning`, or `Error`. |
| Code | The diagnostic code. |
| Message | The human-readable description of the diagnostic. |

## Usage notes

The buffer holds the diagnostics of the previous statement and is replaced when the next statement begins execution, or with its own error when a statement fails, including a statement that fails to parse. Three statement classes leave the buffer unchanged when they succeed: `SET`, `BEGIN` / `COMMIT` / `ROLLBACK`, and `SHOW`, which covers `SHOW WARNINGS` and `SHOW ERRORS` themselves. `SHOW WARNINGS` can therefore be issued repeatedly, and still returns the diagnostics of the last `INSERT` after a `COMMIT`. Switching database with `USE` replaces the buffer as well, whether the client sends it as a statement or as the MySQL `COM_INIT_DB` command.

* Only an `INSERT` reports filtered rows this way. Broker Load, Spark Load and Routine Load are asynchronous jobs that the submitting statement merely registers, and Stream Load has no SQL session at all, so none of them leaves anything for `SHOW WARNINGS` to return. Use [SHOW LOAD](/documents/4.2/sql-reference/sql-statements/loading_unloading/SHOW_LOAD.md) for those.
* An `INSERT` only filters rows when it is allowed to. Under the defaults `enable_insert_strict = true` and `insert_max_filter_ratio = 0`, a single unqualified row fails the statement instead, and the buffer then holds that error rather than a warning. See the first example.
* `warning_count` on the OK packet carries the number of rows that were filtered or substituted, while `SHOW WARNINGS` returns a single row summarizing them. The two values are not expected to match. In MySQL, `warning_count` equals the number of rows `SHOW WARNINGS` returns.
* The diagnostics live in the session that executed the statement. When a session is connected to a follower FE, an `INSERT` is forwarded to the leader and runs there in a per-request session that is discarded when the request returns, so `SHOW WARNINGS` returns an empty result on the follower, and there is no session on the leader to read them back from either. Run the `INSERT` from a session connected to the leader FE, or open the tracking URL carried in the message. A forwarded statement that fails behaves the same way: the follower relays the leader's error response without the error code, so it records nothing and `SHOW ERRORS` is empty as well.
* Diagnostics produced while reading data, such as a `CAST` that overflows and yields `NULL`, are not recorded yet.

## Examples

Example 1: Read back the rows an `INSERT` filtered. Both session variables are needed, because under the defaults the statement fails on the first unqualified row instead of filtering it.

```Plain theme={null}
mysql> SET enable_insert_strict = false;
Query OK, 0 rows affected (0.00 sec)

mysql> SET insert_max_filter_ratio = 0.5;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t_dst SELECT CAST(v AS INT) FROM t_src;
Query OK, 2 rows affected, 1 warning (0.36 sec)

mysql> SHOW WARNINGS;
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1265 | 1 row(s) filtered or substituted to NULL during load; tracking_url=http://172.26.92.1:8040/api/_load_error_log?file=error_log_9a1c2b3d |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Example 2: Return at most one diagnostic.

```SQL theme={null}
SHOW WARNINGS LIMIT 1;
```

Example 3: Read back the error of a statement that failed. `SHOW ERRORS` reports the same code and message that were sent in the error response.

```Plain theme={null}
mysql> SELECT * FROM no_such_table;
ERROR 5502 (42602): Getting analyzing error. Detail message: Unknown table 'example_db.no_such_table'.

mysql> SHOW ERRORS;
+-------+------+------------------------------------------------------------------------------------+
| Level | Code | Message                                                                            |
+-------+------+------------------------------------------------------------------------------------+
| Error | 5502 | Getting analyzing error. Detail message: Unknown table 'example_db.no_such_table'. |
+-------+------+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.