diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index ddf1681479c..ad6c0fd5283 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -219,7 +219,8 @@ AsyncFile::run() rmrfReq(request, (char*)theFileName.c_str(), request->par.rmrf.own_directory); break; case Request:: end: - closeReq(request); + if (theFd > 0) + closeReq(request); endReq(); return; default: @@ -239,6 +240,7 @@ void AsyncFile::openReq(Request* request) { m_openedWithSync = false; m_syncFrequency = 0; + m_syncCount= 0; // for open.flags, see signal FSOPENREQ #ifdef NDB_WIN32 @@ -329,7 +331,6 @@ void AsyncFile::openReq(Request* request) } else { #endif m_openedWithSync = false; - m_syncCount = 0; m_syncFrequency = Global_syncFreq; #if 0 } @@ -656,6 +657,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, } #endif + m_syncCount+= bytes_written; buf += bytes_written; size -= bytes_written; offset += bytes_written; @@ -682,6 +684,10 @@ AsyncFile::closeReq(Request * request) hFile = INVALID_HANDLE_VALUE; #else if (-1 == ::close(theFd)) { +#ifndef DBUG_OFF + if (theFd == -1) + abort(); +#endif request->error = errno; } theFd = -1; @@ -700,7 +706,8 @@ bool AsyncFile::isOpen(){ void AsyncFile::syncReq(Request * request) { - if(m_openedWithSync){ + if(m_openedWithSync || + m_syncCount == 0){ return; } #ifdef NDB_WIN32 @@ -756,7 +763,6 @@ AsyncFile::appendReq(Request * request){ if(m_syncFrequency != 0 && m_syncCount > m_syncFrequency){ syncReq(request); - request->error = 0; } } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 88e840d1c4e..880cce06c27 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2394,8 +2394,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, strxmov(src_path, (*tmp_table)->s->path, reg_ext, NullS); else { - strxmov(src_path, mysql_data_home, "/", src_db, "/", src_table, - reg_ext, NullS); + fn_format( src_path, src_table, src_db, reg_ext, MYF(MY_UNPACK_FILENAME)); if (access(src_path, F_OK)) { my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table); @@ -2422,8 +2421,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, } else { - strxmov(dst_path, mysql_data_home, "/", db, "/", table_name, - reg_ext, NullS); + fn_format( dst_path, table_name, db, reg_ext, MYF(MY_UNPACK_FILENAME)); if (!access(dst_path, F_OK)) goto table_exists; }