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

Function RenameCreateTable

driver/mysql/base/utils.go:752–773  ·  view source on GitHub ↗
(createTable string, newSchema string, newTable string, columnMap []string)

Source from the content-addressed store, hash-verified

750}
751
752func RenameCreateTable(createTable string, newSchema string, newTable string, columnMap []string) (string, error) {
753 stmt0, err := parser.New().ParseOneStmt(createTable, "", "")
754 if err != nil {
755 return "", err
756 }
757 stmt, ok := stmt0.(*ast.CreateTableStmt)
758 if !ok {
759 return "", fmt.Errorf("not create table stmt %v", createTable)
760 }
761 stmt.Table.Schema = model.NewCIStr(newSchema)
762 stmt.Table.Name = model.NewCIStr(newTable)
763
764 stmt.Cols = BuildCreateTableColsFromMap(stmt.Cols, columnMap)
765
766 buf := bytes.NewBuffer(nil)
767 err = stmt.Restore(parserformat.NewRestoreCtx(common.ParserRestoreFlag, buf))
768 if err != nil {
769 return "", err
770 }
771
772 return buf.String(), nil
773}

Callers 2

mysqlDumpMethod · 0.92
TestRenameCreateTableFunction · 0.85

Calls 2

StringMethod · 0.45

Tested by 1

TestRenameCreateTableFunction · 0.68