Skip to content

Commit

Permalink
fix add index on multi generated column bugs and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 committed Sep 30, 2018
1 parent 2818aab commit 012ea29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package ddl
import (
"context"
"math"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -881,7 +880,7 @@ func makeupDecodeColMap(sessCtx sessionctx.Context, t table.Table, indexInfo *mo
}
if col.IsGenerated() && !col.GeneratedStored {
for _, c := range cols {
if strings.Contains(col.GeneratedExprString, c.Name.L) {
if _, ok := col.Dependences[c.Name.L]; ok {
decodeColMap[c.ID] = decoder.Column{
Info: c.ToInfo(),
}
Expand Down
22 changes: 11 additions & 11 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,28 +276,28 @@ func (s *testSuite) TestAdmin(c *C) {
// For add index on virtual column
tk.MustExec("drop table if exists t1;")
tk.MustExec(`create table t1 (
a int as (JSON_EXTRACT(k,'$.a')),
c double as (JSON_EXTRACT(k,'$.c')),
d decimal(20,10) as (JSON_EXTRACT(k,'$.d')),
e char(10) as (JSON_EXTRACT(k,'$.e')),
f date as (JSON_EXTRACT(k,'$.f')),
g time as (JSON_EXTRACT(k,'$.g')),
h datetime as (JSON_EXTRACT(k,'$.h')),
i timestamp as (JSON_EXTRACT(k,'$.i')),
j year as (JSON_EXTRACT(k,'$.j')),
a int as (JSON_EXTRACT(k,'$.a')),
c double as (JSON_EXTRACT(k,'$.c')),
d decimal(20,10) as (JSON_EXTRACT(k,'$.d')),
e char(10) as (JSON_EXTRACT(k,'$.e')),
f date as (JSON_EXTRACT(k,'$.f')),
g time as (JSON_EXTRACT(k,'$.g')),
h datetime as (JSON_EXTRACT(k,'$.h')),
i timestamp as (JSON_EXTRACT(k,'$.i')),
j year as (JSON_EXTRACT(k,'$.j')),
k json);`)

tk.MustExec("insert into t1 set k='{\"a\": 100,\"c\":1.234,\"d\":1.2340000000,\"e\":\"abcdefg\",\"f\":\"2018-09-28\",\"g\":\"12:59:59\",\"h\":\"2018-09-28 12:59:59\",\"i\":\"2018-09-28 16:40:33\",\"j\":\"2018\"}';")
tk.MustExec("alter table t1 add index idx_a(a);")
tk.MustExec("alter table t1 add index idx_c(c);")
tk.MustExec("alter table t1 add index idx_d(d);")
tk.MustExec("alter table t1 add index idx_e(e);")
tk.MustExec("alter table t1 add index idx_f(f);")
tk.MustExec("alter table t1 add index idx_g(g);")
tk.MustExec("alter table t1 add index idx_h(h);")
tk.MustExec("alter table t1 add index idx_j(j);")
tk.MustExec("alter table t1 add index idx_i(i);")
// TODO: fix add index on decimal column bug cause by admin check compare.
//tk.MustExec("alter table t1 add index idx_e(e);")
tk.MustExec("alter table t1 add index idx_m(a,c,d,e,f,g,h,i,j);")
tk.MustExec("admin check table t1;")
}

Expand Down

0 comments on commit 012ea29

Please sign in to comment.