mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Windows fixes
-new option WITH_MARIA_STORAGE_ENGINE for config.js -correct build errors -build test executables -downport changes for atomic functions from 5.2 -remove LOCK_uuid_generator from C++ files to avoid linker errors -new function my_uuid2str() BitKeeper/deleted/.del-x86-msvc.h: Delete: include/atomic/x86-msvc.h CMakeLists.txt: Windows fixes: -New option WITH_MARIA_STORAGE_ENGINE -Add unit tests include/Makefile.am: replace x86-msvc.h with generic-msvc.h include/config-win.h: my_chmod() support include/my_atomic.h: Downport my_atomic from 5.2 tree include/my_bit.h: Correct unresolved symbol errors on Windows include/my_pthread.h: pthread_mutex_unlock now returns 0 (was void previously) defined PTHREAD_STACK_MIN include/my_sys.h: New function my_uuid2str() define MY_UUID_STRING_LENGTH include/atomic/nolock.h: Downport my_atomic from 5.2 tree libmysqld/CMakeLists.txt: New option WITH_MARIA_STORAGE_ENGINE mysys/CMakeLists.txt: Add missing files mysys/lf_dynarray.c: Fix compiler errors on Windows mysys/my_getncpus.c: Windows port mysys/my_uuid.c: Windows fixes: there is no random() on Windows, use ANSI rand() New function my_uuid2str() mysys/my_winthread.c: Downport from 5.2 tree -Call my_thread_end() before pthread_exit() -Avoid crash if pthread_create is called with NULL attributes sql/CMakeLists.txt: Link mysqld with Maria storage engine sql/item_func.cc: Remove LOCK_uuid_generator from C++ to avoid linker errors. Use dedicated mutex for short uuids sql/item_strfunc.cc: Use my_uuid() and my_uuid2str() functions from mysys. sql/item_strfunc.h: Define MY_UUID_STRING_LENGTH in my_sys.h sql/mysql_priv.h: LOCK_uuid_generator must be declared as extern "C" sql/mysqld.cc: Init and destroy LOCK_uuid_short mutex storage/maria/CMakeLists.txt: -Use the same source files as in Makefile.am -Build test binaries storage/maria/ha_maria.cc: snprintf->my_snprintf storage/maria/lockman.c: Fix compiler error on Windows storage/maria/ma_check.c: Fix compiler error on Windows storage/maria/ma_loghandler.c: Fix compile errors my_open()/my_sync() do not work for directories on Windows storage/maria/ma_recovery.c: Fix compile error on Windows storage/maria/ma_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/maria/ma_test3.c: Fix build errors on Windows storage/maria/tablockman.c: Fix build errors on Windows storage/maria/unittest/Makefile.am: Add CMakeLists.txt storage/maria/unittest/ma_pagecache_consist.c: Fix build errors on Windows remove loop from get_len() storage/maria/unittest/ma_pagecache_single.c: Fix build errors on Windows storage/maria/unittest/ma_test_loghandler-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Fix build errors on Windows storage/maria/unittest/test_file.c: Correct the code to get file size on Windows. stat() information can be outdated and thus cannot be trusted. On Vista,stat() returns file size=0 until the file is closed at the first time. storage/myisam/CMakeLists.txt: Fix compiler errors on Windows Build test executables storage/myisam/mi_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/myisam/mi_test3.c: Fix build errors on Windows strings/CMakeLists.txt: Add missing file unittest/unit.pl: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/my_atomic-t.c: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/tap.c: Windows: downport unittest changes from 5.2 bk tree win/configure.js: Add WITH_MARIA_STORAGE_ENGINE configure option unittest/mytap/CMakeLists.txt: Add missing file unittest/mysys/CMakeLists.txt: Add missing file storage/maria/unittest/CMakeLists.txt: Add missing file BitKeeper/etc/ignore: Added comments maria-win.patch to the ignore list include/atomic/generic-msvc.h: Implement atomic operations with MSVC intrinsics
This commit is contained in:
@ -3067,3 +3067,8 @@ ylwrap
|
||||
zlib/*.ds?
|
||||
zlib/*.vcproj
|
||||
libmysqld/sql_profile.cc
|
||||
*.dll
|
||||
*.ilk
|
||||
*.exp
|
||||
comments
|
||||
maria-win.patch
|
||||
|
@ -75,6 +75,10 @@ IF(WITH_FEDERATED_STORAGE_ENGINE)
|
||||
ADD_DEFINITIONS(-DWITH_FEDERATED_STORAGE_ENGINE)
|
||||
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin")
|
||||
ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
|
||||
IF(WITH_MARIA_STORAGE_ENGINE)
|
||||
ADD_DEFINITIONS(-DWITH_MARIA_STORAGE_ENGINE)
|
||||
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_maria_plugin")
|
||||
ENDIF(WITH_MARIA_STORAGE_ENGINE)
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
|
||||
${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc @ONLY)
|
||||
@ -237,10 +241,17 @@ ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
|
||||
IF(WITH_INNOBASE_STORAGE_ENGINE)
|
||||
ADD_SUBDIRECTORY(storage/innobase)
|
||||
ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
|
||||
IF(WITH_MARIA_STORAGE_ENGINE)
|
||||
ADD_SUBDIRECTORY(storage/maria)
|
||||
ADD_SUBDIRECTORY(storage/maria/unittest)
|
||||
ENDIF(WITH_MARIA_STORAGE_ENGINE)
|
||||
ADD_SUBDIRECTORY(sql)
|
||||
ADD_SUBDIRECTORY(server-tools/instance-manager)
|
||||
ADD_SUBDIRECTORY(libmysql)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ADD_SUBDIRECTORY(unittest/mytap)
|
||||
ADD_SUBDIRECTORY(unittest/examples)
|
||||
ADD_SUBDIRECTORY(unittest/mysys)
|
||||
IF(WITH_EMBEDDED_SERVER)
|
||||
ADD_SUBDIRECTORY(libmysqld)
|
||||
ADD_SUBDIRECTORY(libmysqld/examples)
|
||||
|
@ -35,7 +35,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
|
||||
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
|
||||
mysql_version.h.in my_handler.h my_time.h \
|
||||
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
|
||||
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
|
||||
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
|
||||
my_libwrap.h wqueue.h
|
||||
|
||||
# Remove built files and the symlinked directories
|
||||
|
108
include/atomic/generic-msvc.h
Normal file
108
include/atomic/generic-msvc.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* Copyright (C) 2006 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 */
|
||||
|
||||
#ifndef _atomic_h_cleanup_
|
||||
#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
|
||||
/*
|
||||
We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
|
||||
intrinsics.
|
||||
8 and 16-bit atomics are not implemented, but it can be done if necessary.
|
||||
*/
|
||||
|
||||
/*
|
||||
x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
|
||||
function calls to kernel32 instead, even in the optimized build.
|
||||
We force intrinsics as described in MSDN documentation for
|
||||
_InterlockedCompareExchange.
|
||||
*/
|
||||
#ifdef _M_IX86
|
||||
|
||||
#if (_MSC_VER >= 1400)
|
||||
#include <intrin.h>
|
||||
#else
|
||||
/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
|
||||
LONG _InterlockedExchange (LONG volatile *Target,LONG Value);
|
||||
LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
|
||||
LONG _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value);
|
||||
#pragma intrinsic(_InterlockedExchangeAdd)
|
||||
#pragma intrinsic(_InterlockedCompareExchange)
|
||||
#pragma intrinsic(_InterlockedExchange)
|
||||
#endif
|
||||
|
||||
#define InterlockedExchange _InterlockedExchange
|
||||
#define InterlockedExchangeAdd _InterlockedExchangeAdd
|
||||
#define InterlockedCompareExchange _InterlockedCompareExchange
|
||||
/*
|
||||
No need to do something special for InterlockedCompareExchangePointer
|
||||
as it is a #define to InterlockedCompareExchange. The same applies to
|
||||
InterlockedExchangePointer.
|
||||
*/
|
||||
#endif /*_M_IX86*/
|
||||
|
||||
#define MY_ATOMIC_MODE "msvc-intrinsics"
|
||||
#define IL_EXCHG_ADD32 InterlockedExchangeAdd
|
||||
#define IL_COMP_EXCHG32 InterlockedCompareExchange
|
||||
#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
|
||||
#define IL_EXCHG32 InterlockedExchange
|
||||
#define IL_EXCHGptr InterlockedExchangePointer
|
||||
#define make_atomic_add_body(S) \
|
||||
v= IL_EXCHG_ADD ## S (a, v)
|
||||
#define make_atomic_cas_body(S) \
|
||||
int ## S initial_cmp= *cmp; \
|
||||
int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
|
||||
if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
|
||||
#define make_atomic_swap_body(S) \
|
||||
v= IL_EXCHG ## S (a, v)
|
||||
|
||||
/*
|
||||
my_yield_processor (equivalent of x86 PAUSE instruction) should be used
|
||||
to improve performance on hyperthreaded CPUs. Intel recommends to use it in
|
||||
spin loops also on non-HT machines to reduce power consumption (see e.g
|
||||
http://softwarecommunity.intel.com/articles/eng/2004.htm)
|
||||
|
||||
Running benchmarks for spinlocks implemented with InterlockedCompareExchange
|
||||
and YieldProcessor shows that much better performance is achieved by calling
|
||||
YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
|
||||
loop count in the range 200-300 brought best results.
|
||||
*/
|
||||
#ifndef YIELD_LOOPS
|
||||
#define YIELD_LOOPS 200
|
||||
#endif
|
||||
|
||||
static __inline int my_yield_processor()
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<YIELD_LOOPS; i++)
|
||||
{
|
||||
#if (_MSC_VER <= 1310)
|
||||
/* On older compilers YieldProcessor is not available, use inline assembly*/
|
||||
__asm { rep nop }
|
||||
#else
|
||||
YieldProcessor();
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LF_BACKOFF my_yield_processor()
|
||||
#else /* cleanup */
|
||||
|
||||
#undef IL_EXCHG_ADD32
|
||||
#undef IL_COMP_EXCHG32
|
||||
#undef IL_COMP_EXCHGptr
|
||||
#undef IL_EXCHG32
|
||||
#undef IL_EXCHGptr
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)
|
||||
#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__)
|
||||
|
||||
# ifdef MY_ATOMIC_MODE_DUMMY
|
||||
# define LOCK_prefix ""
|
||||
@ -24,14 +24,13 @@
|
||||
# ifdef __GNUC__
|
||||
# include "x86-gcc.h"
|
||||
# elif defined(_MSC_VER)
|
||||
# error Broken!
|
||||
# include "x86-msvc.h"
|
||||
# include "generic-msvc.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef make_atomic_cas_body
|
||||
|
||||
typedef struct { } my_atomic_rwlock_t __attribute__ ((unused));
|
||||
typedef char my_atomic_rwlock_t __attribute__ ((unused));
|
||||
#define my_atomic_rwlock_destroy(name)
|
||||
#define my_atomic_rwlock_init(name)
|
||||
#define my_atomic_rwlock_rdlock(name)
|
||||
|
@ -1,96 +0,0 @@
|
||||
/* Copyright (C) 2006 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 */
|
||||
|
||||
/*
|
||||
XXX 64-bit atomic operations can be implemented using
|
||||
cmpxchg8b, if necessary
|
||||
*/
|
||||
|
||||
// Would it be better to use intrinsics ?
|
||||
// (InterlockedCompareExchange, InterlockedCompareExchange16
|
||||
// InterlockedExchangeAdd, InterlockedExchange)
|
||||
|
||||
#ifndef _atomic_h_cleanup_
|
||||
#define _atomic_h_cleanup_ "atomic/x86-msvc.h"
|
||||
|
||||
#define MY_ATOMIC_MODE "msvc-x86" LOCK_prefix
|
||||
|
||||
#define make_atomic_add_body(S) \
|
||||
_asm { \
|
||||
_asm mov reg_ ## S, v \
|
||||
_asm LOCK_prefix xadd *a, reg_ ## S \
|
||||
_asm movzx v, reg_ ## S \
|
||||
}
|
||||
#define make_atomic_cas_body(S) \
|
||||
_asm { \
|
||||
_asm mov areg_ ## S, *cmp \
|
||||
_asm mov reg2_ ## S, set \
|
||||
_asm LOCK_prefix cmpxchg *a, reg2_ ## S \
|
||||
_asm mov *cmp, areg_ ## S \
|
||||
_asm setz al \
|
||||
_asm movzx ret, al \
|
||||
}
|
||||
#define make_atomic_fas_body(S) \
|
||||
_asm { \
|
||||
_asm mov reg_ ## S, v \
|
||||
_asm xchg *a, reg_ ## S \
|
||||
_asm mov v, reg_ ## S \
|
||||
}
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
#define make_atomic_load_body(S) ret=*a
|
||||
#define make_atomic_store_body(S) *a=v
|
||||
#else
|
||||
/*
|
||||
Actually 32-bit reads/writes are always atomic on x86
|
||||
But we add LOCK_prefix here anyway to force memory barriers
|
||||
*/
|
||||
#define make_atomic_load_body(S) \
|
||||
_asm { \
|
||||
_asm mov areg_ ## S, 0 \
|
||||
_asm mov reg2_ ## S, areg_ ## S \
|
||||
_asm LOCK_prefix cmpxchg *a, reg2_ ## S \
|
||||
_asm mov ret, areg_ ## S \
|
||||
}
|
||||
#define make_atomic_store_body(S) \
|
||||
_asm { \
|
||||
_asm mov reg_ ## S, v \
|
||||
_asm xchg *a, reg_ ## S \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define reg_8 al
|
||||
#define reg_16 ax
|
||||
#define reg_32 eax
|
||||
#define areg_8 al
|
||||
#define areg_16 ax
|
||||
#define areg_32 eax
|
||||
#define reg2_8 bl
|
||||
#define reg2_16 bx
|
||||
#define reg2_32 ebx
|
||||
|
||||
#else /* cleanup */
|
||||
|
||||
#undef reg_8
|
||||
#undef reg_16
|
||||
#undef reg_32
|
||||
#undef areg_8
|
||||
#undef areg_16
|
||||
#undef areg_32
|
||||
#undef reg2_8
|
||||
#undef reg2_16
|
||||
#undef reg2_32
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@ functions */
|
||||
#endif
|
||||
|
||||
#include <sys/locking.h>
|
||||
#include <sys/stat.h> /* chmod() constants*/
|
||||
#include <winsock2.h>
|
||||
#include <math.h> /* Because of rint() */
|
||||
#include <fcntl.h>
|
||||
@ -93,6 +94,15 @@ functions */
|
||||
|
||||
#define S_IROTH S_IREAD /* for my_lib */
|
||||
|
||||
/*
|
||||
Constants used by chmod. Note, that group/others is ignored
|
||||
- because unsupported by Windows due to different access control model.
|
||||
*/
|
||||
#define S_IRWXU S_IREAD|S_IWRITE
|
||||
#define S_IRWXG 0
|
||||
#define S_IRWXO 0
|
||||
typedef int mode_t;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
|
||||
#define O_TEMPORARY 0
|
||||
|
@ -45,6 +45,8 @@
|
||||
|
||||
On architectures where these operations are really atomic, rwlocks will
|
||||
be optimized away.
|
||||
8- and 16-bit atomics aren't implemented for windows (see generic-msvc.h),
|
||||
but can be added, if necessary.
|
||||
*/
|
||||
|
||||
#ifndef my_atomic_rwlock_init
|
||||
@ -56,15 +58,32 @@
|
||||
#endif
|
||||
|
||||
#ifndef make_atomic_cas_body
|
||||
/* nolock.h was not able to generate even a CAS function, fall back */
|
||||
#include "atomic/rwlock.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* define missing functions by using the already generated ones */
|
||||
#ifndef make_atomic_add_body
|
||||
#define make_atomic_add_body(S) \
|
||||
int ## S tmp=*a; \
|
||||
while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \
|
||||
v=tmp;
|
||||
#endif
|
||||
#ifndef make_atomic_fas_body
|
||||
#define make_atomic_fas_body(S) \
|
||||
int ## S tmp=*a; \
|
||||
while (!my_atomic_cas ## S(a, &tmp, v)); \
|
||||
v=tmp;
|
||||
#endif
|
||||
#ifndef make_atomic_load_body
|
||||
#define make_atomic_load_body(S) \
|
||||
ret= 0; /* avoid compiler warning */ \
|
||||
(void)(my_atomic_cas ## S(a, &ret, ret));
|
||||
#endif
|
||||
#ifndef make_atomic_store_body
|
||||
#define make_atomic_store_body(S) \
|
||||
(void)(my_atomic_fas ## S (a, v));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
transparent_union doesn't work in g++
|
||||
@ -122,6 +141,15 @@ make_transparent_unions(ptr)
|
||||
|
||||
#ifdef HAVE_INLINE
|
||||
|
||||
#define make_atomic_cas(S) \
|
||||
STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
|
||||
Uv_ ## S U_cmp, U_ ## S U_set) \
|
||||
{ \
|
||||
int8 ret; \
|
||||
make_atomic_cas_body(S); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define make_atomic_add(S) \
|
||||
STATIC_INLINE int ## S my_atomic_add ## S( \
|
||||
Uv_ ## S U_a, U_ ## S U_v) \
|
||||
@ -138,15 +166,6 @@ STATIC_INLINE int ## S my_atomic_fas ## S( \
|
||||
return v; \
|
||||
}
|
||||
|
||||
#define make_atomic_cas(S) \
|
||||
STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
|
||||
Uv_ ## S U_cmp, U_ ## S U_set) \
|
||||
{ \
|
||||
int8 ret; \
|
||||
make_atomic_cas_body(S); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define make_atomic_load(S) \
|
||||
STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
|
||||
{ \
|
||||
@ -181,30 +200,20 @@ extern void my_atomic_store ## S(Uv_ ## S, U_ ## S);
|
||||
|
||||
#endif
|
||||
|
||||
make_atomic_cas( 8)
|
||||
make_atomic_cas(16)
|
||||
make_atomic_cas(32)
|
||||
make_atomic_cas(ptr)
|
||||
|
||||
make_atomic_add( 8)
|
||||
make_atomic_add(16)
|
||||
make_atomic_add(32)
|
||||
|
||||
make_atomic_load( 8)
|
||||
make_atomic_load(16)
|
||||
make_atomic_load(32)
|
||||
make_atomic_load(ptr)
|
||||
|
||||
make_atomic_store( 8)
|
||||
make_atomic_store(16)
|
||||
make_atomic_store(32)
|
||||
make_atomic_store(ptr)
|
||||
|
||||
make_atomic_fas( 8)
|
||||
make_atomic_fas(16)
|
||||
make_atomic_fas(32)
|
||||
make_atomic_fas(ptr)
|
||||
|
||||
make_atomic_store(32)
|
||||
make_atomic_store(ptr)
|
||||
|
||||
#ifdef _atomic_h_cleanup_
|
||||
#include _atomic_h_cleanup_
|
||||
#undef _atomic_h_cleanup_
|
||||
|
@ -2,6 +2,7 @@
|
||||
Some useful bit functions
|
||||
*/
|
||||
|
||||
C_MODE_START
|
||||
#ifdef HAVE_INLINE
|
||||
|
||||
extern const char _my_bits_nbits[256];
|
||||
@ -105,3 +106,4 @@ uint32 my_reverse_bits(uint32 key);
|
||||
extern uint my_count_bits(ulonglong v);
|
||||
extern uint my_count_bits_ushort(ushort v);
|
||||
#endif
|
||||
C_MODE_END
|
||||
|
@ -125,6 +125,8 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define _REENTRANT 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
#define PTHREAD_STACK_MIN 65536
|
||||
|
||||
|
||||
/*
|
||||
Windows has two ways to use thread local storage. The most efficient
|
||||
@ -158,7 +160,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
|
||||
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
|
||||
#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
|
||||
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
|
||||
#define pthread_mutex_unlock(A) (LeaveCriticalSection(A),0)
|
||||
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
|
||||
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
|
||||
#define pthread_kill(A,B) pthread_dummy(ESRCH)
|
||||
|
@ -933,8 +933,11 @@ int my_getpagesize(void);
|
||||
int my_msync(int, void *, size_t, int);
|
||||
|
||||
#define MY_UUID_SIZE 16
|
||||
#define MY_UUID_STRING_LENGTH (8+1+4+1+4+1+4+1+12)
|
||||
|
||||
void my_uuid_init(ulong seed1, ulong seed2);
|
||||
void my_uuid(uchar *guid);
|
||||
void my_uuid2str(const uchar *guid, char *s);
|
||||
void my_uuid_end();
|
||||
|
||||
struct my_rnd_struct {
|
||||
|
@ -145,6 +145,13 @@ IF(WITH_CSV_STORAGE_ENGINE)
|
||||
ENDFOREACH(rpath)
|
||||
ENDIF(WITH_CSV_STORAGE_ENGINE)
|
||||
|
||||
IF(WITH_MARIA_STORAGE_ENGINE)
|
||||
INCLUDE(${CMAKE_SOURCE_DIR}/storage/maria/CMakeLists.txt)
|
||||
FOREACH(rpath ${MARIA_SOURCES})
|
||||
SET(LIB_SOURCES ${LIB_SOURCES} ../storage/maria/${rpath})
|
||||
ENDFOREACH(rpath)
|
||||
ENDIF(WITH_MARIA_STORAGE_ENGINE)
|
||||
|
||||
SET(SOURCE_SUBLIBS FALSE)
|
||||
|
||||
SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
|
||||
|
@ -31,7 +31,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
|
||||
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
|
||||
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_arr_appstr.c mf_tempdir.c
|
||||
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
|
||||
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
|
||||
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chmod.c my_chsize.c
|
||||
my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
|
||||
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
|
||||
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
|
||||
@ -41,7 +41,11 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
|
||||
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
|
||||
my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c
|
||||
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
|
||||
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c)
|
||||
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
|
||||
lf_alloc-pin.c lf_dynarray.c lf_hash.c
|
||||
my_atomic.c my_getncpus.c my_rnd.c
|
||||
my_uuid.c wqueue.c
|
||||
)
|
||||
|
||||
IF(NOT SOURCE_SUBLIBS)
|
||||
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
|
||||
|
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include <strings.h>
|
||||
#include <m_string.h>
|
||||
#include <my_sys.h>
|
||||
#include <lf.h>
|
||||
|
||||
@ -123,7 +123,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
||||
}
|
||||
if (!(ptr= *ptr_ptr))
|
||||
{
|
||||
void *alloc, *data;
|
||||
uchar *alloc, *data;
|
||||
alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
|
||||
max(array->size_of_element, sizeof(void *)),
|
||||
MYF(MY_WME|MY_ZEROFILL));
|
||||
@ -142,7 +142,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
||||
else
|
||||
my_free(alloc, MYF(0));
|
||||
}
|
||||
return ptr + array->size_of_element * idx;
|
||||
return ((uchar*)ptr) + array->size_of_element * idx;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -167,7 +167,7 @@ void *_lf_dynarray_value(LF_DYNARRAY *array, uint idx)
|
||||
}
|
||||
if (!(ptr= *ptr_ptr))
|
||||
return(NULL);
|
||||
return ptr + array->size_of_element * idx;
|
||||
return ((uchar*)ptr) + array->size_of_element * idx;
|
||||
}
|
||||
|
||||
static int recursive_iterate(LF_DYNARRAY *array, void *ptr, int level,
|
||||
|
@ -16,24 +16,26 @@
|
||||
/* get the number of (online) CPUs */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static int ncpus=0;
|
||||
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
int my_getncpus()
|
||||
{
|
||||
if (!ncpus)
|
||||
{
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
ncpus= sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined(__WIN__)
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
ncpus= sysinfo.dwNumberOfProcessors;
|
||||
#else
|
||||
/* unknown so play safe: assume SMP and forbid uniprocessor build */
|
||||
ncpus= 2;
|
||||
#endif
|
||||
}
|
||||
return ncpus;
|
||||
}
|
||||
|
||||
#else
|
||||
/* unknown */
|
||||
int my_getncpus()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include <m_string.h>
|
||||
#include <myisampack.h> /* mi_int2store, mi_int4store */
|
||||
|
||||
static my_bool my_uuid_inited= 0;
|
||||
static struct my_rnd_struct uuid_rand;
|
||||
@ -67,7 +68,7 @@ pthread_mutex_t LOCK_uuid_generator;
|
||||
static void set_clock_seq()
|
||||
{
|
||||
uint16 clock_seq= ((uint)(my_rnd(&uuid_rand)*16383)) | UUID_VARIANT;
|
||||
int2store(uuid_suffix, clock_seq);
|
||||
mi_int2store(uuid_suffix, clock_seq);
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +106,7 @@ void my_uuid_init(ulong seed1, ulong seed2)
|
||||
randominit() here.
|
||||
*/
|
||||
/* purecov: begin inspected */
|
||||
my_rnd_init(&uuid_rand, (ulong) (seed2+ now/2), now+random());
|
||||
my_rnd_init(&uuid_rand, (ulong) (seed2+ now/2), now+rand());
|
||||
for (i=0; i < sizeof(mac); i++)
|
||||
mac[i]= (uchar)(my_rnd(&uuid_rand)*255);
|
||||
/* purecov: end */
|
||||
@ -160,14 +161,35 @@ void my_uuid(uchar *to)
|
||||
Note, that the standard does NOT specify byte ordering in
|
||||
multi-byte fields. it's implementation defined (but must be
|
||||
the same for all fields).
|
||||
We use big-endian, so we can use memcmp() to compare UUIDs
|
||||
and for straightforward UUID to string conversion.
|
||||
*/
|
||||
int4store(to, time_low);
|
||||
int2store(to+4, time_mid);
|
||||
int2store(to+6, time_hi_and_version);
|
||||
mi_int4store(to, time_low);
|
||||
mi_int2store(to+4, time_mid);
|
||||
mi_int2store(to+6, time_hi_and_version);
|
||||
bmove(to+8, uuid_suffix, sizeof(uuid_suffix));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert uuid to string representation
|
||||
|
||||
@func my_uuid2str()
|
||||
@param guid uuid
|
||||
@param s Output buffer.Must be at least MY_UUID_STRING_LENGTH+1 large.
|
||||
*/
|
||||
void my_uuid2str(const uchar *guid, char *s)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < MY_UUID_SIZE; i++)
|
||||
{
|
||||
*s++= _dig_vec_lower[guid[i] >>4];
|
||||
*s++= _dig_vec_lower[guid[i] & 15];
|
||||
if(i == 4 || i == 6 || i == 8 || i == 10)
|
||||
*s++= '-';
|
||||
}
|
||||
}
|
||||
|
||||
void my_uuid_end()
|
||||
{
|
||||
if (my_uuid_inited)
|
||||
|
@ -77,12 +77,15 @@ pthread_handler_t pthread_start(void *param)
|
||||
{
|
||||
pthread_handler func=((struct pthread_map *) param)->func;
|
||||
void *func_param=((struct pthread_map *) param)->param;
|
||||
void *result;
|
||||
my_thread_init(); /* Will always succeed in windows */
|
||||
pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */
|
||||
win_pthread_self=((struct pthread_map *) param)->pthreadself;
|
||||
pthread_mutex_unlock(&THR_LOCK_thread);
|
||||
free((char*) param); /* Free param from create */
|
||||
pthread_exit((void*) (*func)(func_param));
|
||||
result= (void*) (*func)(func_param);
|
||||
my_thread_end();
|
||||
pthread_exit(result);
|
||||
return 0; /* Safety */
|
||||
}
|
||||
|
||||
@ -92,21 +95,28 @@ int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
|
||||
{
|
||||
HANDLE hThread;
|
||||
struct pthread_map *map;
|
||||
DWORD StackSize= 0;
|
||||
int priority= 0;
|
||||
DBUG_ENTER("pthread_create");
|
||||
|
||||
if (!(map=malloc(sizeof(*map))))
|
||||
DBUG_RETURN(-1);
|
||||
map->func=func;
|
||||
map->param=param;
|
||||
if (attr != NULL)
|
||||
{
|
||||
StackSize= attr->dwStackSize;
|
||||
priority= attr->priority;
|
||||
}
|
||||
if (StackSize == 0)
|
||||
StackSize= PTHREAD_STACK_MIN;
|
||||
pthread_mutex_lock(&THR_LOCK_thread);
|
||||
#ifdef __BORLANDC__
|
||||
hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start,
|
||||
attr->dwStackSize ? attr->dwStackSize :
|
||||
65535, (void*) map);
|
||||
StackSize, (void*) map);
|
||||
#else
|
||||
hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start,
|
||||
attr->dwStackSize ? attr->dwStackSize :
|
||||
65535, (void*) map);
|
||||
StackSize, (void*) map);
|
||||
#endif
|
||||
DBUG_PRINT("info", ("hThread=%lu",(long) hThread));
|
||||
*thread_id=map->pthreadself=hThread;
|
||||
@ -119,7 +129,7 @@ int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
|
||||
("Can't create thread to handle request (error %d)",error));
|
||||
DBUG_RETURN(error ? error : -1);
|
||||
}
|
||||
VOID(SetThreadPriority(hThread, attr->priority)) ;
|
||||
VOID(SetThreadPriority(hThread, priority)) ;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,9 @@ ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
|
||||
IF(WITH_INNOBASE_STORAGE_ENGINE)
|
||||
TARGET_LINK_LIBRARIES(mysqld innobase)
|
||||
ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
|
||||
IF(WITH_MARIA_STORAGE_ENGINE)
|
||||
TARGET_LINK_LIBRARIES(mysqld maria)
|
||||
ENDIF(WITH_MARIA_STORAGE_ENGINE)
|
||||
|
||||
ADD_DEPENDENCIES(mysqld GenError)
|
||||
|
||||
|
@ -5652,12 +5652,13 @@ void uuid_short_init()
|
||||
(((ulonglong) server_start_time) << 24));
|
||||
}
|
||||
|
||||
pthread_mutex_t LOCK_uuid_short;
|
||||
|
||||
longlong Item_func_uuid_short::val_int()
|
||||
{
|
||||
ulonglong val;
|
||||
pthread_mutex_lock(&LOCK_uuid_generator);
|
||||
pthread_mutex_lock(&LOCK_uuid_short);
|
||||
val= uuid_value++;
|
||||
pthread_mutex_unlock(&LOCK_uuid_generator);
|
||||
pthread_mutex_unlock(&LOCK_uuid_short);
|
||||
return (longlong) val;
|
||||
}
|
||||
|
@ -3347,115 +3347,17 @@ err:
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
UUID, as in
|
||||
DCE 1.1: Remote Procedure Call,
|
||||
Open Group Technical Standard Document Number C706, October 1997,
|
||||
(supersedes C309 DCE: Remote Procedure Call 8/1994,
|
||||
which was basis for ISO/IEC 11578:1996 specification)
|
||||
*/
|
||||
|
||||
static struct my_rnd_struct uuid_rand;
|
||||
static uint nanoseq;
|
||||
static ulonglong uuid_time=0;
|
||||
static char clock_seq_and_node_str[]="-0000-000000000000";
|
||||
|
||||
/**
|
||||
number of 100-nanosecond intervals between
|
||||
1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00.
|
||||
*/
|
||||
#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * 1000 * 10 )
|
||||
|
||||
#define UUID_VERSION 0x1000
|
||||
#define UUID_VARIANT 0x8000
|
||||
|
||||
static void tohex(char *to, uint from, uint len)
|
||||
{
|
||||
to+= len;
|
||||
while (len--)
|
||||
{
|
||||
*--to= _dig_vec_lower[from & 15];
|
||||
from >>= 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_clock_seq_str()
|
||||
{
|
||||
uint16 clock_seq= ((uint)(my_rnd(&uuid_rand)*16383)) | UUID_VARIANT;
|
||||
tohex(clock_seq_and_node_str+1, clock_seq, 4);
|
||||
nanoseq= 0;
|
||||
}
|
||||
|
||||
String *Item_func_uuid::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
char *s;
|
||||
THD *thd= current_thd;
|
||||
uchar guid[MY_UUID_SIZE];
|
||||
|
||||
pthread_mutex_lock(&LOCK_uuid_generator);
|
||||
if (! uuid_time) /* first UUID() call. initializing data */
|
||||
{
|
||||
ulong tmp=sql_rnd_with_mutex();
|
||||
uchar mac[6];
|
||||
int i;
|
||||
if (my_gethwaddr(mac))
|
||||
{
|
||||
/* purecov: begin inspected */
|
||||
/*
|
||||
generating random "hardware addr"
|
||||
and because specs explicitly specify that it should NOT correlate
|
||||
with a clock_seq value (initialized random below), we use a separate
|
||||
my_rnd_init() here
|
||||
*/
|
||||
my_rnd_init(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)global_query_id);
|
||||
for (i=0; i < (int)sizeof(mac); i++)
|
||||
mac[i]=(uchar)(my_rnd(&uuid_rand)*255);
|
||||
/* purecov: end */
|
||||
}
|
||||
s=clock_seq_and_node_str+sizeof(clock_seq_and_node_str)-1;
|
||||
for (i=sizeof(mac)-1 ; i>=0 ; i--)
|
||||
{
|
||||
*--s=_dig_vec_lower[mac[i] & 15];
|
||||
*--s=_dig_vec_lower[mac[i] >> 4];
|
||||
}
|
||||
my_rnd_init(&uuid_rand, tmp + (ulong) server_start_time,
|
||||
tmp + (ulong) thd->status_var.bytes_sent);
|
||||
set_clock_seq_str();
|
||||
}
|
||||
|
||||
ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
|
||||
if (unlikely(tv < uuid_time))
|
||||
set_clock_seq_str();
|
||||
else if (unlikely(tv == uuid_time))
|
||||
{
|
||||
/* special protection from low-res system clocks */
|
||||
nanoseq++;
|
||||
tv++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nanoseq)
|
||||
{
|
||||
tv-=nanoseq;
|
||||
nanoseq=0;
|
||||
}
|
||||
DBUG_ASSERT(tv > uuid_time);
|
||||
}
|
||||
uuid_time=tv;
|
||||
pthread_mutex_unlock(&LOCK_uuid_generator);
|
||||
|
||||
uint32 time_low= (uint32) (tv & 0xFFFFFFFF);
|
||||
uint16 time_mid= (uint16) ((tv >> 32) & 0xFFFF);
|
||||
uint16 time_hi_and_version= (uint16) ((tv >> 48) | UUID_VERSION);
|
||||
|
||||
str->realloc(UUID_LENGTH+1);
|
||||
str->length(UUID_LENGTH);
|
||||
str->realloc(MY_UUID_STRING_LENGTH+1);
|
||||
str->length(MY_UUID_STRING_LENGTH);
|
||||
str->set_charset(system_charset_info);
|
||||
s=(char *) str->ptr();
|
||||
s[8]=s[13]='-';
|
||||
tohex(s, time_low, 8);
|
||||
tohex(s+9, time_mid, 4);
|
||||
tohex(s+14, time_hi_and_version, 4);
|
||||
strmov(s+18, clock_seq_and_node_str);
|
||||
my_uuid(guid);
|
||||
my_uuid2str(guid, (char *)str->ptr());
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ public:
|
||||
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
|
||||
};
|
||||
|
||||
#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
|
||||
|
||||
class Item_func_uuid: public Item_str_func
|
||||
{
|
||||
public:
|
||||
@ -827,7 +827,7 @@ public:
|
||||
charset when hex(), format(), md5(), etc, and implicit
|
||||
number-to-string conversion will use 'ascii'
|
||||
*/
|
||||
max_length= UUID_LENGTH * system_charset_info->mbmaxlen;
|
||||
max_length= MY_UUID_STRING_LENGTH * system_charset_info->mbmaxlen;
|
||||
}
|
||||
const char *func_name() const{ return "uuid"; }
|
||||
String *val_str(String *);
|
||||
|
@ -1914,7 +1914,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
|
||||
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
|
||||
LOCK_global_system_variables, LOCK_user_conn,
|
||||
LOCK_prepared_stmt_count,
|
||||
LOCK_bytes_sent, LOCK_bytes_received;
|
||||
LOCK_bytes_sent, LOCK_bytes_received, LOCK_uuid_short;
|
||||
#ifdef HAVE_OPENSSL
|
||||
extern pthread_mutex_t LOCK_des_key_file;
|
||||
#endif
|
||||
|
@ -1346,6 +1346,7 @@ static void clean_up_mutexes()
|
||||
(void) rwlock_destroy(&LOCK_sys_init_connect);
|
||||
(void) rwlock_destroy(&LOCK_sys_init_slave);
|
||||
(void) pthread_mutex_destroy(&LOCK_global_system_variables);
|
||||
(void) pthread_mutex_destroy(&LOCK_uuid_short);
|
||||
(void) rwlock_destroy(&LOCK_system_variables_hash);
|
||||
(void) pthread_mutex_destroy(&LOCK_global_read_lock);
|
||||
(void) pthread_mutex_destroy(&LOCK_prepared_stmt_count);
|
||||
@ -3278,6 +3279,7 @@ static int init_thread_environment()
|
||||
(void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
|
||||
(void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_uuid_short, MY_MUTEX_INIT_FAST);
|
||||
#ifdef HAVE_OPENSSL
|
||||
(void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST);
|
||||
#ifndef HAVE_YASSL
|
||||
|
@ -21,38 +21,61 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
|
||||
${CMAKE_SOURCE_DIR}/sql
|
||||
${CMAKE_SOURCE_DIR}/regex
|
||||
${CMAKE_SOURCE_DIR}/extra/yassl/include)
|
||||
SET(MARIA_SOURCES ft_maria.c ha_maria.cc lockman.c ma_bitmap.c ma_blockrec.c
|
||||
ma_cache.c ma_changed.c ma_check.c ma_checkpoint.c ma_checksum.c
|
||||
ma_close.c ma_commit.c ma_control_file.c ma_create.c ma_dbug.c
|
||||
ma_delete.c ma_delete_all.c ma_delete_table.c ma_dynrec.c
|
||||
ma_extra.c ma_ft_boolean_search.c ma_ft_eval.c ma_ft_nlq_search.c
|
||||
ma_ft_parser.c ma_ft_stem.c ma_ft_test1.c ma_ft_update.c ma_info.c
|
||||
ma_init.c ma_key.c ma_keycache.c ma_least_recently_dirtied.c
|
||||
ma_locking.c ma_loghandler.c ma_open.c ma_packrec.c ma_page.c
|
||||
ma_pagecache.c ma_pagecaches.c ma_panic.c ma_preload.c ma_range.c
|
||||
ma_recovery.c ma_rename.c ma_rfirst.c ma_rkey.c ma_rlast.c
|
||||
ma_rnext.c ma_rnext_same.c ma_rprev.c ma_rrnd.c ma_rsame.c
|
||||
ma_rsamepos.c ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
|
||||
ma_rt_test.c ma_scan.c ma_search.c ma_sort.c ma_sp_key.c
|
||||
ma_sp_test.c ma_static.c ma_statrec.c
|
||||
ma_unique.c ma_update.c ma_write.c tablockman.c trnman.c
|
||||
ha_maria.h maria_def.h)
|
||||
SET(MARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
|
||||
ma_rnext.c ma_rnext_same.c
|
||||
ma_search.c ma_page.c ma_key_recover.c ma_key.c
|
||||
ma_locking.c
|
||||
ma_rrnd.c ma_scan.c ma_cache.c
|
||||
ma_statrec.c ma_packrec.c ma_dynrec.c
|
||||
ma_blockrec.c ma_bitmap.c
|
||||
ma_update.c ma_write.c ma_unique.c
|
||||
ma_delete.c
|
||||
ma_rprev.c ma_rfirst.c ma_rlast.c ma_rsame.c
|
||||
ma_rsamepos.c ma_panic.c ma_close.c ma_create.c
|
||||
ma_range.c ma_dbug.c ma_checksum.c
|
||||
ma_changed.c ma_static.c ma_delete_all.c
|
||||
ma_delete_table.c ma_rename.c ma_check.c
|
||||
ma_keycache.c ma_preload.c ma_ft_parser.c
|
||||
ma_ft_update.c ma_ft_boolean_search.c
|
||||
ma_ft_nlq_search.c ft_maria.c ma_sort.c
|
||||
ha_maria.cc trnman.c lockman.c tablockman.c
|
||||
ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
|
||||
ma_sp_key.c ma_control_file.c ma_loghandler.c
|
||||
ma_pagecache.c ma_pagecaches.c
|
||||
ma_checkpoint.c ma_recovery.c ma_commit.c ma_pagecrc.c
|
||||
ha_maria.h maria_def.h
|
||||
)
|
||||
|
||||
IF(NOT SOURCE_SUBLIBS)
|
||||
|
||||
ADD_LIBRARY(maria ${MARIA_SOURCES})
|
||||
|
||||
ADD_EXECUTABLE(maria_ftdump maria_ftdump.c)
|
||||
TARGET_LINK_LIBRARIES(maria_ftdump maria myisam mysys debug dbug strings zlib wsock32)
|
||||
TARGET_LINK_LIBRARIES(maria_ftdump maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(maria_chk maria_chk.c)
|
||||
TARGET_LINK_LIBRARIES(maria_chk maria myisam mysys debug dbug strings zlib wsock32)
|
||||
TARGET_LINK_LIBRARIES(maria_chk maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(maria_read_log maria_read_log.c)
|
||||
TARGET_LINK_LIBRARIES(maria_read_log maria myisam mysys debug dbug strings zlib wsock32)
|
||||
TARGET_LINK_LIBRARIES(maria_read_log maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(maria_pack maria_pack.c)
|
||||
TARGET_LINK_LIBRARIES(maria_pack maria myisam mysys debug dbug strings zlib wsock32)
|
||||
TARGET_LINK_LIBRARIES(maria_pack maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(ma_test1 ma_test1.c)
|
||||
TARGET_LINK_LIBRARIES(ma_test1 maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(ma_test2 ma_test2.c)
|
||||
TARGET_LINK_LIBRARIES(ma_test2 maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(ma_test3 ma_test3.c)
|
||||
TARGET_LINK_LIBRARIES(ma_test3 maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(ma_rt_test ma_rt_test.c)
|
||||
TARGET_LINK_LIBRARIES(ma_rt_test maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(ma_sp_test ma_sp_test.c)
|
||||
TARGET_LINK_LIBRARIES(ma_sp_test maria myisam mysys dbug strings zlib wsock32)
|
||||
|
||||
IF(EMBED_MANIFESTS)
|
||||
MYSQL_EMBED_MANIFEST("maria_ftdump" "asInvoker")
|
||||
|
@ -2586,7 +2586,7 @@ bool maria_show_status(handlerton *hton,
|
||||
{
|
||||
status= error;
|
||||
status_len= sizeof(error);
|
||||
length= snprintf(object, SHOW_MSG_LEN, "Size unknown ; %s", file);
|
||||
length= my_snprintf(object, SHOW_MSG_LEN, "Size unknown ; %s", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2605,7 +2605,7 @@ bool maria_show_status(handlerton *hton,
|
||||
status= needed;
|
||||
status_len= sizeof(needed);
|
||||
}
|
||||
length= snprintf(object, SHOW_MSG_LEN, "Size %12lu ; %s",
|
||||
length= my_snprintf(object, SHOW_MSG_LEN, "Size %12lu ; %s",
|
||||
(ulong) stat->st_size, file);
|
||||
}
|
||||
|
||||
|
@ -690,8 +690,7 @@ enum lockman_getlock_result lockman_getlock(LOCKMAN *lm, LOCK_OWNER *lo,
|
||||
|
||||
/* yuck. waiting */
|
||||
deadline= my_getsystime() + lm->lock_timeout * 10000;
|
||||
timeout.tv_sec= deadline/10000000;
|
||||
timeout.tv_nsec= (deadline % 10000000) * 100;
|
||||
set_timespec_nsec(timeout,lm->lock_timeout * 1000000);
|
||||
do
|
||||
{
|
||||
pthread_cond_timedwait(wait_for_lo->cond, wait_for_lo->mutex, &timeout);
|
||||
|
@ -4362,8 +4362,8 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
|
||||
case DYNAMIC_RECORD:
|
||||
{
|
||||
uchar *to;
|
||||
LINT_INIT(to);
|
||||
ha_checksum checksum= 0;
|
||||
LINT_INIT(to);
|
||||
|
||||
pos=sort_param->pos;
|
||||
searching=(sort_param->fix_datafile && (param->testflag & T_EXTEND));
|
||||
|
@ -18,6 +18,17 @@
|
||||
#include "ma_blockrec.h" /* for some constants and in-write hooks */
|
||||
#include "ma_key_recover.h" /* For some in-write hooks */
|
||||
|
||||
/*
|
||||
On Windows, neither my_open() nor my_sync() work for directories.
|
||||
Also there is no need to flush filesystem changes ,i.e to sync()
|
||||
directories.
|
||||
*/
|
||||
#ifdef __WIN__
|
||||
#define sync_dir(A,B) 0
|
||||
#else
|
||||
#define sync_dir(A,B) my_sync(A,B)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@file
|
||||
@brief Module which writes and reads to a transaction log
|
||||
@ -788,7 +799,7 @@ static File create_logfile_by_number_no_cache(uint32 file_no)
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
if (sync_log_dir >= TRANSLOG_SYNC_DIR_NEWFILE &&
|
||||
my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD)))
|
||||
sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD)))
|
||||
{
|
||||
DBUG_PRINT("error", ("Error %d during syncing directory '%s'",
|
||||
errno, log_descriptor.directory));
|
||||
@ -1116,11 +1127,11 @@ static void translog_mark_file_unfinished(uint32 file)
|
||||
{
|
||||
int place, i;
|
||||
struct st_file_counter fc, *fc_ptr;
|
||||
fc.file= file; fc.counter= 1;
|
||||
|
||||
DBUG_ENTER("translog_mark_file_unfinished");
|
||||
DBUG_PRINT("enter", ("file: %lu", (ulong) file));
|
||||
|
||||
fc.file= file; fc.counter= 1;
|
||||
pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
|
||||
|
||||
if (log_descriptor.unfinished_files.elements == 0)
|
||||
@ -2447,7 +2458,7 @@ translog_check_sector_protection(uchar *page, TRANSLOG_FILE *file)
|
||||
{
|
||||
uint i, offset;
|
||||
uchar *table= page + page_overhead[page[TRANSLOG_PAGE_FLAGS]] -
|
||||
TRANSLOG_PAGE_SIZE / DISK_DRIVE_SECTOR_SIZE; ;
|
||||
TRANSLOG_PAGE_SIZE / DISK_DRIVE_SECTOR_SIZE;
|
||||
uint8 current= table[0];
|
||||
DBUG_ENTER("translog_check_sector_protection");
|
||||
|
||||
@ -2989,7 +3000,7 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr)
|
||||
my_sync(fd, MYF(MY_WME)) ||
|
||||
my_close(fd, MYF(MY_WME)) ||
|
||||
(sync_log_dir >= TRANSLOG_SYNC_DIR_ALWAYS &&
|
||||
my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD))))
|
||||
sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD))))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
/* fix the horizon */
|
||||
@ -3121,7 +3132,7 @@ my_bool translog_init_with_table(const char *directory,
|
||||
|
||||
/* Directory to store files */
|
||||
unpack_dirname(log_descriptor.directory, directory);
|
||||
|
||||
#ifndef __WIN__
|
||||
if ((log_descriptor.directory_fd= my_open(log_descriptor.directory,
|
||||
O_RDONLY, MYF(MY_WME))) < 0)
|
||||
{
|
||||
@ -3130,7 +3141,7 @@ my_bool translog_init_with_table(const char *directory,
|
||||
errno, log_descriptor.directory));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
log_descriptor.in_buffers_only= LSN_IMPOSSIBLE;
|
||||
DBUG_ASSERT(log_file_max_size % TRANSLOG_PAGE_SIZE == 0 &&
|
||||
log_file_max_size >= TRANSLOG_MIN_FILE_SIZE);
|
||||
@ -3596,7 +3607,7 @@ my_bool translog_init_with_table(const char *directory,
|
||||
if (unlikely(LSN_OFFSET(page_addr) == TRANSLOG_PAGE_SIZE))
|
||||
{
|
||||
uint32 file_no= LSN_FILE_NO(page_addr);
|
||||
bool last_page_ok;
|
||||
my_bool last_page_ok;
|
||||
/* it is beginning of the current file */
|
||||
if (unlikely(file_no == 1))
|
||||
{
|
||||
@ -5155,9 +5166,9 @@ translog_write_variable_record_mgroup(LSN *lsn,
|
||||
}
|
||||
else if (chunk3_pages)
|
||||
{
|
||||
uchar chunk3_header[3];
|
||||
DBUG_PRINT("info", ("chunk 3"));
|
||||
DBUG_ASSERT(full_pages == 0);
|
||||
uchar chunk3_header[3];
|
||||
chunk3_pages= 0;
|
||||
chunk3_header[0]= TRANSLOG_CHUNK_LNGTH;
|
||||
int2store(chunk3_header + 1, chunk3_size);
|
||||
@ -6491,9 +6502,9 @@ int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
|
||||
{
|
||||
uint8 chunk_type;
|
||||
translog_size_t res;
|
||||
buff->groups_no= 0; /* to be sure that we will free it right */
|
||||
|
||||
DBUG_ENTER("translog_read_next_record_header");
|
||||
buff->groups_no= 0; /* to be sure that we will free it right */
|
||||
DBUG_PRINT("enter", ("scanner: 0x%lx", (ulong) scanner));
|
||||
DBUG_PRINT("info", ("Scanner: Cur: (%lu,0x%lx) Hrz: (%lu,0x%lx) "
|
||||
"Lst: (%lu,0x%lx) Offset: %u(%x) fixed: %d",
|
||||
@ -7088,7 +7099,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
|
||||
((LSN_OFFSET(log_descriptor.previous_flush_horizon) - 1) /
|
||||
TRANSLOG_PAGE_SIZE) !=
|
||||
((LSN_OFFSET(flush_horizon) - 1) / TRANSLOG_PAGE_SIZE)))
|
||||
rc|= my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
|
||||
rc|= sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
|
||||
log_descriptor.previous_flush_horizon= flush_horizon;
|
||||
out:
|
||||
pthread_mutex_unlock(&log_descriptor.log_flush_lock);
|
||||
@ -7125,6 +7136,9 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
|
||||
pthread_mutex_lock(&share->intern_lock);
|
||||
if (likely(share->id == 0))
|
||||
{
|
||||
LSN lsn;
|
||||
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2];
|
||||
uchar log_data[FILEID_STORE_SIZE];
|
||||
/* Inspired by set_short_trid() of trnman.c */
|
||||
uint i= share->kfile.file % SHARE_ID_MAX + 1;
|
||||
do
|
||||
@ -7144,9 +7158,6 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
|
||||
i= 1; /* scan the whole array */
|
||||
} while (share->id == 0);
|
||||
DBUG_PRINT("info", ("id_to_share: 0x%lx -> %u", (ulong)share, share->id));
|
||||
LSN lsn;
|
||||
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2];
|
||||
uchar log_data[FILEID_STORE_SIZE];
|
||||
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
|
||||
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
|
||||
/*
|
||||
|
@ -2859,9 +2859,10 @@ static LSN parse_checkpoint_record(LSN lsn)
|
||||
{
|
||||
pgcache_page_no_t page_id;
|
||||
LSN rec_lsn;
|
||||
uint32 is_index;
|
||||
uint16 table_id= uint2korr(ptr);
|
||||
ptr+= 2;
|
||||
uint32 is_index= ptr[0];
|
||||
is_index= ptr[0];
|
||||
ptr++;
|
||||
page_id= uint4korr(ptr);
|
||||
ptr+= 4;
|
||||
|
@ -45,7 +45,7 @@ static void put_blob_in_record(uchar *blob_pos,char **blob_buffer,
|
||||
static void copy_key(MARIA_HA *info, uint inx, uchar *record, uchar *key);
|
||||
|
||||
static int verbose= 0, testflag= 0, first_key= 0, async_io= 0, pagecacheing= 0;
|
||||
static int write_cacheing= 0, locking= 0, rec_pointer_size= 0, pack_fields= 1;
|
||||
static int write_cacheing= 0, do_locking= 0, rec_pointer_size= 0, pack_fields= 1;
|
||||
static int silent= 0, opt_quick_mode= 0, transactional= 0, skip_update= 0;
|
||||
static int die_in_middle_of_transaction= 0;
|
||||
static int pack_seg= HA_SPACE_PACK, pack_type= HA_PACK_KEY, remove_count= -1;
|
||||
@ -242,7 +242,7 @@ int main(int argc, char *argv[])
|
||||
goto err;
|
||||
if (!silent)
|
||||
printf("- Writing key:s\n");
|
||||
if (locking)
|
||||
if (do_locking)
|
||||
maria_lock_database(file,F_WRLCK);
|
||||
if (write_cacheing)
|
||||
maria_extra(file,HA_EXTRA_WRITE_CACHE,0);
|
||||
@ -316,7 +316,10 @@ int main(int argc, char *argv[])
|
||||
printf("- Delete\n");
|
||||
if (srand_arg)
|
||||
srand(srand_arg);
|
||||
for (i=0 ; i<recant/10 ; i++)
|
||||
if (!update_count)
|
||||
update_count= recant/10;
|
||||
|
||||
for (i=0 ; i < update_count ; i++)
|
||||
{
|
||||
for (j=rnd(1000)+1 ; j>0 && key1[j] == 0 ; j--) ;
|
||||
if (j != 0)
|
||||
@ -453,8 +456,9 @@ int main(int argc, char *argv[])
|
||||
goto err;
|
||||
}
|
||||
{
|
||||
int skr;
|
||||
info.recpos= maria_position(file);
|
||||
int skr=maria_rnext(file,read_record2,0);
|
||||
skr= maria_rnext(file,read_record2,0);
|
||||
if ((skr && my_errno != HA_ERR_END_OF_FILE) ||
|
||||
maria_rprev(file,read_record2,0) ||
|
||||
memcmp(read_record,read_record2,reclength) != 0 ||
|
||||
@ -784,7 +788,7 @@ int main(int argc, char *argv[])
|
||||
printf("- maria_extra(CACHE) + maria_rrnd.... + maria_extra(NO_CACHE)\n");
|
||||
if (maria_reset(file) || maria_extra(file,HA_EXTRA_CACHE,0))
|
||||
{
|
||||
if (locking || (!use_blob && !pack_fields))
|
||||
if (do_locking || (!use_blob && !pack_fields))
|
||||
{
|
||||
puts("got error from maria_extra(HA_EXTRA_CACHE)");
|
||||
goto err;
|
||||
@ -963,9 +967,9 @@ end:
|
||||
puts("Write cacheing used");
|
||||
if (write_cacheing)
|
||||
puts("quick mode");
|
||||
if (async_io && locking)
|
||||
if (async_io && do_locking)
|
||||
puts("Asyncron io with locking used");
|
||||
else if (locking)
|
||||
else if (do_locking)
|
||||
puts("Locking used");
|
||||
if (use_blob)
|
||||
puts("blobs used");
|
||||
@ -1036,7 +1040,7 @@ static void get_options(int argc, char **argv)
|
||||
srand(srand_arg= atoi(pos));
|
||||
break;
|
||||
case 'L':
|
||||
locking=1;
|
||||
do_locking=1;
|
||||
break;
|
||||
case 'a': /* use asyncron io */
|
||||
async_io=1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/* Test av locking */
|
||||
|
||||
#ifndef __NETWARE__
|
||||
#if !(defined (__NETWARE_) || defined (_WIN32)) /*no fork() in Windows*/
|
||||
|
||||
#include "maria.h"
|
||||
#include <sys/types.h>
|
||||
@ -488,14 +488,14 @@ int test_update(MARIA_HA *file,int id,int lock_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* __NETWARE__ */
|
||||
#else /* __NETWARE__ || __WIN__ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
fprintf(stderr,"this test has not been ported to NetWare\n");
|
||||
fprintf(stderr,"this test has not been ported to Netware or Windows\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __NETWARE__ */
|
||||
#endif /* __NETWARE__|| __WIN__ */
|
||||
|
@ -273,7 +273,6 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
|
||||
{
|
||||
TABLE_LOCK *old, *new, *blocker, *blocker2;
|
||||
TABLE_LOCK_OWNER *wait_for;
|
||||
ulonglong deadline;
|
||||
struct timespec timeout;
|
||||
enum lockman_lock_type new_lock;
|
||||
enum lockman_getlock_result res;
|
||||
@ -434,9 +433,8 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
|
||||
}
|
||||
lo->waiting_lock= new;
|
||||
|
||||
deadline= my_getsystime() + lm->lock_timeout * 10000;
|
||||
timeout.tv_sec= deadline/10000000;
|
||||
timeout.tv_nsec= (deadline % 10000000) * 100;
|
||||
set_timespec_nsec(timeout,lm->lock_timeout * 1000000);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
97
storage/maria/unittest/CMakeLists.txt
Normal file
97
storage/maria/unittest/CMakeLists.txt
Normal file
@ -0,0 +1,97 @@
|
||||
# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
|
||||
${CMAKE_SOURCE_DIR}/unittest/mytap)
|
||||
LINK_LIBRARIES(maria myisam mytap mysys dbug strings wsock32 zlib)
|
||||
|
||||
ADD_EXECUTABLE(ma_test_loghandler_t
|
||||
ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_multigroup_t
|
||||
ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_multithread_t
|
||||
ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_pagecache_t
|
||||
ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_long_t_big
|
||||
ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
SET_TARGET_PROPERTIES(ma_test_loghandler_long_t_big PROPERTIES COMPILE_FLAGS "-DLONG_LOG_TEST")
|
||||
|
||||
ADD_EXECUTABLE(ma_test_loghandler_noflush_t
|
||||
ma_test_loghandler_noflush-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_first_lsn_t
|
||||
ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_max_lsn_t
|
||||
ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_purge_t
|
||||
ma_test_loghandler_purge-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
ADD_EXECUTABLE(ma_test_loghandler_readonly_t
|
||||
ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
|
||||
SET_TARGET_PROPERTIES(ma_test_loghandler_readonly_t PROPERTIES COMPILE_FLAGS "-DREADONLY_TEST")
|
||||
|
||||
|
||||
SET(ma_pagecache_single_src ma_pagecache_single.c test_file.c test_file.h)
|
||||
SET(ma_pagecache_consist_src ma_pagecache_consist.c test_file.c test_file.h)
|
||||
SET(ma_pagecache_common_cppflags "-DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_single_1k_t ${ma_pagecache_single_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_single_1k_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_single_8k_t ${ma_pagecache_single_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_single_8k_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=8192")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_single_64k_t_big ${ma_pagecache_single_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_single_64k_t_big
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_1k_t ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_1k_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_64k_t_big ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_64k_t_big
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536")
|
||||
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_1kHC_t
|
||||
${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kHC_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY")
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_64kHC_t_big
|
||||
${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kHC_t_big
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY")
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_1kRD_t ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kRD_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_READERS")
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_64kRD_t_big ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kRD_t_big
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_READERS")
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_1kWR_t ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kWR_t
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_WRITERS")
|
||||
ADD_EXECUTABLE(ma_pagecache_consist_64kWR_t_big ${ma_pagecache_consist_src})
|
||||
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kWR_t_big
|
||||
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_WRITERS")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
|
||||
INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
# Only reason to link with libmyisam.a here is that it's where some fulltext
|
||||
# pieces are (but soon we'll remove fulltext dependencies from Maria).
|
||||
LDADD= $(top_builddir)/unittest/mytap/libmytap.a \
|
||||
|
@ -95,13 +95,7 @@ dummy_fail_callback(uchar* data_ptr __attribute__((unused)))
|
||||
|
||||
static uint get_len(uint limit)
|
||||
{
|
||||
uint32 rec_len;
|
||||
do
|
||||
{
|
||||
rec_len= random() /
|
||||
(RAND_MAX / limit);
|
||||
} while (rec_len >= limit || rec_len == 0);
|
||||
return rec_len;
|
||||
return (uint)((ulonglong)rand()*(limit-1)/RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
@ -275,9 +269,10 @@ void writer(int num)
|
||||
static void *test_thread_reader(void *arg)
|
||||
{
|
||||
int param=*((int*) arg);
|
||||
DBUG_ENTER("test_reader");
|
||||
|
||||
my_thread_init();
|
||||
DBUG_ENTER("test_reader");
|
||||
|
||||
DBUG_PRINT("enter", ("param: %d", param));
|
||||
|
||||
reader(param);
|
||||
@ -295,9 +290,9 @@ static void *test_thread_reader(void *arg)
|
||||
static void *test_thread_writer(void *arg)
|
||||
{
|
||||
int param=*((int*) arg);
|
||||
DBUG_ENTER("test_writer");
|
||||
|
||||
my_thread_init();
|
||||
DBUG_ENTER("test_writer");
|
||||
DBUG_PRINT("enter", ("param: %d", param));
|
||||
|
||||
writer(param);
|
||||
@ -334,7 +329,7 @@ int main(int argc __attribute__((unused)),
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
{
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
|
||||
if ((file1.file= my_open(file1_name,
|
||||
@ -470,4 +465,5 @@ int main(int argc __attribute__((unused)),
|
||||
DBUG_PRINT("info", ("Program end"));
|
||||
|
||||
DBUG_RETURN(exit_status());
|
||||
}
|
||||
}
|
||||
|
@ -577,6 +577,7 @@ static void *test_thread(void *arg)
|
||||
#endif
|
||||
|
||||
my_thread_init();
|
||||
{
|
||||
DBUG_ENTER("test_thread");
|
||||
DBUG_PRINT("enter", ("param: %d", param));
|
||||
|
||||
@ -602,6 +603,7 @@ static void *test_thread(void *arg)
|
||||
free((uchar*) arg);
|
||||
my_thread_end();
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -626,6 +628,7 @@ int main(int argc __attribute__((unused)),
|
||||
DBUG_SET_INITIAL(default_dbug_option);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
|
||||
if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR,
|
||||
@ -728,4 +731,5 @@ int main(int argc __attribute__((unused)),
|
||||
DBUG_PRINT("info", ("Program end"));
|
||||
|
||||
DBUG_RETURN(exit_status());
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,14 @@ static TRN *trn= &dummy_transaction_object;
|
||||
#define ITERATIONS 65000
|
||||
*/
|
||||
|
||||
/*
|
||||
Generate random value in the range (0,LONG_BUFFER_SIZE)
|
||||
*/
|
||||
static uint32 rand_buffer_size()
|
||||
{
|
||||
return (uint32)((ulonglong)rand()*(LONG_BUFFER_SIZE + 1)/RAND_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
Check that the buffer filled correctly
|
||||
|
||||
@ -58,6 +66,7 @@ static TRN *trn= &dummy_transaction_object;
|
||||
1 - Error
|
||||
*/
|
||||
|
||||
|
||||
static my_bool check_content(uchar *ptr, ulong length)
|
||||
{
|
||||
ulong i;
|
||||
@ -88,7 +97,7 @@ static my_bool check_content(uchar *ptr, ulong length)
|
||||
void read_ok(TRANSLOG_HEADER_BUFFER *rec)
|
||||
{
|
||||
char buff[80];
|
||||
snprintf(buff, sizeof(buff), "read record type: %u LSN: (%lu,0x%lx)",
|
||||
my_snprintf(buff, sizeof(buff), "read record type: %u LSN: (%lu,0x%lx)",
|
||||
rec->type, LSN_IN_PARTS(rec->lsn));
|
||||
ok(1, buff);
|
||||
}
|
||||
@ -188,7 +197,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
|
||||
plan(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1 + 1);
|
||||
|
||||
srandom(122334817L);
|
||||
srand(122334817L);
|
||||
|
||||
long_tr_id[5]= 0xff;
|
||||
|
||||
@ -232,7 +241,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
}
|
||||
ok(1, "write LOGREC_FIXED_RECORD_1LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 12)
|
||||
if ((rec_len= rand_buffer_size()) < 12)
|
||||
rec_len= 12;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE;
|
||||
@ -272,7 +281,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
ok(1, "write LOGREC_FIXED_RECORD_2LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
lsn_store(lsn_buff + LSN_STORE_SIZE, first_lsn);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 19)
|
||||
if ((rec_len= rand_buffer_size()) < 19)
|
||||
rec_len= 19;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 14;
|
||||
@ -310,7 +319,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
|
||||
lsn_base= lsn;
|
||||
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 9)
|
||||
if ((rec_len= rand_buffer_size()) < 9)
|
||||
rec_len= 9;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_buffer;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len;
|
||||
@ -345,7 +354,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
}
|
||||
ok(1, "flush");
|
||||
|
||||
srandom(122334817L);
|
||||
srand(122334817L);
|
||||
|
||||
rc= 1;
|
||||
|
||||
@ -475,7 +484,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
{
|
||||
LSN ref;
|
||||
ref= lsn_korr(rec.header);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 12)
|
||||
if ((rec_len= rand_buffer_size()) < 12)
|
||||
rec_len= 12;
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
@ -516,7 +525,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
LSN ref1, ref2;
|
||||
ref1= lsn_korr(rec.header);
|
||||
ref2= lsn_korr(rec.header + LSN_STORE_SIZE);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 19)
|
||||
if ((rec_len= rand_buffer_size()) < 19)
|
||||
rec_len= 19;
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
@ -584,7 +593,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
translog_free_record_header(&rec);
|
||||
|
||||
len= translog_read_next_record_header(&scanner, &rec);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 9)
|
||||
if ((rec_len= rand_buffer_size()) < 9)
|
||||
rec_len= 9;
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
|
@ -114,13 +114,8 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
|
||||
|
||||
static uint32 get_len()
|
||||
{
|
||||
uint32 rec_len;
|
||||
do
|
||||
{
|
||||
rec_len= random() /
|
||||
(RAND_MAX / (LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)) + MIN_REC_LENGTH;
|
||||
} while (rec_len >= LONG_BUFFER_SIZE);
|
||||
return rec_len;
|
||||
return (uint32)
|
||||
((ulonglong)rand()*(LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)/RAND_MAX)+ MIN_REC_LENGTH;
|
||||
}
|
||||
|
||||
int main(int argc __attribute__((unused)), char *argv[])
|
||||
@ -196,7 +191,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
|
||||
plan(((ITERATIONS - 1) * 4 + 1) * 2);
|
||||
|
||||
srandom(122334817L);
|
||||
srand(122334817L);
|
||||
|
||||
long_tr_id[5]= 0xff;
|
||||
|
||||
@ -356,7 +351,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srandom(122334817L);
|
||||
srand(122334817L);
|
||||
|
||||
rc= 1;
|
||||
|
||||
|
@ -46,13 +46,9 @@ static uchar *long_buffer;
|
||||
|
||||
static uint32 get_len()
|
||||
{
|
||||
uint32 rec_len;
|
||||
do
|
||||
{
|
||||
rec_len= random() /
|
||||
(RAND_MAX / (LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)) + MIN_REC_LENGTH;
|
||||
} while (rec_len >= LONG_BUFFER_SIZE);
|
||||
return rec_len;
|
||||
return MIN_REC_LENGTH +
|
||||
(uint32)(((ulonglong)rand())*
|
||||
(LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)/RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
@ -129,8 +125,8 @@ void writer(int num)
|
||||
for (i= 0; i < ITERATIONS; i++)
|
||||
{
|
||||
uint len= get_len();
|
||||
lens[num][i]= len;
|
||||
LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
||||
lens[num][i]= len;
|
||||
|
||||
int2store(long_tr_id, num);
|
||||
int4store(long_tr_id + 2, i);
|
||||
@ -293,7 +289,7 @@ int main(int argc __attribute__((unused)),
|
||||
/* Suppressing of automatic record writing */
|
||||
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
|
||||
|
||||
srandom(122334817L);
|
||||
srand(122334817L);
|
||||
{
|
||||
LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
||||
uchar long_tr_id[6]=
|
||||
|
@ -27,6 +27,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
LSN first_lsn;
|
||||
TRANSLOG_HEADER_BUFFER rec;
|
||||
LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
||||
translog_size_t len;
|
||||
|
||||
MY_INIT(argv[0]);
|
||||
|
||||
@ -90,7 +91,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
translog_size_t len= translog_read_record_header(first_lsn, &rec);
|
||||
len= translog_read_record_header(first_lsn, &rec);
|
||||
if (len == 0)
|
||||
{
|
||||
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
|
||||
|
@ -23,13 +23,38 @@
|
||||
int test_file(PAGECACHE_FILE file, char *file_name,
|
||||
off_t size, size_t buff_size, struct file_desc *desc)
|
||||
{
|
||||
MY_STAT stat_buff, *stat;
|
||||
unsigned char *buffr= my_malloc(buff_size, MYF(0));
|
||||
off_t pos= 0;
|
||||
size_t byte;
|
||||
int step= 0;
|
||||
int res= 1; /* ok */
|
||||
|
||||
#ifdef __WIN__
|
||||
/*
|
||||
On Windows, the info returned by stat(), specifically file length
|
||||
is not necessarily current, because this is the behavior of
|
||||
underlying FindFirstFile() function.
|
||||
*/
|
||||
WIN32_FILE_ATTRIBUTE_DATA file_attr;
|
||||
LARGE_INTEGER li;
|
||||
if(GetFileAttributesEx(file_name, GetFileExInfoStandard, &file_attr) == 0)
|
||||
{
|
||||
diag("Can't GetFileAttributesEx %s (errno: %d)\n", file_name,
|
||||
GetLastError());
|
||||
res= 0;
|
||||
goto err;
|
||||
}
|
||||
li.HighPart= file_attr.nFileSizeHigh;
|
||||
li.LowPart= file_attr.nFileSizeLow;
|
||||
if(li.QuadPart != size)
|
||||
{
|
||||
diag("file %s size is %llu (should be %llu)\n",
|
||||
file_name, (ulonglong)size, (ulonglong)li.QuadPart);
|
||||
res= 0; /* failed */
|
||||
/* continue to get more information */
|
||||
}
|
||||
#else
|
||||
MY_STAT stat_buff, *stat;
|
||||
if ((stat= my_stat(file_name, &stat_buff, MYF(0))) == NULL)
|
||||
{
|
||||
diag("Can't stat() %s (errno: %d)\n", file_name, errno);
|
||||
@ -43,6 +68,7 @@ int test_file(PAGECACHE_FILE file, char *file_name,
|
||||
res= 0; /* failed */
|
||||
/* continue to get more information */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check content */
|
||||
my_seek(file.file, 0, SEEK_SET, MYF(MY_WME));
|
||||
|
@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
|
||||
|
||||
SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c
|
||||
ha_myisam.cc
|
||||
ft_myisam.c
|
||||
ft_stopwords.c ft_update.c mi_cache.c mi_changed.c mi_check.c
|
||||
mi_checksum.c mi_close.c mi_create.c mi_dbug.c mi_delete.c
|
||||
mi_delete_all.c mi_delete_table.c mi_dynrec.c mi_extra.c mi_info.c
|
||||
@ -50,6 +51,21 @@ IF(NOT SOURCE_SUBLIBS)
|
||||
ADD_EXECUTABLE(myisampack myisampack.c)
|
||||
TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(mi_test1 mi_test1.c)
|
||||
TARGET_LINK_LIBRARIES(mi_test1 myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(mi_test2 mi_test2.c)
|
||||
TARGET_LINK_LIBRARIES(mi_test2 myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(mi_test3 mi_test3.c)
|
||||
TARGET_LINK_LIBRARIES(mi_test3 myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(sp_test sp_test.c)
|
||||
TARGET_LINK_LIBRARIES(sp_test myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(rt_test rt_test.c)
|
||||
TARGET_LINK_LIBRARIES(rt_test myisam mysys debug dbug strings zlib wsock32)
|
||||
|
||||
IF(EMBED_MANIFESTS)
|
||||
MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
|
||||
MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
|
||||
|
@ -43,7 +43,7 @@ static void copy_key(struct st_myisam_info *info,uint inx,
|
||||
uchar *record,uchar *key);
|
||||
|
||||
static int verbose=0,testflag=0,
|
||||
first_key=0,async_io=0,key_cacheing=0,write_cacheing=0,locking=0,
|
||||
first_key=0,async_io=0,key_cacheing=0,write_cacheing=0,do_locking=0,
|
||||
rec_pointer_size=0,pack_fields=1,use_log=0,silent=0,
|
||||
opt_quick_mode=0;
|
||||
static int pack_seg=HA_SPACE_PACK,pack_type=HA_PACK_KEY,remove_count=-1,
|
||||
@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
printf("- Writing key:s\n");
|
||||
if (key_cacheing)
|
||||
init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0);
|
||||
if (locking)
|
||||
if (do_locking)
|
||||
mi_lock_database(file,F_WRLCK);
|
||||
if (write_cacheing)
|
||||
mi_extra(file,HA_EXTRA_WRITE_CACHE,0);
|
||||
@ -713,7 +713,7 @@ int main(int argc, char *argv[])
|
||||
printf("- mi_extra(CACHE) + mi_rrnd.... + mi_extra(NO_CACHE)\n");
|
||||
if (mi_reset(file) || mi_extra(file,HA_EXTRA_CACHE,0))
|
||||
{
|
||||
if (locking || (!use_blob && !pack_fields))
|
||||
if (do_locking || (!use_blob && !pack_fields))
|
||||
{
|
||||
puts("got error from mi_extra(HA_EXTRA_CACHE)");
|
||||
goto end;
|
||||
@ -833,9 +833,9 @@ end:
|
||||
puts("Write cacheing used");
|
||||
if (write_cacheing)
|
||||
puts("quick mode");
|
||||
if (async_io && locking)
|
||||
if (async_io && do_locking)
|
||||
puts("Asyncron io with locking used");
|
||||
else if (locking)
|
||||
else if (do_locking)
|
||||
puts("Locking used");
|
||||
if (use_blob)
|
||||
puts("blobs used");
|
||||
@ -904,7 +904,7 @@ static void get_options(int argc, char **argv)
|
||||
use_log=1;
|
||||
break;
|
||||
case 'L':
|
||||
locking=1;
|
||||
do_locking=1;
|
||||
break;
|
||||
case 'A': /* use asyncron io */
|
||||
async_io=1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/* Test av locking */
|
||||
|
||||
#ifndef __NETWARE__
|
||||
#if !(defined (__NETWARE_) || defined (_WIN32)) /*no fork() in Windows*/
|
||||
|
||||
#include "myisam.h"
|
||||
#include <sys/types.h>
|
||||
@ -488,14 +488,14 @@ int test_update(MI_INFO *file,int id,int lock_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* __NETWARE__ */
|
||||
#else /* __NETWARE__ || __WIN__*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
fprintf(stderr,"this test has not been ported to NetWare\n");
|
||||
fprintf(stderr,"this test has not been ported to NetWare or Windows\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __NETWARE__ */
|
||||
#endif /* __NETWARE__ || __WIN__ */
|
||||
|
@ -25,7 +25,8 @@ SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c
|
||||
is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c
|
||||
str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
|
||||
strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
|
||||
my_strchr.c strcont.c strinstr.c strnlen.c)
|
||||
my_strchr.c strcont.c strinstr.c strnlen.c
|
||||
strappend.c)
|
||||
|
||||
IF(NOT SOURCE_SUBLIBS)
|
||||
ADD_LIBRARY(strings ${STRINGS_SOURCES})
|
||||
|
28
unittest/mysys/CMakeLists.txt
Normal file
28
unittest/mysys/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/unittest/mytap)
|
||||
ADD_EXECUTABLE(bitmap-t bitmap-t.c)
|
||||
TARGET_LINK_LIBRARIES(bitmap-t mytap mysys dbug strings wsock32)
|
||||
|
||||
ADD_EXECUTABLE(base64-t base64-t.c)
|
||||
TARGET_LINK_LIBRARIES(base64-t mytap mysys dbug strings wsock32)
|
||||
|
||||
ADD_EXECUTABLE(my_atomic-t my_atomic-t.c)
|
||||
TARGET_LINK_LIBRARIES(my_atomic-t mytap mysys dbug strings wsock32)
|
@ -23,5 +23,7 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/strings/libmystrings.a
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
|
@ -31,8 +31,10 @@ volatile int32 c32, N;
|
||||
my_atomic_rwlock_t rwl;
|
||||
LF_ALLOCATOR lf_allocator;
|
||||
LF_HASH lf_hash;
|
||||
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_t thr_attr;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
uint running_threads;
|
||||
size_t stacksize= 0;
|
||||
#define STACK_SIZE (((int)stacksize-2048)*STACK_DIRECTION)
|
||||
|
||||
@ -52,6 +54,9 @@ pthread_handler_t test_atomic_add_handler(void *arg)
|
||||
my_atomic_add32(&a32, -x);
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
}
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -66,9 +71,15 @@ pthread_handler_t test_atomic_add_handler(void *arg)
|
||||
pthread_handler_t test_atomic_fas_handler(void *arg)
|
||||
{
|
||||
int m= *(int *)arg;
|
||||
uint32 x= my_atomic_add32(&b32, 1);
|
||||
int32 x;
|
||||
|
||||
my_atomic_rwlock_wrlock(&rwl);
|
||||
x= my_atomic_add32(&b32, 1);
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
|
||||
my_atomic_rwlock_wrlock(&rwl);
|
||||
my_atomic_add32(&a32, x);
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
|
||||
for (; m ; m--)
|
||||
{
|
||||
@ -88,6 +99,9 @@ pthread_handler_t test_atomic_fas_handler(void *arg)
|
||||
my_atomic_add32(&a32, -x);
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -117,9 +131,13 @@ pthread_handler_t test_atomic_cas_handler(void *arg)
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
} while (!ok) ;
|
||||
}
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
pin allocator - alloc and release an element in a loop
|
||||
*/
|
||||
@ -137,6 +155,9 @@ pthread_handler_t test_lf_pinbox(void *arg)
|
||||
pins= lf_pinbox_get_pins(&lf_allocator.pinbox, &m + STACK_SIZE);
|
||||
}
|
||||
lf_pinbox_put_pins(pins);
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -181,6 +202,9 @@ pthread_handler_t test_lf_alloc(void *arg)
|
||||
#endif
|
||||
}
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -228,44 +252,40 @@ pthread_handler_t test_lf_hash(void *arg)
|
||||
a32|= lf_hash.count;
|
||||
}
|
||||
my_atomic_rwlock_wrunlock(&rwl);
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (!--running_threads) pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void test_atomic(const char *test, pthread_handler handler, int n, int m)
|
||||
{
|
||||
pthread_t *threads;
|
||||
pthread_t t;
|
||||
ulonglong now= my_getsystime();
|
||||
int i;
|
||||
|
||||
a32= 0;
|
||||
b32= 0;
|
||||
c32= 0;
|
||||
|
||||
threads= (pthread_t *)my_malloc(sizeof(void *)*n, MYF(0));
|
||||
if (!threads)
|
||||
{
|
||||
diag("Out of memory");
|
||||
abort();
|
||||
}
|
||||
|
||||
diag("Testing %s with %d threads, %d iterations... ", test, n, m);
|
||||
N= n;
|
||||
for (i= 0 ; i < n ; i++)
|
||||
for (running_threads= n ; n ; n--)
|
||||
{
|
||||
if (pthread_create(threads+i, 0, handler, &m) != 0)
|
||||
if (pthread_create(&t, &thr_attr, handler, &m) != 0)
|
||||
{
|
||||
diag("Could not create thread");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
for (i= 0 ; i < n ; i++)
|
||||
pthread_join(threads[i], 0);
|
||||
pthread_mutex_lock(&mutex);
|
||||
while (running_threads)
|
||||
pthread_cond_wait(&cond, &mutex);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
now= my_getsystime()-now;
|
||||
ok(a32 == 0, "tested %s in %g secs (%d)", test, ((double)now)/1e7, a32);
|
||||
my_free((void *)threads, MYF(0));
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int err;
|
||||
@ -277,23 +297,34 @@ int main()
|
||||
plan(7);
|
||||
ok(err == 0, "my_atomic_initialize() returned %d", err);
|
||||
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
pthread_cond_init(&cond, 0);
|
||||
my_atomic_rwlock_init(&rwl);
|
||||
lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used));
|
||||
lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0,
|
||||
&my_charset_bin);
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_init(&thr_attr);
|
||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
|
||||
pthread_attr_getstacksize(&attr, &stacksize);
|
||||
pthread_attr_getstacksize(&thr_attr, &stacksize);
|
||||
if (stacksize == 0)
|
||||
#endif
|
||||
stacksize= PTHREAD_STACK_MIN;
|
||||
stacksize = PTHREAD_STACK_MIN;
|
||||
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_RWLOCKS
|
||||
#ifdef HPUX11 /* showed to be very slow (scheduler-related) */
|
||||
#define CYCLES 300
|
||||
#else
|
||||
#define CYCLES 3000
|
||||
#endif
|
||||
#else
|
||||
#ifdef HPUX11
|
||||
#define CYCLES 30000
|
||||
#else
|
||||
#define CYCLES 300000
|
||||
#endif
|
||||
#endif
|
||||
#define THREADS 100
|
||||
|
||||
test_atomic("my_atomic_add32", test_atomic_add_handler, THREADS,CYCLES);
|
||||
@ -305,6 +336,15 @@ int main()
|
||||
|
||||
lf_hash_destroy(&lf_hash);
|
||||
lf_alloc_destroy(&lf_allocator);
|
||||
|
||||
/*
|
||||
workaround until we know why it crashes randomly on some machine
|
||||
(BUG#22320).
|
||||
*/
|
||||
sleep(2);
|
||||
pthread_mutex_destroy(&mutex);
|
||||
pthread_cond_destroy(&cond);
|
||||
pthread_attr_destroy(&thr_attr);
|
||||
my_atomic_rwlock_destroy(&rwl);
|
||||
my_end(0);
|
||||
return exit_status();
|
||||
|
20
unittest/mytap/CMakeLists.txt
Normal file
20
unittest/mytap/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
||||
ADD_LIBRARY(mytap tap.c)
|
@ -20,6 +20,8 @@ noinst_HEADERS = tap.h
|
||||
|
||||
libmytap_a_SOURCES = tap.c
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
||||
SUBDIRS = . t
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "tap.h"
|
||||
|
||||
#include "my_config.h"
|
||||
#include "my_global.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@ -27,6 +27,16 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
Visual Studio 2003 does not know vsnprintf but knows _vsnprintf.
|
||||
We don't put this #define in config-win.h because we prefer
|
||||
my_vsnprintf everywhere instead, except when linking with libmysys
|
||||
is not desirable - the case here.
|
||||
*/
|
||||
#if defined(_MSC_VER) && ( _MSC_VER == 1310 )
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup MyTAP_Internal MyTAP Internals
|
||||
|
||||
@ -150,8 +160,10 @@ static signal_entry install_signal[]= {
|
||||
{ SIGILL, handle_core_signal },
|
||||
{ SIGABRT, handle_core_signal },
|
||||
{ SIGFPE, handle_core_signal },
|
||||
{ SIGSEGV, handle_core_signal },
|
||||
{ SIGBUS, handle_core_signal }
|
||||
{ SIGSEGV, handle_core_signal }
|
||||
#ifdef SIGBUS
|
||||
, { SIGBUS, handle_core_signal }
|
||||
#endif
|
||||
#ifdef SIGXCPU
|
||||
, { SIGXCPU, handle_core_signal }
|
||||
#endif
|
||||
@ -172,6 +184,7 @@ void
|
||||
plan(int const count)
|
||||
{
|
||||
char *config= getenv("MYTAP_CONFIG");
|
||||
size_t i;
|
||||
|
||||
if (config)
|
||||
skip_big_tests= strcmp(config, "big");
|
||||
@ -180,7 +193,7 @@ plan(int const count)
|
||||
/*
|
||||
Install signal handler
|
||||
*/
|
||||
size_t i;
|
||||
|
||||
for (i= 0; i < sizeof(install_signal)/sizeof(*install_signal); ++i)
|
||||
signal(install_signal[i].signo, install_signal[i].handler);
|
||||
|
||||
|
@ -66,7 +66,7 @@ sub _find_test_files (@) {
|
||||
my @files;
|
||||
find sub {
|
||||
$File::Find::prune = 1 if /^SCCS$/;
|
||||
push(@files, $File::Find::name) if -x _ && /-t\z/;
|
||||
push(@files, $File::Find::name) if -x _ && (/-t\z/ || /-t\.exe\z/);
|
||||
}, @dirs;
|
||||
return @files;
|
||||
}
|
||||
@ -102,7 +102,7 @@ sub run_cmd (@) {
|
||||
if (@files > 0) {
|
||||
# Removing the first './' from the file names
|
||||
foreach (@files) { s!^\./!! }
|
||||
$ENV{'HARNESS_PERL_SWITCHES'} .= q" -e 'exec @ARGV'";
|
||||
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
|
||||
runtests @files;
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ try
|
||||
case "WITH_FEDERATED_STORAGE_ENGINE":
|
||||
case "WITH_INNOBASE_STORAGE_ENGINE":
|
||||
case "WITH_PARTITION_STORAGE_ENGINE":
|
||||
case "WITH_MARIA_STORAGE_ENGINE":
|
||||
case "__NT__":
|
||||
case "CYBOZU":
|
||||
case "EMBED_MANIFESTS":
|
||||
|
Reference in New Issue
Block a user