--- sql/sql_class.cc.orig 2014-11-16 08:44:45.417221421 +0100 +++ sql/sql_class.cc 2014-11-16 09:06:49.933288618 +0100 @@ -2618,7 +2618,9 @@ IO_CACHE *cache) { File file; + MY_STAT stat; uint option= MY_UNPACK_FILENAME | MY_RELATIVE_PATH; + int file_created= 0; #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS option|= MY_REPLACE_DIR; // Force use of db directory @@ -2640,25 +2642,38 @@ return -1; } - if (!access(path, F_OK)) + /* Check if file is a named pipe */ + if (my_stat(path, &stat, MYF(0)) && MY_S_ISFIFO(stat.st_mode)) + { + if ((file= mysql_file_open(key_select_to_file, + path, O_WRONLY, MYF(MY_WME))) < 0) + return file; + } + else if (!access(path, F_OK)) { my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); return -1; } - /* Create the file world readable */ - if ((file= mysql_file_create(key_select_to_file, - path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) - return file; + else + { + /* Create the file world readable */ + if ((file= mysql_file_create(key_select_to_file, + path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) + return file; #ifdef HAVE_FCHMOD - (void) fchmod(file, 0666); // Because of umask() + (void) fchmod(file, 0666); // Because of umask() #else - (void) chmod(path, 0666); + (void) chmod(path, 0666); #endif + file_created= 1; + } + if (init_io_cache(cache, file, 0L, WRITE_CACHE, 0L, 1, MYF(MY_WME))) { mysql_file_close(file, MYF(0)); /* Delete file on error, it was just created */ - mysql_file_delete(key_select_to_file, path, MYF(0)); + if (file_created) + mysql_file_delete(key_select_to_file, path, MYF(0)); return -1; } return file;