mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3
TODO: enable MDEV-13049 optimization for 10.3
This commit is contained in:
@ -142,6 +142,12 @@ bool get_lookup_field_values(THD *, COND *, TABLE_LIST *, LOOKUP_FIELD_VALUES *)
|
||||
** List all table types supported
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
static bool is_show_command(THD *thd)
|
||||
{
|
||||
return sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND;
|
||||
}
|
||||
|
||||
static int make_version_string(char *buf, int buf_length, uint version)
|
||||
{
|
||||
return my_snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff);
|
||||
@ -281,7 +287,7 @@ int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
TABLE *table= tables->table;
|
||||
|
||||
if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN,
|
||||
~PLUGIN_IS_FREED, table))
|
||||
~(PLUGIN_IS_FREED | PLUGIN_IS_DYING), table))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
@ -989,13 +995,20 @@ find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, LEX_CSTRING *db,
|
||||
if (tl.add_file(file->name))
|
||||
goto err;
|
||||
}
|
||||
tl.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ha_discover_table_names(thd, db, dirp, &tl, false))
|
||||
goto err;
|
||||
}
|
||||
#if 1 // TODO: MDEV-13049: #if MYSQL_VERSION_ID < 100300
|
||||
/* incomplete optimization, but a less drastic change in GA version */
|
||||
if (!thd->lex->select_lex.order_list.elements &&
|
||||
!thd->lex->select_lex.group_list.elements)
|
||||
#else
|
||||
if (is_show_command(thd))
|
||||
#endif
|
||||
tl.sort();
|
||||
|
||||
DBUG_PRINT("info",("found: %zu files", files->elements()));
|
||||
my_dirend(dirp);
|
||||
@ -3460,7 +3473,7 @@ static bool show_status_array(THD *thd, const char *wild,
|
||||
prefix_end=strnmov(name_buffer, prefix, sizeof(name_buffer)-1);
|
||||
if (*prefix)
|
||||
*prefix_end++= '_';
|
||||
len=name_buffer + sizeof(name_buffer) - prefix_end;
|
||||
len=(int)(name_buffer + sizeof(name_buffer) - prefix_end);
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
bool is_wsrep_var= FALSE;
|
||||
@ -3803,6 +3816,15 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (item->type() == Item::ROW_ITEM)
|
||||
{
|
||||
Item_row *item_row= static_cast<Item_row*>(item);
|
||||
for (uint i= 0; i < item_row->cols(); i++)
|
||||
{
|
||||
if (!uses_only_table_name_fields(item_row->element_index(i), table))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (item->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Item_field *item_field= (Item_field*)item;
|
||||
@ -3822,6 +3844,11 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
|
||||
item_field->field_name.length)))
|
||||
return 0;
|
||||
}
|
||||
else if (item->type() == Item::EXPR_CACHE_ITEM)
|
||||
{
|
||||
Item_cache_wrapper *tmp= static_cast<Item_cache_wrapper*>(item);
|
||||
return uses_only_table_name_fields(tmp->get_orig_item(), table);
|
||||
}
|
||||
else if (item->type() == Item::REF_ITEM)
|
||||
return uses_only_table_name_fields(item->real_item(), table);
|
||||
|
||||
@ -4216,7 +4243,7 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_CSTRING*> *table_names,
|
||||
*/
|
||||
if (res == FIND_FILES_DIR)
|
||||
{
|
||||
if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)
|
||||
if (is_show_command(thd))
|
||||
return 1;
|
||||
thd->clear_error();
|
||||
return 2;
|
||||
@ -5435,7 +5462,7 @@ static void store_column_type(TABLE *table, Field *field, CHARSET_INFO *cs,
|
||||
*/
|
||||
tmp_buff= strchr(column_type.c_ptr_safe(), ' ');
|
||||
table->field[offset]->store(column_type.ptr(),
|
||||
(tmp_buff ? tmp_buff - column_type.ptr() :
|
||||
(tmp_buff ? (uint)(tmp_buff - column_type.ptr()) :
|
||||
column_type.length()), cs);
|
||||
|
||||
is_blob= (field->type() == MYSQL_TYPE_BLOB);
|
||||
@ -5757,7 +5784,8 @@ int fill_schema_engines(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
DBUG_ENTER("fill_schema_engines");
|
||||
if (plugin_foreach_with_mask(thd, iter_schema_engines,
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||
~PLUGIN_IS_FREED, tables->table))
|
||||
~(PLUGIN_IS_FREED | PLUGIN_IS_DYING),
|
||||
tables->table))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -6017,11 +6045,8 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
|
||||
check_some_routine_access(thd, db.str, name.str, sph))
|
||||
return 0;
|
||||
|
||||
if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
|
||||
sph->type() == TYPE_ENUM_PROCEDURE) ||
|
||||
(lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
|
||||
sph->type() == TYPE_ENUM_FUNCTION) ||
|
||||
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
|
||||
if (!is_show_command(thd) ||
|
||||
sph == Sp_handler::handler(lex->sql_command))
|
||||
{
|
||||
restore_record(table, s->default_values);
|
||||
if (!wild || !wild[0] || !wild_case_compare(system_charset_info,
|
||||
@ -6147,6 +6172,10 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/* Disable padding temporarily so it doesn't break the query */
|
||||
ulonglong sql_mode_was = thd->variables.sql_mode;
|
||||
thd->variables.sql_mode &= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
|
||||
|
||||
if (proc_table->file->ha_index_init(0, 1))
|
||||
{
|
||||
res= 1;
|
||||
@ -6182,6 +6211,7 @@ err:
|
||||
(void) proc_table->file->ha_index_end();
|
||||
|
||||
close_system_tables(thd, &open_tables_state_backup);
|
||||
thd->variables.sql_mode = sql_mode_was;
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
@ -6405,7 +6435,7 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables,
|
||||
table->field[5]->store(STRING_WITH_LEN("NO"), cs);
|
||||
}
|
||||
|
||||
definer_len= (strxmov(definer, tables->definer.user.str, "@",
|
||||
definer_len= (uint)(strxmov(definer, tables->definer.user.str, "@",
|
||||
tables->definer.host.str, NullS) - definer);
|
||||
table->field[6]->store(definer, definer_len, cs);
|
||||
if (tables->view_suid)
|
||||
@ -7769,7 +7799,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
|
||||
tmp_table_param->field_count= field_count;
|
||||
tmp_table_param->schema_table= 1;
|
||||
SELECT_LEX *select_lex= thd->lex->current_select;
|
||||
bool keep_row_order= sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND;
|
||||
bool keep_row_order= is_show_command(thd);
|
||||
if (!(table= create_tmp_table(thd, tmp_table_param,
|
||||
field_list, (ORDER*) 0, 0, 0,
|
||||
(select_lex->options | thd->variables.option_bits |
|
||||
|
Reference in New Issue
Block a user