Skip to content

Commit

Permalink
txn: produce warning for Pipelined DML when falling back because of t…
Browse files Browse the repository at this point in the history
…idb_constraint_check_in_place (#51923)

ref #50215
  • Loading branch information
ekexium authored Apr 2, 2024
1 parent 4a92d81 commit 7c16a45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4413,6 +4413,12 @@ func (s *session) usePipelinedDmlOrWarn() bool {
}
if s.GetSessionVars().ConstraintCheckInPlace {
// we enforce that pipelined DML must lazily check key.
stmtCtx.AppendWarning(
errors.New(
"Pipelined DML can not be used when tidb_constraint_check_in_place=ON. " +
"Fallback to standard mode",
),
)
return false
}
is, ok := s.GetDomainInfoSchema().(infoschema.InfoSchema)
Expand Down
6 changes: 6 additions & 0 deletions tests/realtikvtest/pipelineddmltest/pipelineddml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ func TestPipelinedDMLNegative(t *testing.T) {
tk.MustExec("insert into t values(10, 10)")
tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used without Metadata Lock. Fallback to standard mode")
tk.MustExec("set global tidb_enable_metadata_lock = on")

// tidb_constraint_check_in_place = ON
tk.MustExec("set @@tidb_constraint_check_in_place = 1")
tk.MustExec("insert into t values(11, 11)")
tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used when tidb_constraint_check_in_place=ON. Fallback to standard mode")
tk.MustExec("set @@tidb_constraint_check_in_place = 0")
}

func compareTables(t *testing.T, tk *testkit.TestKit, t1, t2 string) {
Expand Down

0 comments on commit 7c16a45

Please sign in to comment.