本文整理匯總了Golang中github.com/pingcap/tidb/infoschema.InfoSchema.SchemaMetaVersion方法的典型用法代碼示例。如果您正苦於以下問題:Golang InfoSchema.SchemaMetaVersion方法的具體用法?Golang InfoSchema.SchemaMetaVersion怎麽用?Golang InfoSchema.SchemaMetaVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/infoschema.InfoSchema
的用法示例。
在下文中一共展示了InfoSchema.SchemaMetaVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetInfoSchema
// GetInfoSchema gets TxnCtx InfoSchema if snapshot schema is not set,
// Otherwise, snapshot schema is returned.
func GetInfoSchema(ctx context.Context) infoschema.InfoSchema {
sessVar := ctx.GetSessionVars()
var is infoschema.InfoSchema
if snap := sessVar.SnapshotInfoschema; snap != nil {
is = snap.(infoschema.InfoSchema)
log.Infof("[%d] use snapshot schema %d", sessVar.ConnectionID, is.SchemaMetaVersion())
} else {
is = sessVar.TxnCtx.InfoSchema.(infoschema.InfoSchema)
}
return is
}
示例2: Compile
// Compile compiles an ast.StmtNode to an ast.Statement.
// After preprocessed and validated, it will be optimized to a plan,
// then wrappped to an adapter *statement as stmt.Statement.
func (c *Compiler) Compile(ctx context.Context, node ast.StmtNode) (ast.Statement, error) {
stmtNodeCounter.WithLabelValues(statementLabel(node)).Inc()
if _, ok := node.(*ast.UpdateStmt); ok {
sVars := variable.GetSessionVars(ctx)
sVars.InUpdateStmt = true
defer func() {
sVars.InUpdateStmt = false
}()
}
var is infoschema.InfoSchema
if snap := variable.GetSessionVars(ctx).SnapshotInfoschema; snap != nil {
is = snap.(infoschema.InfoSchema)
log.Infof("use snapshot schema %d", is.SchemaMetaVersion())
} else {
is = sessionctx.GetDomain(ctx).InfoSchema()
binloginfo.SetSchemaVersion(ctx, is.SchemaMetaVersion())
}
if err := plan.Preprocess(node, is, ctx); err != nil {
return nil, errors.Trace(err)
}
// Validate should be after NameResolve.
if err := plan.Validate(node, false); err != nil {
return nil, errors.Trace(err)
}
p, err := plan.Optimize(ctx, node, is)
if err != nil {
return nil, errors.Trace(err)
}
_, isDDL := node.(ast.DDLNode)
sa := &statement{
is: is,
plan: p,
text: node.Text(),
isDDL: isDDL,
}
return sa, nil
}