Skip to content

Commit

Permalink
address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Jul 25, 2018
1 parent d9d0fa0 commit 312010e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plan/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,12 @@ func (b *planBuilder) buildSelectPlanOfInsert(insert *ast.InsertStmt, insertPlan
}

// Check to guarantee that there's no generated column.
// This check is done after the above one is to make compatible with mysql.
// i.e. table t have two column a and b where b is generated column.
// `insert into t (b) select * from t` will raise a error which tells you that the column count is not matched.
// `insert into t select * from t` will raise a error which tells you that there's generated column in column list.
// If we do this check before the above one, the first example will raise the error same with the second example.
// This check should be done after the above one to make its behavior compatible with MySQL.
// For example, table t has two columns, namely a and b, and b is a generated column.
// "insert into t (b) select * from t" will raise an error that the column count is not matched.
// "insert into t select * from t" will raise an error that there's a generated column in the column list.
// If we do this check before the above one, "insert into t (b) select * from t" will raise an error
// that there's a generated column in the column list.
for _, col := range affectedValuesCols {
if col.IsGenerated() {
b.err = ErrBadGeneratedColumn.GenByArgs(col.Name.O, insertPlan.Table.Meta().Name.O)
Expand Down

0 comments on commit 312010e

Please sign in to comment.