dropped columns are not 'shared' and no data copy attempted for such columns
This commit is contained in:
parent
b0469b95b5
commit
8a0f1413eb
@ -181,6 +181,7 @@ type MigrationContext struct {
|
|||||||
UniqueKey *sql.UniqueKey
|
UniqueKey *sql.UniqueKey
|
||||||
SharedColumns *sql.ColumnList
|
SharedColumns *sql.ColumnList
|
||||||
ColumnRenameMap map[string]string
|
ColumnRenameMap map[string]string
|
||||||
|
DroppedColumnsMap map[string]bool
|
||||||
MappedSharedColumns *sql.ColumnList
|
MappedSharedColumns *sql.ColumnList
|
||||||
MigrationRangeMinValues *sql.ColumnValues
|
MigrationRangeMinValues *sql.ColumnValues
|
||||||
MigrationRangeMaxValues *sql.ColumnValues
|
MigrationRangeMaxValues *sql.ColumnValues
|
||||||
|
@ -662,7 +662,14 @@ func (this *Inspector) getSharedColumns(originalColumns, ghostColumns *sql.Colum
|
|||||||
}
|
}
|
||||||
sharedColumnNames := []string{}
|
sharedColumnNames := []string{}
|
||||||
for _, originalColumn := range originalColumns.Names() {
|
for _, originalColumn := range originalColumns.Names() {
|
||||||
|
isSharedColumn := false
|
||||||
if columnsInGhost[originalColumn] || columnsInGhost[columnRenameMap[originalColumn]] {
|
if columnsInGhost[originalColumn] || columnsInGhost[columnRenameMap[originalColumn]] {
|
||||||
|
isSharedColumn = true
|
||||||
|
}
|
||||||
|
if this.migrationContext.DroppedColumnsMap[originalColumn] {
|
||||||
|
isSharedColumn = false
|
||||||
|
}
|
||||||
|
if isSharedColumn {
|
||||||
sharedColumnNames = append(sharedColumnNames, originalColumn)
|
sharedColumnNames = append(sharedColumnNames, originalColumn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,6 +248,7 @@ func (this *Migrator) validateStatement() (err error) {
|
|||||||
}
|
}
|
||||||
log.Infof("Alter statement has column(s) renamed. gh-ost finds the following renames: %v; --approve-renamed-columns is given and so migration proceeds.", this.parser.GetNonTrivialRenames())
|
log.Infof("Alter statement has column(s) renamed. gh-ost finds the following renames: %v; --approve-renamed-columns is given and so migration proceeds.", this.parser.GetNonTrivialRenames())
|
||||||
}
|
}
|
||||||
|
this.migrationContext.DroppedColumnsMap = this.parser.DroppedColumnsMap()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,3 +111,7 @@ func (this *Parser) GetNonTrivialRenames() map[string]string {
|
|||||||
func (this *Parser) HasNonTrivialRenames() bool {
|
func (this *Parser) HasNonTrivialRenames() bool {
|
||||||
return len(this.GetNonTrivialRenames()) > 0
|
return len(this.GetNonTrivialRenames()) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Parser) DroppedColumnsMap() map[string]bool {
|
||||||
|
return this.droppedColumns
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user