Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: quote identifier with backquote when getting SQL digest #22893

Merged
merged 10 commits into from
Feb 26, 2021
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
154 changes: 77 additions & 77 deletions bindinfo/bind_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5238,7 +5238,7 @@ func (s *testSuite) TestSummaryFailedUpdate(c *C) {
c.Assert(err, NotNil)
c.Assert(err.Error(), Matches, "Out Of Memory Quota!.*")
tk.MustExec("set @@tidb_mem_quota_query=1000000000")
tk.MustQuery("select stmt_type from information_schema.statements_summary where digest_text = 'update t set t . a = t . a - ? where t . a in ( select a from t where a < ? )'").Check(testkit.Rows("Update"))
tk.MustQuery("select stmt_type from information_schema.statements_summary where digest_text = 'update `t` set `t` . `a` = `t` . `a` - ? where `t` . `a` in ( select `a` from `t` where `a` < ? )'").Check(testkit.Rows("Update"))
}

func (s *testSuite) TestOOMPanicAction(c *C) {
Expand Down Expand Up @@ -6731,7 +6731,7 @@ func (s *testSerialSuite) TestPrevStmtDesensitization(c *C) {
tk.MustExec("create table t (a int, unique key (a))")
tk.MustExec("begin")
tk.MustExec("insert into t values (1),(2)")
c.Assert(tk.Se.GetSessionVars().PrevStmt.String(), Equals, "insert into t values ( ? ) , ( ? )")
c.Assert(tk.Se.GetSessionVars().PrevStmt.String(), Equals, "insert into `t` values ( ? ) , ( ? )")
c.Assert(tk.ExecToErr("insert into t values (1)").Error(), Equals, `[kv:1062]Duplicate entry '?' for key 'a'`)
}

Expand Down
2 changes: 1 addition & 1 deletion executor/prepared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *testSerialSuite) TestPrepareStmtAfterIsolationReadChange(c *C) {
c.Assert(rows[len(rows)-1][2], Equals, "cop[tiflash]")

c.Assert(len(tk.Se.GetSessionVars().PreparedStmts), Equals, 1)
c.Assert(tk.Se.GetSessionVars().PreparedStmts[1].(*plannercore.CachedPrepareStmt).NormalizedSQL, Equals, "select * from t")
c.Assert(tk.Se.GetSessionVars().PreparedStmts[1].(*plannercore.CachedPrepareStmt).NormalizedSQL, Equals, "select * from `t`")
c.Assert(tk.Se.GetSessionVars().PreparedStmts[1].(*plannercore.CachedPrepareStmt).NormalizedPlan, Equals, "")
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
github.com/pingcap/kvproto v0.0.0-20210204054616-1c1ed89bb167
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8
github.com/pingcap/parser v0.0.0-20210203141130-32ef3e0e2e13
github.com/pingcap/parser v0.0.0-20210224050355-ce3c7711a45f
github.com/pingcap/sysutil v0.0.0-20201130064824-f0c8aa6a6966
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible
github.com/pingcap/tipb v0.0.0-20210204051656-2870a0852037
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd/go.mod h1:4rbK1p9ILyIf
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8 h1:M+DNpOu/I3uDmwee6vcnoPd6GgSMqND4gxvDQ/W584U=
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/parser v0.0.0-20210203141130-32ef3e0e2e13 h1:hIbRR2siRrJniSRrMU+XgZl3reOWiPZk0P+7PwKXuEQ=
github.com/pingcap/parser v0.0.0-20210203141130-32ef3e0e2e13/go.mod h1:GbEr2PgY72/4XqPZzmzstlOU/+il/wrjeTNFs6ihsSE=
github.com/pingcap/parser v0.0.0-20210224050355-ce3c7711a45f h1:pifEcAWoLMCwNcaUuXWyDOjmh1MZKnkffC+WTTmAr6A=
github.com/pingcap/parser v0.0.0-20210224050355-ce3c7711a45f/go.mod h1:GbEr2PgY72/4XqPZzmzstlOU/+il/wrjeTNFs6ihsSE=
github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI=
github.com/pingcap/sysutil v0.0.0-20201130064824-f0c8aa6a6966 h1:JI0wOAb8aQML0vAVLHcxTEEC0VIwrk6gtw3WjbHvJLA=
github.com/pingcap/sysutil v0.0.0-20201130064824-f0c8aa6a6966/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI=
Expand Down
176 changes: 86 additions & 90 deletions infoschema/tables_test.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions planner/core/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,15 +851,15 @@ func (s *testPlanSerialSuite) TestIssue18066(c *C) {
tk.MustExec("create table t(a int)")
tk.MustExec("prepare stmt from 'select * from t'")
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from t'").Check(
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("1 0 0"))
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from t'").Check(
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("2 1 1"))
tk.MustExec("prepare stmt from 'select * from t'")
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from t'").Check(
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("3 1 0"))
}

Expand Down
6 changes: 3 additions & 3 deletions session/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ func (s *testBootstrapSuite) TestUpdateBindInfo(c *C) {
originText: "select * from t where a > ?",
bindText: "select /*+ use_index(t, idxb) */ * from t where a > 1",
db: "test",
originWithDB: "select * from test . t where a > ?",
originWithDB: "select * from `test` . `t` where `a` > ?",
bindWithDB: "SELECT /*+ use_index(t idxb)*/ * FROM test.t WHERE a > 1",
deleteText: "select * from test.t where a > 1",
},
{
originText: "select count ( ? ), max ( a ) from t group by b",
bindText: "select /*+ use_index(t, idx) */ count(1), max(a) from t group by b",
db: "test",
originWithDB: "select count ( ? ) , max ( a ) from test . t group by b",
originWithDB: "select count ( ? ) , max ( `a` ) from `test` . `t` group by `b`",
bindWithDB: "SELECT /*+ use_index(t idx)*/ count(1),max(a) FROM test.t GROUP BY b",
deleteText: "select count(1), max(a) from test.t group by b",
},
Expand Down Expand Up @@ -590,7 +590,7 @@ func (s *testBootstrapSuite) TestUpdateDuplicateBindInfo(c *C) {
c.Assert(r.Next(ctx, req), IsNil)
c.Assert(req.NumRows(), Equals, 1)
row := req.GetRow(0)
c.Assert(row.GetString(0), Equals, "select * from test . t")
c.Assert(row.GetString(0), Equals, "select * from `test` . `t`")
c.Assert(row.GetString(1), Equals, "SELECT /*+ use_index(t idx_b)*/ * FROM test.t")
c.Assert(row.GetString(2), Equals, "")
c.Assert(row.GetString(3), Equals, "using")
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (*testSessionSuite) TestSlowLogFormat(c *C) {
# DB: test
# Index_names: [t1:a,t2:b]
# Is_internal: true
# Digest: f94c76d7fa8f60e438118752bfbfb71fe9e1934888ac415ddd8625b121af124c
# Digest: 01d00e6e93b28184beae487ac05841145d2a2f6a7b16de32a763bed27967e83d
# Stats: t1:pseudo
# Num_cop_tasks: 10
# Cop_proc_avg: 1 Cop_proc_p90: 2 Cop_proc_max: 3 Cop_proc_addr: 10.6.131.78
Expand Down
2 changes: 1 addition & 1 deletion util/expensivequery/expensivequerey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ func (s *testSuite) TestLogFormat(c *C) {

info.RedactSQL = true
logFields = genLogFields(costTime, info)
c.Assert(logFields[6].String, Equals, "select * from table where a > ?")
c.Assert(logFields[6].String, Equals, "select * from table where `a` > ?")
}