本文整理汇总了Golang中github.com/pingcap/tidb/meta.Meta.GetSchemaDiff方法的典型用法代码示例。如果您正苦于以下问题:Golang Meta.GetSchemaDiff方法的具体用法?Golang Meta.GetSchemaDiff怎么用?Golang Meta.GetSchemaDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/meta.Meta
的用法示例。
在下文中一共展示了Meta.GetSchemaDiff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: tryLoadSchemaDiffs
// tryLoadSchemaDiffs tries to only load latest schema changes.
// Returns true if the schema is loaded successfully.
// Returns false if the schema can not be loaded by schema diff, then we need to do full load.
func (do *Domain) tryLoadSchemaDiffs(m *meta.Meta, usedVersion, newVersion int64) (bool, error) {
if usedVersion == initialVersion || newVersion-usedVersion > maxNumberOfDiffsToLoad {
// If there isn't any used version, or used version is too old, we do full load.
return false, nil
}
if usedVersion > newVersion {
// When user use History Read feature, history schema will be loaded.
// usedVersion may be larger than newVersion, full load is needed.
return false, nil
}
var diffs []*model.SchemaDiff
for usedVersion < newVersion {
usedVersion++
diff, err := m.GetSchemaDiff(usedVersion)
if err != nil {
return false, errors.Trace(err)
}
if diff == nil {
// If diff is missing for any version between used and new version, we fall back to full reload.
return false, nil
}
diffs = append(diffs, diff)
}
builder := infoschema.NewBuilder(do.infoHandle).InitWithOldInfoSchema()
for _, diff := range diffs {
err := builder.ApplyDiff(m, diff)
if err != nil {
return false, errors.Trace(err)
}
}
builder.Build()
return true, nil
}