diff --git a/plan/planbuilder.go b/plan/planbuilder.go index 8647b48d938d9..0e0b77f50e413 100644 --- a/plan/planbuilder.go +++ b/plan/planbuilder.go @@ -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)