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.
|
// DropSeriesStatement represents a command for removing a series from the database.
|
||||||
type DropSeriesStatement struct {
|
type DropSeriesStatement struct {
|
||||||
// The Id of the series being dropped (optional)
|
|
||||||
SeriesID uint64
|
|
||||||
|
|
||||||
// Data source that fields are extracted from (optional)
|
// Data source that fields are extracted from (optional)
|
||||||
Source Source
|
Source Source
|
||||||
|
|
||||||
|
@ -1461,20 +1458,15 @@ type DropSeriesStatement struct {
|
||||||
// String returns a string representation of the drop series statement.
|
// String returns a string representation of the drop series statement.
|
||||||
func (s *DropSeriesStatement) String() string {
|
func (s *DropSeriesStatement) String() string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
i, _ := buf.WriteString("DROP SERIES")
|
buf.WriteString("DROP SERIES")
|
||||||
|
|
||||||
if s.Source != nil {
|
if s.Source != nil {
|
||||||
_, _ = buf.WriteString(" FROM ")
|
buf.WriteString(" FROM ")
|
||||||
_, _ = buf.WriteString(s.Source.String())
|
buf.WriteString(s.Source.String())
|
||||||
}
|
}
|
||||||
if s.Condition != nil {
|
if s.Condition != nil {
|
||||||
_, _ = buf.WriteString(" WHERE ")
|
buf.WriteString(" WHERE ")
|
||||||
_, _ = buf.WriteString(s.Condition.String())
|
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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.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 they didn't provide a FROM or a WHERE, they need to provide the SeriesID
|
||||||
if stmt.Condition == nil && stmt.Source == nil {
|
if stmt.Condition == nil && stmt.Source == nil {
|
||||||
id, err := p.parseUInt64()
|
return nil, fmt.Errorf("DROP SERIES requires a FROM or WHERE clause")
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
stmt.SeriesID = id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmt, nil
|
return stmt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
server.go
14
server.go
|
@ -2547,20 +2547,8 @@ func (s *Server) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement,
|
||||||
defer s.mu.RUnlock()
|
defer s.mu.RUnlock()
|
||||||
|
|
||||||
seriesByMeasurement := make(map[string][]uint64)
|
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 `DROP SERIES` with sources and/or conditions...
|
||||||
}
|
|
||||||
|
|
||||||
// Handle the more complicated `DROP SERIES` with sources and/or conditions...
|
|
||||||
|
|
||||||
// Find the database.
|
// Find the database.
|
||||||
db := s.databases[database]
|
db := s.databases[database]
|
||||||
|
|
Loading…
Reference in New Issue