Skip to content

Commit

Permalink
Merge branch 'master' into fix-infoschema-user-privs
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored Jul 16, 2021
2 parents 85c149d + 1f6c669 commit 0da4dcf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) {
WithStore(store),
WithLease(testLease),
)
defer d.Stop()
defer func() {
err := d.Stop()
c.Assert(err, IsNil)
}()
getFirstNotificationAfterStartDDL(d)
// Ensure that the notification is not handled in workers `start` function.
d.cancel()
Expand Down Expand Up @@ -141,7 +144,10 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) {
WithStore(store),
WithLease(testLease),
)
defer d1.Stop()
defer func() {
err := d1.Stop()
c.Assert(err, IsNil)
}()
getFirstNotificationAfterStartDDL(d1)
// Ensure that the notification is not handled by worker's "start".
d1.cancel()
Expand Down
22 changes: 22 additions & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2745,6 +2745,28 @@ func checkColFuncDepend(
Name: colInfo.Name,
}
pIdx, err := expression.FindFieldName(p.OutputNames(), pkName)
// It is possible that `pIdx < 0` and here is a case.
// ```
// CREATE TABLE `BB` (
// `pk` int(11) NOT NULL AUTO_INCREMENT,
// `col_int_not_null` int NOT NULL,
// PRIMARY KEY (`pk`)
// );
//
// SELECT OUTR . col2 AS X
// FROM
// BB AS OUTR2
// INNER JOIN
// (SELECT col_int_not_null AS col1,
// pk AS col2
// FROM BB) AS OUTR ON OUTR2.col_int_not_null = OUTR.col1
// GROUP BY OUTR2.col_int_not_null;
// ```
// When we enter `checkColFuncDepend`, `pkName.Table` is `OUTR` which is an alias, while `pkName.Name` is `pk`
// which is a original name. Hence `expression.FindFieldName` will fail and `pIdx` will be less than 0.
// Currently, when we meet `pIdx < 0`, we directly regard `primaryFuncDepend` as false and jump out. This way is
// easy to implement but makes only-full-group-by checker not smart enough. Later we will refactor only-full-group-by
// checker and resolve the inconsistency between the alias table name and the original column name.
if err != nil || pIdx < 0 {
primaryFuncDepend = false
break
Expand Down

0 comments on commit 0da4dcf

Please sign in to comment.