collect all series IDs then unlock

pull/1629/head
David Norton 2015-02-21 18:05:14 -05:00 committed by Cory LaNou
parent 5ab3731159
commit 9a6e29ece8
1 changed files with 14 additions and 16 deletions

View File

@ -2122,34 +2122,32 @@ func (s *Server) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement,
return &Result{Err: err}
}
s.mu.RUnlock()
var ids seriesIDs
for _, m := range measurements {
var ids seriesIDs
var tmpIDs seriesIDs
if stmt.Condition != nil {
// Get series IDs that match the WHERE clause.
filters := map[uint32]influxql.Expr{}
ids, _, _ = m.walkWhereForSeriesIds(stmt.Condition, filters)
// If no series matched, then go to the next measurement.
if len(ids) == 0 {
continue
}
tmpIDs, _, _ = m.walkWhereForSeriesIds(stmt.Condition, filters)
// TODO: check return of walkWhereForSeriesIds for fields
} else {
// No WHERE clause so get all series IDs for this measurement.
ids = m.seriesIDs
tmpIDs = m.seriesIDs
}
// Delete series by ID.
for _, id := range ids {
err := s.DropSeries(database, id)
if err != nil {
return &Result{Err: err}
}
ids = ids.union(tmpIDs)
}
s.mu.RUnlock()
// Delete series by ID.
for _, id := range ids {
err := s.DropSeries(database, id)
if err != nil {
return &Result{Err: err}
}
}
return &Result{}
}