Skip to content

Commit

Permalink
bindinfo: extract the table hint from the union statement (#50070)
Browse files Browse the repository at this point in the history
close #50068
  • Loading branch information
hawkingrei authored Jan 4, 2024
1 parent a1fd1be commit 62c83d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,8 @@ func TestConnExecutionTimeout(t *testing.T) {

err = cc.handleQuery(context.Background(), "select /*+ MAX_EXECUTION_TIME(100)*/ * FROM testTable2 WHERE SLEEP(1);")
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)
tk.MustExec("set @@max_execution_time = 500;")
Expand Down
12 changes: 12 additions & 0 deletions pkg/util/hint/hint_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ func ExtractTableHintsFromStmtNode(node ast.Node, sctx sessionctx.Context) []*as
// check duplicated hints
checkInsertStmtHintDuplicated(node, sctx)
return x.TableHints
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
default:
return nil
}
Expand Down

0 comments on commit 62c83d4

Please sign in to comment.