本文整理匯總了Golang中github.com/pingcap/tidb/expression.Schema.DeepCopy方法的典型用法代碼示例。如果您正苦於以下問題:Golang Schema.DeepCopy方法的具體用法?Golang Schema.DeepCopy怎麽用?Golang Schema.DeepCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/expression.Schema
的用法示例。
在下文中一共展示了Schema.DeepCopy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildNewSelect
func (b *planBuilder) buildNewSelect(sel *ast.SelectStmt) Plan {
oldLen := len(sel.Fields.Fields)
hasAgg := b.detectSelectAgg(sel)
var aggFuncs []*ast.AggregateFuncExpr
var havingMap, orderMap, totalMap map[*ast.AggregateFuncExpr]int
if hasAgg {
aggFuncs, havingMap, orderMap, totalMap = b.extractAggFunc(sel)
}
// Build subquery
// Convert subquery to expr with plan
// TODO: add subquery support.
//b.buildSubquery(sel)
var p Plan
if sel.From != nil {
p = b.buildResultSetNode(sel.From.TableRefs)
if b.err != nil {
return nil
}
if sel.Where != nil {
p = b.buildSelection(p, sel.Where, nil)
}
if b.err != nil {
return nil
}
if sel.LockTp != ast.SelectLockNone {
p = b.buildSelectLock(p, sel.LockTp)
if b.err != nil {
return nil
}
}
if hasAgg {
p = b.buildAggregation(p, aggFuncs, sel.GroupBy)
if b.err != nil {
return nil
}
}
} else {
p = b.buildNewTableDual()
if b.err != nil {
return nil
}
if sel.Where != nil {
b.buildSelection(p, sel.Where, nil)
}
if hasAgg {
p = b.buildAggregation(p, aggFuncs, nil)
if b.err != nil {
return nil
}
}
}
p = b.buildProjection(p, sel.Fields.Fields, totalMap)
if b.err != nil {
return nil
}
if sel.Having != nil {
p = b.buildSelection(p, sel.Having.Expr, havingMap)
if b.err != nil {
return nil
}
}
if sel.Distinct {
p = b.buildDistinct(p)
if b.err != nil {
return nil
}
}
// TODO: implement push order during cbo
if sel.OrderBy != nil {
p = b.buildNewSort(p, sel.OrderBy.Items, orderMap)
if b.err != nil {
return nil
}
}
if sel.Limit != nil {
p = b.buildLimit(p, sel.Limit)
if b.err != nil {
return nil
}
}
if oldLen != len(sel.Fields.Fields) {
proj := &Projection{}
proj.id = b.allocID(proj)
var newSchema expression.Schema
oldSchema := p.GetSchema()
proj.Exprs = make([]expression.Expression, 0, oldLen)
for _, col := range oldSchema[:oldLen] {
proj.Exprs = append(proj.Exprs, col)
}
newSchema = oldSchema[:oldLen]
newSchema = newSchema.DeepCopy()
for _, s := range newSchema {
s.FromID = proj.id
}
proj.SetSchema(newSchema)
addChild(proj, p)
proj.correlated = p.IsCorrelated()
return proj
}
return p
//.........這裏部分代碼省略.........