where:=fmt.Sprintf(`next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted')`,nextCronTime)
dtmimp.DBTypeMysql:fmt.Sprintf(`next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted') limit 1`,nextCronTime),
dtmimp.DBTypePostgres:fmt.Sprintf(`id in (select id from trans_global where next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted') limit 1 )`,nextCronTime),
order:=map[string]string{
dtmimp.DBTypeMysql:`order by rand()`,
dtmimp.DBTypePostgres:`order by random()`,
}[conf.Store.Driver]
}[conf.Store.Driver]
ssql:=fmt.Sprintf(`select count(1) from trans_global where %s`,where)
ssql:=fmt.Sprintf(`select id from trans_global where %s %s limit 1`,where,order)
varcntint64
varidint64
err:=db.ToSQLDB().QueryRow(ssql).Scan(&cnt)
err:=db.ToSQLDB().QueryRow(ssql).Scan(&id)
dtmimp.PanicIf(err!=nil,err)
iferrors.Is(err,sql.ErrNoRows){
ifcnt==0{
returnnil
returnnil
}
}
dtmimp.PanicIf(err!=nil,err)
sql:=fmt.Sprintf(`UPDATE trans_global SET update_time='%s',next_cron_time='%s', owner='%s' WHERE %s`,
sql:=fmt.Sprintf(`UPDATE trans_global SET update_time='%s',next_cron_time='%s', owner='%s' WHERE id=%d and %s`,