IsAllDML checks if all statements are DML (INSERT, UPDATE, DELETE). Returns false for unsupported engines or parse errors (conservative approach). Results are cached to avoid repeated parsing of the same statement. Safe for concurrent calls with the same statement.
(engine storepb.Engine, statement string)
| 320 | // Results are cached to avoid repeated parsing of the same statement. |
| 321 | // Safe for concurrent calls with the same statement. |
| 322 | func IsAllDML(engine storepb.Engine, statement string) bool { |
| 323 | key := isAllDMLCacheKey{engine: engine, hash: xxh3.HashString(statement)} |
| 324 | |
| 325 | isAllDMLCacheMu.Lock() |
| 326 | result, ok := isAllDMLCache.Get(key) |
| 327 | if !ok { |
| 328 | result = &isAllDMLResult{} |
| 329 | isAllDMLCache.Add(key, result) |
| 330 | } |
| 331 | isAllDMLCacheMu.Unlock() |
| 332 | |
| 333 | result.Lock() |
| 334 | defer result.Unlock() |
| 335 | if result.computed { |
| 336 | return result.value |
| 337 | } |
| 338 | result.value = isAllDMLImpl(engine, statement) |
| 339 | result.computed = true |
| 340 | return result.value |
| 341 | } |
| 342 | |
| 343 | func isAllDMLImpl(engine storepb.Engine, statement string) bool { |
| 344 | stmts, err := ParseStatements(engine, statement) |
nothing calls this directly
no test coverage detected