Skip to content

Commit

Permalink
address comment: change restricted to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
eurekaka committed Sep 6, 2018
1 parent e2ee36d commit 2689501
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions distsql/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func Select(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, fie
}, nil
}

restrLabel := metrics.LblGeneral
label := metrics.LblGeneral
if sctx.GetSessionVars().InRestrictedSQL {
restrLabel = metrics.LblRestricted
label = metrics.LblInternal
}
return &selectResult{
label: "dag",
Expand All @@ -68,7 +68,7 @@ func Select(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, fie
fieldTypes: fieldTypes,
ctx: sctx,
feedback: fb,
sqlType: restrLabel,
sqlType: label,
}, nil
}

Expand All @@ -79,17 +79,17 @@ func Analyze(ctx context.Context, client kv.Client, kvReq *kv.Request, vars *kv.
if resp == nil {
return nil, errors.New("client returns nil response")
}
restrLabel := metrics.LblGeneral
label := metrics.LblGeneral
if isRestrict {
restrLabel = metrics.LblRestricted
label = metrics.LblInternal
}
result := &selectResult{
label: "analyze",
resp: resp,
results: make(chan resultWithErr, kvReq.Concurrency),
closed: make(chan struct{}),
feedback: statistics.NewQueryFeedback(0, nil, 0, false),
sqlType: restrLabel,
sqlType: label,
}
return result, nil
}
Expand Down
2 changes: 1 addition & 1 deletion distsql/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (s *testSuite) TestAnalyze(c *C) {
result, ok := response.(*selectResult)
c.Assert(ok, IsTrue)
c.Assert(result.label, Equals, "analyze")
c.Assert(result.sqlType, Equals, "restricted")
c.Assert(result.sqlType, Equals, "internal")

response.Fetch(context.TODO())

Expand Down
8 changes: 4 additions & 4 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,18 @@ func (a *ExecStmt) logSlowQuery(txnTS uint64, succ bool) {
indexIDs = strings.Replace(fmt.Sprintf("index_ids:%v ", a.Ctx.GetSessionVars().StmtCtx.IndexIDs), " ", ",", -1)
}
user := sessVars.User
var restricted string
var internal string
if sessVars.InRestrictedSQL {
restricted = "[RESTRICTED] "
internal = "[INTERNAL] "
}
if costTime < threshold {
logutil.SlowQueryLogger.Debugf(
"[QUERY] %vcost_time:%v %s succ:%v con:%v user:%s txn_start_ts:%v database:%v %v%vsql:%v",
restricted, costTime, sessVars.StmtCtx.GetExecDetails(), succ, connID, user, txnTS, currentDB, tableIDs, indexIDs, sql)
internal, costTime, sessVars.StmtCtx.GetExecDetails(), succ, connID, user, txnTS, currentDB, tableIDs, indexIDs, sql)
} else {
logutil.SlowQueryLogger.Warnf(
"[SLOW_QUERY] %vcost_time:%v %s succ:%v con:%v user:%s txn_start_ts:%v database:%v %v%vsql:%v",
restricted, costTime, sessVars.StmtCtx.GetExecDetails(), succ, connID, user, txnTS, currentDB, tableIDs, indexIDs, sql)
internal, costTime, sessVars.StmtCtx.GetExecDetails(), succ, connID, user, txnTS, currentDB, tableIDs, indexIDs, sql)
}
}

Expand Down
2 changes: 1 addition & 1 deletion metrics/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const (
LblResult = "result"
LblSQLType = "sql_type"
LblGeneral = "general"
LblRestricted = "restricted"
LblInternal = "internal"
)

func init() {
Expand Down
16 changes: 8 additions & 8 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func (s *session) ExecRestrictedSQL(sctx sessionctx.Context, sql string) ([]chun
fields = rs.Fields()
}
}
metrics.QueryDurationHistogram.WithLabelValues(metrics.LblRestricted).Observe(time.Since(startTime).Seconds())
metrics.QueryDurationHistogram.WithLabelValues(metrics.LblInternal).Observe(time.Since(startTime).Seconds())
return rows, fields, nil
}

Expand Down Expand Up @@ -734,11 +734,11 @@ func (s *session) executeStatement(ctx context.Context, connID uint64, stmtNode
}
return nil, errors.Trace(err)
}
restrLabel := metrics.LblGeneral
label := metrics.LblGeneral
if s.sessionVars.InRestrictedSQL {
restrLabel = metrics.LblRestricted
label = metrics.LblInternal
}
metrics.SessionExecuteRunDuration.WithLabelValues(restrLabel).Observe(time.Since(startTime).Seconds())
metrics.SessionExecuteRunDuration.WithLabelValues(label).Observe(time.Since(startTime).Seconds())

if recordSet != nil {
recordSets = append(recordSets, recordSet)
Expand Down Expand Up @@ -772,11 +772,11 @@ func (s *session) execute(ctx context.Context, sql string) (recordSets []ast.Rec
log.Warnf("con:%d parse error:\n%v\n%s", connID, err, sql)
return nil, errors.Trace(err)
}
restrLabel := metrics.LblGeneral
label := metrics.LblGeneral
if s.sessionVars.InRestrictedSQL {
restrLabel = metrics.LblRestricted
label = metrics.LblInternal
}
metrics.SessionExecuteParseDuration.WithLabelValues(restrLabel).Observe(time.Since(startTS).Seconds())
metrics.SessionExecuteParseDuration.WithLabelValues(label).Observe(time.Since(startTS).Seconds())

compiler := executor.Compiler{Ctx: s}
for _, stmtNode := range stmtNodes {
Expand All @@ -794,7 +794,7 @@ func (s *session) execute(ctx context.Context, sql string) (recordSets []ast.Rec
log.Warnf("con:%d compile error:\n%v\n%s", connID, err, sql)
return nil, errors.Trace(err)
}
metrics.SessionExecuteCompileDuration.WithLabelValues(restrLabel).Observe(time.Since(startTS).Seconds())
metrics.SessionExecuteCompileDuration.WithLabelValues(label).Observe(time.Since(startTS).Seconds())

// Step3: Execute the physical plan.
if recordSets, err = s.executeStatement(ctx, connID, stmtNode, stmt, recordSets); err != nil {
Expand Down

0 comments on commit 2689501

Please sign in to comment.