enough to stop panics

This commit is contained in:
James Cor
2023-04-26 16:07:44 -07:00
parent 0630a5345d
commit da422f6da2
+5 -1
View File
@@ -1492,7 +1492,11 @@ func validateSchemaChange(
idxCols []sql.IndexColumn,
) error {
for _, idxCol := range idxCols {
col := newSchema.Schema[newSchema.Schema.IndexOfColName(idxCol.Name)]
idx := newSchema.Schema.IndexOfColName(idxCol.Name)
if idx < 0 { // avoid panics
return sql.ErrColumnNotFound.New(idxCol.Name)
}
col := newSchema.Schema[idx]
if col.PrimaryKey && idxCol.Length > 0 && sqltypes.IsText(col.Type) {
return sql.ErrUnsupportedIndexPrefix.New(col.Name)
}