mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.0.14 into 10.1
This commit is contained in:
301
sql/sql_show.cc
301
sql/sql_show.cc
@ -116,6 +116,8 @@ static void get_cs_converted_string_value(THD *thd,
|
||||
bool use_hex);
|
||||
#endif
|
||||
|
||||
static int show_create_view(THD *thd, TABLE_LIST *table, String *buff);
|
||||
|
||||
static void append_algorithm(TABLE_LIST *table, String *buff);
|
||||
|
||||
bool get_lookup_field_values(THD *, COND *, TABLE_LIST *, LOOKUP_FIELD_VALUES *);
|
||||
@ -1025,9 +1027,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
|
||||
buffer.set_charset(table_list->view_creation_ctx->get_client_cs());
|
||||
|
||||
if ((table_list->view ?
|
||||
view_store_create_info(thd, table_list, &buffer) :
|
||||
store_create_info(thd, table_list, &buffer, NULL,
|
||||
FALSE /* show_database */, FALSE)))
|
||||
show_create_view(thd, table_list, &buffer) :
|
||||
show_create_table(thd, table_list, &buffer, NULL, WITHOUT_DB_NAME)))
|
||||
goto exit;
|
||||
|
||||
if (table_list->view)
|
||||
@ -1283,9 +1284,22 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
|
||||
it's a keyword
|
||||
*/
|
||||
|
||||
/*
|
||||
Special code for swe7. It encodes the letter "E WITH ACUTE" on
|
||||
the position 0x60, where backtick normally resides.
|
||||
In swe7 we cannot append 0x60 using system_charset_info,
|
||||
because it cannot be converted to swe7 and will be replaced to
|
||||
question mark '?'. Use &my_charset_bin to avoid this.
|
||||
It will prevent conversion and will append the backtick as is.
|
||||
*/
|
||||
CHARSET_INFO *quote_charset= q == 0x60 &&
|
||||
(packet->charset()->state & MY_CS_NONASCII) &&
|
||||
packet->charset()->mbmaxlen == 1 ?
|
||||
&my_charset_bin : system_charset_info;
|
||||
|
||||
(void) packet->reserve(length*2 + 2);
|
||||
quote_char= (char) q;
|
||||
if (packet->append("e_char, 1, system_charset_info))
|
||||
if (packet->append("e_char, 1, quote_charset))
|
||||
return true;
|
||||
|
||||
for (name_end= name+length ; name < name_end ; name+= length)
|
||||
@ -1302,12 +1316,12 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
|
||||
if (!length)
|
||||
length= 1;
|
||||
if (length == 1 && chr == (uchar) quote_char &&
|
||||
packet->append("e_char, 1, system_charset_info))
|
||||
packet->append("e_char, 1, quote_charset))
|
||||
return true;
|
||||
if (packet->append(name, length, system_charset_info))
|
||||
return true;
|
||||
}
|
||||
return packet->append("e_char, 1, system_charset_info);
|
||||
return packet->append("e_char, 1, quote_charset);
|
||||
}
|
||||
|
||||
|
||||
@ -1481,13 +1495,34 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
|
||||
@param thd thread handler
|
||||
@param packet string to append
|
||||
@param opt list of options
|
||||
@param check_options only print known options
|
||||
@param rules list of known options
|
||||
*/
|
||||
|
||||
static void append_create_options(THD *thd, String *packet,
|
||||
engine_option_value *opt)
|
||||
engine_option_value *opt,
|
||||
bool check_options,
|
||||
ha_create_table_option *rules)
|
||||
{
|
||||
bool in_comment= false;
|
||||
for(; opt; opt= opt->next)
|
||||
{
|
||||
if (check_options)
|
||||
{
|
||||
if (is_engine_option_known(opt, rules))
|
||||
{
|
||||
if (in_comment)
|
||||
packet->append(STRING_WITH_LEN(" */"));
|
||||
in_comment= false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!in_comment)
|
||||
packet->append(STRING_WITH_LEN(" /*"));
|
||||
in_comment= true;
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_ASSERT(opt->value.str);
|
||||
packet->append(' ');
|
||||
append_identifier(thd, packet, opt->name.str, opt->name.length);
|
||||
@ -1497,13 +1532,15 @@ static void append_create_options(THD *thd, String *packet,
|
||||
else
|
||||
packet->append(opt->value.str, opt->value.length);
|
||||
}
|
||||
if (in_comment)
|
||||
packet->append(STRING_WITH_LEN(" */"));
|
||||
}
|
||||
|
||||
/*
|
||||
Build a CREATE TABLE statement for a table.
|
||||
|
||||
SYNOPSIS
|
||||
store_create_info()
|
||||
show_create_table()
|
||||
thd The thread
|
||||
table_list A list containing one table to write statement
|
||||
for.
|
||||
@ -1513,8 +1550,7 @@ static void append_create_options(THD *thd, String *packet,
|
||||
to tailor the format of the statement. Can be
|
||||
NULL, in which case only SQL_MODE is considered
|
||||
when building the statement.
|
||||
show_database Add database name to table name
|
||||
create_or_replace Use CREATE OR REPLACE syntax
|
||||
with_db_name Add database name to table name
|
||||
|
||||
NOTE
|
||||
Currently always return 0, but might return error code in the
|
||||
@ -1524,9 +1560,9 @@ static void append_create_options(THD *thd, String *packet,
|
||||
0 OK
|
||||
*/
|
||||
|
||||
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
HA_CREATE_INFO *create_info_arg, bool show_database,
|
||||
bool create_or_replace)
|
||||
int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
HA_CREATE_INFO *create_info_arg,
|
||||
enum_with_db_name with_db_name)
|
||||
{
|
||||
List<Item> field_list;
|
||||
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
|
||||
@ -1540,27 +1576,35 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
handler *file= table->file;
|
||||
TABLE_SHARE *share= table->s;
|
||||
HA_CREATE_INFO create_info;
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
bool show_table_options= FALSE;
|
||||
#endif /* WITH_PARTITION_STORAGE_ENGINE */
|
||||
bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
|
||||
MODE_ORACLE |
|
||||
MODE_MSSQL |
|
||||
MODE_DB2 |
|
||||
MODE_MAXDB |
|
||||
MODE_ANSI)) != 0;
|
||||
bool limited_mysql_mode= (thd->variables.sql_mode & (MODE_NO_FIELD_OPTIONS |
|
||||
MODE_MYSQL323 |
|
||||
MODE_MYSQL40)) != 0;
|
||||
sql_mode_t sql_mode= thd->variables.sql_mode;
|
||||
bool foreign_db_mode= sql_mode & (MODE_POSTGRESQL | MODE_ORACLE |
|
||||
MODE_MSSQL | MODE_DB2 |
|
||||
MODE_MAXDB | MODE_ANSI);
|
||||
bool limited_mysql_mode= sql_mode & (MODE_NO_FIELD_OPTIONS | MODE_MYSQL323 |
|
||||
MODE_MYSQL40);
|
||||
bool show_table_options= !(sql_mode & MODE_NO_TABLE_OPTIONS) &&
|
||||
!foreign_db_mode;
|
||||
bool check_options= !(sql_mode & MODE_IGNORE_BAD_TABLE_OPTIONS) &&
|
||||
!create_info_arg;
|
||||
handlerton *hton;
|
||||
my_bitmap_map *old_map;
|
||||
int error= 0;
|
||||
DBUG_ENTER("store_create_info");
|
||||
DBUG_ENTER("show_create_table");
|
||||
DBUG_PRINT("enter",("table: %s", table->s->table_name.str));
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (table->part_info)
|
||||
hton= table->part_info->default_engine_type;
|
||||
else
|
||||
#endif
|
||||
hton= file->ht;
|
||||
|
||||
restore_record(table, s->default_values); // Get empty record
|
||||
|
||||
packet->append(STRING_WITH_LEN("CREATE "));
|
||||
if (create_or_replace)
|
||||
if (create_info_arg &&
|
||||
(create_info_arg->org_options & HA_LEX_CREATE_REPLACE ||
|
||||
create_info_arg->table_was_deleted))
|
||||
packet->append(STRING_WITH_LEN("OR REPLACE "));
|
||||
if (share->tmp_table)
|
||||
packet->append(STRING_WITH_LEN("TEMPORARY "));
|
||||
@ -1587,7 +1631,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
avoid having to update gazillions of tests and result files, but
|
||||
it also saves a few bytes of the binary log.
|
||||
*/
|
||||
if (show_database)
|
||||
if (with_db_name == WITH_DB_NAME)
|
||||
{
|
||||
const LEX_STRING *const db=
|
||||
table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
|
||||
@ -1626,8 +1670,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
field->sql_type(type);
|
||||
packet->append(type.ptr(), type.length(), system_charset_info);
|
||||
|
||||
if (field->has_charset() &&
|
||||
!(thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)))
|
||||
if (field->has_charset() && !(sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)))
|
||||
{
|
||||
if (field->charset() != share->table_charset)
|
||||
{
|
||||
@ -1684,7 +1727,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
|
||||
|
||||
if (field->unireg_check == Field::NEXT_NUMBER &&
|
||||
!(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS))
|
||||
!(sql_mode & MODE_NO_FIELD_OPTIONS))
|
||||
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT"));
|
||||
|
||||
if (field->comment.length)
|
||||
@ -1692,7 +1735,8 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
packet->append(STRING_WITH_LEN(" COMMENT "));
|
||||
append_unescaped(packet, field->comment.str, field->comment.length);
|
||||
}
|
||||
append_create_options(thd, packet, field->option_list);
|
||||
append_create_options(thd, packet, field->option_list, check_options,
|
||||
hton->field_options);
|
||||
}
|
||||
|
||||
key_info= table->key_info;
|
||||
@ -1759,7 +1803,8 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
append_identifier(thd, packet, parser_name->str, parser_name->length);
|
||||
packet->append(STRING_WITH_LEN(" */ "));
|
||||
}
|
||||
append_create_options(thd, packet, key_info->option_list);
|
||||
append_create_options(thd, packet, key_info->option_list, check_options,
|
||||
hton->index_options);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1774,12 +1819,8 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
}
|
||||
|
||||
packet->append(STRING_WITH_LEN("\n)"));
|
||||
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
|
||||
if (show_table_options)
|
||||
{
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
show_table_options= TRUE;
|
||||
#endif /* WITH_PARTITION_STORAGE_ENGINE */
|
||||
|
||||
/*
|
||||
IF check_create_info
|
||||
THEN add ENGINE only if it was used when creating the table
|
||||
@ -1787,19 +1828,11 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
if (!create_info_arg ||
|
||||
(create_info_arg->used_fields & HA_CREATE_USED_ENGINE))
|
||||
{
|
||||
if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
|
||||
if (sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
|
||||
packet->append(STRING_WITH_LEN(" TYPE="));
|
||||
else
|
||||
packet->append(STRING_WITH_LEN(" ENGINE="));
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (table->part_info)
|
||||
packet->append(ha_resolve_storage_engine_name(
|
||||
table->part_info->default_engine_type));
|
||||
else
|
||||
packet->append(file->table_type());
|
||||
#else
|
||||
packet->append(file->table_type());
|
||||
#endif
|
||||
packet->append(hton_name(hton));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1821,9 +1854,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
packet->append(buff, (uint) (end - buff));
|
||||
}
|
||||
|
||||
if (share->table_charset &&
|
||||
!(thd->variables.sql_mode & MODE_MYSQL323) &&
|
||||
!(thd->variables.sql_mode & MODE_MYSQL40))
|
||||
if (share->table_charset && !(sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)))
|
||||
{
|
||||
/*
|
||||
IF check_create_info
|
||||
@ -1924,7 +1955,8 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
packet->append(STRING_WITH_LEN(" CONNECTION="));
|
||||
append_unescaped(packet, share->connect_string.str, share->connect_string.length);
|
||||
}
|
||||
append_create_options(thd, packet, share->option_list);
|
||||
append_create_options(thd, packet, share->option_list, check_options,
|
||||
hton->table_options);
|
||||
append_directory(thd, packet, "DATA", create_info.data_file_name);
|
||||
append_directory(thd, packet, "INDEX", create_info.index_file_name);
|
||||
}
|
||||
@ -2076,8 +2108,7 @@ void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
|
||||
static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
|
||||
{
|
||||
my_bool compact_view_name= TRUE;
|
||||
my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
|
||||
@ -2222,77 +2253,77 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
|
||||
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
if (thd->killed)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
|
||||
if (!thd->killed)
|
||||
I_List_iterator<THD> it(threads);
|
||||
THD *tmp;
|
||||
while ((tmp=it++))
|
||||
{
|
||||
I_List_iterator<THD> it(threads);
|
||||
THD *tmp;
|
||||
while ((tmp=it++))
|
||||
Security_context *tmp_sctx= tmp->security_ctx;
|
||||
struct st_my_thread_var *mysys_var;
|
||||
if ((tmp->vio_ok() || tmp->system_thread) &&
|
||||
(!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
|
||||
{
|
||||
Security_context *tmp_sctx= tmp->security_ctx;
|
||||
struct st_my_thread_var *mysys_var;
|
||||
if ((tmp->vio_ok() || tmp->system_thread) &&
|
||||
(!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
|
||||
thread_info *thd_info= new thread_info;
|
||||
|
||||
thd_info->thread_id=tmp->thread_id;
|
||||
thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
|
||||
(tmp->system_thread ?
|
||||
"system user" : "unauthenticated user"));
|
||||
if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
|
||||
thd->security_ctx->host_or_ip[0])
|
||||
{
|
||||
thread_info *thd_info= new thread_info;
|
||||
|
||||
thd_info->thread_id=tmp->thread_id;
|
||||
thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
|
||||
(tmp->system_thread ?
|
||||
"system user" : "unauthenticated user"));
|
||||
if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
|
||||
thd->security_ctx->host_or_ip[0])
|
||||
{
|
||||
if ((thd_info->host= (char*) thd->alloc(LIST_PROCESS_HOST_LEN+1)))
|
||||
my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN,
|
||||
"%s:%u", tmp_sctx->host_or_ip, tmp->peer_port);
|
||||
}
|
||||
else
|
||||
thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ?
|
||||
tmp_sctx->host_or_ip :
|
||||
tmp_sctx->host ? tmp_sctx->host : "");
|
||||
thd_info->command=(int) tmp->get_command();
|
||||
mysql_mutex_lock(&tmp->LOCK_thd_data);
|
||||
if ((thd_info->db= tmp->db)) // Safe test
|
||||
thd_info->db= thd->strdup(thd_info->db);
|
||||
if ((mysys_var= tmp->mysys_var))
|
||||
mysql_mutex_lock(&mysys_var->mutex);
|
||||
thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ?
|
||||
"Killed" : 0);
|
||||
thd_info->state_info= thread_state_info(tmp);
|
||||
if (mysys_var)
|
||||
mysql_mutex_unlock(&mysys_var->mutex);
|
||||
|
||||
/* Lock THD mutex that protects its data when looking at it. */
|
||||
if (tmp->query())
|
||||
{
|
||||
uint length= MY_MIN(max_query_length, tmp->query_length());
|
||||
char *q= thd->strmake(tmp->query(),length);
|
||||
/* Safety: in case strmake failed, we set length to 0. */
|
||||
thd_info->query_string=
|
||||
CSET_STRING(q, q ? length : 0, tmp->query_charset());
|
||||
}
|
||||
|
||||
/*
|
||||
Progress report. We need to do this under a lock to ensure that all
|
||||
is from the same stage.
|
||||
*/
|
||||
if (tmp->progress.max_counter)
|
||||
{
|
||||
uint max_stage= MY_MAX(tmp->progress.max_stage, 1);
|
||||
thd_info->progress= (((tmp->progress.stage / (double) max_stage) +
|
||||
((tmp->progress.counter /
|
||||
(double) tmp->progress.max_counter) /
|
||||
(double) max_stage)) *
|
||||
100.0);
|
||||
set_if_smaller(thd_info->progress, 100);
|
||||
}
|
||||
else
|
||||
thd_info->progress= 0.0;
|
||||
thd_info->start_time= tmp->start_time;
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
thread_infos.append(thd_info);
|
||||
if ((thd_info->host= (char*) thd->alloc(LIST_PROCESS_HOST_LEN+1)))
|
||||
my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN,
|
||||
"%s:%u", tmp_sctx->host_or_ip, tmp->peer_port);
|
||||
}
|
||||
else
|
||||
thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ?
|
||||
tmp_sctx->host_or_ip :
|
||||
tmp_sctx->host ? tmp_sctx->host : "");
|
||||
thd_info->command=(int) tmp->get_command();
|
||||
mysql_mutex_lock(&tmp->LOCK_thd_data);
|
||||
if ((thd_info->db= tmp->db)) // Safe test
|
||||
thd_info->db= thd->strdup(thd_info->db);
|
||||
if ((mysys_var= tmp->mysys_var))
|
||||
mysql_mutex_lock(&mysys_var->mutex);
|
||||
thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ?
|
||||
"Killed" : 0);
|
||||
thd_info->state_info= thread_state_info(tmp);
|
||||
if (mysys_var)
|
||||
mysql_mutex_unlock(&mysys_var->mutex);
|
||||
|
||||
/* Lock THD mutex that protects its data when looking at it. */
|
||||
if (tmp->query())
|
||||
{
|
||||
uint length= MY_MIN(max_query_length, tmp->query_length());
|
||||
char *q= thd->strmake(tmp->query(),length);
|
||||
/* Safety: in case strmake failed, we set length to 0. */
|
||||
thd_info->query_string=
|
||||
CSET_STRING(q, q ? length : 0, tmp->query_charset());
|
||||
}
|
||||
|
||||
/*
|
||||
Progress report. We need to do this under a lock to ensure that all
|
||||
is from the same stage.
|
||||
*/
|
||||
if (tmp->progress.max_counter)
|
||||
{
|
||||
uint max_stage= MY_MAX(tmp->progress.max_stage, 1);
|
||||
thd_info->progress= (((tmp->progress.stage / (double) max_stage) +
|
||||
((tmp->progress.counter /
|
||||
(double) tmp->progress.max_counter) /
|
||||
(double) max_stage)) *
|
||||
100.0);
|
||||
set_if_smaller(thd_info->progress, 100);
|
||||
}
|
||||
else
|
||||
thd_info->progress= 0.0;
|
||||
thd_info->start_time= tmp->start_time;
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
thread_infos.append(thd_info);
|
||||
}
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
@ -2778,7 +2809,7 @@ int add_status_vars(SHOW_VAR *list)
|
||||
{
|
||||
int res= 0;
|
||||
if (status_vars_inited)
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
mysql_mutex_lock(&LOCK_show_status);
|
||||
if (!all_status_vars.buffer && // array is not allocated yet - do it now
|
||||
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20, MYF(0)))
|
||||
{
|
||||
@ -2793,7 +2824,7 @@ int add_status_vars(SHOW_VAR *list)
|
||||
sort_dynamic(&all_status_vars, show_var_cmp);
|
||||
err:
|
||||
if (status_vars_inited)
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_unlock(&LOCK_show_status);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2855,7 +2886,7 @@ void remove_status_vars(SHOW_VAR *list)
|
||||
{
|
||||
if (status_vars_inited)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
mysql_mutex_lock(&LOCK_show_status);
|
||||
SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *);
|
||||
|
||||
for (; list->name; list++)
|
||||
@ -2876,7 +2907,7 @@ void remove_status_vars(SHOW_VAR *list)
|
||||
}
|
||||
}
|
||||
shrink_var_array(&all_status_vars);
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_unlock(&LOCK_show_status);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4769,7 +4800,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
|
||||
str.qs_append(STRING_WITH_LEN(" transactional="));
|
||||
str.qs_append(ha_choice_values[(uint) share->transactional]);
|
||||
}
|
||||
append_create_options(thd, &str, share->option_list);
|
||||
append_create_options(thd, &str, share->option_list, false, 0);
|
||||
|
||||
if (str.length())
|
||||
table->field[19]->store(str.ptr()+1, str.length()-1, cs);
|
||||
@ -6903,7 +6934,7 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
bool upper_case_names= lex->sql_command != SQLCOM_SHOW_VARIABLES;
|
||||
bool sorted_vars= lex->sql_command == SQLCOM_SHOW_VARIABLES;
|
||||
|
||||
if (lex->option_type == OPT_GLOBAL ||
|
||||
if ((sorted_vars && lex->option_type == OPT_GLOBAL) ||
|
||||
schema_table_idx == SCH_GLOBAL_VARIABLES)
|
||||
scope= OPT_GLOBAL;
|
||||
|
||||
@ -6954,14 +6985,20 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
if (partial_cond)
|
||||
partial_cond->val_int();
|
||||
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
if (scope == OPT_GLOBAL)
|
||||
{
|
||||
/* We only hold LOCK_status for summary status vars */
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
calc_sum_of_all_status(&tmp);
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
}
|
||||
|
||||
mysql_mutex_lock(&LOCK_show_status);
|
||||
res= show_status_array(thd, wild,
|
||||
(SHOW_VAR *)all_status_vars.buffer,
|
||||
scope, tmp1, "", tables->table,
|
||||
upper_case_names, partial_cond);
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_unlock(&LOCK_show_status);
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
@ -7675,7 +7712,8 @@ bool optimize_schema_tables_reads(JOIN *join)
|
||||
bool result= 0;
|
||||
DBUG_ENTER("optimize_schema_tables_reads");
|
||||
|
||||
for (JOIN_TAB *tab= first_linear_tab(join, WITH_CONST_TABLES);
|
||||
JOIN_TAB *tab;
|
||||
for (tab= first_linear_tab(join, WITHOUT_BUSH_ROOTS, WITH_CONST_TABLES);
|
||||
tab;
|
||||
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||
{
|
||||
@ -7743,8 +7781,9 @@ bool get_schema_tables_result(JOIN *join,
|
||||
Warnings_only_error_handler err_handler;
|
||||
thd->push_internal_handler(&err_handler);
|
||||
old_proc_info= thd_proc_info(thd, "Filling schema table");
|
||||
|
||||
for (JOIN_TAB *tab= first_linear_tab(join, WITH_CONST_TABLES);
|
||||
|
||||
JOIN_TAB *tab;
|
||||
for (tab= first_linear_tab(join, WITHOUT_BUSH_ROOTS, WITH_CONST_TABLES);
|
||||
tab;
|
||||
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||
{
|
||||
|
Reference in New Issue
Block a user