Skip to main content
ADD SQLBLACKLIST adds a regular expression to the SQL blacklist to forbid certain SQL patterns. When the SQL Blacklist feature is enabled, the database compares all SQL statements to be executed against the SQL regular expressions in the blacklist. The database does not execute SQLs that match any regular expression in the blacklist and returns an error. This prevents certain SQLs from triggering cluster crashes or unexpected behavior. For more about SQL Blacklist, see Manage SQL Blacklist. Tip
  • This operation requires the SYSTEM-level BLACKLIST privilege. You can follow the instructions in GRANT to grant this privilege.
  • The blacklist is only for SELECT statements, INSERT statements (from v3.1 onwards), and CTAS statements (from v3.4 onwards).

Syntax

Parameter

sql_reg_expr: the regular expression that is used to specify a certain SQL pattern. To distinguish the special characters in the SQL statement and those in the regular expression, you need to use the escape character \ as a prefix for the special characters in the SQL statement, such as (, ), and +. Whereas ( and ) have been often used in SQL statements, the database can identify ( and ) in SQL statements directly. You do not need to use the escape character for ( and ).

Examples

Example 1: Add count(\*) to the SQL blacklist.
Example 2: Add count(distinct ) to the SQL blacklist.
Example 3: Add order by limit x, y, 1 <= x <=7, 5 <=y <=7 to the SQL blacklist.
Example 4: Add a complex SQL regular expression to the SQL blacklist. This example is to demonstrate how to use escape characters for * and - in SQL statements.
Example 5: Prohibit all INSERT INTO statements:
Example 6: Prohibit all INSERT INTO … VALUES statements:
Example 7: Prohibit all INSERT INTO … VALUES statements except those against the system-defined view _statistics_.column_statistics: