MCPcopy Create free account
hub / github.com/actiontech/dtle / RenameCreateSchemaAddINE

Function RenameCreateSchemaAddINE

driver/mysql/base/utils.go:714–727  ·  view source on GitHub ↗

rename schema and add `if not exists`

(createSchema string, newSchema string)

Source from the content-addressed store, hash-verified

712
713// rename schema and add `if not exists`
714func RenameCreateSchemaAddINE(createSchema string, newSchema string) (string, error) {
715 stmt0, err := parser.New().ParseOneStmt(createSchema, "", "")
716 if err != nil {
717 return "", err
718 }
719 stmt, ok := stmt0.(*ast.CreateDatabaseStmt)
720 if !ok {
721 return "", fmt.Errorf("not create schema stmt %v", createSchema)
722 }
723 stmt.Name = newSchema
724 stmt.IfNotExists = true
725
726 return ParserRestore(stmt)
727}
728func ParserRestore(stmt ast.Node) (string, error) {
729 buf := bytes.NewBuffer(nil)
730 err := stmt.Restore(parserformat.NewRestoreCtx(common.ParserRestoreFlag, buf))

Callers 1

mysqlDumpMethod · 0.92

Calls 1

ParserRestoreFunction · 0.85

Tested by

no test coverage detected