MCPcopy Create free account
hub / github.com/bytebase/bytebase / IsAllDML

Function IsAllDML

backend/plugin/parser/base/interface.go:322–341  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

320// Results are cached to avoid repeated parsing of the same statement.
321// Safe for concurrent calls with the same statement.
322func 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
343func isAllDMLImpl(engine storepb.Engine, statement string) bool {
344 stmts, err := ParseStatements(engine, statement)

Callers

nothing calls this directly

Calls 2

isAllDMLImplFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected