Skip to content

Commit 43196c0

Browse files
committed
In dolt diff, short-circuit computing a unified schema unless the schema has changed, avoid comparing two sql.Types directly, since some implementations are not comparable.
1 parent 6a2ee9f commit 43196c0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

go/cmd/dolt/commands/diff.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,12 @@ func diffRows(
14011401
toSch = pkSch.Schema
14021402
}
14031403

1404-
unionSch := unionSchemas(fromSch, toSch)
1404+
var unionSch sql.Schema
1405+
if fromSch.Equals(toSch) {
1406+
unionSch = fromSch
1407+
} else {
1408+
unionSch = unionSchemas(fromSch, toSch)
1409+
}
14051410

14061411
// We always instantiate a RowWriter in case the diffWriter needs it to close off any work from schema output
14071412
rowWriter, err := dw.RowWriter(fromTableInfo, toTableInfo, tableSummary, unionSch)
@@ -1561,13 +1566,13 @@ func unionSchemas(s1 sql.Schema, s2 sql.Schema) sql.Schema {
15611566
//
15621567
// Note this is only for printing the diff. This is not robust for other purposes.
15631568
func chooseMostFlexibleType(origA, origB sql.Type) sql.Type {
1564-
if origA == origB {
1565-
return origA
1566-
}
1567-
15681569
at := origA.Type()
15691570
bt := origB.Type()
15701571

1572+
if at == bt {
1573+
return origA
1574+
}
1575+
15711576
// If both are numbers, we'll take the float.
15721577
if sqltypes.IsIntegral(at) && sqltypes.IsFloat(bt) {
15731578
return origB

0 commit comments

Comments
 (0)