mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into mysql.com:/home/gluh/MySQL/Merge/5.1-opt BitKeeper/etc/ignore: auto-union client/mysql.cc: Auto merged client/mysqltest.c: Auto merged include/mysql_com.h: Auto merged libmysql/CMakeLists.txt: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/r/archive.result: Auto merged mysql-test/r/create.result: Auto merged mysql-test/r/delayed.result: Auto merged mysql-test/r/func_misc.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/innodb_mysql.result: Auto merged mysql-test/r/merge.result: Auto merged mysql-test/r/ps.result: Auto merged mysql-test/r/type_date.result: Auto merged mysql-test/suite/rpl/r/rpl_innodb_bug28430.result: Auto merged mysql-test/t/create.test: Auto merged mysql-test/t/func_misc.test: Auto merged mysql-test/t/information_schema.test: Auto merged mysql-test/t/merge.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/type_date.test: Auto merged mysql-test/t/type_datetime.test: Auto merged mysql-test/t/variables.test: Auto merged mysys/queues.c: Auto merged sql/events.cc: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_partition.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/protocol.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_partition.cc: Auto merged sql/sql_plugin.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_string.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_open.c: Auto merged tests/mysql_client_test.c: Auto merged mysql-test/lib/mtr_report.pl: manual merge mysql-test/r/myisam.result: manual merge mysql-test/r/partition.result: manual merge mysql-test/r/user_var.result: manual merge mysql-test/t/myisam.test: manual merge mysql-test/t/partition.test: manual merge mysql-test/t/user_var.test: manual merge sql/item.h: manual merge sql/item_func.cc: manual merge storage/myisammrg/ha_myisammrg.cc: manual merge
This commit is contained in:
129
sql/sql_table.cc
129
sql/sql_table.cc
@@ -279,7 +279,7 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
|
||||
*/
|
||||
|
||||
|
||||
typedef struct st_global_ddl_log
|
||||
struct st_global_ddl_log
|
||||
{
|
||||
/*
|
||||
We need to adjust buffer size to be able to handle downgrades/upgrades
|
||||
@@ -297,10 +297,12 @@ typedef struct st_global_ddl_log
|
||||
uint name_len;
|
||||
uint io_size;
|
||||
bool inited;
|
||||
bool do_release;
|
||||
bool recovery_phase;
|
||||
} GLOBAL_DDL_LOG;
|
||||
st_global_ddl_log() : inited(false), do_release(false) {}
|
||||
};
|
||||
|
||||
GLOBAL_DDL_LOG global_ddl_log;
|
||||
st_global_ddl_log global_ddl_log;
|
||||
|
||||
pthread_mutex_t LOCK_gdl;
|
||||
|
||||
@@ -460,6 +462,7 @@ static uint read_ddl_log_header()
|
||||
global_ddl_log.first_used= NULL;
|
||||
global_ddl_log.num_entries= 0;
|
||||
VOID(pthread_mutex_init(&LOCK_gdl, MY_MUTEX_INIT_FAST));
|
||||
global_ddl_log.do_release= true;
|
||||
DBUG_RETURN(entry_no);
|
||||
}
|
||||
|
||||
@@ -1150,6 +1153,9 @@ void release_ddl_log()
|
||||
DDL_LOG_MEMORY_ENTRY *used_list= global_ddl_log.first_used;
|
||||
DBUG_ENTER("release_ddl_log");
|
||||
|
||||
if (!global_ddl_log.do_release)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
pthread_mutex_lock(&LOCK_gdl);
|
||||
while (used_list)
|
||||
{
|
||||
@@ -1167,6 +1173,7 @@ void release_ddl_log()
|
||||
global_ddl_log.inited= 0;
|
||||
pthread_mutex_unlock(&LOCK_gdl);
|
||||
VOID(pthread_mutex_destroy(&LOCK_gdl));
|
||||
global_ddl_log.do_release= false;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -1241,6 +1248,10 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
char shadow_path[FN_REFLEN+1];
|
||||
char shadow_frm_name[FN_REFLEN+1];
|
||||
char frm_name[FN_REFLEN+1];
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
char *part_syntax_buf;
|
||||
uint syntax_len;
|
||||
#endif
|
||||
DBUG_ENTER("mysql_write_frm");
|
||||
|
||||
/*
|
||||
@@ -1264,12 +1275,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
{
|
||||
partition_info *part_info= lpt->table->part_info;
|
||||
char *part_syntax_buf;
|
||||
uint syntax_len;
|
||||
|
||||
if (part_info)
|
||||
{
|
||||
TABLE_SHARE *share= lpt->table->s;
|
||||
if (!(part_syntax_buf= generate_partition_syntax(part_info,
|
||||
&syntax_len,
|
||||
TRUE, TRUE)))
|
||||
@@ -1277,16 +1284,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
part_info->part_info_string= part_syntax_buf;
|
||||
share->partition_info_len= part_info->part_info_len= syntax_len;
|
||||
if (share->partition_info_buffer_size < syntax_len + 1)
|
||||
{
|
||||
share->partition_info_buffer_size= syntax_len+1;
|
||||
if (!(share->partition_info=
|
||||
(char*) alloc_root(&share->mem_root, syntax_len+1)))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
}
|
||||
memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1);
|
||||
part_info->part_info_len= syntax_len;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1364,7 +1362,40 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
#endif
|
||||
{
|
||||
error= 1;
|
||||
goto err;
|
||||
}
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (part_info)
|
||||
{
|
||||
TABLE_SHARE *share= lpt->table->s;
|
||||
char *tmp_part_syntax_str;
|
||||
if (!(part_syntax_buf= generate_partition_syntax(part_info,
|
||||
&syntax_len,
|
||||
TRUE, TRUE)))
|
||||
{
|
||||
error= 1;
|
||||
goto err;
|
||||
}
|
||||
if (share->partition_info_buffer_size < syntax_len + 1)
|
||||
{
|
||||
share->partition_info_buffer_size= syntax_len+1;
|
||||
if (!(tmp_part_syntax_str= (char*) strmake_root(&share->mem_root,
|
||||
part_syntax_buf,
|
||||
syntax_len)))
|
||||
{
|
||||
error= 1;
|
||||
goto err;
|
||||
}
|
||||
share->partition_info= tmp_part_syntax_str;
|
||||
}
|
||||
else
|
||||
memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1);
|
||||
share->partition_info_len= part_info->part_info_len= syntax_len;
|
||||
part_info->part_info_string= part_syntax_buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
err:
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos);
|
||||
@@ -1630,8 +1661,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
}
|
||||
alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
|
||||
/* remove .frm file and engine files */
|
||||
path_length= build_table_filename(path, sizeof(path),
|
||||
db, alias, reg_ext, 0);
|
||||
path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
|
||||
table->internal_tmp_table ?
|
||||
FN_IS_TMP : 0);
|
||||
}
|
||||
if (drop_temporary ||
|
||||
(table_type == NULL &&
|
||||
@@ -4574,6 +4606,55 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@brief Create frm file based on I_S table
|
||||
|
||||
@param[in] thd thread handler
|
||||
@param[in] schema_table I_S table
|
||||
@param[in] dst_path path where frm should be created
|
||||
@param[in] create_info Create info
|
||||
|
||||
@return Operation status
|
||||
@retval 0 success
|
||||
@retval 1 error
|
||||
*/
|
||||
|
||||
|
||||
bool mysql_create_like_schema_frm(THD* thd, TABLE_LIST* schema_table,
|
||||
char *dst_path, HA_CREATE_INFO *create_info)
|
||||
{
|
||||
HA_CREATE_INFO local_create_info;
|
||||
Alter_info alter_info;
|
||||
bool tmp_table= (create_info->options & HA_LEX_CREATE_TMP_TABLE);
|
||||
uint keys= schema_table->table->s->keys;
|
||||
uint db_options= 0;
|
||||
DBUG_ENTER("mysql_create_like_schema_frm");
|
||||
|
||||
bzero((char*) &local_create_info, sizeof(local_create_info));
|
||||
local_create_info.db_type= schema_table->table->s->db_type();
|
||||
local_create_info.row_type= schema_table->table->s->row_type;
|
||||
local_create_info.default_table_charset=default_charset_info;
|
||||
alter_info.flags= (ALTER_CHANGE_COLUMN | ALTER_RECREATE);
|
||||
schema_table->table->use_all_columns();
|
||||
if (mysql_prepare_alter_table(thd, schema_table->table,
|
||||
&local_create_info, &alter_info))
|
||||
DBUG_RETURN(1);
|
||||
if (mysql_prepare_create_table(thd, &local_create_info, &alter_info,
|
||||
tmp_table, &db_options,
|
||||
schema_table->table->file,
|
||||
&schema_table->table->s->key_info, &keys, 0))
|
||||
DBUG_RETURN(1);
|
||||
local_create_info.max_rows= 0;
|
||||
if (mysql_create_frm(thd, dst_path, NullS, NullS,
|
||||
&local_create_info, alter_info.create_list,
|
||||
keys, schema_table->table->s->key_info,
|
||||
schema_table->table->file))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Create a table identical to the specified table
|
||||
|
||||
@@ -4677,7 +4758,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
||||
during the call to ha_create_table(). See bug #28614 for more info.
|
||||
*/
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
if (my_copy(src_path, dst_path, MYF(MY_DONT_OVERWRITE_FILE)))
|
||||
if (src_table->schema_table)
|
||||
{
|
||||
if (mysql_create_like_schema_frm(thd, src_table, dst_path, create_info))
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else if (my_copy(src_path, dst_path, MYF(MY_DONT_OVERWRITE_FILE)))
|
||||
{
|
||||
if (my_errno == ENOENT)
|
||||
my_error(ER_BAD_DB_ERROR,MYF(0),db);
|
||||
|
||||
Reference in New Issue
Block a user