Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111

Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
 
   The server crashed on an attempt to optimize a MERGE table with
   non-existent child table.
 
   mysql_admin_table() relied on the table to be successfully open
   if a table object had been allocated.
 
   Changed code to check return value of the open function before
   calling a handler:: function on it.

mysql-test/r/merge.result:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Updated result file.
mysql-test/t/merge.test:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Changed tests to respect changed TEMPORARY MERGE locking (unrelated).
      Changed tests to respect changed CREATE TABLE ... LIKE (unrelated).
      Changed tests to respect that no new tables can be created
      under LOCK TABLE (unrelated).
      Added test for Bug#47633.
  Changed error numbers to symbolic names.
  Added test for child locking for ALTER under LOCK TABLE.
  
  Since Bug 36171 is not pushed yet, not the whole patch has been backported.
mysys/my_delete.c:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Fixed error reporting.
      Fixed indentation.
mysys/my_mmap.c:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Added DBUG.
sql/item_func.cc:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
  Added Debug Sync point, required by merge_sync.test.
sql/sql_table.cc:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Do not call handler:: functions if the table was not opened
      successfully.
  Added Debug Sync point, required by merge_sync.test.
storage/myisam/mi_check.c:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
      Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
      Unmap memory before exchanging data files. Needed on Windows.
storage/myisammrg/ha_myisammrg.cc:
  Backport of revid:ingo.struewing@sun.com-20091223200354-r2uzbdkj2v6yv111
  Added Debug Sync point, required by merge_sync.test.
  
  merge_sync.test will be introduced by a patch for Bug 36171,
  which is not pushed yet.
This commit is contained in:
Alexander Nozdrin 2010-06-25 19:32:59 +04:00
commit 8f521b41ba
8 changed files with 124 additions and 30 deletions

View file

@ -93,23 +93,33 @@ int nt_share_delete(const char *name, myf MyFlags)
name, buf, errno));
break;
}
if (errno == ERROR_FILE_NOT_FOUND)
{
my_errno= ENOENT; // marking, that `name' doesn't exist
my_errno= ENOENT; // marking, that `name' doesn't exist
}
else if (errno == 0)
{
if (DeleteFile(buf))
DBUG_RETURN(0);
else if ((my_errno= GetLastError()) == 0)
my_errno= ENOENT; // marking, that `buf' doesn't exist
} else
my_errno= errno;
if (DeleteFile(buf))
DBUG_RETURN(0);
/*
The below is more complicated than necessary. For some reason, the
assignment to my_errno clears the error number, which is retrieved
by GetLastError() (VC2005EE). Assigning to errno first, allows to
retrieve the correct value.
*/
errno= GetLastError();
if (errno == 0)
my_errno= ENOENT; // marking, that `buf' doesn't exist
else
my_errno= errno;
}
else
my_errno= errno;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
name, my_errno);
my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
name, my_errno);
DBUG_RETURN(-1);
}
#endif

View file

@ -38,13 +38,16 @@ void *my_mmap(void *addr, size_t len, int prot,
HANDLE hFileMap;
LPVOID ptr;
HANDLE hFile= (HANDLE)my_get_osfhandle(fd);
DBUG_ENTER("my_mmap");
DBUG_PRINT("mysys", ("map fd: %d", fd));
if (hFile == INVALID_HANDLE_VALUE)
return MAP_FAILED;
DBUG_RETURN(MAP_FAILED);
hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
PAGE_READWRITE, 0, (DWORD) len, NULL);
if (hFileMap == 0)
return MAP_FAILED;
DBUG_RETURN(MAP_FAILED);
ptr=MapViewOfFile(hFileMap,
prot & PROT_WRITE ? FILE_MAP_WRITE : FILE_MAP_READ,
@ -59,14 +62,19 @@ void *my_mmap(void *addr, size_t len, int prot,
CloseHandle(hFileMap);
if (ptr)
return ptr;
{
DBUG_PRINT("mysys", ("mapped addr: %p", ptr));
DBUG_RETURN(ptr);
}
return MAP_FAILED;
DBUG_RETURN(MAP_FAILED);
}
int my_munmap(void *addr, size_t len)
{
return UnmapViewOfFile(addr) ? 0 : -1;
DBUG_ENTER("my_munmap");
DBUG_PRINT("mysys", ("unmap addr: %p", addr));
DBUG_RETURN(UnmapViewOfFile(addr) ? 0 : -1);
}
int my_msync(int fd, void *addr, size_t len, int flags)