mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
8f521b41ba
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.
88 lines
2.4 KiB
C
88 lines
2.4 KiB
C
/* Copyright (C) 2000-2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "mysys_priv.h"
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
/*
|
|
system msync() only syncs mmap'ed area to fs cache.
|
|
fsync() is required to really sync to disc
|
|
*/
|
|
int my_msync(int fd, void *addr, size_t len, int flags)
|
|
{
|
|
msync(addr, len, flags);
|
|
return my_sync(fd, MYF(0));
|
|
}
|
|
|
|
#elif defined(_WIN32)
|
|
|
|
static SECURITY_ATTRIBUTES mmap_security_attributes=
|
|
{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
|
|
|
|
void *my_mmap(void *addr, size_t len, int prot,
|
|
int flags, File fd, my_off_t offset)
|
|
{
|
|
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)
|
|
DBUG_RETURN(MAP_FAILED);
|
|
|
|
hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
|
|
PAGE_READWRITE, 0, (DWORD) len, NULL);
|
|
if (hFileMap == 0)
|
|
DBUG_RETURN(MAP_FAILED);
|
|
|
|
ptr=MapViewOfFile(hFileMap,
|
|
prot & PROT_WRITE ? FILE_MAP_WRITE : FILE_MAP_READ,
|
|
(DWORD)(offset >> 32), (DWORD)offset, len);
|
|
|
|
/*
|
|
MSDN explicitly states that it's possible to close File Mapping Object
|
|
even when a view is not unmapped - then the object will be held open
|
|
implicitly until unmap, as every view stores internally a handler of
|
|
a corresponding File Mapping Object
|
|
*/
|
|
CloseHandle(hFileMap);
|
|
|
|
if (ptr)
|
|
{
|
|
DBUG_PRINT("mysys", ("mapped addr: %p", ptr));
|
|
DBUG_RETURN(ptr);
|
|
}
|
|
|
|
DBUG_RETURN(MAP_FAILED);
|
|
}
|
|
|
|
int my_munmap(void *addr, size_t len)
|
|
{
|
|
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)
|
|
{
|
|
return FlushViewOfFile(addr, len) ? 0 : -1;
|
|
}
|
|
|
|
#else
|
|
#warning "no mmap!"
|
|
#endif
|
|
|