From f415b40162623cef084caf6c18ed3e595a5c6373 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 14 五月 2020 20:26:04 +0800 Subject: [PATCH] fix dumpSqls is nil --- sync.go | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/sync.go b/sync.go index 19f8e24..57499fb 100755 --- a/sync.go +++ b/sync.go @@ -152,14 +152,12 @@ sqls = append(sqls, delSql) } - var dumpSqls *[]string dumpSqls, err := agent.GetTableDataFromCluster(syncTables) - fmt.Println("dumpSqls:", dumpSqls, "err:",err) - if dumpSqls != nil { - for _, dumpSql := range *dumpSqls { - sqls = append(sqls, dumpSql) - } + if dumpSqls != nil && len(*dumpSqls) > 0 { + fmt.Println("len(dumpSqls):", len(*dumpSqls), "err:", err) + sqls = append(sqls, *dumpSqls) } else { + fmt.Println("dumpSqls is nil, err:", err) return false } @@ -201,8 +199,7 @@ func UpdateClusterName(clusterName, clusterID string) bool { sql := string("update cluster set cluster_name='" + clusterName + "' where cluster_id='" + clusterID + "'") - _, err := sdb.ExecuteWriteSql([]string{sql}, false) - if err != nil { + if !sdb.DbHandle.Execute(sql) { return false } @@ -220,10 +217,9 @@ agent.Shutdown() agent = nil - sqls := []string{"delete from cluster_node", "delete from cluster"} + sqls := "delete from cluster_node;delete from cluster;" - _, err = sdb.ExecuteWriteSql(sqls, false) - if err != nil { + if !sdb.DbHandle.Execute(sqls) { return false } } -- Gitblit v1.8.0