Skip to content

Commit

Permalink
executor: set the DDL query string instead of execute (pingcap#17407)…
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored May 29, 2020
1 parent fbd6270 commit 30209e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ func (a *ExecStmt) buildExecutor() (Executor, error) {
if err != nil {
return nil, err
}

a.Ctx.SetValue(sessionctx.QueryString, executorExec.stmt.Text())
a.isPreparedStmt = true
a.Plan = executorExec.plan
if executorExec.lowerPriority {
Expand Down
12 changes: 12 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ func (s *testSessionSuite) TestQueryString(c *C) {
c.Assert(err, IsNil)
qs := tk.Se.Value(sessionctx.QueryString)
c.Assert(qs.(string), Equals, "CREATE TABLE t2(id bigint PRIMARY KEY, age int)")

// Test execution of DDL through the "Execute" interface.
_, err = tk.Se.Execute(context.Background(), "use test;")
c.Assert(err, IsNil)
_, err = tk.Se.Execute(context.Background(), "drop table t2")
c.Assert(err, IsNil)
_, err = tk.Se.Execute(context.Background(), "prepare stmt from 'CREATE TABLE t2(id bigint PRIMARY KEY, age int)'")
c.Assert(err, IsNil)
_, err = tk.Se.Execute(context.Background(), "execute stmt")
c.Assert(err, IsNil)
qs = tk.Se.Value(sessionctx.QueryString)
c.Assert(qs.(string), Equals, "CREATE TABLE t2(id bigint PRIMARY KEY, age int)")
}

func (s *testSessionSuite) TestAffectedRows(c *C) {
Expand Down

0 comments on commit 30209e3

Please sign in to comment.