=== modified file 'include/mysql/plugin.h' --- include/mysql/plugin.h revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ include/mysql/plugin.h 2014-10-08 06:26:56 +0000 @@ -579,6 +579,23 @@ int thd_allow_batch(MYSQL_THD thd); int mysql_tmpfile(const char *prefix); /** + Create a temporary file. + + @details + The temporary file is created in a location specified by the parameter + path. if path is null, then it will be created on the location given + by the mysql server configuration (--tmpdir option). The caller + does not need to delete the file, it will be deleted automatically. + + @param path location for creating temporary file + @param prefix prefix for temporary file name + @retval -1 error + @retval >= 0 a file handle that can be passed to dup or my_close +*/ +int mysql_tmpfile_path(const char *path, const char *prefix); + + +/** Check the killed state of a connection @details === modified file 'include/mysql/plugin_audit.h.pp' --- include/mysql/plugin_audit.h.pp revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ include/mysql/plugin_audit.h.pp 2014-10-07 06:30:45 +0000 @@ -235,6 +235,7 @@ char *thd_security_context(void* thd, ch void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); int mysql_tmpfile(const char *prefix); +int mysql_tmpfile_path(const char *path, const char *prefix); int thd_killed(const void* thd); void thd_binlog_pos(const void* thd, const char **file_var, === modified file 'include/mysql/plugin_auth.h.pp' --- include/mysql/plugin_auth.h.pp revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ include/mysql/plugin_auth.h.pp 2014-10-07 06:31:59 +0000 @@ -235,6 +235,7 @@ char *thd_security_context(void* thd, ch void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); int mysql_tmpfile(const char *prefix); +int mysql_tmpfile_path(const char *path, const char *prefix); int thd_killed(const void* thd); void thd_binlog_pos(const void* thd, const char **file_var, === modified file 'include/mysql/plugin_ftparser.h.pp' --- include/mysql/plugin_ftparser.h.pp revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ include/mysql/plugin_ftparser.h.pp 2014-10-07 06:31:46 +0000 @@ -188,6 +188,7 @@ char *thd_security_context(void* thd, ch void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); int mysql_tmpfile(const char *prefix); +int mysql_tmpfile_path(const char *path, const char *prefix); int thd_killed(const void* thd); void thd_binlog_pos(const void* thd, const char **file_var, === added file 'mysql-test/suite/innodb/r/tmpdir.result' --- mysql-test/suite/innodb/r/tmpdir.result 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/innodb/r/tmpdir.result 2014-10-08 09:16:46 +0000 @@ -0,0 +1,49 @@ +# +# Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL +# WHERE INNODB WRITES TEMP FILES +# +# If innodb_tmpdir is NULL or "", temporary file will be created in +# server configuration variable location(--tmpdir) +create table t1(a int primary key)engine=innodb; +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +alter table t1 add column b int not null; +set global innodb_tmpdir=NULL; +# Connection con1 +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +alter table t1 add key(b); +drop table t1; +# Alter table fails due to invalid location specified in innodb_tmpdir. +create table t1(a int primary key)engine=innodb; +set global innodb_tmpdir='wrong_value'; +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +# Connection con2 +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir wrong_value +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot create temporary merge file"); +alter table t1 add column b int not null; +ERROR HY000: Can't create/write to file '' (Errcode: 2 - No such file or directory) +set global innodb_tmpdir=NULL; +drop table t1; +# innodb_tmpdir with valid location. +create table t1(a text, b text, fulltext(a,b))engine=innodb; +insert into t1 values('test1', 'test2'); +insert into t1 values('text1', 'text2'); +set @tmpdir = @@global.tmpdir; +set global innodb_tmpdir = @tmpdir; +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +# Connection con3 +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir MYSQL_TMP_DIR/mysqld.1 +alter table t1 add fulltext(b); +set global innodb_tmpdir=NULL; +drop table t1; === added file 'mysql-test/suite/innodb/t/tmpdir.test' --- mysql-test/suite/innodb/t/tmpdir.test 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/innodb/t/tmpdir.test 2014-10-09 16:46:34 +0000 @@ -0,0 +1,58 @@ +--source include/have_innodb.inc +--source include/count_sessions.inc + +--echo # +--echo # Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL +--echo # WHERE INNODB WRITES TEMP FILES +--echo # + +--echo # If innodb_tmpdir is NULL or "", temporary file will be created in +--echo # server configuration variable location(--tmpdir) + +create table t1(a int primary key)engine=innodb; +show session variables like 'innodb_tmpdir'; +alter table t1 add column b int not null; +set global innodb_tmpdir=NULL; +--echo # Connection con1 +connect (con1,localhost,root); +show session variables like 'innodb_tmpdir'; +alter table t1 add key(b); +connection default; +disconnect con1; +drop table t1; + +--echo # Alter table fails due to invalid location specified in innodb_tmpdir. + +create table t1(a int primary key)engine=innodb; +set global innodb_tmpdir='wrong_value'; +show session variables like 'innodb_tmpdir'; +--echo # Connection con2 +connect (con2,localhost,root); +show session variables like 'innodb_tmpdir'; +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot create temporary merge file"); +--replace_regex /wrong_value\/[A-Za-z0-9_]*// +--error 1 +alter table t1 add column b int not null; +disconnect con2; +connection default; +set global innodb_tmpdir=NULL; +drop table t1; + +--echo # innodb_tmpdir with valid location. + +create table t1(a text, b text, fulltext(a,b))engine=innodb; +insert into t1 values('test1', 'test2'); +insert into t1 values('text1', 'text2'); +set @tmpdir = @@global.tmpdir; +set global innodb_tmpdir = @tmpdir; +show session variables like 'innodb_tmpdir'; +--echo # Connection con3 +connect (con3,localhost,root); +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +show session variables like 'innodb_tmpdir'; +alter table t1 add fulltext(b); +disconnect con3; +connection default; +set global innodb_tmpdir=NULL; +drop table t1; +--source include/wait_until_count_sessions.inc === added file 'mysql-test/suite/sys_vars/r/innodb_tmpdir_basic.result' --- mysql-test/suite/sys_vars/r/innodb_tmpdir_basic.result 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/sys_vars/r/innodb_tmpdir_basic.result 2014-10-07 06:55:16 +0000 @@ -0,0 +1,29 @@ +SET @start_global_value = @@global.innodb_tmpdir; +SELECT @start_global_value; +@start_global_value + +select @@session.innodb_tmpdir; +@@session.innodb_tmpdir + +show global variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +show session variables like 'innodb_tmpdir'; +Variable_name Value +innodb_tmpdir +select * from information_schema.global_variables where variable_name='innodb_tmpdir'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_TMPDIR +select * from information_schema.session_variables where variable_name='innodb_tmpdir'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_TMPDIR +set global innodb_tmpdir='value'; +set session innodb_tmpdir='value'; +set global innodb_tmpdir=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_tmpdir' +set global innodb_tmpdir=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_tmpdir' +SET @@global.innodb_tmpdir = @start_global_value; +SELECT @@global.innodb_tmpdir; +@@global.innodb_tmpdir + === added file 'mysql-test/suite/sys_vars/t/innodb_tmpdir_basic.test' --- mysql-test/suite/sys_vars/t/innodb_tmpdir_basic.test 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/sys_vars/t/innodb_tmpdir_basic.test 2014-10-07 07:29:38 +0000 @@ -0,0 +1,36 @@ +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_tmpdir; +SELECT @start_global_value; + +# +# exists as global and session +# +select @@session.innodb_tmpdir; + +show global variables like 'innodb_tmpdir'; +show session variables like 'innodb_tmpdir'; + +select * from information_schema.global_variables where variable_name='innodb_tmpdir'; +select * from information_schema.session_variables where variable_name='innodb_tmpdir'; +# +# Show that it is writable +# + +set global innodb_tmpdir='value'; +set session innodb_tmpdir='value'; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_tmpdir=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_tmpdir=1e1; + +# +# Cleanup +# + +SET @@global.innodb_tmpdir = @start_global_value; +SELECT @@global.innodb_tmpdir; === modified file 'sql/sql_class.cc' --- sql/sql_class.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ sql/sql_class.cc 2014-10-15 09:03:02 +0000 @@ -527,8 +527,16 @@ ulong get_max_connections(void) extern "C" int mysql_tmpfile(const char *prefix) { + return mysql_tmpfile_path(mysql_tmpdir, prefix); +} + +int mysql_tmpfile_path(const char *path, const char *prefix) +{ + DBUG_ASSERT(path != NULL); + DBUG_ASSERT((strlen(path) + strlen(prefix)) <= FN_REFLEN); + char filename[FN_REFLEN]; - File fd = create_temp_file(filename, mysql_tmpdir, prefix, + File fd = create_temp_file(filename, path, prefix, #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | O_SHORT_LIVED | @@ -549,7 +557,6 @@ extern "C" int mysql_tmpfile(const char return fd; } - extern "C" int thd_in_lock_tables(const THD *thd) { === modified file 'storage/innobase/dict/dict0dict.cc' --- storage/innobase/dict/dict0dict.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/dict/dict0dict.cc 2014-10-07 06:28:01 +0000 @@ -973,7 +973,7 @@ dict_init(void) &dict_operation_lock, SYNC_DICT_OPERATION); if (!srv_read_only_mode) { - dict_foreign_err_file = os_file_create_tmpfile(); + dict_foreign_err_file = os_file_create_tmpfile(NULL); ut_a(dict_foreign_err_file); mutex_create(dict_foreign_err_mutex_key, === modified file 'storage/innobase/handler/ha_innodb.cc' --- storage/innobase/handler/ha_innodb.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/handler/ha_innodb.cc 2014-10-20 06:27:21 +0000 @@ -543,6 +543,11 @@ static MYSQL_THDVAR_STR(ft_user_stopword "User supplied stopword table name, effective in the session level.", innodb_stopword_table_validate, NULL, NULL); +static MYSQL_THDVAR_STR(tmpdir, + PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_MEMALLOC, + "Directory for temporary files during DDL operations.", + NULL, NULL, ""); + static SHOW_VAR innodb_status_variables[]= { {"buffer_pool_dump_status", (char*) &export_vars.innodb_buffer_pool_dump_status, SHOW_CHAR}, @@ -1265,6 +1270,26 @@ thd_supports_xa( return(THDVAR(thd, support_xa)); } +/** Get the value of innodb_tmpdir. +@param[in] thd thread handle, or NULL to query + the global innodb_tmpdir. +@return value or NULL if innodb_tmpdir is set to default value "" */ +UNIV_INTERN +const char* +thd_innodb_tmpdir( + THD* thd) +{ +#ifdef UNIV_SYNC_DEBUG + ut_ad(!sync_thread_levels_nonempty_trx(false)); +#endif /* UNIV_SYNC_DEBUG */ + + const char* tmp_dir = THDVAR(thd, tmpdir); + if (tmp_dir != NULL && *tmp_dir == '\0') { + tmp_dir = NULL; + } + + return(tmp_dir); +} /******************************************************************//** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ @@ -1783,13 +1808,14 @@ innobase_get_lower_case_table_names(void return(lower_case_table_names); } -/*********************************************************************//** -Creates a temporary file. +/** Create a temporary file in the location specified by the parameter +path. If the path is null, then it will be created in tmpdir. +@param[in] path location for creating temporary file @return temporary file descriptor, or < 0 on error */ UNIV_INTERN int -innobase_mysql_tmpfile(void) -/*========================*/ +innobase_mysql_tmpfile( + const char* path) { int fd2 = -1; File fd; @@ -1799,7 +1825,11 @@ innobase_mysql_tmpfile(void) return(-1); ); - fd = mysql_tmpfile("ib"); + if (path == NULL) { + fd = mysql_tmpfile("ib"); + } else { + fd = mysql_tmpfile_path(path, "ib"); + } if (fd >= 0) { /* Copy the file descriptor, so that the additional resources @@ -16536,6 +16566,7 @@ static struct st_mysql_sys_var* innobase MYSQL_SYSVAR(adaptive_max_sleep_delay), #endif /* HAVE_ATOMIC_BUILTINS */ MYSQL_SYSVAR(thread_sleep_delay), + MYSQL_SYSVAR(tmpdir), MYSQL_SYSVAR(autoinc_lock_mode), MYSQL_SYSVAR(version), MYSQL_SYSVAR(use_sys_malloc), === modified file 'storage/innobase/handler/handler0alter.cc' --- storage/innobase/handler/handler0alter.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/handler/handler0alter.cc 2014-10-07 18:03:19 +0000 @@ -2608,6 +2608,9 @@ prepare_inplace_alter_table_dict( ctx->num_to_add_index = ha_alter_info->index_add_count; + const char* path = thd_innodb_tmpdir( + ctx->prebuilt->trx->mysql_thd); + index_defs = innobase_create_key_defs( ctx->heap, ha_alter_info, altered_table, ctx->num_to_add_index, num_fts_index, @@ -2946,8 +2949,10 @@ prepare_inplace_alter_table_dict( error = DB_OUT_OF_MEMORY; goto error_handling;); rw_lock_x_lock(&ctx->add_index[a]->lock); + bool ok = row_log_allocate(ctx->add_index[a], - NULL, true, NULL, NULL); + NULL, true, NULL, + NULL, path); rw_lock_x_unlock(&ctx->add_index[a]->lock); if (!ok) { @@ -2973,7 +2978,7 @@ prepare_inplace_alter_table_dict( clust_index, ctx->new_table, !(ha_alter_info->handler_flags & Alter_inplace_info::ADD_PK_INDEX), - ctx->add_cols, ctx->col_map); + ctx->add_cols, ctx->col_map, path); rw_lock_x_unlock(&clust_index->lock); if (!ok) { @@ -3920,6 +3925,7 @@ ok_exit: files and merge sort. */ DBUG_EXECUTE_IF("innodb_OOM_inplace_alter", error = DB_OUT_OF_MEMORY; goto oom;); + error = row_merge_build_indexes( prebuilt->trx, prebuilt->table, ctx->new_table, === modified file 'storage/innobase/include/ha_prototypes.h' --- storage/innobase/include/ha_prototypes.h revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/include/ha_prototypes.h 2014-10-13 07:58:53 +0000 @@ -328,6 +328,15 @@ thd_supports_xa( THD* thd); /*!< in: thread handle, or NULL to query the global innodb_supports_xa */ +/** Get status of innodb_tmpdir. +@param[in] thd thread handle, or NULL to query + the global innodb_tmpdir. +@return value or NULL if innodb_tmpdir is set to default value "" */ +UNIV_INTERN +const char* +thd_innodb_tmpdir( + THD* thd); + /******************************************************************//** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ === modified file 'storage/innobase/include/os0file.h' --- storage/innobase/include/os0file.h revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/include/os0file.h 2014-10-20 06:28:32 +0000 @@ -431,14 +431,19 @@ UNIV_INTERN void os_io_init_simple(void); /*===================*/ -/***********************************************************************//** -Creates a temporary file. This function is like tmpfile(3), but -the temporary file is created in the MySQL temporary directory. -@return temporary file handle, or NULL on error */ + +/** Create a temporary file. This function is like tmpfile(3), but +the temporary file is created in the given parameter path. If the path +is null then it will create the file in the mysql server configuration +parameter (--tmpdir). +@param[in] path location for creating temporary file +@return temporary file handle, or NULL on error */ +UNIV_INTERN FILE* -os_file_create_tmpfile(void); -/*========================*/ +os_file_create_tmpfile( + const char* path); + #endif /* !UNIV_HOTBACKUP */ /***********************************************************************//** The os_file_opendir() function opens a directory stream corresponding to the @@ -1244,14 +1249,14 @@ os_file_get_status( file can be opened in RW mode */ #if !defined(UNIV_HOTBACKUP) -/*********************************************************************//** -Creates a temporary file that will be deleted on close. -This function is defined in ha_innodb.cc. -@return temporary file descriptor, or < 0 on error */ +/** Create a temporary file in the location specified by the parameter +path. If the path is null, then it will be created in tmpdir. +@param[in] path location for creating temporary file +@return temporary file descriptor, or < 0 on error */ UNIV_INTERN int -innobase_mysql_tmpfile(void); -/*========================*/ +innobase_mysql_tmpfile( + const char* path); #endif /* !UNIV_HOTBACKUP */ === modified file 'storage/innobase/include/row0log.h' --- storage/innobase/include/row0log.h revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/include/row0log.h 2014-10-07 18:03:58 +0000 @@ -51,8 +51,9 @@ row_log_allocate( const dtuple_t* add_cols, /*!< in: default values of added columns, or NULL */ - const ulint* col_map)/*!< in: mapping of old column + const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ + const char* path) /*!< in: where to create temporary file */ __attribute__((nonnull(1), warn_unused_result)); /******************************************************//** === modified file 'storage/innobase/include/row0merge.h' --- storage/innobase/include/row0merge.h revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/include/row0merge.h 2014-10-15 09:40:47 +0000 @@ -170,14 +170,14 @@ void row_merge_drop_temp_indexes(void); /*=============================*/ -/*********************************************************************//** -Creates temporary merge files, and if UNIV_PFS_IO defined, register -the file descriptor with Performance Schema. +/** Create temporary merge files in the given paramater path, and if +UNIV_PFS_IO defined, register the file descriptor with Performance Schema. +@param[in] path location for creating temporary merge files. @return File descriptor */ UNIV_INTERN int -row_merge_file_create_low(void) -/*===========================*/ +row_merge_file_create_low( + const char* path) __attribute__((warn_unused_result)); /*********************************************************************//** Destroy a merge file. And de-register the file from Performance Schema @@ -348,15 +348,17 @@ row_merge_buf_empty( /*================*/ row_merge_buf_t* buf) /*!< in,own: sort buffer */ __attribute__((warn_unused_result, nonnull)); -/*********************************************************************//** -Create a merge file. + +/** Create a merge file in the given location. +@param[out] merge_file merge file structure +@param[in] path location for creating temporary file @return file descriptor, or -1 on failure */ UNIV_INTERN int row_merge_file_create( -/*==================*/ - merge_file_t* merge_file) /*!< out: merge file structure */ - __attribute__((nonnull)); + merge_file_t* merge_file, + const char* path); + /*********************************************************************//** Merge disk files. @return DB_SUCCESS or error code */ === modified file 'storage/innobase/lock/lock0lock.cc' --- storage/innobase/lock/lock0lock.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/lock/lock0lock.cc 2014-10-07 06:28:01 +0000 @@ -616,7 +616,7 @@ lock_sys_create( lock_sys->rec_hash = hash_create(n_cells); if (!srv_read_only_mode) { - lock_latest_err_file = os_file_create_tmpfile(); + lock_latest_err_file = os_file_create_tmpfile(NULL); ut_a(lock_latest_err_file); } } === modified file 'storage/innobase/os/os0file.cc' --- storage/innobase/os/os0file.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/os/os0file.cc 2014-10-20 06:33:17 +0000 @@ -753,17 +753,19 @@ os_io_init_simple(void) } } -/***********************************************************************//** -Creates a temporary file. This function is like tmpfile(3), but -the temporary file is created in the MySQL temporary directory. -@return temporary file handle, or NULL on error */ +/** Create a temporary file. This function is like tmpfile(3), but +the temporary file is created in the given parameter path. If the path +is null then it will create the file in the mysql server configuration +parameter (--tmpdir). +@param[in] path location for creating temporary file +@return temporary file handle, or NULL on error */ UNIV_INTERN FILE* -os_file_create_tmpfile(void) -/*========================*/ +os_file_create_tmpfile( + const char* path) { FILE* file = NULL; - int fd = innobase_mysql_tmpfile(); + int fd = innobase_mysql_tmpfile(path); ut_ad(!srv_read_only_mode); @@ -3587,7 +3589,7 @@ os_aio_native_aio_supported(void) return(FALSE); } else if (!srv_read_only_mode) { /* Now check if tmpdir supports native aio ops. */ - fd = innobase_mysql_tmpfile(); + fd = innobase_mysql_tmpfile(NULL); if (fd < 0) { ib_logf(IB_LOG_LEVEL_WARN, === modified file 'storage/innobase/row/row0ftsort.cc' --- storage/innobase/row/row0ftsort.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/row/row0ftsort.cc 2014-10-08 06:30:33 +0000 @@ -220,6 +220,8 @@ row_fts_psort_info_init( common_info->merge_event = os_event_create(); common_info->opt_doc_id_size = opt_doc_id_size; + const char* path = thd_innodb_tmpdir(trx->mysql_thd); + /* There will be FTS_NUM_AUX_INDEX number of "sort buckets" for each parallel sort thread. Each "sort bucket" holds records for a particular "FTS index partition" */ @@ -241,8 +243,8 @@ row_fts_psort_info_init( psort_info[j].merge_buf[i] = row_merge_buf_create( dup->index); - if (row_merge_file_create(psort_info[j].merge_file[i]) - < 0) { + if (row_merge_file_create(psort_info[j].merge_file[i], + path) < 0) { goto func_exit; } @@ -610,6 +612,9 @@ fts_parallel_tokenization( ulint retried = 0; dberr_t error = DB_SUCCESS; + const char* path = thd_innodb_tmpdir( + psort_info->psort_common->trx->mysql_thd); + ut_ad(psort_info); buf = psort_info->merge_buf; @@ -839,7 +844,7 @@ exit: continue; } - tmpfd[i] = row_merge_file_create_low(); + tmpfd[i] = row_merge_file_create_low(path); if (tmpfd[i] < 0) { error = DB_OUT_OF_MEMORY; goto func_exit; === modified file 'storage/innobase/row/row0log.cc' --- storage/innobase/row/row0log.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/row/row0log.cc 2014-10-08 06:11:04 +0000 @@ -2814,8 +2814,9 @@ row_log_allocate( const dtuple_t* add_cols, /*!< in: default values of added columns, or NULL */ - const ulint* col_map)/*!< in: mapping of old column + const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ + const char* path) /*!< in: where to create temporary file */ { row_log_t* log; DBUG_ENTER("row_log_allocate"); @@ -2834,7 +2835,7 @@ row_log_allocate( DBUG_RETURN(false); } - log->fd = row_merge_file_create_low(); + log->fd = row_merge_file_create_low(path); if (log->fd < 0) { ut_free(log); DBUG_RETURN(false); === modified file 'storage/innobase/row/row0merge.cc' --- storage/innobase/row/row0merge.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/row/row0merge.cc 2014-10-15 09:40:56 +0000 @@ -2922,14 +2922,15 @@ row_merge_drop_temp_indexes(void) trx_free_for_background(trx); } -/*********************************************************************//** -Creates temporary merge files, and if UNIV_PFS_IO defined, register -the file descriptor with Performance Schema. -@return file descriptor, or -1 on failure */ + +/** Create temporary merge files in the given paramater path, and if +UNIV_PFS_IO defined, register the file descriptor with Performance Schema. +@param[in] path location for creating temporary merge files. +@return File descriptor */ UNIV_INTERN int -row_merge_file_create_low(void) -/*===========================*/ +row_merge_file_create_low( + const char* path) { int fd; #ifdef UNIV_PFS_IO @@ -2943,7 +2944,7 @@ row_merge_file_create_low(void) "Innodb Merge Temp File", __FILE__, __LINE__); #endif - fd = innobase_mysql_tmpfile(); + fd = innobase_mysql_tmpfile(path); #ifdef UNIV_PFS_IO register_pfs_file_open_end(locker, fd); #endif @@ -2956,16 +2957,18 @@ row_merge_file_create_low(void) return(fd); } -/*********************************************************************//** -Create a merge file. + +/** Create a merge file in the given location. +@param[out] merge_file merge file structure +@param[in] path location for creating temporary file @return file descriptor, or -1 on failure */ UNIV_INTERN int row_merge_file_create( -/*==================*/ - merge_file_t* merge_file) /*!< out: merge file structure */ + merge_file_t* merge_file, + const char* path) { - merge_file->fd = row_merge_file_create_low(); + merge_file->fd = row_merge_file_create_low(path); merge_file->offset = 0; merge_file->n_rec = 0; @@ -3467,6 +3470,8 @@ row_merge_build_indexes( DBUG_RETURN(DB_OUT_OF_MEMORY); } + const char* path = thd_innodb_tmpdir(trx->mysql_thd); + trx_start_if_not_started_xa(trx); merge_files = static_cast( @@ -3481,7 +3486,7 @@ row_merge_build_indexes( } for (i = 0; i < n_indexes; i++) { - if (row_merge_file_create(&merge_files[i]) < 0) { + if (row_merge_file_create(&merge_files[i], path) < 0) { error = DB_OUT_OF_MEMORY; goto func_exit; } @@ -3513,7 +3518,7 @@ row_merge_build_indexes( } } - tmpfd = row_merge_file_create_low(); + tmpfd = row_merge_file_create_low(path); if (tmpfd < 0) { error = DB_OUT_OF_MEMORY; === modified file 'storage/innobase/srv/srv0start.cc' --- storage/innobase/srv/srv0start.cc revid:yasufumi.kinoshita@oracle.com-20140916074624-p0bdaux31vxvavtq +++ storage/innobase/srv/srv0start.cc 2014-10-07 06:28:01 +0000 @@ -1854,7 +1854,7 @@ innobase_start_or_create_for_mysql(void) } } else { srv_monitor_file_name = NULL; - srv_monitor_file = os_file_create_tmpfile(); + srv_monitor_file = os_file_create_tmpfile(NULL); if (!srv_monitor_file) { return(DB_ERROR); @@ -1864,7 +1864,7 @@ innobase_start_or_create_for_mysql(void) mutex_create(srv_dict_tmpfile_mutex_key, &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION); - srv_dict_tmpfile = os_file_create_tmpfile(); + srv_dict_tmpfile = os_file_create_tmpfile(NULL); if (!srv_dict_tmpfile) { return(DB_ERROR); @@ -1873,7 +1873,7 @@ innobase_start_or_create_for_mysql(void) mutex_create(srv_misc_tmpfile_mutex_key, &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH); - srv_misc_tmpfile = os_file_create_tmpfile(); + srv_misc_tmpfile = os_file_create_tmpfile(NULL); if (!srv_misc_tmpfile) { return(DB_ERROR);