Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#54048
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
qw4990 authored and ti-chi-bot committed Jul 1, 2024
1 parent 4f5d583 commit b75aa0c
Show file tree
Hide file tree
Showing 4 changed files with 1,108 additions and 4 deletions.
20 changes: 20 additions & 0 deletions pkg/bindinfo/session_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package bindinfo_test

import (
"context"
"fmt"
"strconv"
"testing"
"time"
Expand Down Expand Up @@ -430,6 +431,25 @@ func TestDropSingleBindings(t *testing.T) {
require.Len(t, rows, 0)
}

func TestIssue53834(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec(`use test`)
tk.MustExec(`create table t (a varchar(1024))`)
tk.MustExec(`insert into t values (space(1024))`)
for i := 0; i < 12; i++ {
tk.MustExec(`insert into t select * from t`)
}
oomAction := tk.MustQuery(`select @@tidb_mem_oom_action`).Rows()[0][0].(string)
defer func() {
tk.MustExec(fmt.Sprintf(`set global tidb_mem_oom_action='%v'`, oomAction))
}()
tk.MustExec(`set global tidb_mem_oom_action='cancel'`)
tk.MustExec(`create binding using replace into t select /*+ memory_quota(1 mb) */ * from t`)
err := tk.ExecToErr(`replace into t select * from t`)
require.ErrorContains(t, err, "cancelled due to exceeding the allowed memory limit")
}

func TestPreparedStmt(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down
4 changes: 4 additions & 0 deletions pkg/planner/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ func Optimize(ctx context.Context, sctx sessionctx.Context, node ast.Node, is in
}
metrics.BindUsageCounter.WithLabelValues(scope).Inc()
hint.BindHint(stmtNode, binding.Hint)
<<<<<<< HEAD
curStmtHints, _, curWarns := handleStmtHints(binding.Hint.GetFirstTableHints())
=======
curStmtHints, _, curWarns := hint.ParseStmtHints(binding.Hint.GetStmtHints(), setVarHintChecker, byte(kv.ReplicaReadFollower))
>>>>>>> 01a45732ad5 (planner: fix the issue that bindings with query-level hint can not take effect for replace statements (#54048))
sessVars.StmtCtx.StmtHints = curStmtHints
// update session var by hint /set_var/
for name, val := range sessVars.StmtCtx.StmtHints.SetVars {
Expand Down
Loading

0 comments on commit b75aa0c

Please sign in to comment.