当前位置: 首页>>代码示例>>Golang>>正文


Golang TableDescriptor.AllNonDropIndexes方法代码示例

本文整理汇总了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
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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
}
开发者ID:,项目名称:,代码行数:24,代码来源:


注:本文中的github.com/cockroachdb/cockroach/pkg/sql/sqlbase.TableDescriptor.AllNonDropIndexes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。