queryHasCreateSecret reports whether query contains a CREATE SECRET at its head or in any top-level statement. It shares the tokenizer with RedactForLog (parseSecretDDLHead / splitTopLevel) so the query and error redactors can never drift apart. DROP SECRET (which carries only a name) is not a match
(query string)
| 78 | // (parseSecretDDLHead / splitTopLevel) so the query and error redactors can |
| 79 | // never drift apart. DROP SECRET (which carries only a name) is not a match. |
| 80 | func queryHasCreateSecret(query string) bool { |
| 81 | if st, _, ok := parseSecretDDLHead(query); ok && st.Kind == KindCreate { |
| 82 | return true |
| 83 | } |
| 84 | // A single top-level statement whose head is not CREATE SECRET cannot hide |
| 85 | // secret DDL; only multi-statement strings need the per-segment scan. |
| 86 | if !hasTrailingStatement(query) { |
| 87 | return false |
| 88 | } |
| 89 | for _, seg := range splitTopLevel(query) { |
| 90 | if st, _, ok := parseSecretDDLHead(seg); ok && st.Kind == KindCreate { |
| 91 | return true |
| 92 | } |
| 93 | } |
| 94 | return false |
| 95 | } |
no test coverage detected