Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#38966
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <[email protected]>
  • Loading branch information
YangKeao committed Nov 15, 2022
1 parent 33261f2 commit 64d06cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4992,3 +4992,14 @@ func (s *testIntegrationSuite) TestExplainAnalyzeDMLCommit(c *C) {
c.Assert(err, IsNil)
tk.MustQuery("select * from t").Check(testkit.Rows())
}

func TestAutoIncrementCheckWithCheckConstraint(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`CREATE TABLE t (
id INTEGER NOT NULL AUTO_INCREMENT,
CHECK (id IN (0, 1)),
KEY idx_autoinc_id (id)
)`)
}
4 changes: 4 additions & 0 deletions planner/core/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ func checkAutoIncrementOp(colDef *ast.ColumnDef, index int) (bool, error) {

func isConstraintKeyTp(constraints []*ast.Constraint, colDef *ast.ColumnDef) bool {
for _, c := range constraints {
// ignore constraint check
if c.Tp == ast.ConstraintCheck {
continue
}
if c.Keys[0].Expr != nil {
continue
}
Expand Down

0 comments on commit 64d06cc

Please sign in to comment.