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

Function writeDeleteSuffix

backend/plugin/parser/mysql/backup.go:379–406  ·  view source on GitHub ↗
(buf *strings.Builder, n *ast.DeleteStmt, sql string)

Source from the content-addressed store, hash-verified

377}
378
379func writeDeleteSuffix(buf *strings.Builder, n *ast.DeleteStmt, sql string) error {
380 // For single-table DELETE: everything from the table ref to statement end.
381 // For multi-table DELETE: everything from the USING/reference table list to end.
382 if len(n.Using) > 0 {
383 start := nodeLocStart(n.Using[0])
384 end := n.Loc.End
385 if end <= 0 || end > len(sql) {
386 end = len(sql)
387 }
388 if start >= 0 && end > start {
389 if _, err := buf.WriteString(strings.TrimSpace(sql[start:end])); err != nil {
390 return err
391 }
392 }
393 } else if len(n.Tables) > 0 {
394 start := nodeLocStart(n.Tables[0])
395 end := n.Loc.End
396 if end <= 0 || end > len(sql) {
397 end = len(sql)
398 }
399 if start >= 0 && end > start {
400 if _, err := buf.WriteString(strings.TrimSpace(sql[start:end])); err != nil {
401 return err
402 }
403 }
404 }
405 return nil
406}
407
408func nodeLocStart(expr ast.TableExpr) int {
409 switch e := expr.(type) {

Callers 1

writeSuffixSelectClauseFunction · 0.70

Calls 1

nodeLocStartFunction · 0.70

Tested by

no test coverage detected