Exemple #1
0
func testCreateSchema(c *C, ctx context.Context, d *ddl, dbInfo *model.DBInfo) *model.Job {
	job := &model.Job{
		SchemaID: dbInfo.ID,
		Type:     model.ActionCreateSchema,
		Args:     []interface{}{dbInfo},
	}
	err := d.doDDLJob(ctx, job)
	c.Assert(err, IsNil)

	v := getSchemaVer(c, ctx)
	dbInfo.State = model.StatePublic
	checkHistoryJobArgs(c, ctx, job.ID, &historyJobArgs{ver: v, db: dbInfo})
	dbInfo.State = model.StateNone
	return job
}
Exemple #2
0
// updateDBInfo clones a new DBInfo from old DBInfo, and update on the new one.
func (b *Builder) updateDBInfo(roDBInfo *model.DBInfo, oldTableID, newTableID int64) {
	newDbInfo := new(model.DBInfo)
	*newDbInfo = *roDBInfo
	newDbInfo.Tables = make([]*model.TableInfo, 0, len(roDBInfo.Tables))
	if newTableID != 0 {
		// All types except DropTable.
		newTblInfo := b.is.tables[newTableID].Meta()
		newDbInfo.Tables = append(newDbInfo.Tables, newTblInfo)
	}
	for _, tblInfo := range roDBInfo.Tables {
		if tblInfo.ID != oldTableID && tblInfo.ID != newTableID {
			newDbInfo.Tables = append(newDbInfo.Tables, tblInfo)
		}
	}
	b.is.schemas[newDbInfo.ID] = newDbInfo
}