Documentation
¶
Overview ¶
Package sqlident reads a SQL statement lexically for what it names: every identifier outside strings and comments, and whether it selects every column of a table (a * projection). Dialect-agnostic, since it tokenizes rather than parses. Semantic enrichment narrows column context to the identifiers a statement names, and the Trino PII prompt counts only the columns it reads (#2586).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Identifiers ¶
Identifiers lexes a SQL string and returns all identifiers found, lowercased. This is dialect-agnostic because it operates at the lexical level (tokenization), not at the grammar level (parsing). String literals, block comments, and line comments are skipped entirely. Double-quoted identifiers are extracted and lowercased.
The function runs in O(n) time with a single pass over the input.
func ReadsEveryColumn ¶
ReadsEveryColumn reports whether a statement selects every column of a table it reads: a `*` projection, bare (`SELECT *`, `SELECT a, *`) or qualified (`t.*`). A star inside parentheses (`count(*)`) and a multiplication (`a * b`) read no column by themselves and do not count, and a star inside a string literal, a quoted identifier or a comment is not read at all.
It is lexical, like Identifiers, and errs toward true: the PII consent check counts every PII column of a table when this holds, and a missed star would let a query read personal data without the prompt (#2586).
Types ¶
This section is empty.