MCPcopy Index your code
hub / github.com/bytebase/bytebase / GenerateRestoreSQL

Function GenerateRestoreSQL

backend/plugin/parser/plsql/restore.go:25–44  ·  view source on GitHub ↗
(ctx context.Context, rCtx base.RestoreContext, statement string, backupItem *storepb.PriorBackupDetail_Item)

Source from the content-addressed store, hash-verified

23)
24
25func GenerateRestoreSQL(ctx context.Context, rCtx base.RestoreContext, statement string, backupItem *storepb.PriorBackupDetail_Item) (string, error) {
26 originalSQL, err := extractSQL(statement, backupItem)
27 if err != nil {
28 return "", errors.Errorf("failed to extract single SQL: %v", err)
29 }
30
31 node, err := findFirstOracleDML(originalSQL)
32 if err != nil {
33 return "", err
34 }
35 if node == nil {
36 return "", errors.New("no DML statement found in extracted SQL")
37 }
38
39 sqlForComment, truncated := common.TruncateString(originalSQL, maxCommentLength)
40 if truncated {
41 sqlForComment += "..."
42 }
43 return doGenerate(ctx, rCtx, sqlForComment, node, backupItem)
44}
45
46func findFirstOracleDML(statement string) (oracleast.StmtNode, error) {
47 node, err := findFirstOracleDMLOnce(statement)

Callers 2

TestRestoreFunction · 0.70

Calls 5

TruncateStringFunction · 0.92
extractSQLFunction · 0.85
findFirstOracleDMLFunction · 0.85
ErrorfMethod · 0.80
doGenerateFunction · 0.70

Tested by 2

TestRestoreFunction · 0.56