本文整理汇总了Golang中github.com/pingcap/tidb/ast.TableName.DBInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang TableName.DBInfo方法的具体用法?Golang TableName.DBInfo怎么用?Golang TableName.DBInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/ast.TableName
的用法示例。
在下文中一共展示了TableName.DBInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleTableName
// handleTableName looks up and sets the schema information and result fields for table name.
func (nr *nameResolver) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = nr.DefaultSchema
}
ctx := nr.currentContext()
if ctx.inCreateOrDropTable {
// The table may not exist in create table or drop table statement.
// Skip resolving the table to avoid error.
return
}
if ctx.inDeleteTableList {
idx, ok := ctx.tableMap[nr.tableUniqueName(tn.Schema, tn.Name)]
if !ok {
nr.Err = errors.Errorf("Unknown table %s", tn.Name.O)
return
}
ts := ctx.tables[idx]
tableName := ts.Source.(*ast.TableName)
tn.DBInfo = tableName.DBInfo
tn.TableInfo = tableName.TableInfo
tn.SetResultFields(tableName.GetResultFields())
return
}
table, err := nr.Info.TableByName(tn.Schema, tn.Name)
if err != nil {
nr.Err = errors.Trace(err)
return
}
tn.TableInfo = table.Meta()
dbInfo, _ := nr.Info.SchemaByName(tn.Schema)
tn.DBInfo = dbInfo
rfs := make([]*ast.ResultField, 0, len(tn.TableInfo.Columns))
sVars := variable.GetSessionVars(nr.Ctx)
for _, v := range tn.TableInfo.Columns {
if v.State != model.StatePublic {
if !sVars.InUpdateStmt || v.State != model.StateWriteReorganization {
// TODO: check this
continue
}
}
expr := &ast.ValueExpr{}
expr.SetType(&v.FieldType)
rf := &ast.ResultField{
Column: v,
Table: tn.TableInfo,
DBName: tn.Schema,
Expr: expr,
TableName: tn,
}
rfs = append(rfs, rf)
}
tn.SetResultFields(rfs)
return
}
示例2: handleTableName
// handleTableName looks up and sets the schema information and result fields for table name.
func (nr *nameResolver) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = nr.DefaultSchema
}
table, err := nr.Info.TableByName(tn.Schema, tn.Name)
if err != nil {
nr.Err = err
return
}
tn.TableInfo = table.Meta()
dbInfo, _ := nr.Info.SchemaByName(tn.Schema)
tn.DBInfo = dbInfo
rfs := make([]*ast.ResultField, len(tn.TableInfo.Columns))
for i, v := range tn.TableInfo.Columns {
expr := &ast.ValueExpr{}
expr.SetType(&v.FieldType)
rfs[i] = &ast.ResultField{
Column: v,
Table: tn.TableInfo,
DBName: tn.Schema,
Expr: expr,
TableName: tn,
}
}
tn.SetResultFields(rfs)
return
}
示例3: handleTableName
// handleTableName looks up and sets the schema information and result fields for table name.
func (nr *nameResolver) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = nr.DefaultSchema
}
ctx := nr.currentContext()
if ctx.inDeleteTableList {
idx, ok := ctx.tableMap[nr.tableUniqueName(tn.Schema, tn.Name)]
if !ok {
nr.Err = errors.Errorf("Unknown table %s", tn.Name.O)
return
}
ts := ctx.tables[idx]
tableName := ts.Source.(*ast.TableName)
tn.DBInfo = tableName.DBInfo
tn.TableInfo = tableName.TableInfo
tn.SetResultFields(tableName.GetResultFields())
return
}
table, err := nr.Info.TableByName(tn.Schema, tn.Name)
if err != nil {
nr.Err = errors.Trace(err)
return
}
tn.TableInfo = table.Meta()
dbInfo, _ := nr.Info.SchemaByName(tn.Schema)
tn.DBInfo = dbInfo
rfs := make([]*ast.ResultField, len(tn.TableInfo.Columns))
for i, v := range tn.TableInfo.Columns {
expr := &ast.ValueExpr{}
expr.SetType(&v.FieldType)
rfs[i] = &ast.ResultField{
Column: v,
Table: tn.TableInfo,
DBName: tn.Schema,
Expr: expr,
TableName: tn,
}
}
tn.SetResultFields(rfs)
return
}
示例4: handleTableName
// handleTableName looks up and bind the schema information for table name
// and set result fields for table name.
func (sb *InfoBinder) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = sb.DefaultSchema
}
table, err := sb.Info.TableByName(tn.Schema, tn.Name)
if err != nil {
sb.Err = err
return
}
tn.TableInfo = table.Meta()
dbInfo, _ := sb.Info.SchemaByName(tn.Schema)
tn.DBInfo = dbInfo
rfs := make([]*ast.ResultField, len(tn.TableInfo.Columns))
for i, v := range tn.TableInfo.Columns {
rfs[i] = &ast.ResultField{
Column: v,
Table: tn.TableInfo,
DBName: tn.Schema,
}
}
tn.SetResultFields(rfs)
return
}