diff --git a/memory/stats.go b/memory/stats.go index 1bcf130b9e..d68d59f3a9 100644 --- a/memory/stats.go +++ b/memory/stats.go @@ -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 +} diff --git a/sql/analyzer/catalog.go b/sql/analyzer/catalog.go index ada9e2d686..9551e0052f 100644 --- a/sql/analyzer/catalog.go +++ b/sql/analyzer/catalog.go @@ -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) diff --git a/sql/catalog_map.go b/sql/catalog_map.go index 0539603ac4..b4a19dd365 100644 --- a/sql/catalog_map.go +++ b/sql/catalog_map.go @@ -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") +} diff --git a/sql/statistics.go b/sql/statistics.go index 469cd562bd..303760d9e3 100644 --- a/sql/statistics.go +++ b/sql/statistics.go @@ -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 diff --git a/test/test_catalog.go b/test/test_catalog.go index 670aef55fb..31d2c30e55 100644 --- a/test/test_catalog.go +++ b/test/test_catalog.go @@ -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") +}