Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta committed Sep 27, 2024
1 parent 6580c8f commit 291d8cc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/planner/core/memtable_infoschema_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,13 @@ func findTableAndSchemaByName(
tableSlice = append(tableSlice, st.table)
}
sort.Slice(schemaSlice, func(i, j int) bool {
cmp := schemaSlice[i].L < schemaSlice[j].L
if cmp {
iSchema, jSchema := schemaSlice[i].L, schemaSlice[j].L
less := iSchema < jSchema ||
(iSchema == jSchema && tableSlice[i].Name.L < tableSlice[j].Name.L)
if less {
tableSlice[i], tableSlice[j] = tableSlice[j], tableSlice[i]
}
return cmp
return less
})
return schemaSlice, tableSlice, nil
}
Expand Down Expand Up @@ -705,6 +707,9 @@ func listTablesForEachSchema(
return schemaSlice, tableSlice, nil
}

// findSchemasForTables finds a schema for each tableInfo, and it
// returns a schema slice and a table slice that has the same length.
// Note that input arg "tableSlice" will be changed in place.
func findSchemasForTables(
ctx context.Context,
is infoschema.InfoSchema,
Expand Down Expand Up @@ -740,11 +745,13 @@ func findSchemasForTables(
}
}
sort.Slice(schemaSlice, func(i, j int) bool {
cmp := schemaSlice[i].L < schemaSlice[j].L
if cmp {
iSchema, jSchema := schemaSlice[i].L, schemaSlice[j].L
less := iSchema < jSchema ||
(iSchema == jSchema && remains[i].Name.L < remains[j].Name.L)
if less {
remains[i], remains[j] = remains[j], remains[i]
}
return cmp
return less
})
return schemaSlice, remains, nil
}
Expand Down

0 comments on commit 291d8cc

Please sign in to comment.