sql:=fmt.Sprintf("select last_row(ts) from %s.%s group by tbname",srcDB,stbname)
row,err:=d.db.Query(sql)
iferr!=nil{
checkErr(err,sql)
}
forrow.Next(){
vartstime.Time
vartbnamestring
row.Scan(&ts,&tbname)
result[tbname]=ts
}
row.Close()
returnresult
}(d.db,d.srcdbname,d.suptabname)
for_,e:=rangetbs{
tbname:=e.tbname
lastTime,ok:=lastRowDict[tbname]
if!ok{
lastTime=time.Now()
}
fori,f:=rangefields{
col:=fmt.Sprintf("%s %s",tbname,f)
var(
tstime.Time
dbnamestring
tablenamestring
colnamestring
checkintervalint
thresholdint
)
checkSql:=fmt.Sprintf("select * from %s.%s where dbname = \"%s\" and tablename = \"%s\" and colname = \"%s\"",d.dbname,d.metaTable,d.srcdbname,tbname,f)