1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-34860 Implement MAX_EXECUTION_TIME hint

It places a limit N (a timeout value in milliseconds) on how long
a statement is permitted to execute before the server terminates it.

Syntax:
SELECT /*+ MAX_EXECUTION_TIME(milliseconds) */ ...

Only top-level SELECT statements support the hint.
This commit is contained in:
Oleg Smirnov
2024-08-07 22:10:50 +07:00
parent 1e2774d829
commit 67319f3e8d
20 changed files with 573 additions and 51 deletions

View File

@@ -8229,6 +8229,7 @@ void make_leaves_list(THD *thd, List<TABLE_LIST> &list, TABLE_LIST *tables,
refresh It is only refresh for subquery
select_insert It is SELECT ... INSERT command
full_table_list a parameter to pass to the make_leaves_list function
resolve_opt_hints Whether optimizer hints must be resolved here
NOTE
Check also that the 'used keys' and 'ignored keys' exists and set up the
@@ -8248,7 +8249,7 @@ void make_leaves_list(THD *thd, List<TABLE_LIST> &list, TABLE_LIST *tables,
bool setup_tables(THD *thd, Name_resolution_context *context,
List<TABLE_LIST> *from_clause, TABLE_LIST *tables,
List<TABLE_LIST> &leaves, bool select_insert,
bool full_table_list)
bool full_table_list, bool resolve_opt_hints)
{
uint tablenr= 0;
List_iterator<TABLE_LIST> ti(leaves);
@@ -8393,8 +8394,13 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
if (setup_natural_join_row_types(thd, from_clause, context))
DBUG_RETURN(1);
if (qb_hints)
qb_hints->check_unresolved(thd);
if (resolve_opt_hints)
{
if (thd->lex->opt_hints_global && select_lex->select_number == 1)
thd->lex->opt_hints_global->resolve(thd);
if (qb_hints)
qb_hints->check_unresolved(thd);
}
DBUG_RETURN(0);
}
@@ -8414,6 +8420,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
select_insert It is SELECT ... INSERT command
want_access what access is needed
full_table_list a parameter to pass to the make_leaves_list function
resolve_opt_hints Whether optimizer hints must be resolved here
NOTE
a wrapper for check_tables that will also check the resulting
@@ -8430,12 +8437,13 @@ bool setup_tables_and_check_access(THD *thd, Name_resolution_context *context,
bool select_insert,
privilege_t want_access_first,
privilege_t want_access,
bool full_table_list)
bool full_table_list,
bool resolve_opt_hints)
{
DBUG_ENTER("setup_tables_and_check_access");
if (setup_tables(thd, context, from_clause, tables,
leaves, select_insert, full_table_list))
leaves, select_insert, full_table_list, resolve_opt_hints))
DBUG_RETURN(TRUE);
List_iterator<TABLE_LIST> ti(leaves);