From 0cb86d20f22d3346405203af9b34d3b48ef20035 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Thu, 4 Jan 2024 22:00:34 +0800 Subject: [PATCH] This is an automated cherry-pick of #50070 Signed-off-by: ti-chi-bot --- server/conn_test.go | 8 ++++++++ util/hint/hint_processor.go | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/server/conn_test.go b/server/conn_test.go index 0a2a8c428dcb6..76338d0553b9b 100644 --- a/server/conn_test.go +++ b/server/conn_test.go @@ -755,8 +755,16 @@ func TestConnExecutionTimeout(t *testing.T) { require.NoError(t, err) err = cc.handleQuery(context.Background(), "select /*+ MAX_EXECUTION_TIME(100)*/ * FROM testTable2 WHERE SLEEP(1);") +<<<<<<< HEAD:server/conn_test.go require.NoError(t, err) +======= + require.Equal(t, "[executor:3024]Query execution was interrupted, maximum statement execution time exceeded", err.Error()) + err = cc.handleQuery(context.Background(), "select /*+ set_var(max_execution_time=100) */ age, sleep(1) from testTable2 union all select age, 1 from testTable2") + require.Equal(t, "[executor:3024]Query execution was interrupted, maximum statement execution time exceeded", err.Error()) + // Killed because of max execution time, reset Killed to 0. + tk.Session().GetSessionVars().SQLKiller.SendKillSignal(sqlkiller.MaxExecTimeExceeded) +>>>>>>> 62c83d40fe2 (bindinfo: extract the table hint from the union statement (#50070)):pkg/server/conn_test.go tk.MustExec("set @@max_execution_time = 500;") err = cc.handleQuery(context.Background(), "alter table testTable2 add index idx(age);") diff --git a/util/hint/hint_processor.go b/util/hint/hint_processor.go index 7164390cdad69..fc2d9ba3a50a1 100644 --- a/util/hint/hint_processor.go +++ b/util/hint/hint_processor.go @@ -89,8 +89,23 @@ func ExtractTableHintsFromStmtNode(node ast.Node, sctx sessionctx.Context) []*as // check duplicated hints checkInsertStmtHintDuplicated(node, sctx) return x.TableHints +<<<<<<< HEAD:util/hint/hint_processor.go case *ast.ExplainStmt: return ExtractTableHintsFromStmtNode(x.Stmt, sctx) +======= + case *ast.SetOprStmt: + var result []*ast.TableOptimizerHint + if x.SelectList == nil { + return nil + } + for _, s := range x.SelectList.Selects { + tmp := ExtractTableHintsFromStmtNode(s, sctx) + if len(tmp) != 0 { + result = append(result, tmp...) + } + } + return result +>>>>>>> 62c83d40fe2 (bindinfo: extract the table hint from the union statement (#50070)):pkg/util/hint/hint_processor.go default: return nil }