diff --git a/coordinator/statement_executor.go b/coordinator/statement_executor.go index 2bc334384a4..c4bc21cb440 100644 --- a/coordinator/statement_executor.go +++ b/coordinator/statement_executor.go @@ -857,11 +857,11 @@ func (e *StatementExecutor) executeShowSubscriptionsStatement(stmt *influxql.Sho } func (e *StatementExecutor) executeShowTagValues(q *influxql.ShowTagValuesStatement, ctx *influxql.ExecutionContext) error { - if ctx.Database == "" { + if q.Database == "" { return ErrDatabaseNameRequired } - tagValues, err := e.TSDBStore.TagValues(ctx.Database, q.Condition) + tagValues, err := e.TSDBStore.TagValues(q.Database, q.Condition) if err != nil { ctx.Results <- &influxql.Result{ StatementID: ctx.StatementID, @@ -1089,6 +1089,10 @@ func (e *StatementExecutor) NormalizeStatement(stmt influxql.Statement, defaultD if node.Database == "" { node.Database = defaultDatabase } + case *influxql.ShowTagValuesStatement: + if node.Database == "" { + node.Database = defaultDatabase + } case *influxql.Measurement: switch stmt.(type) { case *influxql.DropSeriesStatement, *influxql.DeleteSeriesStatement: diff --git a/influxql/statement_rewriter.go b/influxql/statement_rewriter.go index 3ca717b4dd1..ef2f6c39030 100644 --- a/influxql/statement_rewriter.go +++ b/influxql/statement_rewriter.go @@ -122,6 +122,7 @@ func rewriteShowTagValuesStatement(stmt *ShowTagValuesStatement) (Statement, err condition = rewriteSourcesCondition(stmt.Sources, condition) return &ShowTagValuesStatement{ + Database: stmt.Database, Op: stmt.Op, TagKeyExpr: stmt.TagKeyExpr, Condition: condition,