Skip to content

Commit

Permalink
fixup default function in expression of generated columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Deardrops committed Oct 9, 2019
1 parent 4d81fba commit b2297a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,13 @@ func (s *testDBSuite5) TestModifyGeneratedColumn(c *C) {
tk.MustExec("insert into t1 set a=1;")
tk.MustExec("alter table t1 modify column b int;")
tk.MustQuery("select * from t1").Check(testkit.Rows("1 2"))

// Issue #12471
// Unexpect error when use `default` sql function in expression of generated column
tk.MustExec("drop table t1;")
tk.MustExec("create table t1(a int default 9, b int as (default(a)));")
tk.MustExec("insert into t1 values(1, default);")
tk.MustExec("select * from t1;")
}

func (s *testDBSuite4) TestIssue9100(c *C) {
Expand Down
1 change: 1 addition & 0 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func ColumnInfos2ColumnsWithDBName(ctx sessionctx.Context, dbName, tblName model
newCol := &Column{
ColName: col.Name,
TblName: tblName,
OrigTblName: tblName,
DBName: dbName,
RetType: &col.FieldType,
ID: col.ID,
Expand Down
1 change: 1 addition & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,7 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
DBName: dbName,
TblName: tableInfo.Name,
ColName: col.Name,
OrigTblName: tableInfo.Name,
OrigColName: col.Name,
ID: col.ID,
RetType: &col.FieldType,
Expand Down

0 comments on commit b2297a3

Please sign in to comment.