Пример #1
0
func (d *ddl) dropSchemaData(tIDs []int64, startKey kv.Key, job *model.Job, m *meta.Meta) (bool, error) {
	if len(tIDs) == 0 {
		return true, nil
	}

	var isFinished bool
	var nextStartKey kv.Key
	for i, id := range tIDs {
		job.TableID = id
		if startKey == nil {
			startKey = tablecodec.EncodeTablePrefix(id)
		}
		limit := defaultBatchSize
		delCount, err := d.dropTableData(startKey, job, limit)
		if err != nil {
			return false, errors.Trace(err)
		}
		if delCount == limit {
			isFinished = false
			nextStartKey = job.Args[len(job.Args)-1].(kv.Key)
			break
		}

		if i < len(tIDs)-1 {
			tIDs = tIDs[i+1:]
		} else {
			tIDs = nil
		}
		startKey = nil
		isFinished = true
		continue
	}
	job.TableID = 0
	job.Args = []interface{}{tIDs, nextStartKey}

	return isFinished, nil
}