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 752bc44 commit 2687f4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6686,3 +6686,15 @@ func TestExplainAnalyzeDMLCommit(t *testing.T) {
require.NoError(t, err)
tk.MustQuery("select * from t").Check(testkit.Rows())
}

func TestAutoIncrementCheckWithCheckConstraint(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
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 @@ -629,6 +629,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 2687f4d

Please sign in to comment.