Пример #1
0
// writeColumnMutation adds column as a mutation and writes the
// descriptor to the DB.
func (mt mutationTest) writeColumnMutation(column string, m sqlbase.DescriptorMutation) {
	_, i, err := mt.tableDesc.FindColumnByNormalizedName(column)
	if err != nil {
		mt.Fatal(err)
	}
	col := mt.tableDesc.Columns[i]
	mt.tableDesc.Columns = append(mt.tableDesc.Columns[:i], mt.tableDesc.Columns[i+1:]...)
	m.Descriptor_ = &sqlbase.DescriptorMutation_Column{Column: &col}
	mt.writeMutation(m)
}
Пример #2
0
// writeIndexMutation adds index as a mutation and writes the
// descriptor to the DB.
func (mt mutationTest) writeIndexMutation(index string, m sqlbase.DescriptorMutation) {
	tableDesc := mt.tableDesc
	_, i, err := tableDesc.FindIndexByNormalizedName(index)
	if err != nil {
		mt.Fatal(err)
	}
	idx := tableDesc.Indexes[i]
	tableDesc.Indexes = append(tableDesc.Indexes[:i], tableDesc.Indexes[i+1:]...)
	m.Descriptor_ = &sqlbase.DescriptorMutation_Index{Index: &idx}
	mt.writeMutation(m)
}