isValidSqlQuery

internal fun isValidSqlQuery(sqlQuery: String): Boolean

Validates that sqlQuery is a read-only query when SqlValidation.ReadOnly is requested.

Validation is tokenization-based: string literals and comments are stripped via stripSqlNoise before any keyword checks, so SQL-valid constructs like regexp_split_to_array(col, ';') or CTEs with WITH are not rejected.

Checks (in order):

  1. The first token of the stripped query must be in READ_ONLY_ALLOWED_FIRST_TOKENS.

  2. No semicolon followed by a non-whitespace character (multiple statements).

  3. No DDL/DML keyword present as a whole word.