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

executor: set the DDL query string instead of execute (#17407) #17415

Merged
merged 3 commits into from
May 29, 2020
Merged
Changes from 2 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
2 changes: 2 additions & 0 deletions executor/adapter.go
Original file line number Diff line number Diff line change
@@ -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 {
12 changes: 12 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
@@ -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) {