From 0db97c83bb09cb131f1d07ad3dc37a83dc505a0f Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 17 Jun 2024 14:43:12 +0800 Subject: [PATCH] fixup --- pkg/bindinfo/session_handle_test.go | 13 +++++++++++++ pkg/util/hint/hint_processor.go | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/bindinfo/session_handle_test.go b/pkg/bindinfo/session_handle_test.go index ebbe4bd6471fc..4ea95e6357f24 100644 --- a/pkg/bindinfo/session_handle_test.go +++ b/pkg/bindinfo/session_handle_test.go @@ -381,6 +381,19 @@ func TestDropSingleBindings(t *testing.T) { tk.MustExec("drop table t") } +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`) + } + tk.MustExec(`create binding using replace /*+ memory_quota(1 mb) */ into t select * from t`) + tk.MustExec(`replace into t select * from t`) +} + func TestPreparedStmt(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) diff --git a/pkg/util/hint/hint_processor.go b/pkg/util/hint/hint_processor.go index 728d0b06f0f3a..68f317e205854 100644 --- a/pkg/util/hint/hint_processor.go +++ b/pkg/util/hint/hint_processor.go @@ -68,6 +68,8 @@ func setTableHints4StmtNode(node ast.Node, hints []*ast.TableOptimizerHint) { x.TableHints = hints case *ast.DeleteStmt: x.TableHints = hints + case *ast.InsertStmt: + x.TableHints = hints } } @@ -203,7 +205,7 @@ type hintProcessor struct { func (hp *hintProcessor) Enter(in ast.Node) (ast.Node, bool) { switch v := in.(type) { - case *ast.SelectStmt, *ast.UpdateStmt, *ast.DeleteStmt: + case *ast.SelectStmt, *ast.UpdateStmt, *ast.DeleteStmt, *ast.InsertStmt: if hp.bindHint2Ast { if hp.tableCounter < len(hp.tableHints) { setTableHints4StmtNode(in, hp.tableHints[hp.tableCounter])