<@U0A71G31CDV> Is it possible to blacklist `select...
# questions-and-troubleshooting
m
@Rocky Is it possible to blacklist
select *
queries from primary key table
r
Yes, it is possible to blacklist
SELECT *
queries in StarRocks using the SQL Blacklist feature. This feature allows you to define regular expressions that match specific SQL patterns and block them from executing. 1. Enable the Blacklist Feature First, you must enable the SQL blacklist feature in your Frontend (FE) configuration:
Copy code
sql
ADMIN SET FRONTEND CONFIG ("enable_sql_blacklist" = "true");
2. Add a Blacklist Rule You can then add a regular expression to block
SELECT *
queries. Since the blacklist works by matching the SQL string, you can target specific tables or all tables. * *To block
SELECT *
for a specific Primary Key table (e.g.,
my_table
):*
Copy code
sql
    ADD SQLBLACKLIST "(?i)select\\s+\\_\\s+from\\s+my_table._";
(Note:
(?i)
makes the regex case-insensitive, and
\\s+
matches one or more spaces.)
* *To block
SELECT *
for any table (not recommended for all scenarios but possible):*
Copy code
sql
    ADD SQLBLACKLIST "(?i)select\\s+\\*\\s+from\\s+.+";
3. Managing the Blacklist * View current rules:
Copy code
sql
    SHOW SQLBLACKLIST;
* Delete a rule (using the Index from the SHOW command):
Copy code
sql
    DELETE SQLBLACKLIST <index_number>;
Important Considerations * Table Type Awareness: The SQL Blacklist matches the raw SQL string. It does not natively distinguish between Primary Key tables and other table types (like Duplicate or Aggregate tables) unless you specify the table names or follow a specific naming convention in your regex. * Performance: Once enabled, every query is checked against the blacklist. While the overhead is generally low, it is best to keep regex patterns efficient. * Scope: The blacklist currently supports
SELECT
,
INSERT
(from v3.1+), and
CTAS
(from v3.4+) statements. * Privileges: You need the
SYSTEM-level BLACKLIST
privilege to manage these rules. References • using_starrocks/async_mv/use_cases/query_rewrite_with_materialized_views.md