Skip to content

Commit

Permalink
planner: fix column name with no quote when scatter to backends radon…
Browse files Browse the repository at this point in the history
…db#489

[summary]
When scatter sql to backends, the column name should be with quote '`'
e.g.: create table db.t(`key` int primary key, `col` int);
For the ddl with rename table, we remove all quotes '`' to uniform
standars.
e.g.: alter table t1 rename t2.

[test case]
src/planner/ddl_plan_test.go
src/planner/ddl_test.go
src/executor/ddl_executor_test.go

[patch codecov]
src/planner/ddl_plan.go 95.1%
coverage: 89.8% of statements
  • Loading branch information
hustjieke committed Dec 5, 2019
1 parent 5ab0417 commit a6c78fe
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 283 deletions.
23 changes: 1 addition & 22 deletions src/executor/ddl_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestDDLExecutor(t *testing.T) {
// Create scatter and query handler.
scatter, fakedbs, cleanup := backend.MockScatter(log, 10)
defer cleanup()
fakedbs.AddQueryPattern("create table `sbtest`.`A.*", fakedb.Result3)
fakedbs.AddQueryPattern("create table sbtest.A.*", fakedb.Result3)
fakedbs.AddQueryPattern("create database.*", fakedb.Result3)

route, cleanup := router.MockNewRouter(log)
Expand Down Expand Up @@ -58,25 +58,4 @@ func TestDDLExecutor(t *testing.T) {
assert.Nil(t, err)
}
}

// create database
{
query := "create database sbtest"
node, err := sqlparser.Parse(query)
assert.Nil(t, err)

plan := planner.NewDDLPlan(log, database, query, node.(*sqlparser.DDL), route)
err = plan.Build()
assert.Nil(t, err)

txn, err := scatter.CreateTransaction()
assert.Nil(t, err)
defer txn.Finish()
executor := NewDDLExecutor(log, plan, txn)
{
ctx := xcontext.NewResultContext()
err := executor.Execute(ctx)
assert.Nil(t, err)
}
}
}
Loading

0 comments on commit a6c78fe

Please sign in to comment.