Skip to content

Commit

Permalink
executor: set the DDL query string instead of execute (#17407) (#17421
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wjhuang2016 authored May 26, 2020
1 parent 682549b commit 689a6b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ func (a *ExecStmt) buildExecutor() (Executor, error) {
if err != nil {
return nil, err
}
a.Ctx.SetValue(sessionctx.QueryString, executorExec.stmt.Text())
a.OutputNames = executorExec.outputNames
a.isPreparedStmt = true
a.Plan = executorExec.plan
Expand Down
12 changes: 12 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,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 689a6b6

Please sign in to comment.