本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/sql/sqlbase.TableDescriptor.AllNonDropIndexes方法的典型用法代碼示例。如果您正苦於以下問題:Golang TableDescriptor.AllNonDropIndexes方法的具體用法?Golang TableDescriptor.AllNonDropIndexes怎麽用?Golang TableDescriptor.AllNonDropIndexes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/pkg/sql/sqlbase.TableDescriptor
的用法示例。
在下文中一共展示了TableDescriptor.AllNonDropIndexes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: makeFKDeleteHelper
func makeFKDeleteHelper(
txn *client.Txn,
table sqlbase.TableDescriptor,
otherTables tableLookupsByID,
colMap map[sqlbase.ColumnID]int,
) (fkDeleteHelper, error) {
var fks fkDeleteHelper
for _, idx := range table.AllNonDropIndexes() {
for _, ref := range idx.ReferencedBy {
if otherTables[ref.Table].isAdding {
// We can assume that a table being added but not yet public is empty,
// and thus does not need to be checked for FK violations.
continue
}
fk, err := makeBaseFKHelper(txn, otherTables, idx, ref, colMap)
if err == errSkipUnusedFK {
continue
}
if err != nil {
return fks, err
}
if fks == nil {
fks = make(fkDeleteHelper)
}
fks[idx.ID] = append(fks[idx.ID], fk)
}
}
return fks, nil
}
示例2: tablesNeededForFKs
// tablesNeededForFKs calculates the IDs of the additional TableDescriptors that
// will be needed for FK checking delete and/or insert operations on `table`.
//
// NB: the returned map's values are *not* set -- higher level calling code, eg
// in planner, should fill the map's values by acquiring leases. This function
// is essentially just returning a slice of IDs, but the empty map can be filled
// in place and reused, avoiding a second allocation.
func tablesNeededForFKs(table sqlbase.TableDescriptor, usage FKCheck) tableLookupsByID {
var ret tableLookupsByID
for _, idx := range table.AllNonDropIndexes() {
if usage != CheckDeletes && idx.ForeignKey.IsSet() {
if ret == nil {
ret = make(tableLookupsByID)
}
ret[idx.ForeignKey.Table] = tableLookup{}
}
if usage != CheckInserts {
for _, idx := range table.AllNonDropIndexes() {
for _, ref := range idx.ReferencedBy {
if ret == nil {
ret = make(tableLookupsByID)
}
ret[ref.Table] = tableLookup{}
}
}
}
}
return ret
}
示例3: makeFKInsertHelper
func makeFKInsertHelper(
txn *client.Txn,
table sqlbase.TableDescriptor,
otherTables tableLookupsByID,
colMap map[sqlbase.ColumnID]int,
) (fkInsertHelper, error) {
var fks fkInsertHelper
for _, idx := range table.AllNonDropIndexes() {
if idx.ForeignKey.IsSet() {
fk, err := makeBaseFKHelper(txn, otherTables, idx, idx.ForeignKey, colMap)
if err == errSkipUnusedFK {
continue
}
if err != nil {
return fks, err
}
if fks == nil {
fks = make(fkInsertHelper)
}
fks[idx.ID] = append(fks[idx.ID], fk)
}
}
return fks, nil
}