mirror of https://github.com/milvus-io/milvus.git
Support create alias with dropping collection name (#25616)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/25613/head
parent
b70da0859a
commit
c114d46244
|
@ -864,8 +864,15 @@ func (mt *MetaTable) CreateAlias(ctx context.Context, dbName string, alias strin
|
||||||
return fmt.Errorf("database %s not found", dbName)
|
return fmt.Errorf("database %s not found", dbName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := mt.names.get(dbName, alias); ok {
|
if collID, ok := mt.names.get(dbName, alias); ok {
|
||||||
return fmt.Errorf("cannot create alias, collection already exists with same name: %s", alias)
|
coll, ok := mt.collID2Meta[collID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("meta error, name mapped non-exist collection id")
|
||||||
|
}
|
||||||
|
// allow alias with dropping&dropped
|
||||||
|
if coll.State != pb.CollectionState_CollectionDropping && coll.State != pb.CollectionState_CollectionDropped {
|
||||||
|
return fmt.Errorf("cannot alter alias, collection already exists with same name: %s", alias)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
collectionID, ok := mt.names.get(dbName, collectionName)
|
collectionID, ok := mt.names.get(dbName, collectionName)
|
||||||
|
@ -961,9 +968,13 @@ func (mt *MetaTable) AlterAlias(ctx context.Context, dbName string, alias string
|
||||||
return fmt.Errorf("database not found: %s", dbName)
|
return fmt.Errorf("database not found: %s", dbName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := mt.names.get(dbName, alias); ok {
|
if collID, ok := mt.names.get(dbName, alias); ok {
|
||||||
|
coll := mt.collID2Meta[collID]
|
||||||
|
// allow alias with dropping&dropped
|
||||||
|
if coll.State != pb.CollectionState_CollectionDropping && coll.State != pb.CollectionState_CollectionDropped {
|
||||||
return fmt.Errorf("cannot alter alias, collection already exists with same name: %s", alias)
|
return fmt.Errorf("cannot alter alias, collection already exists with same name: %s", alias)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
collectionID, ok := mt.names.get(dbName, collectionName)
|
collectionID, ok := mt.names.get(dbName, collectionName)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue