Remove references to SeriesID in `DROP SERIES` handlers.
parent
8daec06f49
commit
e7c40e5cae
|
@ -1448,9 +1448,6 @@ func (s *ShowSeriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
|||
|
||||
// DropSeriesStatement represents a command for removing a series from the database.
|
||||
type DropSeriesStatement struct {
|
||||
// The Id of the series being dropped (optional)
|
||||
SeriesID uint64
|
||||
|
||||
// Data source that fields are extracted from (optional)
|
||||
Source Source
|
||||
|
||||
|
@ -1461,20 +1458,15 @@ type DropSeriesStatement struct {
|
|||
// String returns a string representation of the drop series statement.
|
||||
func (s *DropSeriesStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
i, _ := buf.WriteString("DROP SERIES")
|
||||
buf.WriteString("DROP SERIES")
|
||||
|
||||
if s.Source != nil {
|
||||
_, _ = buf.WriteString(" FROM ")
|
||||
_, _ = buf.WriteString(s.Source.String())
|
||||
buf.WriteString(" FROM ")
|
||||
buf.WriteString(s.Source.String())
|
||||
}
|
||||
if s.Condition != nil {
|
||||
_, _ = buf.WriteString(" WHERE ")
|
||||
_, _ = buf.WriteString(s.Condition.String())
|
||||
}
|
||||
|
||||
// If we haven't written any data since the initial statement, then this was a SeriesID statement
|
||||
if len(buf.String()) == i {
|
||||
_, _ = buf.WriteString(fmt.Sprintf(" %d", s.SeriesID))
|
||||
buf.WriteString(" WHERE ")
|
||||
buf.WriteString(s.Condition.String())
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
|
|
|
@ -1039,12 +1039,9 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) {
|
|||
|
||||
// If they didn't provide a FROM or a WHERE, they need to provide the SeriesID
|
||||
if stmt.Condition == nil && stmt.Source == nil {
|
||||
id, err := p.parseUInt64()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stmt.SeriesID = id
|
||||
return nil, fmt.Errorf("DROP SERIES requires a FROM or WHERE clause")
|
||||
}
|
||||
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
|
|
14
server.go
14
server.go
|
@ -2547,20 +2547,8 @@ func (s *Server) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement,
|
|||
defer s.mu.RUnlock()
|
||||
|
||||
seriesByMeasurement := make(map[string][]uint64)
|
||||
// Handle the simple `DROP SERIES <id>` case.
|
||||
if stmt.Source == nil && stmt.Condition == nil {
|
||||
for _, db := range s.databases {
|
||||
for _, m := range db.measurements {
|
||||
if m.seriesByID[stmt.SeriesID] != nil {
|
||||
seriesByMeasurement[m.Name] = []uint64{stmt.SeriesID}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return seriesByMeasurement, nil
|
||||
}
|
||||
|
||||
// Handle the more complicated `DROP SERIES` with sources and/or conditions...
|
||||
// Handle `DROP SERIES` with sources and/or conditions...
|
||||
|
||||
// Find the database.
|
||||
db := s.databases[database]
|
||||
|
|
Loading…
Reference in New Issue