1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

bzr merge -r4346 maria/10.0 (maria-10.0.13)

This commit is contained in:
Nirbhay Choubey
2014-08-11 23:55:41 -04:00
631 changed files with 28781 additions and 9885 deletions

View File

@ -120,8 +120,9 @@ static void get_cs_converted_string_value(THD *thd,
bool use_hex);
#endif
static void
append_algorithm(TABLE_LIST *table, String *buff);
static int show_create_view(THD *thd, TABLE_LIST *table, String *buff);
static void append_algorithm(TABLE_LIST *table, String *buff);
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table);
@ -1067,9 +1068,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)
@ -1523,13 +1523,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);
@ -1539,13 +1560,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.
@ -1555,8 +1578,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
@ -1566,9 +1588,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];
@ -1582,27 +1604,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 "));
@ -1629,7 +1659,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;
@ -1668,8 +1698,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)
{
@ -1726,7 +1755,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)
@ -1734,7 +1763,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;
@ -1801,7 +1831,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);
}
/*
@ -1816,12 +1847,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
@ -1829,19 +1856,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));
}
/*
@ -1863,9 +1882,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
@ -1966,7 +1983,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);
}
@ -2118,8 +2136,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 |
@ -5177,7 +5194,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);
@ -8092,8 +8109,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, WITHOUT_BUSH_ROOTS))
{