Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions memory/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,12 @@ func (s *StatsProv) DataLength(ctx *sql.Context, db, table string) (uint64, erro
}
return size, nil
}

func (s *StatsProv) DropDbStats(ctx *sql.Context, db string, flush bool) error {
for key, _ := range s.colStats {
if strings.HasPrefix(string(key), db) {
delete(s.colStats, key)
}
}
return nil
}
4 changes: 4 additions & 0 deletions sql/analyzer/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type Catalog struct {
locks sessionLocks
}

func (c *Catalog) DropDbStats(ctx *sql.Context, db string, flush bool) error {
return c.StatsProvider.DropDbStats(ctx, db, flush)
}

var _ sql.Catalog = (*Catalog)(nil)
var _ sql.FunctionProvider = (*Catalog)(nil)
var _ sql.TableFunctionProvider = (*Catalog)(nil)
Expand Down
5 changes: 5 additions & 0 deletions sql/catalog_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@ func (t MapCatalog) RowCount(ctx *Context, db, table string) (uint64, error) {
func (t MapCatalog) DataLength(ctx *Context, db, table string) (uint64, error) {
return 1, nil
}

func (t MapCatalog) DropDbStats(ctx *Context, db string, flush bool) error {
//TODO implement me
panic("implement me")
}
2 changes: 2 additions & 0 deletions sql/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type StatsProvider interface {
GetStats(ctx *Context, qual StatQualifier, cols []string) (Statistic, bool)
// DropStats deletes a set of column statistics
DropStats(ctx *Context, qual StatQualifier, cols []string) error
// DropAllStats deletes all database statistics
DropDbStats(ctx *Context, db string, flush bool) error
// RowCount returns the number of rows in a table
RowCount(ctx *Context, db, table string) (uint64, error)
// DataLength returns the estimated size of each row in the table
Expand Down
5 changes: 5 additions & 0 deletions test/test_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,8 @@ func (c *Catalog) DataLength(ctx *sql.Context, db, table string) (uint64, error)
//TODO implement me
panic("implement me")
}

func (c *Catalog) DropDbStats(ctx *sql.Context, db string, flush bool) error {
//TODO implement me
panic("implement me")
}