本文整理汇总了Golang中github.com/cockroachdb/cockroach/sql/sqlbase.TableDescriptor.FindActiveColumnByID方法的典型用法代码示例。如果您正苦于以下问题:Golang TableDescriptor.FindActiveColumnByID方法的具体用法?Golang TableDescriptor.FindActiveColumnByID怎么用?Golang TableDescriptor.FindActiveColumnByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/sql/sqlbase.TableDescriptor
的用法示例。
在下文中一共展示了TableDescriptor.FindActiveColumnByID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: makeRowDeleter
// makeRowDeleter creates a rowDeleter for the given table.
//
// The returned rowDeleter contains a fetchCols field that defines the
// expectation of which values are passed as values to deleteRow.
func makeRowDeleter(
tableDesc *sqlbase.TableDescriptor,
) (rowDeleter, error) {
// TODO(dan): makeRowDeleter should take a param for the sql rows needed for
// returningHelper, etc.
requestedCols := tableDesc.Columns
indexes := tableDesc.Indexes
for _, m := range tableDesc.Mutations {
if index := m.GetIndex(); index != nil {
indexes = append(indexes, *index)
}
}
fetchCols := requestedCols[:len(requestedCols):len(requestedCols)]
fetchColIDtoRowIndex := colIDtoRowIndexFromCols(fetchCols)
for _, index := range indexes {
for _, colID := range index.ColumnIDs {
if _, ok := fetchColIDtoRowIndex[colID]; !ok {
// TODO(dan): What about non-active columns?
col, err := tableDesc.FindActiveColumnByID(colID)
if err != nil {
return rowDeleter{}, err
}
fetchColIDtoRowIndex[colID] = len(fetchCols)
fetchCols = append(fetchCols, *col)
}
}
}
rd := rowDeleter{
helper: rowHelper{tableDesc: tableDesc, indexes: indexes},
fetchCols: fetchCols,
fetchColIDtoRowIndex: fetchColIDtoRowIndex,
}
return rd, nil
}