本文整理匯總了Golang中github.com/pingcap/tidb/ast.TableName.Schema方法的典型用法代碼示例。如果您正苦於以下問題:Golang TableName.Schema方法的具體用法?Golang TableName.Schema怎麽用?Golang TableName.Schema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/ast.TableName
的用法示例。
在下文中一共展示了TableName.Schema方法的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
}
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
}
示例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
}
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
}
示例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
}