本文整理匯總了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
}