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

Function deleteMutatesTable

backend/plugin/parser/tidb/restore.go:537–561  ·  view source on GitHub ↗

deleteMutatesTable reports whether the DELETE removes rows from the specified physical table. Single-table DELETE (no USING): n.Tables is the physical table. Multi-table DELETE (DELETE t1, t2 FROM ...): n.Tables holds the delete-target ALIASES (or bare names), which must be resolved through the FR

(n *ast.DeleteStmt, database, table string)

Source from the content-addressed store, hash-verified

535// to resolve aliases; it is never matched as a mutation target, because doing
536// so re-inserted rows that were never deleted (Codex P1 catch on PR #20345).
537func deleteMutatesTable(n *ast.DeleteStmt, database, table string) bool {
538 if len(n.Using) == 0 {
539 for _, expr := range n.Tables {
540 if tableExprReferences(expr, database, table) {
541 return true
542 }
543 }
544 return false
545 }
546 refs := extractSingleTablesFromTableExprs(database, n.Using)
547 for _, target := range n.Tables {
548 ref, ok := target.(*ast.TableRef)
549 if !ok {
550 continue
551 }
552 resolved, ok := refs[strings.ToLower(ref.Name)]
553 if !ok {
554 continue
555 }
556 if strings.EqualFold(resolved.Database, database) && strings.EqualFold(resolved.Table, table) {
557 return true
558 }
559 }
560 return false
561}
562
563// updateMutatesTable reports whether the UPDATE's SET clauses actually
564// mutate (a column of) the specified table. JOIN-only references that

Callers 1

containsTableFunction · 0.85

Calls 2

tableExprReferencesFunction · 0.70

Tested by

no test coverage detected