Skip to main content
In some cases, administrators need to disable certain patterns of SQL to avoid SQL from triggering cluster crashes or unexpected high concurrent queries. The blacklist is only for SELECT statements, INSERT statements (from v3.1 onwards), and CTAS statements (from v3.4 onwards). The database allows users to add, view, and delete SQL blacklists.

Syntax

Enable SQL blacklisting via enable_sql_blacklist. The default is False (off).
The admin user who has ADMIN_PRIV privileges can manage blacklists by executing the following commands:
  • When enable_sql_blacklist is true, every SQL query needs to be filtered by sqlblacklist. If it matches, the user will be informed that the SQL is in the blacklist. Otherwise, the SQL will be executed normally. The message may be as follows when the SQL is blacklisted:
ERROR 1064 (HY000): Access denied; sql 'select count (*) from test_all_type_select_2556' is in blacklist

Add blacklist

sql is a regular expression for a certain type of SQL. Tip Currently, the database supports adding SELECT statements to the SQL Blacklist. Since SQL itself contains the common characters (, ), *, . that may be mixed up with the semantics of regular expressions, we need to distinguish those by using escape characters. Given that ( and ) are used too often in SQL, there is no need to use escape characters. Other special characters need to use the escape character \ as a prefix. For example:
  • Prohibit count(\*):
  • Prohibit count(distinct):
  • Prohibit order by limit x, y, 1 <= x <=7, 5 <=y <=7:
  • Prohibit complex SQL:
  • Prohibit all INSERT INTO statements:
  • Prohibit all INSERT INTO … VALUES statements:
  • Prohibit all INSERT INTO … VALUES statements except those against the system-defined view _statistics_.column_statistics:

View blacklist

Result format: Index | Forbidden SQL For example:
The SQL shown in Forbidden SQL is escaped for all SQL semantic characters.

Delete blacklist

<sql_index_number> is a list of SQL IDs separated by comma (,). For example, delete the No.3 and No.4 SQLs in the above blacklist:
Then, the remaining sqlblacklist is as follows: