/// SQL reserved keywords (ANSI + common TSQL/PostgreSQL).
/// Must be sorted alphabetically for binary_search.
pub static RESERVED_KEYWORDS: &[&str] = &[
    "ADD",
    "ALL",
    "ALTER",
    "AND",
    "ANY",
    "AS",
    "ASC",
    "BEGIN",
    "BETWEEN",
    "BREAK",
    "BY",
    "CASE",
    "CAST",
    "CATCH",
    "CHECK",
    "CLOSE",
    "CLUSTERED",
    "COALESCE",
    "COLUMN",
    "COMMIT",
    "CONSTRAINT",
    "CONTINUE",
    "CONVERT",
    "CREATE",
    "CROSS",
    "CURRENT",
    "CURRENT_DATE",
    "CURRENT_TIME",
    "CURRENT_TIMESTAMP",
    "CURSOR",
    "DEALLOCATE",
    "DECLARE",
    "DEFAULT",
    "DELETE",
    "DESC",
    "DISTINCT",
    "DROP",
    "ELSE",
    "END",
    "EXCEPT",
    "EXEC",
    "EXECUTE",
    "EXISTS",
    "FALSE",
    "FETCH",
    "FOLLOWING",
    "FOR",
    "FOREIGN",
    "FROM",
    "FULL",
    "FUNCTION",
    "GO",
    "GOTO",
    "GROUP",
    "GROUPS",
    "HAVING",
    "HOLDLOCK",
    "IDENTITY",
    "IF",
    "IN",
    "INDEX",
    "INNER",
    "INSERT",
    "INTERSECT",
    "INTO",
    "IS",
    "JOIN",
    "KEY",
    "LEFT",
    "LIKE",
    "LIMIT",
    "MERGE",
    "NEXT",
    "NOCOUNT",
    "NONCLUSTERED",
    "NOLOCK",
    "NOT",
    "NULL",
    "NULLIF",
    "OFFSET",
    "ON",
    "OPEN",
    "OR",
    "ORDER",
    "OUTER",
    "OUTPUT",
    "OVER",
    "PARTITION",
    "PRECEDING",
    "PRIMARY",
    "PRINT",
    "PROCEDURE",
    "RAISERROR",
    "RANGE",
    "REFERENCES",
    "RETURN",
    "RETURNING",
    "RIGHT",
    "ROLLBACK",
    "ROW",
    "ROWLOCK",
    "ROWS",
    "SCOPE_IDENTITY",
    "SELECT",
    "SET",
    "TABLE",
    "THEN",
    "THROW",
    "TOP",
    "TRAN",
    "TRANSACTION",
    "TRIGGER",
    "TRUE",
    "TRUNCATE",
    "TRY",
    "UNBOUNDED",
    "UNION",
    "UNIQUE",
    "UPDATE",
    "UPDLOCK",
    "USE",
    "USING",
    "VALUES",
    "WHEN",
    "WHERE",
    "WHILE",
    "WITH",
];

/// Check if a word (case-insensitive) is a reserved keyword.
/// Uses zero-allocation binary search with byte-level comparison.
pub fn is_keyword(word: &str) -> bool {
    RESERVED_KEYWORDS
        .binary_search_by(|kw| {
            kw.as_bytes()
                .iter()
                .copied()
                .cmp(word.as_bytes().iter().map(|b| b.to_ascii_uppercase()))
        })
        .is_ok()
}
