mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge branch '10.3' into 10.4
This commit is contained in:
112
sql/sql_base.cc
112
sql/sql_base.cc
@ -12,7 +12,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
||||
|
||||
|
||||
/* Basic functions needed by many modules */
|
||||
@ -699,6 +699,12 @@ bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
|
||||
Marks all tables in the list which were used by current substatement
|
||||
(they are marked by its query_id) as free for reuse.
|
||||
|
||||
Clear 'check_table_binlog_row_based_done' flag. For tables which were used
|
||||
by current substatement the flag is cleared as part of 'ha_reset()' call.
|
||||
For the rest of the open tables not used by current substament if this
|
||||
flag is enabled as part of current substatement execution, clear the flag
|
||||
explicitly.
|
||||
|
||||
NOTE
|
||||
The reason we reset query_id is that it's not enough to just test
|
||||
if table->query_id != thd->query_id to know if a table is in use.
|
||||
@ -721,6 +727,8 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table)
|
||||
table->query_id= 0;
|
||||
table->file->ha_reset();
|
||||
}
|
||||
else if (table->file->check_table_binlog_row_based_done)
|
||||
table->file->clear_cached_table_binlog_row_based_flag();
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -3498,6 +3506,47 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
If we are not already in prelocked mode and extended table list is not
|
||||
yet built we might have to build the prelocking set for this statement.
|
||||
|
||||
Since currently no prelocking strategy prescribes doing anything for
|
||||
tables which are only read, we do below checks only if table is going
|
||||
to be changed.
|
||||
*/
|
||||
bool extend_table_list(THD *thd, TABLE_LIST *tables,
|
||||
Prelocking_strategy *prelocking_strategy,
|
||||
bool has_prelocking_list)
|
||||
{
|
||||
bool error= false;
|
||||
LEX *lex= thd->lex;
|
||||
bool maybe_need_prelocking=
|
||||
(tables->updating && tables->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
|| thd->lex->default_used;
|
||||
|
||||
if (thd->locked_tables_mode <= LTM_LOCK_TABLES &&
|
||||
! has_prelocking_list && maybe_need_prelocking)
|
||||
{
|
||||
bool need_prelocking= FALSE;
|
||||
TABLE_LIST **save_query_tables_last= lex->query_tables_last;
|
||||
/*
|
||||
Extend statement's table list and the prelocking set with
|
||||
tables and routines according to the current prelocking
|
||||
strategy.
|
||||
|
||||
For example, for DML statements we need to add tables and routines
|
||||
used by triggers which are going to be invoked for this element of
|
||||
table list and also add tables required for handling of foreign keys.
|
||||
*/
|
||||
error= prelocking_strategy->handle_table(thd, lex, tables,
|
||||
&need_prelocking);
|
||||
|
||||
if (need_prelocking && ! lex->requires_prelocking())
|
||||
lex->mark_as_requiring_prelocking(save_query_tables_last);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle table list element by obtaining metadata lock, opening table or view
|
||||
@ -3524,14 +3573,13 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
*/
|
||||
|
||||
static bool
|
||||
open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
uint *counter, uint flags,
|
||||
open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags,
|
||||
Prelocking_strategy *prelocking_strategy,
|
||||
bool has_prelocking_list,
|
||||
Open_table_context *ot_ctx)
|
||||
bool has_prelocking_list, Open_table_context *ot_ctx)
|
||||
{
|
||||
bool error= FALSE;
|
||||
bool safe_to_ignore_table= FALSE;
|
||||
LEX *lex= thd->lex;
|
||||
DBUG_ENTER("open_and_process_table");
|
||||
DEBUG_SYNC(thd, "open_and_process_table");
|
||||
|
||||
@ -3590,8 +3638,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
Check whether the information schema contains a table
|
||||
whose name is tables->schema_table_name
|
||||
*/
|
||||
ST_SCHEMA_TABLE *schema_table;
|
||||
schema_table= find_schema_table(thd, &tables->schema_table_name);
|
||||
ST_SCHEMA_TABLE *schema_table= tables->schema_table;
|
||||
if (!schema_table ||
|
||||
(schema_table->hidden &&
|
||||
((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 ||
|
||||
@ -3602,7 +3649,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
lex->sql_command == SQLCOM_SHOW_KEYS)))
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0),
|
||||
tables->schema_table_name.str, INFORMATION_SCHEMA_NAME.str);
|
||||
tables->table_name.str, INFORMATION_SCHEMA_NAME.str);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
@ -3806,38 +3853,9 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
if (tables->open_strategy && !tables->table)
|
||||
goto end;
|
||||
|
||||
/*
|
||||
If we are not already in prelocked mode and extended table list is not
|
||||
yet built we might have to build the prelocking set for this statement.
|
||||
|
||||
Since currently no prelocking strategy prescribes doing anything for
|
||||
tables which are only read, we do below checks only if table is going
|
||||
to be changed.
|
||||
*/
|
||||
if (thd->locked_tables_mode <= LTM_LOCK_TABLES &&
|
||||
! has_prelocking_list &&
|
||||
(tables->lock_type >= TL_WRITE_ALLOW_WRITE || thd->lex->default_used))
|
||||
{
|
||||
bool need_prelocking= FALSE;
|
||||
TABLE_LIST **save_query_tables_last= lex->query_tables_last;
|
||||
/*
|
||||
Extend statement's table list and the prelocking set with
|
||||
tables and routines according to the current prelocking
|
||||
strategy.
|
||||
|
||||
For example, for DML statements we need to add tables and routines
|
||||
used by triggers which are going to be invoked for this element of
|
||||
table list and also add tables required for handling of foreign keys.
|
||||
*/
|
||||
error= prelocking_strategy->handle_table(thd, lex, tables,
|
||||
&need_prelocking);
|
||||
|
||||
if (need_prelocking && ! lex->requires_prelocking())
|
||||
lex->mark_as_requiring_prelocking(save_query_tables_last);
|
||||
|
||||
if (unlikely(error))
|
||||
goto end;
|
||||
}
|
||||
error= extend_table_list(thd, tables, prelocking_strategy, has_prelocking_list);
|
||||
if (unlikely(error))
|
||||
goto end;
|
||||
|
||||
/* Copy grant information from TABLE_LIST instance to TABLE one. */
|
||||
tables->table->grant= tables->grant;
|
||||
@ -4170,7 +4188,8 @@ open_tables_check_upgradable_mdl(THD *thd, TABLE_LIST *tables_start,
|
||||
*/
|
||||
|
||||
bool open_tables(THD *thd, const DDL_options_st &options,
|
||||
TABLE_LIST **start, uint *counter, uint flags,
|
||||
TABLE_LIST **start, uint *counter,
|
||||
Sroutine_hash_entry **sroutine_to_open_list, uint flags,
|
||||
Prelocking_strategy *prelocking_strategy)
|
||||
{
|
||||
/*
|
||||
@ -4209,7 +4228,7 @@ restart:
|
||||
|
||||
has_prelocking_list= thd->lex->requires_prelocking();
|
||||
table_to_open= start;
|
||||
sroutine_to_open= (Sroutine_hash_entry**) &thd->lex->sroutines_list.first;
|
||||
sroutine_to_open= sroutine_to_open_list;
|
||||
*counter= 0;
|
||||
THD_STAGE_INFO(thd, stage_opening_tables);
|
||||
|
||||
@ -4279,9 +4298,9 @@ restart:
|
||||
for (tables= *table_to_open; tables;
|
||||
table_to_open= &tables->next_global, tables= tables->next_global)
|
||||
{
|
||||
error= open_and_process_table(thd, thd->lex, tables, counter,
|
||||
flags, prelocking_strategy,
|
||||
has_prelocking_list, &ot_ctx);
|
||||
error= open_and_process_table(thd, tables, counter, flags,
|
||||
prelocking_strategy, has_prelocking_list,
|
||||
&ot_ctx);
|
||||
|
||||
if (unlikely(error))
|
||||
{
|
||||
@ -8809,8 +8828,7 @@ my_bool mysql_rm_tmp_tables(void)
|
||||
{
|
||||
file=dirp->dir_entry+idx;
|
||||
|
||||
if (!memcmp(file->name, tmp_file_prefix,
|
||||
tmp_file_prefix_length))
|
||||
if (!strncmp(file->name, tmp_file_prefix, tmp_file_prefix_length))
|
||||
{
|
||||
char *ext= fn_ext(file->name);
|
||||
size_t ext_len= strlen(ext);
|
||||
|
Reference in New Issue
Block a user