Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress MySQL warnings?

Lets say, I have executed a query that triggers some warning messages:

eg:
DROP TABLE IF EXISTS "abcd";

Is there a way to suppress only warning message that been triggering?

I see there is a system variable "max_error_count", changing it to zero may ignore warnings but it would also do all errors/note messages.

like image 886
avisheks Avatar asked Oct 18 '25 05:10

avisheks


1 Answers

Maybe the sql_notes variable helps you with this problem. Quote from the manpage:

The sql_notes system variable controls whether note messages increment warning_count and whether the server stores them. By default, sql_notes is 1, but if set to 0, notes do not increment warning_count and the server does not store them:

mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message                            |
+-------+------+------------------------------------+
| Note  | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set (0.00 sec)

mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW WARNINGS;
Empty set (0.00 sec)
like image 138
Olli Avatar answered Oct 20 '25 20:10

Olli