summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/.cvsignore4
-rwxr-xr-xinclude/Attic/config-win32.h247
-rw-r--r--include/Attic/m_ctype.h.in231
-rwxr-xr-xinclude/Attic/mysql_com.h.in216
-rw-r--r--include/Makefile.am53
-rw-r--r--include/config-win.h291
-rw-r--r--include/dbug.h92
-rw-r--r--include/errmsg.h55
-rw-r--r--include/ft_global.h52
-rw-r--r--include/getopt.h133
-rw-r--r--include/global.h845
-rw-r--r--include/hash.h65
-rw-r--r--include/heap.h181
-rw-r--r--include/m_ctype.h157
-rw-r--r--include/m_string.h241
-rw-r--r--include/merge.h94
-rw-r--r--include/my_alarm.h60
-rw-r--r--include/my_base.h265
-rw-r--r--include/my_dir.h100
-rw-r--r--include/my_list.h47
-rw-r--r--include/my_net.h33
-rw-r--r--include/my_no_pthread.h32
-rw-r--r--include/my_nosys.h56
-rw-r--r--include/my_pthread.h538
-rw-r--r--include/my_sys.h555
-rw-r--r--include/my_tree.h75
-rw-r--r--include/myisam.h377
-rw-r--r--include/myisammrg.h92
-rw-r--r--include/myisampack.h207
-rw-r--r--include/mysql.h293
-rw-r--r--include/mysql_com.h242
-rwxr-xr-xinclude/mysql_version.h.in20
-rw-r--r--include/mysqld_error.h195
-rw-r--r--include/mysys_err.h57
-rw-r--r--include/nisam.h213
-rw-r--r--include/queues.h57
-rw-r--r--include/raid.h155
-rw-r--r--include/sslopt-case.h42
-rw-r--r--include/sslopt-longopts.h31
-rw-r--r--include/sslopt-usage.h25
-rw-r--r--include/sslopt-vars.h24
-rw-r--r--include/t_ctype.h239
-rw-r--r--include/thr_alarm.h100
-rw-r--r--include/thr_lock.h89
-rw-r--r--include/violite.h115
45 files changed, 7291 insertions, 0 deletions
diff --git a/include/.cvsignore b/include/.cvsignore
new file mode 100644
index 00000000000..fc53b1b5f65
--- /dev/null
+++ b/include/.cvsignore
@@ -0,0 +1,4 @@
+Makefile
+Makefile.in
+my_config.h
+mysql_version.h
diff --git a/include/Attic/config-win32.h b/include/Attic/config-win32.h
new file mode 100755
index 00000000000..e441749e038
--- /dev/null
+++ b/include/Attic/config-win32.h
@@ -0,0 +1,247 @@
+/* Defines for Win32 to make it compatible for MySQL */
+
+#include <sys/locking.h>
+#include <windows.h>
+#include <math.h> /* Because of rint() */
+#include <fcntl.h>
+#include <io.h>
+#include <malloc.h>
+
+#ifdef __NT__
+#define SYSTEM_TYPE "NT"
+#else
+#define SYSTEM_TYPE "Win95/Win98"
+#endif
+#define MACHINE_TYPE "i586" /* Define to machine type name */
+#ifndef __WIN32__
+#define __WIN32__ /* To make it easier in VC++ */
+#endif
+
+/* File and lock constants */
+#define O_SHARE 0x1000 /* Open file in sharing mode */
+#ifdef __BORLANDC__
+#define F_RDLCK LK_NBLCK /* read lock */
+#define F_WRLCK LK_NBRLCK /* write lock */
+#define F_UNLCK LK_UNLCK /* remove lock(s) */
+#else
+#define F_RDLCK _LK_NBLCK /* read lock */
+#define F_WRLCK _LK_NBRLCK /* write lock */
+#define F_UNLCK _LK_UNLCK /* remove lock(s) */
+#endif
+
+#define F_EXCLUSIVE 1 /* We have only exclusive locking */
+#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
+#define F_OK 0 /* parameter to access() */
+
+#define S_IROTH S_IREAD /* for my_lib */
+
+#ifdef __BORLANDC__
+#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY 0
+#define O_SHORT_LIVED 0
+#define SH_DENYNO _SH_DENYNO
+#else
+#define O_BINARY _O_BINARY /* compability with MSDOS */
+#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY _O_TEMPORARY
+#define O_SHORT_LIVED _O_SHORT_LIVED
+#define SH_DENYNO _SH_DENYNO
+#endif
+#define NO_OPEN_3 /* For my_create() */
+
+#define SIGQUIT SIGTERM /* No SIGQUIT */
+
+#undef _REENTRANT /* Crashes something for win32 */
+
+#define LONGLONG_MIN ((__int64) 0x8000000000000000)
+#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
+#define LL(A) ((__int64) A)
+
+/* Type information */
+
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned int size_t;
+typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
+typedef __int64 longlong;
+typedef int sigset_t;
+#define longlong_defined
+/* off_t should not be __int64 because of conflicts in header files;
+ Use my_off_t or os_off_t instead */
+typedef long off_t;
+typedef __int64 os_off_t;
+
+#define Socket_defined
+#define my_socket SOCKET
+#define bool BOOL
+#define SIGPIPE SIGINT
+#define RETQSORTTYPE void
+#define QSORT_TYPE_IS_VOID
+#define RETSIGTYPE void
+#define SOCKET_SIZE_TYPE int
+#define my_socket_defined
+#define bool_defined
+#define byte_defined
+#define HUGE_PTR
+#define STDCALL __stdcall /* Used by libmysql.dll */
+
+#ifndef UNDEF_THREAD_HACK
+#define THREAD
+#endif
+#define VOID_SIGHANDLER
+#define SIZEOF_CHAR 1
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_OFF_T 8
+#define HAVE_BROKEN_NETINET_INCLUDES
+#ifdef __NT__
+#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
+#endif
+
+/* Convert some simple functions to Posix */
+
+#define sigset(A,B) signal((A),(B))
+#define finite(A) _finite(A)
+#define sleep(A) Sleep((A)*1000)
+
+#ifndef __BORLANDC__
+#define access(A,B) _access(A,B)
+#endif
+
+#if defined(__cplusplus)
+
+inline double rint(double nr)
+{
+ double f = floor(nr);
+ double c = ceil(nr);
+ return (((c-nr) >= (nr-f)) ? f :c);
+}
+
+inline double ulonglong2double(ulonglong value)
+{
+ longlong nr=(longlong) value;
+ if (nr >= 0)
+ return (double) nr;
+ return (18446744073709551616.0 + (double) nr);
+}
+
+#define my_off_t2double(A) ulonglong2double(A)
+#else
+#define inline __inline
+#endif
+
+#if SIZEOF_OFF_T > 4
+#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
+#define tell(A) _telli64(A)
+#endif
+
+#define STACK_DIRECTION -1
+
+/* Optimized store functions for Intel x86 */
+
+#define sint2korr(A) (*((int16 *) (A)))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (*((long *) (A)))
+#define uint2korr(A) (*((uint16 *) (A)))
+#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
+#define uint4korr(A) (*((unsigned long *) (A)))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint8korr(A) (*((ulonglong *) (A)))
+#define sint8korr(A) (*((longlong *) (A)))
+#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
+#define int3store(T,A) { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16)); }
+#define int4store(T,A) *((long *) (T))= (long) (A)
+#define int5store(T,A) { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); }
+#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
+
+#define doubleget(V,M) { *((long *) &V) = *((long*) M); \
+ *(((long *) &V)+1) = *(((long*) M)+1); }
+#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
+ *(((long *) T)+1) = *(((long*) &V)+1); }
+#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
+#define float8get(V,M) doubleget((V),(M))
+#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
+#define float8store(V,M) doublestore((V),(M))
+
+
+#define HAVE_PERROR
+#define HAVE_VFPRINT
+#define HAVE_CHSIZE /* System has chsize() function */
+#define HAVE_RENAME /* Have rename() as function */
+#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
+#define HAVE_LONG_JMP /* Have long jump function */
+#define HAVE_LOCKING /* have locking() call */
+#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
+#define HAVE_STDLIB /* everything is include in this file */
+#define HAVE_MEMCPY
+#define HAVE_MEMMOVE
+#define HAVE_GETCWD
+#define HAVE_TELL
+#define HAVE_TZNAME
+#define HAVE_PUTENV
+#define HAVE_SELECT
+#define HAVE_SETLOCALE
+#define HAVE_SOCKET /* Giangi */
+#define HAVE_FLOAT_H
+#define HAVE_LIMITS_H
+#define HAVE_STDDEF_H
+#define HAVE_RINT /* defined in this file */
+#define NO_FCNTL_NONBLOCK /* No FCNTL */
+#define HAVE_ALLOCA
+#define HAVE_COMPRESS
+
+#ifdef _MSC_VER
+#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
+#define HAVE_ANSI_INCLUDE
+#define HAVE_SYS_UTIME_H
+#define HAVE_STRTOUL
+#endif
+#define my_reinterpret_cast(A) reinterpret_cast <A>
+#define my_const_cast(A) const_cast<A>
+
+/* MYSQL OPTIONS */
+
+#ifdef _CUSTOMCONFIG_
+#include <custom_conf.h>
+#else
+#define DEFAULT_MYSQL_HOME "c:\\mysql"
+#define PACKAGE "mysql"
+#define DEFAULT_BASEDIR "C:\\"
+#define SHAREDIR "share\\"
+#define DEFAULT_CHARSET_HOME "C:\\"
+#endif
+
+/* File name handling */
+
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
+#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
+#define FN_LOWER_CASE TRUE /* Files are represented in lower case */
+#define MY_NFILE 127 /* This is only used to save filenames */
+
+
+#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
+/* The following is only used for statistics, so it should be good enough */
+#ifdef __NT__ /* This should also work on Win98 but .. */
+#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#else
+#define thread_safe_add(V,C,L) InterlockedExchange((long*) &(V),(V)+(C))
+#endif
diff --git a/include/Attic/m_ctype.h.in b/include/Attic/m_ctype.h.in
new file mode 100644
index 00000000000..ea7782987e3
--- /dev/null
+++ b/include/Attic/m_ctype.h.in
@@ -0,0 +1,231 @@
+/* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+ For a more info consult the file COPYRIGHT distributed with this file */
+/*
+ A better inplementation of the UNIX ctype(3) library.
+ Notes: global.h should be included before ctype.h
+*/
+
+#ifndef _m_ctype_h
+#define _m_ctype_h
+
+#define MY_CHARSET_UNDEFINED 0
+#define MY_CHARSET_BIG5 1
+#define MY_CHARSET_CZECH 2
+#define MY_CHARSET_DEC8 3
+#define MY_CHARSET_DOS 4
+#define MY_CHARSET_GERMAN1 5
+#define MY_CHARSET_HP8 6
+#define MY_CHARSET_KOI8_RU 7
+#define MY_CHARSET_LATIN1 8
+#define MY_CHARSET_LATIN2 9
+#define MY_CHARSET_SWE7 10
+#define MY_CHARSET_USA7 11
+#define MY_CHARSET_UJIS 12
+#define MY_CHARSET_SJIS 13
+#define MY_CHARSET_CP1251 14
+#define MY_CHARSET_DANISH 15
+#define MY_CHARSET_HEBREW 16
+#define MY_CHARSET_WIN1251 17
+#define MY_CHARSET_TIS620 18
+#define MY_CHARSET_EUC_KR 19
+#define MY_CHARSET_ESTONIA 20
+#define MY_CHARSET_HUNGARIAN 21
+#define MY_CHARSET_KOI8_UKR 22
+#define MY_CHARSET_WIN1251UKR 23
+#define MY_CHARSET_GB2312 24
+#define MY_CHARSET_GREEK 25
+#define MY_CHARSET_WIN1250 26
+#define MY_CHARSET_CROAT 27
+#define MY_CHARSET_GBK 28
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __WIN32__
+#include <ctype.h>
+#endif
+/* Don't include std ctype.h when this is included */
+#define _CTYPE_H
+#define _CTYPE_INCLUDED
+#define __CTYPE_INCLUDED
+#define _CTYPE_USING /* Don't put names in global namespace. */
+
+#ifndef CTYPE_LIBRARY
+#define EXT extern
+#define D(x)
+#else
+#define EXT
+#define D(x) = x
+#endif
+
+#define _U 01 /* Upper case */
+#define _L 02 /* Lower case */
+#define _N 04 /* Numeral (digit) */
+#define _S 010 /* Spacing character */
+#define _P 020 /* Punctuation */
+#define _C 040 /* Control character */
+#define _B 0100 /* Blank */
+#define _X 0200 /* heXadecimal digit */
+
+extern uchar NEAR ctype_@mystrings_charset@[];
+extern uchar NEAR to_upper_@mystrings_charset@[];
+extern uchar NEAR to_lower_@mystrings_charset@[];
+extern uchar NEAR sort_order_@mystrings_charset@[];
+
+#define my_ctype ctype_@mystrings_charset@
+#define my_to_upper to_upper_@mystrings_charset@
+#define my_to_lower to_lower_@mystrings_charset@
+#define my_sort_order sort_order_@mystrings_charset@
+
+#ifndef __WIN32__
+#define _toupper(c) (char) my_to_upper[(uchar) (c)]
+#define _tolower(c) (char) my_to_lower[(uchar) (c)]
+#define toupper(c) (char) my_to_upper[(uchar) (c)]
+#define tolower(c) (char) my_to_lower[(uchar) (c)]
+
+#define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
+#define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
+#define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
+#define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
+#define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
+#define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
+#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
+#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
+#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
+#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
+#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
+#define isascii(c) (!((c) & ~0177))
+#define toascii(c) ((c) & 0177)
+
+#ifdef ctype
+#undef ctype
+#endif /* ctype */
+
+#endif /* __WIN32__ */
+
+/* Some macros that should be cleaned up a little */
+#define isvar(c) (isalnum(c) || (c) == '_')
+#define isvar_start(c) (isalpha(c) || (c) == '_')
+#define tocntrl(c) ((c) & 31)
+#define toprint(c) ((c) | 64)
+
+/* Support for Japanese(UJIS) characters, by tommy@valley.ne.jp */
+#if MY_CHARSET_CURRENT == MY_CHARSET_UJIS
+#define USE_MB
+#define USE_MB_IDENT
+#define isujis(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xfe))
+#define iskata(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xdf))
+#define isujis_ss2(c) (((c)&0xff) == 0x8e)
+#define isujis_ss3(c) (((c)&0xff) == 0x8f)
+#define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
+ isujis(*(p)) && (end)-(p)>1 && isujis(*((p)+1))? 2:\
+ isujis_ss2(*(p)) && (end)-(p)>1 && iskata(*((p)+1))? 2:\
+ isujis_ss3(*(p)) && (end)-(p)>2 && isujis(*((p)+1)) && isujis(*((p)+2))? 3:\
+ 0)
+#define ismbhead(c) (isujis(c) || isujis_ss2(c) || isujis_ss3(c))
+#define mbcharlen(c) (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 0)
+#define MBMAXLEN 3
+#endif
+
+/* Support for Japanese(SJIS) characters, by tommy@valley.ne.jp */
+#if MY_CHARSET_CURRENT == MY_CHARSET_SJIS
+#define USE_MB
+#define USE_MB_IDENT
+#define issjishead(c) ((0x81<=((c)&0xff) && ((c)&0xff)<=0x9f) || (0xe0<=((c)&0xff) && ((c)&0xff)<=0xfc))
+#define issjistail(c) ((0x40<=((c)&0xff) && ((c)&0xff)<=0x7e) || (0x80<=((c)&0xff) && ((c)&0xff)<=0xfc))
+#define ismbchar(p, end) (issjishead(*(p)) && (end)-(p)>1 && issjistail(*((p)+1))? 2: 0)
+#define ismbhead(c) issjishead(c)
+#define mbcharlen(c) (issjishead(c)? 2: 0)
+#define MBMAXLEN 2
+#endif
+
+/* Support for Chinese(BIG5) characters, by jou@nematic.ieo.nctu.edu.tw
+ modified by Wei He (hewei@mail.ied.ac.cn) */
+
+#if MY_CHARSET_CURRENT == MY_CHARSET_BIG5
+#define USE_MB
+#define USE_MB_IDENT
+#define isbig5head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf9)
+#define isbig5tail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
+ (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
+#define ismbchar(p, end) (isbig5head(*(p)) && (end)-(p)>1 && isbig5tail(*((p)+1))? 2: 0)
+#define ismbhead(c) isbig5head(c)
+#define mbcharlen(c) (isbig5head(c)? 2: 0)
+#define MBMAXLEN 2
+#
+#undef USE_STRCOLL
+#define USE_STRCOLL
+#endif
+
+/* Support for Chinese(GB2312) characters, by Miles Tsai (net-bull@126.com)
+ modified by Wei He (hewei@mail.ied.ac.cn) */
+
+#if MY_CHARSET_CURRENT == MY_CHARSET_GB2312
+#define USE_MB
+#define USE_MB_IDENT
+#define isgb2312head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf7)
+#define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)
+#define ismbchar(p, end) (isgb2312head(*(p)) && (end)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0)
+#define ismbhead(c) isgb2312head(c)
+#define mbcharlen(c) (isgb2312head(c)? 2:0)
+#define MBMAXLEN 2
+#endif
+
+/* Support for Chinese(GBK) characters, by hewei@mail.ied.ac.cn */
+
+#if MY_CHARSET_CURRENT == MY_CHARSET_GBK
+#define USE_MB
+#define USE_MB_IDENT
+#define isgbkhead(c) (0x81<=(uchar)(c) && (uchar)(c)<=0xfe)
+#define isgbktail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
+ (0x80<=(uchar)(c) && (uchar)(c)<=0xfe))
+#define ismbchar(p, end) (isgbkhead(*(p)) && (end)-(p)>1 && isgbktail(*((p)+1))? 2: 0)
+#define ismbhead(c) isgbkhead(c)
+#define mbcharlen(c) (isgbkhead(c)? 2:0)
+#define MBMAXLEN 2
+#undef USE_STRCOLL
+#define USE_STRCOLL
+#endif
+
+/* Define, how much will the string grow under strxfrm */
+#if MY_CHARSET_CURRENT == MY_CHARSET_CZECH
+#undef USE_STRCOLL
+#define USE_STRCOLL
+#endif
+#if MY_CHARSET_CURRENT == MY_CHARSET_TIS620
+#undef USE_STRCOLL
+#define USE_STRCOLL
+#define USE_TIS620
+#include "t_ctype.h"
+#endif
+
+/* Support for Korean(EUC_KR) characters, by powerm90@tinc.co.kr and mrpark@tinc.co.kr */
+#if MY_CHARSET_CURRENT == MY_CHARSET_EUC_KR
+#define USE_MB
+#define USE_MB_IDENT
+#define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
+#define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
+ iseuc_kr(*(p)) && (end)-(p)>1 && iseuc_kr(*((p)+1))? 2:\
+ 0)
+#define ismbhead(c) (iseuc_kr(c))
+#define mbcharlen(c) (iseuc_kr(c) ? 2 : 0)
+#define MBMAXLEN 2
+#endif
+
+#ifdef USE_STRCOLL
+extern uint MY_STRXFRM_MULTIPLY;
+extern int my_strnxfrm(unsigned char *, unsigned char *, int, int);
+extern int my_strnncoll(const unsigned char *, int, const unsigned char *, int);
+extern int my_strxfrm(unsigned char *, unsigned char *, int);
+extern int my_strcoll(const unsigned char *, const unsigned char *);
+extern my_bool my_like_range(const char *ptr,uint ptr_length,pchar escape,
+ uint res_length, char *min_str,char *max_str,
+ uint *min_length,uint *max_length);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _m_ctype_h */
diff --git a/include/Attic/mysql_com.h.in b/include/Attic/mysql_com.h.in
new file mode 100755
index 00000000000..aaf9f3f475f
--- /dev/null
+++ b/include/Attic/mysql_com.h.in
@@ -0,0 +1,216 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+ This file is public domain and comes with NO WARRANTY of any kind */
+
+/*
+** Common definition between mysql server & client
+*/
+
+#ifndef _mysql_com_h
+#define _mysql_com_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NAME_LEN 64 /* Field/table name length */
+#define HOSTNAME_LENGTH 60
+#define USERNAME_LENGTH 16
+
+#define LOCAL_HOST "localhost"
+#define LOCAL_HOST_NAMEDPIPE "."
+
+#ifndef _CUSTOMCONFIG_
+#define MYSQL_PORT @MYSQL_TCP_PORT@ /* Alloced by ISI for MySQL */
+#else
+#include "custom_conf.h"
+#endif
+
+#define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
+#if defined(__EMX__) || defined(__OS2__)
+#undef MYSQL_UNIX_ADDR
+#define MYSQL_OS2_ADDR "\\socket\\MySQL"
+#define MYSQL_UNIX_ADDR MYSQL_OS2_ADDR
+#endif
+#if defined(__WIN32__) && !defined( _CUSTOMCONFIG_)
+#define MYSQL_NAMEDPIPE "MySQL"
+#define MYSQL_SERVICENAME "MySql"
+#endif /* __WIN32__ */
+
+enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
+ COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
+ COM_SHUTDOWN,COM_STATISTICS,
+ COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
+ COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
+ COM_CHANGE_USER, COM_BINLOG_DUMP};
+
+#define NOT_NULL_FLAG 1 /* Field can't be NULL */
+#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
+#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
+#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
+#define BLOB_FLAG 16 /* Field is a blob */
+#define UNSIGNED_FLAG 32 /* Field is unsigned */
+#define ZEROFILL_FLAG 64 /* Field is zerofill */
+#define BINARY_FLAG 128
+/* The following are only sent to new clients */
+#define ENUM_FLAG 256 /* field is an enum */
+#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
+#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
+#define SET_FLAG 2048 /* field is a set */
+#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
+#define GROUP_FLAG 32768 /* Intern: Group field */
+#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
+
+#define REFRESH_GRANT 1 /* Refresh grant tables */
+#define REFRESH_LOG 2 /* Start on new log file */
+#define REFRESH_TABLES 4 /* close all tables */
+#define REFRESH_HOSTS 8 /* Flush host cache */
+#define REFRESH_STATUS 16 /* Flush status variables */
+#define REFRESH_FAST 32768 /* Intern flag */
+
+#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
+#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
+#define CLIENT_LONG_FLAG 4 /* Get all column flags */
+#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
+#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
+#define CLIENT_COMPRESS 32 /* Can use compression protocol */
+#define CLIENT_ODBC 64 /* Odbc client */
+#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
+#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
+#define CLIENT_CHANGE_USER 512 /* Support the mysql_change_user() */
+#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
+#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
+
+#define MYSQL_ERRMSG_SIZE 200
+#define NET_READ_TIMEOUT 30 /* Timeout on read */
+#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
+#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
+
+#ifndef Vio_defined
+#define Vio_defined
+#ifdef HAVE_VIO
+class Vio; /* Fill Vio class in C++ */
+#else
+struct st_vio; /* Only C */
+typedef struct st_vio Vio;
+#endif
+#endif
+
+typedef struct st_net {
+ Vio* vio;
+ my_socket fd; /* For Perl DBI/dbd */
+ int fcntl;
+ unsigned char *buff,*buff_end,*write_pos,*read_pos;
+ char last_error[MYSQL_ERRMSG_SIZE];
+ unsigned int last_errno,max_packet,timeout,pkt_nr;
+ my_bool error,return_errno,compress;
+
+ unsigned long remain_in_buf,length, buf_length, where_b;
+ my_bool more;
+ char save_char;
+} NET;
+
+#define packet_error ((unsigned int) -1)
+
+enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
+ FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
+ FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
+ FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
+ FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
+ FIELD_TYPE_DATE, FIELD_TYPE_TIME,
+ FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
+ FIELD_TYPE_NEWDATE,
+ FIELD_TYPE_ENUM=247,
+ FIELD_TYPE_SET=248,
+ FIELD_TYPE_TINY_BLOB=249,
+ FIELD_TYPE_MEDIUM_BLOB=250,
+ FIELD_TYPE_LONG_BLOB=251,
+ FIELD_TYPE_BLOB=252,
+ FIELD_TYPE_VAR_STRING=253,
+ FIELD_TYPE_STRING=254
+};
+
+#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
+#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
+
+extern unsigned long max_allowed_packet;
+extern unsigned long net_buffer_length;
+
+#define net_new_transaction(net) ((net)->pkt_nr=0)
+
+int my_net_init(NET *net, Vio* vio);
+void net_end(NET *net);
+void net_clear(NET *net);
+int net_flush(NET *net);
+int my_net_write(NET *net,const char *packet,unsigned long len);
+int net_write_command(NET *net,unsigned char command,const char *packet,
+ unsigned long len);
+int net_real_write(NET *net,const char *packet,unsigned long len);
+unsigned int my_net_read(NET *net);
+
+struct rand_struct {
+ unsigned long seed1,seed2,max_value;
+ double max_value_dbl;
+};
+
+ /* The following is for user defined functions */
+
+enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
+
+typedef struct st_udf_args
+{
+ unsigned int arg_count; /* Number of arguments */
+ enum Item_result *arg_type; /* Pointer to item_results */
+ char **args; /* Pointer to argument */
+ unsigned long *lengths; /* Length of string arguments */
+ char *maybe_null; /* Set to 1 for all maybe_null args */
+} UDF_ARGS;
+
+ /* This holds information about the result */
+
+typedef struct st_udf_init
+{
+ my_bool maybe_null; /* 1 if function can return NULL */
+ unsigned int decimals; /* for real functions */
+ unsigned int max_length; /* For string functions */
+ char *ptr; /* free pointer for function data */
+ my_bool const_item; /* 0 if result is independent of arguments */
+} UDF_INIT;
+
+ /* Constants when using compression */
+#define NET_HEADER_SIZE 4 /* standard header size */
+#define COMP_HEADER_SIZE 3 /* compression header extra size */
+
+ /* Prototypes to password functions */
+
+void randominit(struct rand_struct *,unsigned long seed1,
+ unsigned long seed2);
+double rnd(struct rand_struct *);
+void make_scrambled_password(char *to,const char *password);
+void get_salt_from_password(unsigned long *res,const char *password);
+void make_password_from_salt(char *to, unsigned long *hash_res);
+char *scramble(char *to,const char *message,const char *password,
+ my_bool old_ver);
+my_bool check_scramble(const char *, const char *message,
+ unsigned long *salt,my_bool old_ver);
+char *get_tty_password(char *opt_message);
+void hash_password(unsigned long *result, const char *password);
+
+/* Some other useful functions */
+
+void my_init(void);
+void load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv);
+
+#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
+
+#ifdef __WIN32__
+#define socket_errno WSAGetLastError()
+#else
+#define socket_errno errno
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 00000000000..8ba6ea9d41e
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,53 @@
+# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA
+
+BUILT_SOURCES = my_config.h mysql_version.h m_ctype.h
+pkginclude_HEADERS = dbug.h m_string.h my_sys.h mysql.h mysql_com.h \
+ mysqld_error.h my_list.h \
+ my_pthread.h my_no_pthread.h raid.h errmsg.h \
+ my_config.h my_global.h my_net.h \
+ sslopt-case.h sslopt-longopts.h sslopt-usage.h \
+ sslopt-vars.h $(BUILT_SOURCES)
+noinst_HEADERS = global.h config-win.h \
+ nisam.h heap.h merge.h \
+ myisam.h myisampack.h myisammrg.h ft_global.h\
+ my_dir.h mysys_err.h my_base.h \
+ my_nosys.h my_alarm.h queues.h \
+ my_tree.h hash.h thr_alarm.h thr_lock.h \
+ getopt.h t_ctype.h violite.h \
+ mysql_version.h.in
+
+# mysql_version.h are generated
+SUPERCLEANFILES = mysql_version.h
+
+# Some include files that may be moved and patched by configure
+DISTCLEANFILES = $(distdir)/sched.h
+
+all-local: my_config.h my_global.h
+
+# Since we include my_config.h it better exist from the beginning
+my_config.h: ../config.h
+ $(CP) ../config.h my_config.h
+
+# This should be changed in the source and removed.
+my_global.h: global.h
+ $(CP) global.h my_global.h
+
+# These files should not be included in distributions since they are
+# generated by configure from the .h.in files
+dist-hook:
+ rm -f $(distdir)/mysql_version.h $(distdir)/my_config.h
diff --git a/include/config-win.h b/include/config-win.h
new file mode 100644
index 00000000000..3a541e9ca88
--- /dev/null
+++ b/include/config-win.h
@@ -0,0 +1,291 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Defines for Win32 to make it compatible for MySQL */
+
+#include <sys/locking.h>
+#include <windows.h>
+#include <math.h> /* Because of rint() */
+#include <fcntl.h>
+#include <io.h>
+#include <malloc.h>
+
+#if defined(__NT__)
+#define SYSTEM_TYPE "NT"
+#elif defined(__WIN2000__)
+#define SYSTEM_TYPE "WIN2000"
+#else
+#define SYSTEM_TYPE "Win95/Win98"
+#endif
+
+#ifdef _WIN32
+#define MACHINE_TYPE "i32" /* Define to machine type name */
+#else
+#define MACHINE_TYPE "i64" /* Define to machine type name */
+#endif
+#ifndef __WIN__
+#define __WIN__ /* To make it easier in VC++ */
+#endif
+
+/* File and lock constants */
+#define O_SHARE 0x1000 /* Open file in sharing mode */
+#ifdef __BORLANDC__
+#define F_RDLCK LK_NBLCK /* read lock */
+#define F_WRLCK LK_NBRLCK /* write lock */
+#define F_UNLCK LK_UNLCK /* remove lock(s) */
+#else
+#define F_RDLCK _LK_NBLCK /* read lock */
+#define F_WRLCK _LK_NBRLCK /* write lock */
+#define F_UNLCK _LK_UNLCK /* remove lock(s) */
+#endif
+
+#define F_EXCLUSIVE 1 /* We have only exclusive locking */
+#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
+#define F_OK 0 /* parameter to access() */
+
+#define S_IROTH S_IREAD /* for my_lib */
+
+#ifdef __BORLANDC__
+#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY 0
+#define O_SHORT_LIVED 0
+#define SH_DENYNO _SH_DENYNO
+#else
+#define O_BINARY _O_BINARY /* compability with MSDOS */
+#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY _O_TEMPORARY
+#define O_SHORT_LIVED _O_SHORT_LIVED
+#define SH_DENYNO _SH_DENYNO
+#endif
+#define NO_OPEN_3 /* For my_create() */
+
+#define SIGQUIT SIGTERM /* No SIGQUIT */
+
+#undef _REENTRANT /* Crashes something for win32 */
+
+#define LONGLONG_MIN ((__int64) 0x8000000000000000)
+#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
+#define LL(A) ((__int64) A)
+
+/* Type information */
+
+typedef unsigned short ushort;
+typedef unsigned int uint;
+#ifndef _WIN64
+typedef unsigned int size_t;
+#endif
+typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
+typedef __int64 longlong;
+typedef int sigset_t;
+#define longlong_defined
+/* off_t should not be __int64 because of conflicts in header files;
+ Use my_off_t or os_off_t instead */
+typedef long off_t;
+typedef __int64 os_off_t;
+
+#define Socket_defined
+#define my_socket SOCKET
+#define bool BOOL
+#define SIGPIPE SIGINT
+#define RETQSORTTYPE void
+#define QSORT_TYPE_IS_VOID
+#define RETSIGTYPE void
+#define SOCKET_SIZE_TYPE int
+#define my_socket_defined
+#define bool_defined
+#define byte_defined
+#define HUGE_PTR
+#define STDCALL __stdcall /* Used by libmysql.dll */
+
+#ifndef UNDEF_THREAD_HACK
+#define THREAD
+#endif
+#define VOID_SIGHANDLER
+#define SIZEOF_CHAR 1
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_OFF_T 8
+#define HAVE_BROKEN_NETINET_INCLUDES
+#ifdef __NT__
+#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
+#endif
+
+/* Use all character sets in MySQL */
+#define USE_MB 1
+#define USE_MB_IDENT 1
+#define USE_STRCOLL 1
+
+/* Convert some simple functions to Posix */
+
+#define sigset(A,B) signal((A),(B))
+#define finite(A) _finite(A)
+#define sleep(A) Sleep((A)*1000)
+
+#ifndef __BORLANDC__
+#define access(A,B) _access(A,B)
+#endif
+
+#if defined(__cplusplus)
+
+inline double rint(double nr)
+{
+ double f = floor(nr);
+ double c = ceil(nr);
+ return (((c-nr) >= (nr-f)) ? f :c);
+}
+
+#ifdef _WIN64
+#define ulonglong2double(A) ((double) (A))
+#define my_off_t2double(A) ((double) (A))
+
+#else
+inline double ulonglong2double(ulonglong value)
+{
+ longlong nr=(longlong) value;
+ if (nr >= 0)
+ return (double) nr;
+ return (18446744073709551616.0 + (double) nr);
+}
+#define my_off_t2double(A) ulonglong2double(A)
+#endif /* _WIN64 */
+#else
+#define inline __inline
+#endif /* __cplusplus */
+
+#if SIZEOF_OFF_T > 4
+#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
+#define tell(A) _telli64(A)
+#endif
+
+#define STACK_DIRECTION -1
+
+/* Optimized store functions for Intel x86 */
+
+#define sint2korr(A) (*((int16 *) (A)))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (*((long *) (A)))
+#define uint2korr(A) (*((uint16 *) (A)))
+#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
+#define uint4korr(A) (*((unsigned long *) (A)))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint8korr(A) (*((ulonglong *) (A)))
+#define sint8korr(A) (*((longlong *) (A)))
+#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
+#define int3store(T,A) { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16)); }
+#define int4store(T,A) *((long *) (T))= (long) (A)
+#define int5store(T,A) { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); }
+#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
+
+#define doubleget(V,M) { *((long *) &V) = *((long*) M); \
+ *(((long *) &V)+1) = *(((long*) M)+1); }
+#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
+ *(((long *) T)+1) = *(((long*) &V)+1); }
+#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
+#define float8get(V,M) doubleget((V),(M))
+#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
+#define float8store(V,M) doublestore((V),(M))
+
+
+#define HAVE_PERROR
+#define HAVE_VFPRINT
+#define HAVE_CHSIZE /* System has chsize() function */
+#define HAVE_RENAME /* Have rename() as function */
+#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
+#define HAVE_LONG_JMP /* Have long jump function */
+#define HAVE_LOCKING /* have locking() call */
+#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
+#define HAVE_STDLIB /* everything is include in this file */
+#define HAVE_MEMCPY
+#define HAVE_MEMMOVE
+#define HAVE_GETCWD
+#define HAVE_TELL
+#define HAVE_TZNAME
+#define HAVE_PUTENV
+#define HAVE_SELECT
+#define HAVE_SETLOCALE
+#define HAVE_SOCKET /* Giangi */
+#define HAVE_FLOAT_H
+#define HAVE_LIMITS_H
+#define HAVE_STDDEF_H
+#define HAVE_RINT /* defined in this file */
+#define NO_FCNTL_NONBLOCK /* No FCNTL */
+#define HAVE_ALLOCA
+#define HAVE_COMPRESS
+
+#ifdef _MSC_VER
+#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
+#define HAVE_ANSI_INCLUDE
+#define HAVE_SYS_UTIME_H
+#define HAVE_STRTOUL
+#endif
+#define my_reinterpret_cast(A) reinterpret_cast <A>
+#define my_const_cast(A) const_cast<A>
+
+/* MYSQL OPTIONS */
+
+#ifdef _CUSTOMCONFIG_
+#include <custom_conf.h>
+#else
+#define DEFAULT_MYSQL_HOME "c:\\mysql"
+#define PACKAGE "mysql"
+#define DEFAULT_BASEDIR "C:\\"
+#define SHAREDIR "share"
+#define DEFAULT_CHARSET_HOME "C:/mysql/"
+#endif
+
+/* File name handling */
+
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
+#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
+#define FN_LOWER_CASE TRUE /* Files are represented in lower case */
+#define MY_NFILE 127 /* This is only used to save filenames */
+
+
+#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
+/* The following is only used for statistics, so it should be good enough */
+#ifdef __NT__ /* This should also work on Win98 but .. */
+#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#else
+#define thread_safe_add(V,C,L) \
+ pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
+#define thread_safe_sub(V,C,L) \
+ pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
+#define statistic_add(V,C,L) (V)+=(C)
+#endif
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+
diff --git a/include/dbug.h b/include/dbug.h
new file mode 100644
index 00000000000..de6bbc66ed7
--- /dev/null
+++ b/include/dbug.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _dbug_h
+#define _dbug_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if !defined(DBUG_OFF) && !defined(_lint)
+extern int _db_on_,_no_db_;
+extern FILE *_db_fp_;
+extern char *_db_process_;
+extern int _db_keyword_(const char *keyword);
+extern void _db_setjmp_(void);
+extern void _db_longjmp_(void);
+extern void _db_push_(const char *control);
+extern void _db_pop_(void);
+extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
+ const char **_sfunc_,const char **_sfile_,
+ uint *_slevel_, char ***);
+extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
+ uint *_slevel_);
+extern void _db_pargs_(uint _line_,const char *keyword);
+extern void _db_doprnt_ _VARARGS((const char *format,...));
+extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
+ uint length);
+extern void _db_lock_file();
+extern void _db_unlock_file();
+
+#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
+ char **_db_framep_; \
+ _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
+ &_db_framep_)
+#define DBUG_LEAVE \
+ (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
+#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}
+#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
+#define DBUG_EXECUTE(keyword,a1) \
+ {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
+#define DBUG_PRINT(keyword,arglist) \
+ {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
+#define DBUG_PUSH(a1) _db_push_ (a1)
+#define DBUG_POP() _db_pop_ ()
+#define DBUG_PROCESS(a1) (_db_process_ = a1)
+#define DBUG_FILE (_db_fp_)
+#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
+#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
+#define DBUG_DUMP(keyword,a1,a2)\
+ {if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
+#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
+#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
+#define DEBUGGER_ON _no_db_=0
+#define DBUG_LOCK_FILE { _db_lock_file(); }
+#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
+#else /* No debugger */
+
+#define DBUG_ENTER(a1)
+#define DBUG_RETURN(a1) return(a1)
+#define DBUG_VOID_RETURN return
+#define DBUG_EXECUTE(keyword,a1) {}
+#define DBUG_PRINT(keyword,arglist) {}
+#define DBUG_PUSH(a1) {}
+#define DBUG_POP() {}
+#define DBUG_PROCESS(a1) {}
+#define DBUG_FILE (stderr)
+#define DBUG_SETJMP setjmp
+#define DBUG_LONGJMP longjmp
+#define DBUG_DUMP(keyword,a1,a2) {}
+#define DBUG_IN_USE 0
+#define DEBUGGER_OFF
+#define DEBUGGER_ON
+#define DBUG_LOCK_FILE
+#define DBUG_UNLOCK_FILE
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/errmsg.h b/include/errmsg.h
new file mode 100644
index 00000000000..b7afe11b615
--- /dev/null
+++ b/include/errmsg.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Error messages for mysql clients */
+/* error messages for the demon is in share/language/errmsg.sys */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void init_client_errs(void);
+extern const char *client_errors[]; /* Error messages */
+#ifdef __cplusplus
+}
+#endif
+
+#define CR_MIN_ERROR 2000 /* For easier client code */
+#define CR_MAX_ERROR 2999
+#define ER(X) client_errors[(X)-CR_MIN_ERROR]
+#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
+
+#define CR_UNKNOWN_ERROR 2000
+#define CR_SOCKET_CREATE_ERROR 2001
+#define CR_CONNECTION_ERROR 2002
+#define CR_CONN_HOST_ERROR 2003
+#define CR_IPSOCK_ERROR 2004
+#define CR_UNKNOWN_HOST 2005
+#define CR_SERVER_GONE_ERROR 2006
+#define CR_VERSION_ERROR 2007
+#define CR_OUT_OF_MEMORY 2008
+#define CR_WRONG_HOST_INFO 2009
+#define CR_LOCALHOST_CONNECTION 2010
+#define CR_TCP_CONNECTION 2011
+#define CR_SERVER_HANDSHAKE_ERR 2012
+#define CR_SERVER_LOST 2013
+#define CR_COMMANDS_OUT_OF_SYNC 2014
+#define CR_NAMEDPIPE_CONNECTION 2015
+#define CR_NAMEDPIPEWAIT_ERROR 2016
+#define CR_NAMEDPIPEOPEN_ERROR 2017
+#define CR_NAMEDPIPESETSTATE_ERROR 2018
+#define CR_CANT_READ_CHARSET 2019
+#define CR_NET_PACKET_TOO_LARGE 2020
diff --git a/include/ft_global.h b/include/ft_global.h
new file mode 100644
index 00000000000..cbd4ba1a2c2
--- /dev/null
+++ b/include/ft_global.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+/* Written by Sergei A. Golubchik, who has a shared copyright to this code */
+
+/* some definitions for full-text indices */
+
+/* #include "myisam.h" */
+
+#ifndef _ft_global_h
+#define _ft_global_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FT_QUERY_MAXLEN 1024
+
+typedef struct ft_doc_rec {
+ my_off_t dpos;
+ double weight;
+} FT_DOC;
+
+typedef struct st_ft_doclist {
+ int ndocs;
+ int curdoc;
+ void *info; /* actually (MI_INFO *) but don't want to include myisam.h */
+ FT_DOC doc[1];
+} FT_DOCLIST;
+
+int ft_init_stopwords(const char **);
+
+FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool);
+double ft_read_next(FT_DOCLIST *, char *);
+#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/getopt.h b/include/getopt.h
new file mode 100644
index 00000000000..eb29226b1dc
--- /dev/null
+++ b/include/getopt.h
@@ -0,0 +1,133 @@
+/* Declarations for getopt.
+ Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+This file is part of the GNU C Library. Its master source is NOT part of
+the C library, however. The master source lives in /gd/gnu/lib.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns EOF, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+#if defined (__STDC__) && __STDC__ || defined(__cplusplus)
+ const char *name;
+#else
+ char *name;
+#endif
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+#if ( defined (__STDC__) && __STDC__ ) || defined(__cplusplus) || defined(MSDOS)
+#ifdef __GNU_LIBRARY__
+/* Many other libraries have conflicting prototypes for getopt, with
+ differences in the consts, in stdlib.h. To avoid compilation
+ errors, only prototype getopt for the GNU C library. */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
+extern int getopt (int argc, char *const *argv, const char *optstring);
+#endif /* __GNU_LIBRARY__ */
+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+extern int getopt_long_only (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
+
+/* Internal only. Users should not call this directly. */
+extern int _getopt_internal (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+#else /* not __STDC__ */
+extern int getopt ();
+extern int getopt_long ();
+extern int getopt_long_only ();
+
+extern int _getopt_internal ();
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GETOPT_H */
diff --git a/include/global.h b/include/global.h
new file mode 100644
index 00000000000..bb7ee1b6cba
--- /dev/null
+++ b/include/global.h
@@ -0,0 +1,845 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This is the main include file that should included 'first' in every
+ C file. */
+
+#ifndef _global_h
+#define _global_h
+
+#if defined(_WIN32) || defined(_WIN64)
+#include <config-win.h>
+#else
+#include <my_config.h>
+#endif
+#if defined(__cplusplus)
+#if defined(inline)
+#undef inline /* fix configure problem */
+#endif
+#endif /* _cplusplus */
+
+/* The client defines this to avoid all thread code */
+#if defined(UNDEF_THREADS_HACK) && !defined(THREAD_SAFE_CLIENT)
+#undef THREAD
+#undef HAVE_mit_thread
+#undef HAVE_LINUXTHREADS
+#undef HAVE_UNIXWARE7_THREADS
+#endif
+
+#ifdef HAVE_THREADS_WITHOUT_SOCKETS
+/* MIT pthreads does not work with unix sockets */
+#undef HAVE_SYS_UN_H
+#endif
+
+#define __EXTENSIONS__ 1 /* We want some extension */
+#ifndef __STDC_EXT__
+#define __STDC_EXT__ 1 /* To get large file support on hpux */
+#endif
+#if defined(THREAD) && defined(HAVE_LINUXTHREADS) && defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
+#define _GNU_SOURCE 1
+#endif
+
+#if defined(THREAD) && !defined(__WIN__)
+#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
+/* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */
+#if !defined(SCO)
+#define _REENTRANT 1 /* Some thread libraries require this */
+#endif
+#if !defined(_THREAD_SAFE) && !defined(_AIX)
+#define _THREAD_SAFE /* Required for OSF1 */
+#endif
+#ifndef HAVE_mit_thread
+#ifdef HAVE_UNIXWARE7_THREADS
+#include <thread.h>
+#else
+#include <pthread.h> /* AIX must have this included first */
+#endif /* HAVE_UNIXWARE7_THREADS */
+#endif /* HAVE_mit_thread */
+#if !defined(SCO) && !defined(_REENTRANT)
+#define _REENTRANT 1 /* Threads requires reentrant code */
+#endif
+#endif /* THREAD */
+
+/* Go around some bugs in different OS and compilers */
+#ifdef _AIX /* By soren@t.dk */
+#define _H_STRINGS
+#define _SYS_STREAM_H
+#define _AIX32_CURSES
+#endif
+
+#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */
+#undef HAVE_SNPRINTF
+#endif
+#ifdef HAVE_BROKEN_PREAD /* These doesn't work on HPUX 11.x */
+#undef HAVE_PREAD
+#undef HAVE_PWRITE
+#endif
+
+#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */
+#undef HAVE_GETHOSTBYNAME_R
+#endif
+#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */
+#undef HAVE_INITGROUPS
+#endif
+
+/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
+#if SIZEOF_LONG == 4 && defined(__LONG_MAX__)
+#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */
+#define __LONG_MAX__ 2147483647
+#endif
+
+/* egcs 1.1.2 has a problem with memcpy on Alpha */
+#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
+#define BAD_MEMCPY
+#endif
+
+/* In Linux-alpha we have atomic.h if we are using gcc */
+#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95))
+#define HAVE_ATOMIC_ADD
+#define HAVE_ATOMIC_SUB
+#endif
+
+#if defined(_lint) && !defined(lint)
+#define lint
+#endif
+#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
+#define _LONG_LONG 1 /* For AIX string library */
+#endif
+
+#ifndef stdin
+#include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#include <math.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_TIMEB_H
+#include <sys/timeb.h> /* Avoid warnings on SCO */
+#endif
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif /* TIME_WITH_SYS_TIME */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
+#undef HAVE_ALLOCA
+#undef HAVE_ALLOCA_H
+#endif
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#ifdef HAVE_ATOMIC_ADD
+#define __SMP__
+#include <asm/atomic.h>
+#endif
+
+/* Go around some bugs in different OS and compilers */
+#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
+#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
+#define HAVE_ULONG
+#endif
+#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */
+#undef HAVE_FINITE
+#endif
+
+/* We can not live without these */
+
+#define USE_MYFUNC 1 /* Must use syscall indirection */
+#define MASTER 1 /* Compile without unireg */
+#define ENGLISH 1 /* Messages in English */
+#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */
+#define USE_REGEX 1 /* We want the use the regex library */
+/* Do not define for ultra sparcs */
+#define USE_BMOVE512 1 /* Use this unless the system bmove is faster */
+
+/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
+#ifdef I_AM_PARANOID
+#define DONT_ALLOW_USER_CHANGE 1
+#define DONT_USE_MYSQL_PWD 1
+#endif
+
+/* #define USE_some_charset 1 was deprecated by changes to configure */
+/* my_ctype my_to_upper, my_to_lower, my_sort_order gain theit right value */
+/* automagically during configuration */
+
+/* Does the system remember a signal handler after a signal ? */
+#ifndef HAVE_BSD_SIGNALS
+#define DONT_REMEMBER_SIGNAL
+#endif
+
+/* Define void to stop lint from generating "null effekt" comments */
+#ifdef _lint
+int __void__;
+#define VOID(X) (__void__ = (int) (X))
+#else
+#undef VOID
+#define VOID(X) (X)
+#endif
+
+#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
+#define LINT_INIT(var) var=0 /* No uninitialize-warning */
+#else
+#define LINT_INIT(var)
+#endif
+
+/* Define som useful general macros */
+#if defined(__cplusplus) && defined(__GNUC__)
+#define max(a, b) ((a) >? (b))
+#define min(a, b) ((a) <? (b))
+#elif !defined(max)
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#if defined(__EMX__) || !defined(HAVE_UINT)
+typedef unsigned int uint;
+typedef unsigned short ushort;
+#endif
+
+#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
+#define swap(t,a,b) { register t dummy; dummy = a; a = b; b = dummy; }
+#define test(a) ((a) ? 1 : 0)
+#define set_if_bigger(a,b) { if ((a) < (b)) (a)=(b); }
+#define set_if_smaller(a,b) { if ((a) > (b)) (a)=(b); }
+#define test_all_bits(a,b) (((a) & (b)) == (b))
+#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
+#ifndef HAVE_RINT
+#define rint(A) floor((A)+0.5)
+#endif
+
+/* Define som general constants */
+#ifndef TRUE
+#define TRUE (1) /* Logical true */
+#define FALSE (0) /* Logical false */
+#endif
+
+#if defined(__GNUC__)
+#define function_volatile volatile
+#define my_reinterpret_cast(A) reinterpret_cast<A>
+#define my_const_cast(A) const_cast<A>
+#elif !defined(my_reinterpret_cast)
+#define my_reinterpret_cast(A) (A)
+#define my_const_cast(A) (A)
+#endif
+#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
+#define __attribute__(A)
+#endif
+
+/* From old s-system.h */
+
+/* Support macros for non ansi & other old compilers. Since such
+ things are no longer supported we do nothing. We keep then since
+ some of our code may still be needed to upgrade old customers. */
+#define _VARARGS(X) X
+#define _STATIC_VARARGS(X) X
+#define _PC(X) X
+
+#if defined(DBUG_ON) && defined(DBUG_OFF)
+#undef DBUG_OFF
+#endif
+
+#if defined(_lint) && !defined(DBUG_OFF)
+#define DBUG_OFF
+#endif
+
+#include <dbug.h>
+#ifndef DBUG_OFF
+#define dbug_assert(A) assert(A)
+#else
+#define dbug_assert(A)
+#endif
+
+#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
+#define ASCII_BITS_USED 8 /* Bit char used */
+#define NEAR_F /* No near function handling */
+
+/* Some types that is different between systems */
+
+typedef int File; /* File descriptor */
+#ifndef Socket_defined
+typedef int my_socket; /* File descriptor for sockets */
+#define INVALID_SOCKET -1
+#endif
+typedef RETSIGTYPE sig_handler; /* Function to handle signals */
+typedef void (*sig_return)();/* Returns type from signal */
+#if defined(__GNUC__) && !defined(_lint)
+typedef char pchar; /* Mixed prototypes can take char */
+typedef char puchar; /* Mixed prototypes can take char */
+typedef char pbool; /* Mixed prototypes can take char */
+typedef short pshort; /* Mixed prototypes can take short int */
+typedef float pfloat; /* Mixed prototypes can take float */
+#else
+typedef int pchar; /* Mixed prototypes can't take char */
+typedef uint puchar; /* Mixed prototypes can't take char */
+typedef int pbool; /* Mixed prototypes can't take char */
+typedef int pshort; /* Mixed prototypes can't take short int */
+typedef double pfloat; /* Mixed prototypes can't take float */
+#endif
+typedef int (*qsort_cmp)(const void *,const void *);
+#ifdef HAVE_mit_thread
+#define qsort_t void
+#undef QSORT_TYPE_IS_VOID
+#define QSORT_TYPE_IS_VOID
+#else
+#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
+#endif
+#ifdef HAVE_mit_thread
+#define size_socket socklen_t /* Type of last arg to accept */
+#else
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+typedef SOCKET_SIZE_TYPE size_socket;
+#endif
+
+/* file create flags */
+
+#ifndef O_SHARE
+#define O_SHARE 0 /* Flag to my_open for shared files */
+#ifndef O_BINARY
+#define O_BINARY 0 /* Flag to my_open for binary files */
+#endif
+#define FILE_BINARY 0 /* Flag to my_fopen for binary streams */
+#ifdef HAVE_FCNTL
+#define HAVE_FCNTL_LOCK
+#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
+#endif
+#endif /* O_SHARE */
+#ifndef O_TEMPORARY
+#define O_TEMPORARY 0
+#endif
+#ifndef O_SHORT_LIVED
+#define O_SHORT_LIVED 0
+#endif
+
+/* #define USE_RECORD_LOCK */
+
+ /* Unsigned types supported by the compiler */
+#define UNSINT8 /* unsigned int8 (char) */
+#define UNSINT16 /* unsigned int16 */
+#define UNSINT32 /* unsigned int32 */
+
+ /* General constants */
+#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
+#define FN_LEN 256 /* Max file name len */
+#define FN_HEADLEN 253 /* Max length of filepart of file name */
+#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
+#define FN_REFLEN 512 /* Max length of full path-name */
+#define FN_EXTCHAR '.'
+#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
+#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
+#define FN_PARENTDIR ".." /* Parentdirectory; Must be a string */
+#define FN_DEVCHAR ':'
+
+#ifndef FN_LIBCHAR
+#define FN_LIBCHAR '/'
+#define FN_ROOTDIR "/"
+#define MY_NFILE 127 /* This is only used to save filenames */
+#endif
+
+/* #define EXT_IN_LIBNAME */
+/* #define FN_NO_CASE_SENCE */
+/* #define FN_UPPER_CASE TRUE */
+
+/* Io buffer size; Must be a power of 2 and a multiple of 512. May be
+ smaller what the disk page size. This influences the speed of the
+ isam btree library. eg to big to slow. */
+#define IO_SIZE 4096
+/* How much overhead does malloc have. The code often allocates
+ something like 1024-MALLOC_OVERHEAD bytes */
+#ifdef SAFEMALLOC
+#define MALLOC_OVERHEAD (8+24+4)
+#else
+#define MALLOC_OVERHEAD 8
+#endif
+ /* get memory in huncs */
+#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
+ /* Typical record cash */
+#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
+ /* Typical key cash */
+#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
+
+ /* Some things that this system doesn't have */
+
+#define ONLY_OWN_DATABASES /* We are using only databases by monty */
+#define NO_PISAM /* Not needed anymore */
+#define NO_MISAM /* Not needed anymore */
+#define NO_HASH /* Not needed anymore */
+#ifdef __WIN__
+#define NO_DIR_LIBRARY /* Not standar dir-library */
+#define USE_MY_STAT_STRUCT /* For my_lib */
+#endif
+
+/* Some things that this system does have */
+
+#ifndef HAVE_ITOA
+#define USE_MY_ITOA /* There is no itoa */
+#endif
+
+/* Some defines of functions for portability */
+
+#ifndef HAVE_ATOD
+#define atod atof
+#endif
+#ifdef USE_MY_ATOF
+#define atof my_atof
+extern void init_my_atof(void);
+extern double my_atof(const char*);
+#endif
+#undef remove /* Crashes MySQL on SCO 5.0.0 */
+#ifndef __WIN__
+#define closesocket(A) close(A)
+#ifndef ulonglong2double
+#define ulonglong2double(A) ((double) (A))
+#define my_off_t2double(A) ((double) (A))
+#endif
+#endif
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+#define ulong_to_double(X) ((double) (ulong) (X))
+#define SET_STACK_SIZE(X) /* Not needed on real machines */
+
+#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
+#define strtok_r(A,B,C) strtok((A),(B))
+#endif
+
+#ifdef HAVE_LINUXTHREADS
+/* #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) */
+/* #define sigset(A,B) signal((A),(B)) */
+#endif
+
+/* Remove some things that mit_thread break or doesn't support */
+#if defined(HAVE_mit_thread) && defined(THREAD)
+#undef HAVE_PREAD
+#undef HAVE_REALPATH
+#undef HAVE_MLOCK
+#undef HAVE_TEMPNAM /* Use ours */
+#undef HAVE_PTHREAD_SETPRIO
+#endif
+
+/* This is from the old m-machine.h file */
+
+#if SIZEOF_LONG_LONG > 4
+#define HAVE_LONG_LONG 1
+#endif
+
+#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
+#define LONGLONG_MIN ((long long) 0x8000000000000000LL)
+#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
+#endif
+
+#if SIZEOF_LONG == 4
+#define INT_MIN32 (long) 0x80000000L
+#define INT_MAX32 (long) 0x7FFFFFFFL
+#define INT_MIN24 ((long) 0xff800000L)
+#define INT_MAX24 0x007fffffL
+#define INT_MIN16 ((short int) 0x8000)
+#define INT_MAX16 0x7FFF
+#define INT_MIN8 ((char) 0x80)
+#define INT_MAX8 ((char) 0x7F)
+#else /* Probably Alpha */
+#define INT_MIN32 ((long) (int) 0x80000000)
+#define INT_MAX32 ((long) (int) 0x7FFFFFFF)
+#define INT_MIN24 ((long) (int) 0xff800000)
+#define INT_MAX24 ((long) (int) 0x007fffff)
+#define INT_MIN16 ((short int) 0xffff8000)
+#define INT_MAX16 ((short int) 0x00007FFF)
+#endif
+
+/* From limits.h instead */
+#ifndef DBL_MIN
+#define DBL_MIN 4.94065645841246544e-324
+#define FLT_MIN ((float)1.40129846432481707e-45)
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.79769313486231470e+308
+#define FLT_MAX ((float)3.40282346638528860e+38)
+#endif
+
+/* Max size that must be added to a so that we know Size to make
+ adressable obj. */
+typedef long my_ptrdiff_t;
+#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
+#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
+/* Size to make adressable obj. */
+#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
+ /* Offset of filed f in structure t */
+#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
+#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
+#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
+
+#define NullS (char *) 0
+/* Nowdays we do not support MessyDos */
+#ifndef NEAR
+#define NEAR /* Who needs segments ? */
+#define FAR /* On a good machine */
+#define HUGE_PTR
+#define STDCALL
+#endif
+
+/* Typdefs for easyier portability */
+
+#if defined(VOIDTYPE)
+typedef void *gptr; /* Generic pointer */
+#else
+typedef char *gptr; /* Generic pointer */
+#endif
+#ifndef HAVE_INT_8_16_32
+typedef char int8; /* Signed integer >= 8 bits */
+typedef short int16; /* Signed integer >= 16 bits */
+#endif
+#ifndef HAVE_UCHAR
+typedef unsigned char uchar; /* Short for unsigned char */
+#endif
+typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */
+typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */
+
+#if SIZEOF_INT == 4
+#ifndef HAVE_INT_8_16_32
+typedef int int32;
+#endif
+typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */
+#elif SIZEOF_LONG == 4
+#ifndef HAVE_INT_8_16_32
+typedef long int32;
+#endif
+typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */
+#else
+error "Neither int or long is of 4 bytes width"
+#endif
+
+#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
+typedef unsigned long ulong; /* Short for unsigned long */
+#endif
+#ifndef longlong_defined
+#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
+typedef unsigned long long ulonglong; /* ulong or unsigned long long */
+typedef long long longlong;
+#else
+typedef unsigned long ulonglong; /* ulong or unsigned long long */
+typedef long longlong;
+#endif
+#endif
+
+#ifdef USE_RAID
+/* The following is done with a if to not get problems with pre-processors
+ with late define evaluation */
+#if SIZEOF_OFF_T == 4
+#define SYSTEM_SIZEOF_OFF_T 4
+#else
+#define SYSTEM_SIZEOF_OFF_T 8
+#endif
+#undef SIZEOF_OFF_T
+#define SIZEOF_OFF_T 8
+#endif
+
+#if SIZEOF_OFF_T > 4
+typedef ulonglong my_off_t;
+#else
+typedef unsigned long my_off_t;
+#endif
+#define MY_FILEPOS_ERROR (~(my_off_t) 0)
+#ifndef __WIN__
+typedef off_t os_off_t;
+#endif
+
+typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
+typedef short int15; /* Most effective integer 0 <= x <= 32767 */
+typedef char *my_string; /* String of characters */
+typedef unsigned long size_s; /* Size of strings (In string-funcs) */
+typedef int myf; /* Type of MyFlags in my_funcs */
+#ifndef byte_defined
+typedef char byte; /* Smallest addressable unit */
+#endif
+typedef char my_bool; /* Small bool */
+#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
+typedef char bool; /* Ordinary boolean values 0 1 */
+#endif
+ /* Macros for converting *constants* to the right type */
+#define INT8(v) (int8) (v)
+#define INT16(v) (int16) (v)
+#define INT32(v) (int32) (v)
+#define MYF(v) (myf) (v)
+
+/* Defines to make it possible to prioritize register assignments. No
+ longer needed with moder compilers */
+#ifndef USING_X
+#define reg1 register
+#define reg2 register
+#define reg3 register
+#define reg4 register
+#define reg5 register
+#define reg6 register
+#define reg7 register
+#define reg8 register
+#define reg9 register
+#define reg10 register
+#define reg11 register
+#define reg12 register
+#define reg13 register
+#define reg14 register
+#define reg15 register
+#define reg16 register
+#endif
+
+/* Defines for time function */
+#define SCALE_SEC 100
+#define SCALE_USEC 10000
+#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
+#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
+
+/*
+** Define-funktions for reading and storing in machine independent format
+** (low byte first)
+*/
+
+/* Optimized store functions for Intel x86 */
+#ifdef __i386__
+#define sint2korr(A) (*((int16 *) (A)))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (*((long *) (A)))
+#define uint2korr(A) (*((uint16 *) (A)))
+#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
+#define uint4korr(A) (*((unsigned long *) (A)))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint8korr(A) (*((ulonglong *) (A)))
+#define sint8korr(A) (*((longlong *) (A)))
+#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
+#define int3store(T,A) { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16)); }
+#define int4store(T,A) *((long *) (T))= (long) (A)
+#define int5store(T,A) { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); }
+#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
+
+#define doubleget(V,M) { *((long *) &V) = *((long*) M); \
+ *(((long *) &V)+1) = *(((long*) M)+1); }
+#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
+ *(((long *) T)+1) = *(((long*) &V)+1); }
+#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
+#define float8get(V,M) doubleget((V),(M))
+#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
+#define float8store(V,M) doublestore((V),(M))
+#endif /* __i386__ */
+
+#ifndef sint2korr
+#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
+ ((int16) ((int16) (A)[1]) << 8))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\
+ (((int32) ((uchar) (A)[1]) << 8)) +\
+ (((int32) ((uchar) (A)[2]) << 16)) +\
+ (((int32) ((int16) (A)[3]) << 24)))
+#define sint8korr(A) (longlong) uint8korr(A)
+#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\
+ ((uint16) ((uchar) (A)[1]) << 8))
+#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16))
+#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
+ (((uint32) ((uchar) (A)[5])) << 8) +\
+ (((uint32) ((uchar) (A)[6])) << 16) +\
+ (((uint32) ((uchar) (A)[7])) << 24))) <<\
+ 32))
+#define int2store(T,A) { uint def_temp= (uint) (A) ;\
+ *((uchar*) (T))= (uchar)(def_temp); \
+ *((uchar*) (T+1))=(uchar)((def_temp >> 8)); }
+#define int3store(T,A) { /*lint -save -e734 */\
+ *((T))=(char) ((A));\
+ *((T)+1)=(char) (((A) >> 8));\
+ *((T)+2)=(char) (((A) >> 16)); \
+ /*lint -restore */}
+#define int4store(T,A) { *(T)=(char) ((A));\
+ *((T)+1)=(char) (((A) >> 8));\
+ *((T)+2)=(char) (((A) >> 16));\
+ *((T)+3)=(char) (((A) >> 24)); }
+#define int5store(T,A) { *(T)=((A));\
+ *((T)+1)=(((A) >> 8));\
+ *((T)+2)=(((A) >> 16));\
+ *((T)+3)=(((A) >> 24)); \
+ *((T)+4)=(((A) >> 32)); }
+#define int8store(T,A) { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
+ int4store((T),def_temp); \
+ int4store((T+4),def_temp2); \
+ }
+#ifdef WORDS_BIGENDIAN
+#define float4store(T,A) { *(T)= ((byte *) &A)[3];\
+ *((T)+1)=(char) ((byte *) &A)[2];\
+ *((T)+2)=(char) ((byte *) &A)[1];\
+ *((T)+3)=(char) ((byte *) &A)[0]; }
+
+#define float4get(V,M) { float def_temp;\
+ ((byte*) &def_temp)[0]=(M)[3];\
+ ((byte*) &def_temp)[1]=(M)[2];\
+ ((byte*) &def_temp)[2]=(M)[1];\
+ ((byte*) &def_temp)[3]=(M)[0];\
+ (V)=def_temp; }
+#define float8store(T,V) { *(T)= ((byte *) &V)[7];\
+ *((T)+1)=(char) ((byte *) &V)[6];\
+ *((T)+2)=(char) ((byte *) &V)[5];\
+ *((T)+3)=(char) ((byte *) &V)[4];\
+ *((T)+4)=(char) ((byte *) &V)[3];\
+ *((T)+5)=(char) ((byte *) &V)[2];\
+ *((T)+6)=(char) ((byte *) &V)[1];\
+ *((T)+7)=(char) ((byte *) &V)[0]; }
+
+#define float8get(V,M) { double def_temp;\
+ ((byte*) &def_temp)[0]=(M)[7];\
+ ((byte*) &def_temp)[1]=(M)[6];\
+ ((byte*) &def_temp)[2]=(M)[5];\
+ ((byte*) &def_temp)[3]=(M)[4];\
+ ((byte*) &def_temp)[4]=(M)[3];\
+ ((byte*) &def_temp)[5]=(M)[2];\
+ ((byte*) &def_temp)[6]=(M)[1];\
+ ((byte*) &def_temp)[7]=(M)[0];\
+ (V) = def_temp; }
+#else
+#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
+#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
+#define float8get(V,M) doubleget((V),(M))
+#define float8store(V,M) doublestore((V),(M))
+#endif /* WORDS_BIGENDIAN */
+
+#endif /* sint2korr */
+
+/* Define-funktions for reading and storing in machine format from/to
+ short/long to/from some place in memory V should be a (not
+ register) variable, M is a pointer to byte */
+
+#ifdef WORDS_BIGENDIAN
+
+#define ushortget(V,M) { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
+ ((uint16) ((uint16) (M)[0]) << 8)); }
+#define shortget(V,M) { V = (short) (((short) ((uchar) (M)[1]))+\
+ ((short) ((short) (M)[0]) << 8)); }
+#define longget(V,M) { int32 def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; }
+#define ulongget(V,M) { uint32 def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; }
+#define shortstore(T,A) { uint def_temp=(uint) (A) ;\
+ *(T+1)=(char)(def_temp); \
+ *(T+0)=(char)(def_temp >> 8); }
+#define longstore(T,A) { *((T)+3)=((A));\
+ *((T)+2)=(((A) >> 8));\
+ *((T)+1)=(((A) >> 16));\
+ *((T)+0)=(((A) >> 24)); }
+
+#define doubleget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(double))
+#define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double))
+#define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong))
+#define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong))
+
+#else
+
+#define ushortget(V,M) { V = uint2korr(M); }
+#define shortget(V,M) { V = sint2korr(M); }
+#define longget(V,M) { V = sint4korr(M); }
+#define ulongget(V,M) { V = uint4korr(M); }
+#define shortstore(T,V) int2store(T,V)
+#define longstore(T,V) int4store(T,V)
+#ifndef doubleget
+#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
+#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
+#endif
+#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
+#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
+
+#endif /* WORDS_BIGENDIAN */
+
+/* sprintf does not always return the number of bytes :- */
+#ifdef SPRINTF_RETURNS_INT
+#define my_sprintf(buff,args) sprintf args
+#else
+#ifdef SPRINTF_RETURNS_PTR
+#define my_sprintf(buff,args) ((int)(sprintf args - buff))
+#else
+#define my_sprintf(buff,args) sprintf args,strlen(buff)
+#endif
+#endif
+
+
+#endif /* _global_h */
diff --git a/include/hash.h b/include/hash.h
new file mode 100644
index 00000000000..c98b0851645
--- /dev/null
+++ b/include/hash.h
@@ -0,0 +1,65 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Dynamic hashing of record with different key-length */
+
+#ifndef _hash_h
+#define _hash_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef byte *(*hash_get_key)(const byte *,uint*,my_bool);
+typedef void (*hash_free_key)(void *);
+
+ /* flags for hash_init */
+#define HASH_CASE_INSENSITIVE 1
+
+typedef struct st_hash_info {
+ uint next; /* index to next key */
+ byte *data; /* data for current entry */
+} HASH_LINK;
+
+typedef struct st_hash {
+ uint key_offset,key_length; /* Length of key if const length */
+ uint records,blength,current_record;
+ uint flags;
+ DYNAMIC_ARRAY array; /* Place for hash_keys */
+ hash_get_key get_key;
+ void (*free)(void *);
+ uint (*calc_hashnr)(const byte *key,uint length);
+} HASH;
+
+my_bool hash_init(HASH *hash,uint default_array_elements, uint key_offset,
+ uint key_length, hash_get_key get_key,
+ void (*free_element)(void*), uint flags);
+void hash_free(HASH *tree);
+byte *hash_element(HASH *hash,uint idx);
+gptr hash_search(HASH *info,const byte *key,uint length);
+gptr hash_next(HASH *info,const byte *key,uint length);
+my_bool hash_insert(HASH *info,const byte *data);
+my_bool hash_delete(HASH *hash,byte *record);
+my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
+my_bool hash_check(HASH *hash); /* Only in debug library */
+
+#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
+#define hash_inited(H) ((H)->array.buffer != 0)
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/heap.h b/include/heap.h
new file mode 100644
index 00000000000..74b37b0c534
--- /dev/null
+++ b/include/heap.h
@@ -0,0 +1,181 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file should be included when using heap_database_funktions */
+/* Author: Michael Widenius */
+
+#ifndef _heap_h
+#define _heap_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _my_base_h
+#include <my_base.h>
+#endif
+#ifdef THREAD
+#include <my_pthread.h>
+#include <thr_lock.h>
+#endif
+
+ /* defines used by heap-funktions */
+
+#define HP_MAX_LEVELS 4 /* 128^5 records is enough */
+#define HP_PTRS_IN_NOD 128
+
+ /* struct used with heap_funktions */
+
+typedef struct st_heapinfo /* Struct from heap_info */
+{
+ ulong records; /* Records in database */
+ ulong deleted; /* Deleted records in database */
+ ulong max_records;
+ ulong data_length;
+ ulong index_length;
+ uint reclength; /* Length of one record */
+ int errkey;
+} HEAPINFO;
+
+
+ /* Structs used by heap-database-handler */
+
+typedef struct st_heap_ptrs
+{
+ byte *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */
+} HP_PTRS;
+
+struct st_level_info
+{
+ uint free_ptrs_in_block,records_under_level;
+ HP_PTRS *last_blocks; /* pointers to HP_PTRS or records */
+};
+
+typedef struct st_heap_block /* The data is saved in blocks */
+{
+ HP_PTRS *root;
+ struct st_level_info level_info[HP_MAX_LEVELS+1];
+ uint levels;
+ uint records_in_block; /* Records in a heap-block */
+ uint recbuffer; /* Length of one saved record */
+ ulong last_allocated; /* Blocks allocated, used by keys */
+} HP_BLOCK;
+
+typedef struct st_hp_keyseg /* Key-portion */
+{
+ uint start; /* Start of key in record (from 0) */
+ uint length; /* Keylength */
+ uint type;
+} HP_KEYSEG;
+
+typedef struct st_hp_keydef /* Key definition with open */
+{
+ uint flag; /* NOSAME */
+ uint keysegs; /* Number of key-segment */
+ uint length; /* Length of key (automatic) */
+ HP_KEYSEG *seg;
+ HP_BLOCK block; /* Where keys are saved */
+} HP_KEYDEF;
+
+typedef struct st_heap_share
+{
+ HP_BLOCK block;
+ HP_KEYDEF *keydef;
+ ulong min_records,max_records; /* Params to open */
+ ulong data_length,index_length;
+ uint records; /* records */
+ uint blength;
+ uint deleted; /* Deleted records in database */
+ uint reclength; /* Length of one record */
+ uint changed;
+ uint keys,max_key_length;
+ uint open_count;
+ byte *del_link; /* Link to next block with del. rec */
+ my_string name; /* Name of "memory-file" */
+#ifdef THREAD
+ THR_LOCK lock;
+ pthread_mutex_t intern_lock; /* Locking for use with _locking */
+#endif
+ LIST open_list;
+} HP_SHARE;
+
+struct st_hash_info;
+
+typedef struct st_heap_info
+{
+ HP_SHARE *s;
+ byte *current_ptr;
+ struct st_hash_info *current_hash_ptr;
+ ulong current_record,next_block;
+ int lastinx,errkey;
+ int mode; /* Mode of file (READONLY..) */
+ uint opt_flag,update;
+ byte *lastkey; /* Last used key with rkey */
+#ifdef THREAD
+ THR_LOCK_DATA lock;
+#endif
+ LIST open_list;
+} HP_INFO;
+
+ /* Prototypes for heap-functions */
+
+extern HP_INFO* heap_open(const char *name,int mode,uint keys,
+ HP_KEYDEF *keydef,uint reclength,
+ ulong max_records,ulong min_reloc);
+extern int heap_close(HP_INFO *info);
+extern int heap_write(HP_INFO *info,const byte *buff);
+extern int heap_update(HP_INFO *info,const byte *old,const byte *newdata);
+extern int heap_rrnd(HP_INFO *info,byte *buf,byte *pos);
+extern int heap_scan_init(HP_INFO *info);
+extern int heap_scan(register HP_INFO *info, byte *record);
+extern int heap_delete(HP_INFO *info,const byte *buff);
+extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
+extern int heap_create(const char *name);
+extern int heap_delete_all(const char *name);
+extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
+extern int heap_rename(const char *old_name,const char *new_name);
+extern int heap_panic(enum ha_panic_function flag);
+extern int heap_rsame(HP_INFO *info,byte *record,int inx);
+extern int heap_rnext(HP_INFO *info,byte *record);
+extern int heap_rprev(HP_INFO *info,byte *record);
+extern int heap_rfirst(HP_INFO *info,byte *record);
+extern int heap_rlast(HP_INFO *info,byte *record);
+extern void heap_clear(HP_INFO *info);
+extern int heap_rkey(HP_INFO *info,byte *record,int inx,const byte *key);
+extern gptr heap_find(HP_INFO *info,int inx,const byte *key);
+extern int heap_check_heap(HP_INFO *info);
+extern byte *heap_position(HP_INFO *info);
+
+/* The following is for programs that uses the old HEAP interface where
+ pointer to rows where a long instead of a (byte*).
+*/
+
+#if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION)
+extern int heap_rrnd_old(HP_INFO *info,byte *buf,ulong pos);
+extern ulong heap_position_old(HP_INFO *info);
+#endif
+#ifdef OLD_HEAP_VERSION
+typedef ulong HEAP_PTR;
+#define heap_position(A) heap_position_old(A)
+#define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C)
+#else
+typedef byte *HEAP_PTR;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/m_ctype.h b/include/m_ctype.h
new file mode 100644
index 00000000000..438b7b34c9a
--- /dev/null
+++ b/include/m_ctype.h
@@ -0,0 +1,157 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ A better inplementation of the UNIX ctype(3) library.
+ Notes: global.h should be included before ctype.h
+*/
+
+#ifndef _m_ctype_h
+#define _m_ctype_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CHARSET_DIR "charsets/"
+
+typedef struct charset_info_st
+{
+ uint number;
+ const char *name;
+ uchar *ctype;
+ uchar *to_lower;
+ uchar *to_upper;
+ uchar *sort_order;
+
+ uint strxfrm_multiply;
+ int (*strcoll)(const uchar *, const uchar *);
+ int (*strxfrm)(uchar *, const uchar *, int);
+ int (*strnncoll)(const uchar *, int, const uchar *, int);
+ int (*strnxfrm)(uchar *, const uchar *, int, int);
+ my_bool (*like_range)(const char *, uint, pchar, uint,
+ char *, char *, uint *, uint *);
+
+ uint mbmaxlen;
+ int (*ismbchar)(const char *, const char *);
+ my_bool (*ismbhead)(uint);
+ int (*mbcharlen)(uint);
+} CHARSET_INFO;
+
+/* strings/ctype.c */
+extern CHARSET_INFO *default_charset_info;
+extern CHARSET_INFO *find_compiled_charset(uint cs_number);
+extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
+extern CHARSET_INFO compiled_charsets[];
+
+#define MY_CHARSET_UNDEFINED 0
+#define MY_CHARSET_CURRENT (default_charset_info->number)
+
+#ifdef __WIN__
+#include <ctype.h>
+#endif
+/* Don't include std ctype.h when this is included */
+#define _CTYPE_H
+#define _CTYPE_INCLUDED
+#define __CTYPE_INCLUDED
+#define _CTYPE_USING /* Don't put names in global namespace. */
+
+#define _U 01 /* Upper case */
+#define _L 02 /* Lower case */
+#define _N 04 /* Numeral (digit) */
+#define _S 010 /* Spacing character */
+#define _P 020 /* Punctuation */
+#define _C 040 /* Control character */
+#define _B 0100 /* Blank */
+#define _X 0200 /* heXadecimal digit */
+
+#define my_ctype (default_charset_info->ctype)
+#define my_to_upper (default_charset_info->to_upper)
+#define my_to_lower (default_charset_info->to_lower)
+#define my_sort_order (default_charset_info->sort_order)
+
+#ifndef __WIN__
+#define _toupper(c) (char) my_to_upper[(uchar) (c)]
+#define _tolower(c) (char) my_to_lower[(uchar) (c)]
+#define toupper(c) (char) my_to_upper[(uchar) (c)]
+#define tolower(c) (char) my_to_lower[(uchar) (c)]
+
+#define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
+#define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
+#define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
+#define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
+#define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
+#define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
+#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
+#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
+#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
+#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
+#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
+#define isascii(c) (!((c) & ~0177))
+#define toascii(c) ((c) & 0177)
+
+#ifdef ctype
+#undef ctype
+#endif /* ctype */
+
+#endif /* __WIN__ */
+
+#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L))
+#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _U)
+#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _L)
+#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _N)
+#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _X)
+#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L | _N))
+#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _S)
+#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _P)
+#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
+#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
+#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _C)
+
+#define use_strcoll(s) ((s)->strcoll != NULL)
+#define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply)
+#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c), (d)))
+#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((a), (b), (c), (d)))
+#define my_strxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c)))
+#define my_strcoll(s, a, b) ((s)->strcoll((a), (b)))
+#define my_like_range(s, a, b, c, d, e, f, g, h) \
+ ((s)->like_range((a), (b), (c), (d), (e), (f), (g), (h)))
+
+#define use_mb(s) ((s)->ismbchar != NULL)
+#define MBMAXLEN (default_charset_info->mbmaxlen)
+#define my_ismbchar(s, a, b) ((s)->ismbchar((a), (b)))
+#define my_ismbhead(s, a) ((s)->ismbhead((a)))
+#define my_mbcharlen(s, a) ((s)->mbcharlen((a)))
+
+/* Some macros that should be cleaned up a little */
+#define isvar(c) (isalnum(c) || (c) == '_')
+#define isvar_start(c) (isalpha(c) || (c) == '_')
+#define tocntrl(c) ((c) & 31)
+#define toprint(c) ((c) | 64)
+
+/* XXX: still need to take care of this one */
+#ifdef MY_CHARSET_TIS620
+#error The TIS620 charset is broken at the moment. Tell tim to fix it.
+#define USE_TIS620
+#include "t_ctype.h"
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _m_ctype_h */
diff --git a/include/m_string.h b/include/m_string.h
new file mode 100644
index 00000000000..c17e928ea37
--- /dev/null
+++ b/include/m_string.h
@@ -0,0 +1,241 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* There may be prolems include all of theese. Try to test in
+ configure with ones are needed? */
+
+/* This is needed for the definitions of strchr... on solaris */
+
+#ifndef _m_string_h
+#define _m_string_h
+#ifndef __USE_GNU
+#define __USE_GNU /* We want to use stpcpy */
+#endif
+#if defined(HAVE_STRINGS_H)
+#include <strings.h>
+#endif
+#if defined(HAVE_STRING_H)
+#include <string.h>
+#endif
+
+/* Correct some things for UNIXWARE7 */
+#ifdef HAVE_UNIXWARE7_THREADS
+#undef HAVE_STRINGS_H
+#undef HAVE_MEMORY_H
+#define HAVE_MEMCPY
+#ifndef HAVE_MEMMOVE
+#define HAVE_MEMMOVE
+#endif
+#undef HAVE_BCMP
+#undef bcopy
+#undef bcmp
+#undef bzero
+#endif /* HAVE_UNIXWARE7_THREADS */
+#ifdef _AIX
+#undef HAVE_BCMP
+#endif
+
+/* This is needed for the definitions of bzero... on solaris */
+#if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
+#include <strings.h>
+#endif
+
+/* This is needed for the definitions of memcpy... on solaris */
+#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
+#include <memory.h>
+#endif
+
+#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# define memset(A,C,B) bfill((A),(B),(C))
+# define memmove(d, s, n) bmove ((s), (d), (n))
+#elif defined(HAVE_MEMMOVE)
+# define bmove(d, s, n) memmove((d), (s), (n))
+#else
+# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
+#endif
+
+#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
+#define strmov(A,B) stpcpy((A),(B))
+#endif
+
+/* Unixware 7 */
+#if !defined(HAVE_BFILL)
+# define bfill(A,B,C) memset((A),(C),(B))
+# define bmove_allign(A,B,C) memcpy((A),(B),(C))
+#endif
+
+#if !defined(HAVE_BCMP)
+# define bcopy(s, d, n) memcpy((d), (s), (n))
+# define bcmp(A,B,C) memcmp((A),(B),(C))
+# define bzero(A,B) memset((A),0,(B))
+# define bmove_allign(A,B,C) memcpy((A),(B),(C))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char NEAR _dig_vec[]; /* Declared in int2str() */
+
+#ifdef BAD_STRING_COMPILER
+#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
+#else
+#define strmov_overlapp(A,B) strmov(A,B)
+#define strmake_overlapp(A,B,C) strmake(A,B,C)
+#endif
+
+#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
+#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
+#else
+#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
+#endif
+
+#ifdef MSDOS
+#undef bmove_allign
+#define bmove512(A,B,C) bmove_allign(A,B,C)
+#define my_itoa(A,B,C) itoa(A,B,C)
+#define my_ltoa(A,B,C) ltoa(A,B,C)
+extern void bmove_allign(gptr dst,const gptr src,uint len);
+#endif
+
+#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
+#define bmove512(A,B,C) memcpy(A,B,C)
+#endif
+
+ /* Prototypes for string functions */
+
+#if !defined(bfill) && !defined(HAVE_BFILL)
+extern void bfill(gptr dst,uint len,pchar fill);
+#endif
+
+#if !defined(bzero) && !defined(HAVE_BZERO)
+extern void bzero(gptr dst,uint len);
+#endif
+
+#if !defined(bcmp) && !defined(HAVE_BCMP)
+extern int bcmp(const char *s1,const char *s2,uint len);
+#ifdef HAVE_purify
+extern int my_bcmp(const char *s1,const char *s2,uint len);
+#define bcmp(A,B,C) my_bcmp((A),(B),(C))
+#endif
+#endif
+
+#ifndef bmove512
+extern void bmove512(gptr dst,const gptr src,uint len);
+#endif
+
+#if !defined(HAVE_BMOVE) && !defined(bmove)
+extern void bmove(gptr dst,const char *src,uint len);
+#endif
+
+extern void bmove_upp(char *dst,const char *src,uint len);
+extern void bchange(char *dst,uint old_len,const char *src,
+ uint new_len,uint tot_len);
+extern void strappend(char *s,uint len,pchar fill);
+extern char *strend(const char *s);
+extern char *strcend(const char *, pchar);
+extern char *strfield(char *src,int fields,int chars,int blanks,
+ int tabch);
+extern char *strfill(my_string s,uint len,pchar fill);
+extern uint strinstr(const char *str,const char *search);
+extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
+extern char *strkey(char *dst,char *head,char *tail,char *flags);
+extern char *strmake(char *dst,const char *src,uint length);
+#ifndef strmake_overlapp
+extern char *strmake_overlapp(char *dst,const char *src, uint length);
+#endif
+
+#ifndef strmov
+extern char *strmov(char *dst,const char *src);
+#endif
+extern char *strnmov(char *dst,const char *src,uint n);
+extern char *strsuff(const char *src,const char *suffix);
+extern char *strcont(const char *src,const char *set);
+extern char *strxcat _VARARGS((char *dst,const char *src, ...));
+extern char *strxmov _VARARGS((char *dst,const char *src, ...));
+extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
+extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
+extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
+extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
+
+/* Prototypes of normal stringfunctions (with may ours) */
+
+#ifdef WANT_STRING_PROTOTYPES
+extern char *strcat(char *, const char *);
+extern char *strchr(const char *, pchar);
+extern char *strrchr(const char *, pchar);
+extern char *strcpy(char *, const char *);
+extern int strcmp(const char *, const char *);
+#ifndef __GNUC__
+extern size_t strlen(const char *);
+#endif
+#endif
+#ifndef HAVE_STRNLEN
+extern uint strnlen(const char *s, uint n);
+#endif
+
+#if !defined(__cplusplus)
+#ifndef HAVE_STRPBRK
+extern char *strpbrk(const char *, const char *);
+#endif
+#ifndef HAVE_STRSTR
+extern char *strstr(const char *, const char *);
+#endif
+#endif
+extern int is_prefix(const char *, const char *);
+
+/* Conversion rutins */
+
+#ifdef USE_MY_ITOA
+extern char *my_itoa(int val,char *dst,int radix);
+extern char *my_ltoa(long val,char *dst,int radix);
+#endif
+
+extern char *llstr(longlong value,char *buff);
+#ifndef HAVE_STRTOUL
+extern long strtol(const char *str, char **ptr, int base);
+extern ulong strtoul(const char *str, char **ptr, int base);
+#endif
+
+extern char *int2str(long val,char *dst,int radix);
+extern char *int10_to_str(long val,char *dst,int radix);
+extern char *str2int(const char *src,int radix,long lower,long upper,
+ long *val);
+#if SIZEOF_LONG == SIZEOF_LONG_LONG
+#define longlong2str(A,B,C) int2str((A),(B),(C))
+#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
+#define strtoll(A,B,C) strtol((A),(B),(C))
+#define strtoull(A,B,C) strtoul((A),(B),(C))
+#ifndef HAVE_STRTOULL
+#define HAVE_STRTOULL
+#endif
+#else
+#ifdef HAVE_LONG_LONG
+extern char *longlong2str(longlong val,char *dst,int radix);
+extern char *longlong10_to_str(longlong val,char *dst,int radix);
+#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
+extern longlong strtoll(const char *str, char **ptr, int base);
+extern ulonglong strtoull(const char *str, char **ptr, int base);
+#endif
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/merge.h b/include/merge.h
new file mode 100644
index 00000000000..b090e49b471
--- /dev/null
+++ b/include/merge.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file should be included when using merge_isam_funktions */
+/* Author: Michael Widenius */
+
+#ifndef _merge_h
+#define _merge_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _my_base_h
+#include <my_base.h>
+#endif
+#ifndef _nisam_h
+#include <nisam.h>
+#endif
+
+#define MRG_NAME_EXT ".MRG"
+
+ /* Param to/from mrg_info */
+
+typedef struct st_mrg_info /* Struct from h_info */
+{
+ ulonglong records; /* Records in database */
+ ulonglong deleted; /* Deleted records in database */
+ ulonglong recpos; /* Pos for last used record */
+ ulonglong data_file_length;
+ uint reclength; /* Recordlength */
+ int errkey; /* With key was dupplicated on err */
+ uint options; /* HA_OPTIONS_... used */
+} MERGE_INFO;
+
+typedef struct st_mrg_table_info
+{
+ N_INFO *table;
+ ulonglong file_offset;
+} MRG_TABLE;
+
+typedef struct st_merge
+{
+ MRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
+ ulonglong records; /* records in tables */
+ ulonglong del; /* Removed records */
+ ulonglong data_file_length;
+ uint tables,options,reclength;
+ my_bool cache_in_use;
+ LIST open_list;
+} MRG_INFO;
+
+typedef ulong mrg_off_t;
+
+ /* Prototypes for merge-functions */
+
+extern int mrg_close(MRG_INFO *file);
+extern int mrg_delete(MRG_INFO *file,const byte *buff);
+extern MRG_INFO *mrg_open(const char *name,int mode,int wait_if_locked);
+extern int mrg_panic(enum ha_panic_function function);
+extern int mrg_rfirst(MRG_INFO *file,byte *buf,int inx);
+extern int mrg_rkey(MRG_INFO *file,byte *buf,int inx,const byte *key,
+ uint key_len, enum ha_rkey_function search_flag);
+extern int mrg_rrnd(MRG_INFO *file,byte *buf, mrg_off_t pos);
+extern int mrg_rsame(MRG_INFO *file,byte *record,int inx);
+extern int mrg_update(MRG_INFO *file,const byte *old,const byte *new_rec);
+extern int mrg_info(MRG_INFO *file,MERGE_INFO *x,int flag);
+extern int mrg_lock_database(MRG_INFO *file,int lock_type);
+extern int mrg_create(const char *name,const char **table_names);
+extern int mrg_extra(MRG_INFO *file,enum ha_extra_function function);
+extern ha_rows mrg_records_in_range(MRG_INFO *info,int inx,
+ const byte *start_key,uint start_key_len,
+ enum ha_rkey_function start_search_flag,
+ const byte *end_key,uint end_key_len,
+ enum ha_rkey_function end_search_flag);
+
+extern mrg_off_t mrg_position(MRG_INFO *info);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/my_alarm.h b/include/my_alarm.h
new file mode 100644
index 00000000000..b6c5ca6a3f4
--- /dev/null
+++ b/include/my_alarm.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ File to include when we want to use alarm or a loop_counter to display
+ some information when a program is running
+*/
+#ifndef _my_alarm_h
+#define _my_alarm_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int volatile my_have_got_alarm;
+extern ulong my_time_to_wait_for_lock;
+
+#if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP)
+#include <signal.h>
+#define ALARM_VARIABLES uint alarm_old=0; \
+ sig_return alarm_signal=0
+#define ALARM_INIT my_have_got_alarm=0 ; \
+ alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
+ alarm_signal=signal(SIGALRM,my_set_alarm_variable);
+#define ALARM_END VOID(signal(SIGALRM,alarm_signal)); \
+ VOID(alarm(alarm_old));
+#define ALARM_TEST my_have_got_alarm
+#ifdef DONT_REMEMBER_SIGNAL
+#define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \
+ VOID(signal(SIGALRM,my_set_alarm_variable));\
+ my_have_got_alarm=0;
+#else
+#define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \
+ my_have_got_alarm=0;
+#endif /* DONT_REMEMBER_SIGNAL */
+#else
+#define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1
+#define ALARM_INIT
+#define ALARM_END
+#define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
+#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
+#endif /* HAVE_ALARM */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/my_base.h b/include/my_base.h
new file mode 100644
index 00000000000..429c7132444
--- /dev/null
+++ b/include/my_base.h
@@ -0,0 +1,265 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file includes constants used with all databases */
+/* Author: Michael Widenius */
+
+#ifndef _my_base_h
+#define _my_base_h
+
+#ifndef stdin /* Included first in handler */
+#define USES_TYPES /* my_dir with sys/types is included */
+#define CHSIZE_USED
+#include <global.h>
+#include <my_dir.h> /* This includes types */
+#include <my_sys.h>
+#include <m_string.h>
+#include <errno.h>
+#ifdef MSDOS
+#include <share.h> /* Neaded for sopen() */
+#endif
+#if !defined(USE_MY_FUNC) && !defined(THREAD)
+#include <my_nosys.h> /* For faster code, after test */
+#endif /* USE_MY_FUNC */
+#endif /* stdin */
+#include <my_list.h>
+
+/* The following is bits in the flag parameter to ha_open() */
+
+#define HA_OPEN_ABORT_IF_LOCKED 0 /* default */
+#define HA_OPEN_WAIT_IF_LOCKED 1
+#define HA_OPEN_IGNORE_IF_LOCKED 2
+#define HA_OPEN_TMP_TABLE 4
+#define HA_OPEN_DELAY_KEY_WRITE 8
+
+ /* The following is parameter to ha_rkey() how to use key */
+
+enum ha_rkey_function {
+ HA_READ_KEY_EXACT, /* Find first record else error */
+ HA_READ_KEY_OR_NEXT, /* Record or next record */
+ HA_READ_KEY_OR_PREV, /* Record or previous */
+ HA_READ_AFTER_KEY, /* Find next rec. after key-record */
+ HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
+ HA_READ_PREFIX, /* Key which as same prefix */
+ HA_READ_PREFIX_LAST /* Last key with the same prefix */
+};
+
+ /* The following is parameter to ha_extra() */
+
+enum ha_extra_function {
+ HA_EXTRA_NORMAL=0, /* Optimize for space (def) */
+ HA_EXTRA_QUICK=1, /* Optimize for speed */
+ HA_EXTRA_RESET=2, /* Reset database to after open */
+ HA_EXTRA_CACHE=3, /* Cash record in HA_rrnd() */
+ HA_EXTRA_NO_CACHE=4, /* End cacheing of records (def) */
+ HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */
+ HA_EXTRA_READCHECK=6, /* Use readcheck (def) */
+ HA_EXTRA_KEYREAD=7, /* Read only key to database */
+ HA_EXTRA_NO_KEYREAD=8, /* Normal read of records (def) */
+ HA_EXTRA_NO_USER_CHANGE=9, /* No user is allowed to write */
+ HA_EXTRA_KEY_CACHE=10,
+ HA_EXTRA_NO_KEY_CACHE=11,
+ HA_EXTRA_WAIT_LOCK=12, /* Wait until file is avalably (def) */
+ HA_EXTRA_NO_WAIT_LOCK=13, /* If file is locked, return quickly */
+ HA_EXTRA_WRITE_CACHE=14, /* Use write cache in ha_write() */
+ HA_EXTRA_FLUSH_CACHE=15, /* flush write_record_cache */
+ HA_EXTRA_NO_KEYS=16, /* Remove all update of keys */
+ HA_EXTRA_KEYREAD_CHANGE_POS=17, /* Keyread, but change pos */
+ /* xxxxchk -r must be used */
+ HA_EXTRA_REMEMBER_POS=18, /* Remember pos for next/prev */
+ HA_EXTRA_RESTORE_POS=19,
+ HA_EXTRA_REINIT_CACHE=20, /* init cache from current record */
+ HA_EXTRA_FORCE_REOPEN=21, /* Datafile have changed on disk */
+ HA_EXTRA_FLUSH, /* Flush tables to disk */
+ HA_EXTRA_NO_ROWS /* Don't write rows */
+};
+
+ /* The following is parameter to ha_panic() */
+
+enum ha_panic_function {
+ HA_PANIC_CLOSE, /* Close all databases */
+ HA_PANIC_WRITE, /* Unlock and write status */
+ HA_PANIC_READ /* Lock and read keyinfo */
+};
+
+ /* The following is parameter to ha_create(); keytypes */
+
+enum ha_base_keytype {
+ HA_KEYTYPE_END=0,
+ HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
+ HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
+ HA_KEYTYPE_SHORT_INT=3,
+ HA_KEYTYPE_LONG_INT=4,
+ HA_KEYTYPE_FLOAT=5,
+ HA_KEYTYPE_DOUBLE=6,
+ HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
+ HA_KEYTYPE_USHORT_INT=8,
+ HA_KEYTYPE_ULONG_INT=9,
+ HA_KEYTYPE_LONGLONG=10,
+ HA_KEYTYPE_ULONGLONG=11,
+ HA_KEYTYPE_INT24=12,
+ HA_KEYTYPE_UINT24=13,
+ HA_KEYTYPE_INT8=14,
+ HA_KEYTYPE_VARTEXT=15, /* Key is sorted as letters */
+ HA_KEYTYPE_VARBINARY=16 /* Key is sorted as unsigned chars */
+};
+
+#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
+
+ /* These flags kan be OR:ed to key-flag */
+
+#define HA_NOSAME 1 /* Set if not dupplicated records */
+#define HA_PACK_KEY 2 /* Pack string key to previous key */
+#define HA_AUTO_KEY 16
+#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
+#define HA_FULLTEXT 128 /* SerG: for full-text search */
+#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
+
+ /* Automatic bits in key-flag */
+
+#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
+#define HA_VAR_LENGTH_KEY 8
+#define HA_NULL_PART_KEY 64
+#ifndef ISAM_LIBRARY
+#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
+#else
+/* poor old NISAM has 8-bit flags :-( */
+#define HA_SORT_ALLOWS_SAME 128 /* Intern bit when sorting records */
+#endif
+
+ /* These flags can be order to key-seg-flag */
+
+#define HA_SPACE_PACK 1 /* Pack space in key-seg */
+#define HA_PART_KEY 4 /* Used by MySQL for part-key-cols */
+#define HA_VAR_LENGTH 8
+#define HA_NULL_PART 16
+#define HA_BLOB_PART 32
+#define HA_SWAP_KEY 64
+#define HA_REVERSE_SORT 128 /* Sort key in reverse order */
+
+ /* optionbits for database */
+#define HA_OPTION_PACK_RECORD 1
+#define HA_OPTION_PACK_KEYS 2
+#define HA_OPTION_COMPRESS_RECORD 4
+#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
+#define HA_OPTION_TMP_TABLE 16
+#define HA_OPTION_CHECKSUM 32
+#define HA_OPTION_DELAY_KEY_WRITE 64
+#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
+#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
+#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
+
+ /* Bits in flag to ni_create() */
+
+#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
+#define HA_PACK_RECORD 2 /* Request packed record format */
+#define HA_CREATE_TMP_TABLE 4
+#define HA_CREATE_CHECKSUM 8
+#define HA_CREATE_DELAY_KEY_WRITE 64
+
+ /* Bits in flag to _status */
+
+#define HA_STATUS_POS 1 /* Return position */
+#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
+#define HA_STATUS_TIME 4 /* Return update time */
+#define HA_STATUS_CONST 8 /* Return constants values */
+#define HA_STATUS_VARIABLE 16
+#define HA_STATUS_ERRKEY 32
+#define HA_STATUS_AUTO 64
+
+ /* Errorcodes given by functions */
+
+#define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */
+#define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */
+#define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */
+#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
+#define HA_ERR_CRASHED 126 /* Indexfile is crashed */
+#define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */
+#define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */
+#define HA_ERR_WRONG_COMMAND 131 /* Command not supported */
+#define HA_ERR_OLD_FILE 132 /* old databasfile */
+#define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */
+#define HA_ERR_RECORD_DELETED 134 /* Intern error-code */
+#define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */
+#define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */
+#define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */
+#define HA_ERR_UNSUPPORTED 138 /* unsupported extension used */
+#define HA_ERR_TO_BIG_ROW 139 /* Too big row */
+#define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */
+#define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */
+#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
+#define HA_ERR_WRONG_TABLE_DEF 143
+
+ /* Other constants */
+
+#define HA_NAMELEN 64 /* Max length of saved filename */
+
+ /* Intern constants in databases */
+
+ /* bits in _search */
+#define SEARCH_FIND 1
+#define SEARCH_NO_FIND 2
+#define SEARCH_SAME 4
+#define SEARCH_BIGGER 8
+#define SEARCH_SMALLER 16
+#define SEARCH_SAVE_BUFF 32
+#define SEARCH_UPDATE 64
+#define SEARCH_PREFIX 128
+#define SEARCH_LAST 256
+
+ /* bits in opt_flag */
+#define QUICK_USED 1
+#define READ_CACHE_USED 2
+#define READ_CHECK_USED 4
+#define KEY_READ_USED 8
+#define WRITE_CACHE_USED 16
+#define OPT_NO_ROWS 32
+
+ /* bits in update */
+#define HA_STATE_CHANGED 1 /* Database has changed */
+#define HA_STATE_AKTIV 2 /* Has a current record */
+#define HA_STATE_WRITTEN 4 /* Record is written */
+#define HA_STATE_DELETED 8
+#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
+#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
+#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
+#define HA_STATE_KEY_CHANGED 128
+#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
+#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
+#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
+#define HA_STATE_EXTEND_BLOCK 2048
+
+enum en_fieldtype {
+ FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIPP_ENDSPACE,FIELD_SKIPP_PRESPACE,
+ FIELD_SKIPP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO,
+ FIELD_VARCHAR,FIELD_CHECK
+};
+
+enum data_file_type {
+ STATIC_RECORD,DYNAMIC_RECORD,COMPRESSED_RECORD
+};
+
+/* For number of records */
+#ifdef BIG_TABLES
+typedef my_off_t ha_rows;
+#else
+typedef ulong ha_rows;
+#endif
+
+#define HA_POS_ERROR (~ (ha_rows) 0)
+#define HA_OFFSET_ERROR (~ (my_off_t) 0)
+#endif /* _my_base_h */
diff --git a/include/my_dir.h b/include/my_dir.h
new file mode 100644
index 00000000000..1961ca79549
--- /dev/null
+++ b/include/my_dir.h
@@ -0,0 +1,100 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _my_dir_h
+#define _my_dir_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef MY_DIR_H
+#define MY_DIR_H
+
+#include <sys/stat.h>
+
+ /* Defines for my_dir and my_stat */
+
+#define MY_S_IFMT S_IFMT /* type of file */
+#define MY_S_IFDIR S_IFDIR /* directory */
+#define MY_S_IFCHR S_IFCHR /* character special */
+#define MY_S_IFBLK S_IFBLK /* block special */
+#define MY_S_IFREG S_IFREG /* regular */
+#define MY_S_IFIFO S_IFIFO /* fifo */
+#define MY_S_ISUID S_ISUID /* set user id on execution */
+#define MY_S_ISGID S_ISGID /* set group id on execution */
+#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
+#define MY_S_IREAD S_IREAD /* read permission, owner */
+#define MY_S_IWRITE S_IWRITE /* write permission, owner */
+#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
+
+#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
+#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
+#define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
+#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
+#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
+
+#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
+#define MY_WANT_STAT 1024 /* my_lib; stat files */
+
+ /* typedefs for my_dir & my_stat */
+
+#ifdef USE_MY_STAT_STRUCT
+
+typedef struct my_stat
+{
+ dev_t st_dev; /* major & minor device numbers */
+ ino_t st_ino; /* inode number */
+ ushort st_mode; /* file permissons (& suid sgid .. bits) */
+ short st_nlink; /* number of links to file */
+ ushort st_uid; /* user id */
+ ushort st_gid; /* group id */
+ dev_t st_rdev; /* more major & minor device numbers (???) */
+ off_t st_size; /* size of file */
+ time_t st_atime; /* time for last read */
+ time_t st_mtime; /* time for last contens modify */
+ time_t st_ctime; /* time for last inode or contents modify */
+} MY_STAT;
+
+#else
+
+#define MY_STAT struct stat /* Orginal struct have what we need */
+
+#endif /* USE_MY_STAT_STRUCT */
+
+typedef struct fileinfo /* Struct returned from my_dir & my_stat */
+{
+ char *name;
+ MY_STAT mystat;
+} FILEINFO;
+
+typedef struct st_my_dir /* Struct returned from my_dir */
+{
+ struct fileinfo *dir_entry;
+ uint number_off_files;
+} MY_DIR;
+
+extern MY_DIR *my_dir(const char *path,myf MyFlags);
+extern void my_dirend(MY_DIR *buffer);
+extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
+extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
+
+#endif /* MY_DIR_H */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/my_list.h b/include/my_list.h
new file mode 100644
index 00000000000..7391db70e27
--- /dev/null
+++ b/include/my_list.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _list_h_
+#define _list_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct st_list {
+ struct st_list *prev,*next;
+ void *data;
+} LIST;
+
+typedef int (*list_walk_action)(void *,void *);
+
+extern LIST *list_add(LIST *root,LIST *element);
+extern LIST *list_delete(LIST *root,LIST *element);
+extern LIST *list_cons(void *data,LIST *root);
+extern LIST *list_reverse(LIST *root);
+extern void list_free(LIST *root,pbool free_data);
+extern uint list_length(LIST *list);
+extern int list_walk(LIST *list,list_walk_action action,gptr argument);
+
+#define rest(a) ((a)->next)
+#define list_push(a,b) (a)=list_cons((b),(a))
+#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); }
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/my_net.h b/include/my_net.h
new file mode 100644
index 00000000000..a02a564c527
--- /dev/null
+++ b/include/my_net.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* thread safe version of some common functions */
+
+/* for thread safe my_inet_ntoa */
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__)
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#endif /* !defined(MSDOS) && !defined(__WIN__) */
+
+void my_inet_ntoa(struct in_addr in, char *buf);
diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h
new file mode 100644
index 00000000000..2ff8896fa74
--- /dev/null
+++ b/include/my_no_pthread.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ This undefs some pthread mutex locks when one isn't using threads
+ to make thread safe code, that should also work in single thread
+ environment, easier to use.
+*/
+
+#if !defined(_my_no_pthread_h) && !defined(THREADS)
+#define _my_no_pthread_h
+
+#define pthread_mutex_init(A,B)
+#define pthread_mutex_lock(A)
+#define pthread_mutex_unlock(A)
+#define pthread_mutex_destroy(A)
+
+#endif
diff --git a/include/my_nosys.h b/include/my_nosys.h
new file mode 100644
index 00000000000..5991904f260
--- /dev/null
+++ b/include/my_nosys.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ Header to remove use of my_functions in functions where we need speed and
+ where calls to posix functions should work
+*/
+#ifndef _my_nosys_h
+#define _my_nosys_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MY_NOSYS__
+#define __MY_NOSYS__
+
+#ifdef MSDOS
+#include <io.h> /* Get prototypes for read()... */
+#endif
+#ifndef HAVE_STDLIB_H
+#include <malloc.h>
+#endif
+
+#undef my_read /* Can be predefined in raid.h */
+#undef my_write
+#undef my_seek
+#define my_read(a,b,c,d) my_quick_read(a,b,c,d)
+#define my_write(a,b,c,d) my_quick_write(a,b,c)
+extern uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf myFlags);
+extern uint my_quick_write(File Filedes,const byte *Buffer,uint Count);
+
+#if !defined(SAFEMALLOC) && defined(USE_HALLOC)
+#define my_malloc(a,b) halloc(a,1)
+#define my_no_flags_free(a) hfree(a)
+#endif
+
+#endif /* __MY_NOSYS__ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
new file mode 100644
index 00000000000..9c0d6d1b9d9
--- /dev/null
+++ b/include/my_pthread.h
@@ -0,0 +1,538 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Defines to make different thread packages compatible */
+
+#ifndef _my_pthread_h
+#define _my_pthread_h
+
+#include <errno.h>
+#ifndef ETIME
+#define ETIME ETIMEDOUT // For FreeBSD
+#endif
+
+#if defined(__WIN__)
+
+typedef CRITICAL_SECTION pthread_mutex_t;
+typedef HANDLE pthread_t;
+typedef struct thread_attr {
+ DWORD dwStackSize ;
+ DWORD dwCreatingFlag ;
+ int priority ;
+} pthread_attr_t ;
+
+typedef struct { int dummy; } pthread_condattr_t;
+
+/* Implementation of posix conditions */
+
+typedef struct st_pthread_link {
+ DWORD thread_id;
+ struct st_pthread_link *next;
+} pthread_link;
+
+typedef struct {
+ uint32 waiting;
+ HANDLE semaphore;
+} pthread_cond_t;
+
+
+struct timespec { /* For pthread_cond_timedwait() */
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define win_pthread_self my_thread_var->pthread_self
+#define pthread_handler_decl(A,B) unsigned __cdecl A(void *B)
+typedef unsigned (__cdecl *pthread_handler)(void *);
+
+int win_pthread_setspecific(void *A,void *B,uint length);
+int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
+int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ struct timespec *abstime);
+int pthread_cond_signal(pthread_cond_t *cond);
+int pthread_cond_broadcast(pthread_cond_t *cond);
+int pthread_cond_destroy(pthread_cond_t *cond);
+int pthread_attr_init(pthread_attr_t *connect_att);
+int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
+int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
+int pthread_attr_destroy(pthread_attr_t *connect_att);
+struct tm *localtime_r(const time_t *timep,struct tm *tmp);
+
+void pthread_exit(unsigned A); /* was #define pthread_exit(A) ExitThread(A)*/
+
+#define ETIMEDOUT 145 /* Win32 doesn't have this */
+#define getpid() GetCurrentThreadId()
+#define pthread_self() win_pthread_self
+#define HAVE_LOCALTIME_R
+#define _REENTRANT
+#define HAVE_PTHREAD_ATTR_SETSTACKSIZE
+
+#ifdef USE_TLS /* For LIBMYSQL.DLL */
+#define pthread_key(T,V) DWORD V
+#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
+#define pthread_getspecific(A) (TlsGetValue(A))
+#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
+#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(A))
+#define my_pthread_setspecific_ptr(T,V) TlsSetValue(T,V)
+#define pthread_setspecific(A,B) TlsSetValue(A,B)
+#else
+#define pthread_key(T,V) __declspec(thread) T V
+#define pthread_key_create(A,B) pthread_dummy(0)
+#define pthread_getspecific(A) (&(A))
+#define my_pthread_getspecific(T,A) (&(A))
+#define my_pthread_getspecific_ptr(T,V) (V)
+#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0)
+#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
+#endif /* USE_TLS */
+
+#define pthread_equal(A,B) ((A) == (B))
+#define pthread_mutex_init(A,B) InitializeCriticalSection(A)
+#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
+#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
+#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
+#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
+/* Dummy defines for easier code */
+#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
+#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
+#define pthread_attr_setscope(A,B)
+#define pthread_detach_this_thread()
+#define pthread_condattr_init(A)
+#define pthread_condattr_destroy(A)
+
+//Irena: compiler does not like this:
+//#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0)
+#define my_pthread_getprio(thread_id) pthread_dummy(0)
+
+#elif defined(HAVE_UNIXWARE7_THREADS)
+
+#include <thread.h>
+#include <synch.h>
+
+#ifndef _REENTRANT
+#define _REENTRANT
+#endif
+
+#define HAVE_NONPOSIX_SIGWAIT
+#define pthread_t thread_t
+#define pthread_cond_t cond_t
+#define pthread_mutex_t mutex_t
+#define pthread_key_t thread_key_t
+typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */
+
+#define pthread_key_create(A,B) thr_keycreate((A),(B))
+
+#define pthread_handler_decl(A,B) void *A(void *B)
+#define pthread_key(T,V) pthread_key_t V
+
+void * my_pthread_getspecific_imp(pthread_key_t key);
+#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
+#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V)
+
+#define pthread_setspecific(A,B) thr_setspecific(A,B)
+#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V)
+
+#define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A))
+#define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL)
+#define pthread_cond_destroy(a) cond_destroy(a)
+#define pthread_cond_signal(a) cond_signal(a)
+#define pthread_cond_wait(a,b) cond_wait((a),(b))
+#define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c))
+#define pthread_cond_broadcast(a) cond_broadcast(a)
+
+#define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL)
+#define pthread_mutex_lock(a) mutex_lock(a)
+#define pthread_mutex_unlock(a) mutex_unlock(a)
+#define pthread_mutex_destroy(a) mutex_destroy(a)
+
+#define pthread_self() thr_self()
+#define pthread_exit(A) thr_exit(A)
+#define pthread_equal(A,B) (((A) == (B)) ? 1 : 0)
+#define pthread_kill(A,B) thr_kill((A),(B))
+#define HAVE_PTHREAD_KILL
+
+#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C))
+
+extern int my_sigwait(sigset_t *set,int *sig);
+
+#define pthread_detach_this_thread() pthread_dummy(0)
+
+#define pthread_attr_init(A) pthread_dummy(0)
+#define pthread_attr_destroy(A) pthread_dummy(0)
+#define pthread_attr_setscope(A,B) pthread_dummy(0)
+#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
+#define my_pthread_setprio(A,B) pthread_dummy (0)
+#define my_pthread_getprio(A) pthread_dummy (0)
+#define my_pthread_attr_setprio(A,B) pthread_dummy(0)
+
+#else /* Normal threads */
+
+#ifdef HAVE_rts_threads
+#define sigwait org_sigwait
+#include <signal.h>
+#undef sigwait
+#endif
+#undef _REENTRANT /* Fix if _REENTRANT is in pthread.h */
+#include <pthread.h>
+#ifndef _REENTRANT
+#define _REENTRANT
+#endif
+#ifdef HAVE_THR_SETCONCURRENCY
+#include <thread.h> /* Probably solaris */
+#endif
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
+#ifdef HAVE_SYNCH_H
+#include <synch.h>
+#endif
+#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
+#error Requires at least rev 2 of EMX pthreads library.
+#endif
+
+extern int my_pthread_getprio(pthread_t thread_id);
+
+#define pthread_key(T,V) pthread_key_t V
+#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
+#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
+#define pthread_detach_this_thread()
+#define pthread_handler_decl(A,B) void *A(void *B)
+typedef void *(* pthread_handler)(void *);
+
+/* safe mutex for debugging */
+
+typedef struct st_safe_mutex_t
+{
+ pthread_mutex_t global,mutex;
+ char *file;
+ uint line,count;
+ pthread_t thread;
+} safe_mutex_t;
+
+int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
+int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
+int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
+int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
+int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
+ uint line);
+int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
+ struct timespec *abstime, const char *file, uint line);
+
+#ifdef SAFE_MUTEX
+#undef pthread_mutex_init
+#undef pthread_mutex_lock
+#undef pthread_mutex_unlock
+#undef pthread_mutex_destroy
+#undef pthread_mutex_wait
+#undef pthread_mutex_timedwait
+#undef pthread_mutex_t
+#define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
+#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
+#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
+#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
+#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
+#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
+#define pthread_mutex_t safe_mutex_t
+#endif
+
+/* Test first for RTS or FSU threads */
+
+#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
+#define HAVE_rts_threads
+extern int my_pthread_create_detached;
+#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
+#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
+#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
+#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
+#define USE_ALARM_THREAD
+#elif defined(HAVE_mit_thread)
+#define USE_ALARM_THREAD
+#undef HAVE_LOCALTIME_R
+#define HAVE_LOCALTIME_R
+#undef HAVE_PTHREAD_ATTR_SETSCOPE
+#define HAVE_PTHREAD_ATTR_SETSCOPE
+#undef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R /* If we are running linux */
+#undef HAVE_RWLOCK_T
+#undef HAVE_RWLOCK_INIT
+#undef HAVE_PTHREAD_RWLOCK_RDLOCK
+#undef HAVE_SNPRINTF
+
+#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
+#define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
+#define my_pthread_attr_setprio(A,B)
+#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
+
+#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
+int sigwait(const sigset_t *set, int *sig);
+#endif
+
+#if defined(HAVE_UNIXWARE7_POSIX)
+#undef HAVE_NONPOSIX_SIGWAIT
+#define HAVE_NONPOSIX_SIGWAIT /* sigwait takes only 1 argument */
+#endif
+
+#ifndef HAVE_NONPOSIX_SIGWAIT
+#define my_sigwait(A,B) sigwait((A),(B))
+#else
+int my_sigwait(sigset_t *set,int *sig);
+#endif
+
+#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
+#ifndef SAFE_MUTEX
+#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
+extern int my_pthread_mutex_init(pthread_mutex_t *mp,
+ const pthread_mutexattr_t *attr);
+#endif /* SAFE_MUTEX */
+#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
+extern int my_pthread_cond_init(pthread_cond_t *mp,
+ const pthread_condattr_t *attr);
+#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
+
+#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
+#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
+#endif
+
+#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
+int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
+#endif
+#if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
+#define sigset(A,B) do { struct sigaction s; sigset_t set; \
+ sigemptyset(&set); \
+ s.sa_handler = (B); \
+ s.sa_mask = set; \
+ s.sa_flags = 0; \
+ sigaction((A), &s, (struct sigaction *) NULL); \
+ } while (0)
+#endif
+
+#ifndef my_pthread_setprio
+#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
+#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
+#elif defined(HAVE_PTHREAD_SETPRIO)
+#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
+#else
+extern void my_pthread_setprio(pthread_t thread_id,int prior);
+#endif
+#endif
+
+#ifndef my_pthread_attr_setprio
+#ifdef HAVE_PTHREAD_ATTR_SETPRIO
+#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
+#else
+extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
+#endif
+#endif
+
+#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
+#define pthread_attr_setscope(A,B)
+#undef HAVE_GETHOSTBYADDR_R /* No definition */
+#endif
+
+#ifndef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
+#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
+#else
+#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
+void *my_pthread_getspecific_imp(pthread_key_t key);
+#endif
+
+#ifndef HAVE_LOCALTIME_R
+struct tm *localtime_r(const time_t *clock, struct tm *res);
+#endif
+
+#ifdef HAVE_PTHREAD_CONDATTR_CREATE
+/* DCE threads on HPUX 10.20 */
+#define pthread_condattr_init pthread_condattr_create
+#define pthread_condattr_destroy pthread_condattr_delete
+#endif
+
+#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
+#define pthread_cond_destroy(A) pthread_dummy(0)
+#define pthread_mutex_destroy(A) pthread_dummy(0)
+#define pthread_attr_delete(A) pthread_dummy(0)
+#define pthread_condattr_delete(A) pthread_dummy(0)
+#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
+#define pthread_equal(A,B) ((A) == (B))
+#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
+#define pthread_attr_init(A) pthread_attr_create(A)
+#define pthread_attr_destroy(A) pthread_attr_delete(A)
+#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
+#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
+#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
+#define pthread_kill(A,B) pthread_dummy(0)
+#undef pthread_detach_this_thread
+#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
+#endif
+
+#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
+/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
+#define pthread_key_create(A,B) \
+ pthread_keycreate(A,(B) ?\
+ (pthread_destructor_t) (B) :\
+ (pthread_destructor_t) pthread_dummy)
+#define pthread_attr_init(A) pthread_attr_create(A)
+#define pthread_attr_destroy(A) pthread_attr_delete(A)
+#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
+#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
+#ifndef pthread_sigmask
+#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
+#endif
+#define pthread_kill(A,B) pthread_dummy(0)
+#undef pthread_detach_this_thread
+#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
+#else /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
+#define HAVE_PTHREAD_KILL
+#endif
+
+#if defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R)
+#if !defined(HPUX)
+struct hostent;
+#endif /* HPUX */
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *result, char *buffer,
+ int buflen, int *h_errnop);
+#if defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R)
+#define GETHOSTBYNAME_BUFF_SIZE 2048
+#else
+#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
+#endif /* defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
+
+#else
+#ifdef HAVE_GETHOSTBYNAME_R_WITH_HOSTENT_DATA
+#define GETHOSTBYNAME_BUFF_SIZE sizeof(hostent_data)
+#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(hostent_data*) (C))
+#else
+#define GETHOSTBYNAME_BUFF_SIZE 2048
+#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
+#endif /* HAVE_GETHOSTBYNAME_R_WITH_HOSTENT_DATA */
+#endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
+
+#endif /* defined(__WIN__) */
+
+/* READ-WRITE thread locking */
+
+#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
+/* use these defs for simple mutex locking */
+#define rw_lock_t pthread_mutex_t
+#define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
+#define rw_rdlock(A) pthread_mutex_lock((A))
+#define rw_wrlock(A) pthread_mutex_lock((A))
+#define rw_unlock(A) pthread_mutex_unlock((A))
+#define rwlock_destroy(A) pthread_mutex_destroy((A))
+#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
+#define rw_lock_t pthread_rwlock_t
+#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
+#define rw_rdlock(A) pthread_rwlock_rdlock(A)
+#define rw_wrlock(A) pthread_rwlock_wrlock(A)
+#define rw_unlock(A) pthread_rwlock_unlock(A)
+#define rwlock_destroy(A) pthread_rwlock_destroy(A)
+#elif defined(HAVE_RWLOCK_INIT)
+#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */
+#define rw_lock_t rwlock_t
+#endif
+#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
+#else
+/* Use our own version of read/write locks */
+typedef struct _my_rw_lock_t {
+ pthread_mutex_t lock; /* lock for structure */
+ pthread_cond_t readers; /* waiting readers */
+ pthread_cond_t writers; /* waiting writers */
+ int state; /* -1:writer,0:free,>0:readers */
+ int waiters; /* number of waiting writers */
+} my_rw_lock_t;
+
+#define rw_lock_t my_rw_lock_t
+#define rw_rdlock(A) my_rw_rdlock((A))
+#define rw_wrlock(A) my_rw_wrlock((A))
+#define rw_unlock(A) my_rw_unlock((A))
+#define rwlock_destroy(A) my_rwlock_destroy((A))
+
+extern int my_rwlock_init( my_rw_lock_t *, void * );
+extern int my_rwlock_destroy( my_rw_lock_t * );
+extern int my_rw_rdlock( my_rw_lock_t * );
+extern int my_rw_wrlock( my_rw_lock_t * );
+extern int my_rw_unlock( my_rw_lock_t * );
+#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */
+
+#define GETHOSTBYADDR_BUFF_SIZE 2048
+
+#ifndef HAVE_THR_SETCONCURRENCY
+#define thr_setconcurrency(A) pthread_dummy(0)
+#endif
+#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
+#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
+#endif
+
+extern my_bool my_thread_global_init(void);
+extern void my_thread_global_end(void);
+extern my_bool my_thread_init(void);
+extern void my_thread_end(void);
+extern char *my_thread_name(void);
+extern long my_thread_id(void);
+extern int pthread_no_free(void *);
+extern int pthread_dummy(int);
+
+/* All thread specific variables are in the following struct */
+
+#define THREAD_NAME_SIZE 10
+
+struct st_my_thread_var
+{
+ int thr_errno;
+ int cmp_length;
+ volatile int abort;
+ long id;
+ pthread_cond_t suspend, *current_cond;
+ pthread_mutex_t mutex, *current_mutex;
+ pthread_t pthread_self;
+#ifndef DBUG_OFF
+ char name[THREAD_NAME_SIZE+1];
+ gptr dbug;
+#endif
+};
+
+extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
+#define my_thread_var (_my_thread_var())
+#define my_errno my_thread_var->thr_errno
+
+ /* statistics_xxx functions are for not essential statistic */
+
+#ifndef thread_safe_increment
+#ifdef HAVE_ATOMIC_ADD
+#define thread_safe_increment(V,L) atomic_add(1,(atomic_t*) &V);
+#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V);
+#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V);
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#else
+#define thread_safe_increment(V,L) \
+ pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L));
+#define thread_safe_add(V,C,L) \
+ pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
+#define thread_safe_sub(V,C,L) \
+ pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
+#ifdef SAFE_STATISTICS
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#else
+#define statistic_increment(V,L) (V)++
+#define statistic_add(V,C,L) (V)+=(C)
+#endif /* SAFE_STATISTICS */
+#endif /* HAVE_ATOMIC_ADD */
+#endif /* thread_safe_increment */
+#endif /* _my_ptread_h */
diff --git a/include/my_sys.h b/include/my_sys.h
new file mode 100644
index 00000000000..57734e9e534
--- /dev/null
+++ b/include/my_sys.h
@@ -0,0 +1,555 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _my_sys_h
+#define _my_sys_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_AIOWAIT
+#include <sys/asynch.h> /* Used by record-cache */
+typedef struct my_aio_result {
+ aio_result_t result;
+ int pending;
+} my_aio_result;
+#endif
+
+#ifndef THREAD
+extern int NEAR my_errno; /* Last error in mysys */
+#else
+#include <my_pthread.h>
+#endif
+
+#ifndef _m_ctype_h
+#include <m_ctype.h> /* for CHARSET_INFO */
+#endif
+
+#include <stdarg.h>
+
+#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
+#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
+#define MY_INIT(name); { my_progname= name; my_init(); }
+
+#define MAXMAPS (4) /* Number of error message maps */
+#define ERRMOD (1000) /* Max number of errors in a map */
+#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
+#define NRERRBUFFS (2) /* Buffers for parameters */
+#define MY_FILE_ERROR ((uint) ~0)
+
+ /* General bitmaps for my_func's */
+#define MY_FFNF 1 /* Fatal if file not found */
+#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
+#define MY_NABP 4 /* Error if not all bytes read/writen */
+#define MY_FAE 8 /* Fatal if any error */
+#define MY_WME 16 /* Write message on error */
+#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
+#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
+#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
+#define MY_COPYTIME 64 /* my_redel() copys time */
+#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
+#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
+#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
+#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
+#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
+#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
+#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
+#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
+
+#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
+#define MY_GIVE_INFO 2 /* Give time info about process*/
+
+#define ME_HIGHBYTE 8 /* Shift for colours */
+#define ME_NOCUR 1 /* Don't use curses message */
+#define ME_OLDWIN 2 /* Use old window */
+#define ME_BELL 4 /* Ring bell then printing message */
+#define ME_HOLDTANG 8 /* Don't delete last keys */
+#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */
+#define ME_WAITTANG 32 /* Wait for a user action */
+#define ME_NOREFRESH 64 /* Dont refresh screen */
+#define ME_NOINPUT 128 /* Dont use the input libary */
+#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */
+#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
+#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
+
+ /* My seek flags */
+#define MY_SEEK_SET 0
+#define MY_SEEK_CUR 1
+#define MY_SEEK_END 2
+
+ /* My charsets_list flags */
+#define MY_NO_SETS 0
+#define MY_COMPILED_SETS 1 /* show compiled-in sets */
+#define MY_CONFIG_SETS 2 /* sets that have a *.conf file */
+#define MY_INDEX_SETS 4 /* all sets listed in the Index file */
+#define MY_LOADED_SETS 8 /* the sets that are currently loaded */
+
+ /* Some constants */
+#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
+#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
+#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
+#define KEYCACHE_BLOCK_SIZE 1024
+
+ /* defines when allocating data */
+
+#ifdef SAFEMALLOC
+#define my_malloc(SZ,FLAG) _mymalloc( SZ, __FILE__, __LINE__, FLAG )
+#define my_realloc(PTR,SZ,FLAG) _myrealloc( PTR, SZ, __FILE__, __LINE__, FLAG )
+#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
+#define my_free(PTR,FLAG) _myfree( PTR, __FILE__, __LINE__,FLAG)
+#define my_memdup(A,B,C) _my_memdup(A,B,__FILE__,__LINE__,C)
+#define my_strdup(A,C) _my_strdup(A,__FILE__,__LINE__,C)
+#define QUICK_SAFEMALLOC sf_malloc_quick=1
+#define NORMAL_SAFEMALLOC sf_malloc_quick=0
+extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
+#else
+#define my_checkmalloc() (0)
+#define TERMINATE(A) {}
+#define QUICK_SAFEMALLOC
+#define NORMAL_SAFEMALLOC
+extern gptr my_malloc(uint Size,myf MyFlags);
+extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
+extern void my_no_flags_free(gptr ptr);
+extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
+extern my_string my_strdup(const char *from,myf MyFlags);
+#define my_free(PTR,FG) my_no_flags_free(PTR)
+#endif
+#ifdef HAVE_ALLOCA
+#define my_alloca(SZ) alloca((size_t) (SZ))
+#define my_afree(PTR) {}
+#else
+#define my_alloca(SZ) my_malloc(SZ,MYF(0))
+#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
+#endif /* HAVE_ALLOCA */
+#ifdef MSDOS
+#ifdef __ZTC__
+void * __CDECL halloc(long count,size_t length);
+void __CDECL hfree(void *ptr);
+#endif
+#if defined(USE_HALLOC)
+#if defined(_VCM_) || defined(M_IC80386)
+#undef USE_HALLOC
+#endif
+#endif
+#ifdef USE_HALLOC
+#define malloc(a) halloc((long) (a),1)
+#define free(a) hfree(a)
+#endif
+#endif /* MSDOS */
+
+#ifdef HAVE_ERRNO_AS_DEFINE
+#include <errno.h> /* errno is a define */
+#else
+extern int errno; /* declare errno */
+#endif
+extern const char ** NEAR errmsg[];
+extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
+extern char *home_dir; /* Home directory for user */
+extern char *my_progname; /* program-name (printed in errors) */
+extern char NEAR curr_dir[]; /* Current directory for user */
+extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
+extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
+ myf MyFlags);
+
+/* charsets */
+extern uint get_charset_number(const char *cs_name);
+extern const char *get_charset_name(uint cs_number);
+extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
+extern my_bool set_default_charset(uint cs, myf flags);
+extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
+extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
+extern void free_charsets(void);
+extern char *list_charsets(myf want_flags); /* my_free() this string... */
+
+
+/* statisticts */
+extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
+ _my_cache_read;
+extern ulong _my_blocks_used,_my_blocks_changed;
+extern uint my_file_opened,my_stream_opened;
+
+ /* Point to current my_message() */
+extern void (*my_sigtstp_cleanup)(void),
+ /* Executed before jump to shell */
+ (*my_sigtstp_restart)(void),
+ (*my_abort_hook)(int);
+ /* Executed when comming from shell */
+extern int NEAR my_umask, /* Default creation mask */
+ NEAR my_umask_dir,
+ NEAR my_recived_signals, /* Signals we have got */
+ NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
+ NEAR my_dont_interrupt; /* call remember_intr when set */
+extern my_bool NEAR mysys_uses_curses, my_use_symdir;
+extern long lCurMemory,lMaxMemory; /* from safemalloc */
+
+extern ulong my_default_record_cache_size;
+extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
+ NEAR my_disable_flush_key_blocks;
+extern char wild_many,wild_one,wild_prefix;
+extern const char *charsets_dir;
+
+typedef struct wild_file_pack /* Struct to hold info when selecting files */
+{
+ uint wilds; /* How many wildcards */
+ uint not_pos; /* Start of not-theese-files */
+ my_string *wild; /* Pointer to wildcards */
+} WF_PACK;
+
+typedef struct st_typelib { /* Different types saved here */
+ uint count; /* How many types */
+ const char *name; /* Name of typelib */
+ const char **type_names;
+} TYPELIB;
+
+enum cache_type {READ_CACHE,WRITE_CACHE,READ_NET,WRITE_NET};
+enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED,
+ FLUSH_FORCE_WRITE};
+
+typedef struct st_record_cache /* Used when cacheing records */
+{
+ File file;
+ int rc_seek,error,inited;
+ uint rc_length,read_length,reclength;
+ my_off_t rc_record_pos,end_of_file;
+ byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
+#ifdef HAVE_AIOWAIT
+ int use_async_io;
+ my_aio_result aio_result;
+#endif
+ enum cache_type type;
+} RECORD_CACHE;
+
+enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE,
+ STREAM_BY_FOPEN, STREAM_BY_FDOPEN };
+
+extern struct my_file_info
+{
+ my_string name;
+ enum file_type type;
+} my_file_info[MY_NFILE];
+
+
+typedef struct st_dynamic_array {
+ char *buffer;
+ uint elements,max_element;
+ uint alloc_increment;
+ uint size_of_element;
+} DYNAMIC_ARRAY;
+
+typedef struct st_dynamic_string {
+ char *str;
+ uint length,max_length,alloc_increment;
+} DYNAMIC_STRING;
+
+
+typedef struct st_io_cache /* Used when cacheing files */
+{
+ byte *rc_pos,*rc_end,*buffer,*rc_request_pos;
+ File file;
+ int seek_not_done,error;
+ uint buffer_length,read_length;
+ my_off_t pos_in_file,end_of_file;
+ myf myflags; /* Flags used to my_read/my_write */
+#ifdef HAVE_AIOWAIT
+ uint inited;
+ my_off_t aio_read_pos;
+ my_aio_result aio_result;
+#endif
+ enum cache_type type;
+ int (*read_function)(struct st_io_cache *,byte *,uint);
+ char *file_name; /* if used with 'open_cached_file' */
+} IO_CACHE;
+
+typedef int (*qsort2_cmp)(const void *, const void *, const void *);
+
+ /* defines for mf_iocache */
+
+ /* Test if buffer is inited */
+#define my_b_clear(info) (info)->buffer=0
+#define my_b_inited(info) (info)->buffer
+#define my_b_EOF INT_MIN
+
+#define my_b_read(info,Buffer,Count) \
+ ((info)->rc_pos + (Count) <= (info)->rc_end ?\
+ (memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \
+ ((info)->rc_pos+=(Count)),0) :\
+ (*(info)->read_function)((info),Buffer,Count))
+
+#define my_b_get(info) \
+ ((info)->rc_pos != (info)->rc_end ?\
+ ((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
+ _my_b_get(info))
+
+#define my_b_write(info,Buffer,Count) \
+ ((info)->rc_pos + (Count) <= (info)->rc_end ?\
+ (memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
+ ((info)->rc_pos+=(Count)),0) :\
+ _my_b_write(info,Buffer,Count))
+
+ /* my_b_write_byte dosn't have any err-check */
+#define my_b_write_byte(info,chr) \
+ (((info)->rc_pos < (info)->rc_end) ?\
+ ((*(info)->rc_pos++)=(chr)) :\
+ (_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr))))
+
+#define my_b_fill_cache(info) \
+ (((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0))
+
+#define my_b_tell(info) ((info)->pos_in_file + \
+ ((info)->rc_pos - (info)->rc_request_pos))
+
+typedef struct st_changeable_var {
+ const char *name;
+ long *varptr;
+ long def_value,min_value,max_value,sub_size,block_size;
+} CHANGEABLE_VAR;
+
+
+/* structs for alloc_root */
+
+#ifndef ST_USED_MEM_DEFINED
+#define ST_USED_MEM_DEFINED
+typedef struct st_used_mem { /* struct for once_alloc */
+ struct st_used_mem *next; /* Next block in use */
+ unsigned int left; /* memory left in block */
+ unsigned int size; /* size of block */
+} USED_MEM;
+
+typedef struct st_mem_root {
+ USED_MEM *free;
+ USED_MEM *used;
+ unsigned int min_malloc;
+ unsigned int block_size;
+ void (*error_handler)(void);
+} MEM_ROOT;
+#endif
+
+ /* Prototypes for mysys and my_func functions */
+
+extern int my_copy(const char *from,const char *to,myf MyFlags);
+extern int my_append(const char *from,const char *to,myf MyFlags);
+extern int my_delete(const char *name,myf MyFlags);
+extern int my_getwd(my_string buf,uint size,myf MyFlags);
+extern int my_setwd(const char *dir,myf MyFlags);
+extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
+extern gptr my_once_alloc(uint Size,myf MyFlags);
+extern void my_once_free(void);
+extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
+extern File my_open(const char *FileName,int Flags,myf MyFlags);
+extern File my_create(const char *FileName,int CreateFlags,
+ int AccsesFlags, myf MyFlags);
+extern int my_close(File Filedes,myf MyFlags);
+extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
+extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
+extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
+ myf MyFlags);
+extern int my_rename(const char *from,const char *to,myf MyFlags);
+extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
+extern my_off_t my_tell(File fd,myf MyFlags);
+extern uint my_write(File Filedes,const byte *Buffer,uint Count,
+ myf MyFlags);
+extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
+ my_off_t offset,myf MyFlags);
+extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
+extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
+ myf MyFlags);
+extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
+extern my_off_t my_ftell(FILE *stream,myf MyFlags);
+extern gptr _mymalloc(uint uSize,const char *sFile,
+ uint uLine, myf MyFlag);
+extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
+ uint uLine, myf MyFlag);
+extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
+extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
+extern int _sanity(const char *sFile,unsigned int uLine);
+extern gptr _my_memdup(const byte *from,uint length,
+ const char *sFile, uint uLine,myf MyFlag);
+extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
+ myf MyFlag);
+#ifndef TERMINATE
+extern void TERMINATE(FILE *file);
+#endif
+extern void init_glob_errs(void);
+extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
+extern FILE *my_fdopen(File Filedes,int Flags,myf MyFlags);
+extern int my_fclose(FILE *fd,myf MyFlags);
+extern int my_chsize(File fd,my_off_t newlength,myf MyFlags);
+extern int my_error _VARARGS((int nr,myf MyFlags, ...));
+extern int my_printf_error _VARARGS((uint my_err, const char *format,
+ myf MyFlags, ...)
+ __attribute__ ((format (printf, 2, 4))));
+extern int my_vsnprintf( char *str, size_t n,
+ const char *format, va_list ap );
+
+extern int my_message(uint my_err, const char *str,myf MyFlags);
+extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
+extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
+extern void my_init(void);
+extern void my_end(int infoflag);
+extern int my_redel(const char *from, const char *to, int MyFlags);
+extern int my_copystat(const char *from, const char *to, int MyFlags);
+extern my_string my_filename(File fd);
+
+extern void dont_break(void);
+extern void allow_break(void);
+extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
+extern void caseup(my_string str,uint length);
+extern void casedn(my_string str,uint length);
+extern void caseup_str(my_string str);
+extern void casedn_str(my_string str);
+extern void case_sort(my_string str,uint length);
+extern uint dirname_part(my_string to,const char *name);
+extern uint dirname_length(const char *name);
+#define base_name(A) (A+dirname_length(A))
+extern int test_if_hard_path(const char *dir_name);
+extern void convert_dirname(my_string name);
+extern void to_unix_path(my_string name);
+extern my_string fn_ext(const char *name);
+extern my_string fn_same(my_string toname,const char *name,int flag);
+extern my_string fn_format(my_string to,const char *name,const char *dsk,
+ const char *form,int flag);
+extern size_s strlength(const char *str);
+extern void pack_dirname(my_string to,const char *from);
+extern uint unpack_dirname(my_string to,const char *from);
+extern uint cleanup_dirname(my_string to,const char *from);
+extern uint system_filename(my_string to,const char *from);
+extern my_string unpack_filename(my_string to,const char *from);
+extern my_string intern_filename(my_string to,const char *from);
+extern my_string directory_file_name(my_string dst, const char *src);
+extern int pack_filename(my_string to, const char *name, size_s max_length);
+extern my_string my_path(my_string to,const char *progname,
+ const char *own_pathname_part);
+extern my_string my_load_path(my_string to, const char *path,
+ const char *own_path_prefix);
+extern int wild_compare(const char *str,const char *wildstr);
+extern my_string my_strcasestr(const char *src,const char *suffix);
+extern int my_strcasecmp(const char *s,const char *t);
+extern int my_strsortcmp(const char *s,const char *t);
+extern int my_casecmp(const char *s,const char *t,uint length);
+extern int my_sortcmp(const char *s,const char *t,uint length);
+extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
+extern WF_PACK *wf_comp(my_string str);
+extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
+extern void wf_end(struct wild_file_pack *buffer);
+extern size_s stripp_sp(my_string str);
+extern void get_date(my_string to,int timeflag,time_t use_time);
+extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
+extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
+ uint reclength,enum cache_type type,
+ pbool use_async_io);
+extern int read_cache_record(RECORD_CACHE *info,byte *to);
+extern int end_record_cache(RECORD_CACHE *info);
+extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
+ const byte *record,uint length);
+extern int flush_write_cache(RECORD_CACHE *info);
+extern long my_clock(void);
+extern sig_handler sigtstp_handler(int signal_number);
+extern void handle_recived_signals(void);
+extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
+extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length,
+ uint block_length,int return_buffer);
+extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length,
+ uint block_length,int force_write);
+extern int flush_key_blocks(int file, enum flush_type type);
+extern void end_key_cache(void);
+extern sig_handler my_set_alarm_variable(int signo);
+extern void my_string_ptr_sort(void *base,uint items,size_s size);
+extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
+ size_s size_of_element,uchar *buffer[]);
+extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
+ qsort2_cmp cmp, void *cmp_argument);
+extern qsort2_cmp get_ptr_compare(uint);
+extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
+ enum cache_type type,my_off_t seek_offset,
+ pbool use_async_io, myf cache_myflags);
+extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
+ my_off_t seek_offset,pbool use_async_io,
+ pbool clear_cache);
+extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
+extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
+extern int _my_b_get(IO_CACHE *info);
+extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
+extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
+extern int my_block_write(IO_CACHE *info, const byte *Buffer,
+ uint Count, my_off_t pos);
+extern int flush_io_cache(IO_CACHE *info);
+extern int end_io_cache(IO_CACHE *info);
+extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
+ const char *prefix, uint cache_size,
+ myf cache_myflags);
+extern my_bool real_open_cached_file(IO_CACHE *cache);
+extern void close_cached_file(IO_CACHE *cache);
+extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
+ uint init_alloc,uint alloc_increment);
+extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
+extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
+extern byte *pop_dynamic(DYNAMIC_ARRAY*);
+extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
+extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
+extern void delete_dynamic(DYNAMIC_ARRAY *array);
+extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
+extern void freeze_size(DYNAMIC_ARRAY *array);
+#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
+#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
+#define push_dynamic(A,B) insert_dynamic(A,B)
+
+extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
+extern void make_type(my_string to,uint nr,TYPELIB *typelib);
+extern const char *get_type(TYPELIB *typelib,uint nr);
+extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
+ uint init_alloc,uint alloc_increment);
+extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
+extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
+extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
+extern void dynstr_free(DYNAMIC_STRING *str);
+void set_all_changeable_vars(CHANGEABLE_VAR *vars);
+my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
+my_bool set_changeable_varval(const char *var, ulong val,
+ CHANGEABLE_VAR *vars);
+#ifdef HAVE_MLOCK
+extern byte *my_malloc_lock(uint length,myf flags);
+extern void my_free_lock(byte *ptr,myf flags);
+#else
+#define my_malloc_lock(A,B) my_malloc((A),(B))
+#define my_free_lock(A,B) my_free((A),(B))
+#endif
+void init_alloc_root(MEM_ROOT *mem_root,uint block_size);
+gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
+void free_root(MEM_ROOT *root);
+char *strdup_root(MEM_ROOT *root,const char *str);
+char *memdup_root(MEM_ROOT *root,const char *str,uint len);
+void load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv);
+void free_defaults(char **argv);
+void print_defaults(const char *conf_file, const char **groups);
+my_bool my_compress(byte *, ulong *, ulong *);
+my_bool my_uncompress(byte *, ulong *, ulong *);
+byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
+ulong checksum(const byte *mem, uint count);
+
+#if defined(_MSC_VER) && !defined(__WIN__)
+extern void sleep(int sec);
+#endif
+#ifdef __WIN__
+extern my_bool have_tcpip; /* Is set if tcpip is used */
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#include "raid.h"
+#endif /* _my_sys_h */
diff --git a/include/my_tree.h b/include/my_tree.h
new file mode 100644
index 00000000000..84815591e36
--- /dev/null
+++ b/include/my_tree.h
@@ -0,0 +1,75 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _tree_h
+#define _tree_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_TREE_HIGHT 40 /* = max 1048576 leafs in tree */
+#define ELEMENT_KEY(tree,element)\
+(tree->offset_to_key ? (void*)((byte*) element+tree->offset_to_key) :\
+ *((void**) (element+1)))
+
+#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
+
+typedef enum { left_root_right, right_root_left } TREE_WALK;
+typedef uint32 element_count;
+typedef int (*tree_walk_action)(void *,element_count,void *);
+
+#ifdef MSDOS
+typedef struct st_tree_element {
+ struct st_tree_element *left,*right;
+ unsigned long count;
+ uchar colour; /* black is marked as 1 */
+} TREE_ELEMENT;
+#else
+typedef struct st_tree_element {
+ struct st_tree_element *left,*right;
+ uint32 count:31,
+ colour:1; /* black is marked as 1 */
+} TREE_ELEMENT;
+#endif /* MSDOS */
+
+typedef struct st_tree {
+ TREE_ELEMENT *root,null_element;
+ TREE_ELEMENT **parents[MAX_TREE_HIGHT];
+ uint offset_to_key,elements_in_tree,size_of_element;
+ qsort_cmp compare;
+ MEM_ROOT mem_root;
+ my_bool with_delete;
+ void (*free)(void *);
+} TREE;
+
+ /* Functions on hole tree */
+void init_tree(TREE *tree,uint default_alloc_size, int element_size,
+ qsort_cmp compare, my_bool with_delete,
+ void (*free_element)(void*));
+void delete_tree(TREE*);
+
+ /* Functions on leafs */
+TREE_ELEMENT *tree_insert(TREE *tree,void *key,uint key_size);
+void *tree_search(TREE *tree,void *key);
+int tree_walk(TREE *tree,tree_walk_action action,
+ void *argument, TREE_WALK visit);
+int tree_delete(TREE *tree,void *key);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/myisam.h b/include/myisam.h
new file mode 100644
index 00000000000..2b8f75b2050
--- /dev/null
+++ b/include/myisam.h
@@ -0,0 +1,377 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file should be included when using myisam_funktions */
+
+#ifndef _myisam_h
+#define _myisam_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _my_base_h
+#include <my_base.h>
+#endif
+#ifndef _m_ctype_h
+#include <m_ctype.h>
+#endif
+
+ /* defines used by myisam-funktions */
+
+/* The following defines can be increased if necessary */
+#define MI_MAX_KEY 32 /* Max allowed keys */
+#define MI_MAX_KEY_SEG 16 /* Max segments for key */
+#define MI_MAX_KEY_LENGTH 500
+
+#define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8)
+#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */
+#define MI_MAX_POSSIBLE_KEY 64 /* For myisam_chk */
+#define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */
+#define MI_NAME_IEXT ".MYI"
+#define MI_NAME_DEXT ".MYD"
+
+#define mi_portable_sizeof_char_ptr 8
+
+typedef uint32 ha_checksum;
+
+ /* Param to/from mi_info */
+
+typedef struct st_mi_isaminfo /* Struct from h_info */
+{
+ ha_rows records; /* Records in database */
+ ha_rows deleted; /* Deleted records in database */
+ my_off_t recpos; /* Pos for last used record */
+ my_off_t newrecpos; /* Pos if we write new record */
+ my_off_t dupp_key_pos; /* Position to record with dupp key */
+ my_off_t data_file_length, /* Length of data file */
+ max_data_file_length,
+ index_file_length,
+ max_index_file_length,
+ delete_length;
+ ulong reclength; /* Recordlength */
+ ulong mean_reclength; /* Mean recordlength (if packed) */
+ ulonglong auto_increment;
+ ulonglong key_map; /* Which keys are used */
+ uint keys; /* Number of keys in use */
+ uint options; /* HA_OPTIONS_... used */
+ int errkey, /* With key was dupplicated on err */
+ sortkey; /* clustered by this key */
+ File filenr; /* (uniq) filenr for datafile */
+ time_t create_time; /* When table was created */
+ time_t check_time;
+ time_t update_time;
+ uint reflength;
+ ulong record_offset;
+ ulong *rec_per_key; /* for sql optimizing */
+ uint raid_type,raid_chunks;
+ ulong raid_chunksize;
+} MI_ISAMINFO;
+
+
+typedef struct st_mi_create_info
+{
+ ha_rows max_rows;
+ ha_rows reloc_rows;
+ ulonglong auto_increment;
+ ulonglong data_file_length;
+ uint raid_type,raid_chunks;
+ ulong raid_chunksize;
+ uint old_options;
+ uint8 language;
+} MI_CREATE_INFO;
+
+struct st_myisam_info; /* For referense */
+typedef struct st_myisam_info MI_INFO;
+
+typedef struct st_mi_keyseg /* Key-portion */
+{
+ uint8 type; /* Type of key (for sort) */
+ uint8 language;
+ uint8 null_bit; /* bitmask to test for NULL */
+ uint8 bit_start,bit_end; /* if bit field */
+ uint16 flag;
+ uint16 length; /* Keylength */
+ uint32 start; /* Start of key in record */
+ uint32 null_pos; /* position to NULL indicator */
+ CHARSET_INFO *charset;
+} MI_KEYSEG;
+
+
+struct st_mi_s_param;
+
+typedef struct st_mi_keydef /* Key definition with open & info */
+{
+ uint16 keysegs; /* Number of key-segment */
+ uint16 flag; /* NOSAME, PACK_USED */
+
+ uint16 block_length; /* Length of keyblock (auto) */
+ uint16 underflow_block_length; /* When to execute underflow */
+ uint16 keylength; /* Tot length of keyparts (auto) */
+ uint16 minlength; /* min length of (packed) key (auto) */
+ uint16 maxlength; /* max length of (packed) key (auto) */
+ uint16 block_size; /* block_size (auto) */
+ uint32 version; /* For concurrent read/write */
+
+ MI_KEYSEG *seg,*end;
+ int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
+ uchar *page,uchar *key,
+ uint key_len,uint comp_flag,uchar * *ret_pos,
+ uchar *buff, my_bool *was_last_key);
+ uint (*get_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar * *page,
+ uchar *key);
+ int (*pack_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar *next_key,
+ uchar *org_key, uchar *prev_key, uchar *key,
+ struct st_mi_s_param *s_temp);
+ void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
+ struct st_mi_s_param *s_temp);
+} MI_KEYDEF;
+
+
+#define MI_UNIQUE_HASH_LENGTH 4
+
+typedef struct st_unique_def /* Segment definition of unique */
+{
+ uint16 keysegs; /* Number of key-segment */
+ uchar key; /* Mapped to which key */
+ uint8 null_are_equal;
+ MI_KEYSEG *seg,*end;
+} MI_UNIQUEDEF;
+
+typedef struct st_mi_decode_tree /* Decode huff-table */
+{
+ uint16 *table;
+ uint quick_table_bits;
+ byte *intervalls;
+} MI_DECODE_TREE;
+
+
+struct st_mi_bit_buff;
+
+/* Note that null markers should always be first in a row !
+ When creating a column, one should only specify:
+ type, length, null_bit and null_pos */
+
+typedef struct st_columndef /* column information */
+{
+ int16 type; /* en_fieldtype */
+ uint16 length; /* length of field */
+ uint32 offset; /* Offset to position in row */
+ uint8 null_bit; /* If column may be 0 */
+ uint16 null_pos; /* position for null marker */
+
+#ifndef NOT_PACKED_DATABASES
+ void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
+ uchar *start,uchar *end);
+ enum en_fieldtype base_type;
+ uint space_length_bits,pack_type;
+ MI_DECODE_TREE *huff_tree;
+#endif
+} MI_COLUMNDEF;
+
+
+extern my_string myisam_log_filename; /* Name of logfile */
+extern uint myisam_block_size;
+extern my_bool myisam_flush,myisam_delay_key_write,
+ myisam_concurrent_insert;
+
+ /* Prototypes for myisam-functions */
+
+extern int mi_close(struct st_myisam_info *file);
+extern int mi_delete(struct st_myisam_info *file,const byte *buff);
+extern struct st_myisam_info *mi_open(const char *name,int mode,
+ uint wait_if_locked);
+extern int mi_panic(enum ha_panic_function function);
+extern int mi_rfirst(struct st_myisam_info *file,byte *buf,int inx);
+extern int mi_rkey(struct st_myisam_info *file,byte *buf,int inx,
+ const byte *key,
+ uint key_len, enum ha_rkey_function search_flag);
+extern int mi_rlast(struct st_myisam_info *file,byte *buf,int inx);
+extern int mi_rnext(struct st_myisam_info *file,byte *buf,int inx);
+extern int mi_rnext_same(struct st_myisam_info *info, byte *buf);
+extern int mi_rprev(struct st_myisam_info *file,byte *buf,int inx);
+extern int mi_rrnd(struct st_myisam_info *file,byte *buf, my_off_t pos);
+extern int mi_scan_init(struct st_myisam_info *file);
+extern int mi_scan(struct st_myisam_info *file,byte *buf);
+extern int mi_rsame(struct st_myisam_info *file,byte *record,int inx);
+extern int mi_rsame_with_pos(struct st_myisam_info *file,byte *record,
+ int inx, my_off_t pos);
+extern int mi_update(struct st_myisam_info *file,const byte *old,
+ byte *new_record);
+extern int mi_write(struct st_myisam_info *file,byte *buff);
+extern my_off_t mi_position(struct st_myisam_info *file);
+extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
+extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
+extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef,
+ uint columns, MI_COLUMNDEF *columndef,
+ uint uniques, MI_UNIQUEDEF *uniquedef,
+ MI_CREATE_INFO *create_info, uint flags);
+extern int mi_delete_table(const char *name);
+extern int mi_rename(const char *from, const char *to);
+extern int mi_extra(struct st_myisam_info *file,
+ enum ha_extra_function function);
+extern ha_rows mi_records_in_range(struct st_myisam_info *info,int inx,
+ const byte *start_key,uint start_key_len,
+ enum ha_rkey_function start_search_flag,
+ const byte *end_key,uint end_key_len,
+ enum ha_rkey_function end_search_flag);
+extern int mi_log(int activate_log);
+extern int mi_is_changed(struct st_myisam_info *info);
+extern int mi_delete_all_rows(struct st_myisam_info *info);
+extern ulong _mi_calc_blob_length(uint length , const byte *pos);
+extern uint mi_get_pointer_length(ulonglong file_length, uint def);
+
+/* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */
+
+#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r*/
+#define MYISAMCHK_VERIFY 2 /* run equivalent of myisamchk -c,
+ * if corruption is detected, do myisamchk -r*/
+
+/* definitions needed for myisamchk.c -- by Sasha Pachev */
+
+#define T_VERBOSE 1
+#define T_SILENT 2
+#define T_DESCRIPT 4
+#define T_EXTEND 8
+#define T_INFO 16
+#define T_REP 32
+#define T_OPT 64 /* Not currently used */
+#define T_FORCE_CREATE 128
+#define T_WRITE_LOOP 256
+#define T_UNPACK 512
+#define T_STATISTICS 1024
+#define T_VERY_SILENT 2048
+#define T_SORT_RECORDS 4096
+#define T_SORT_INDEX 8192
+#define T_WAIT_FOREVER 16384
+#define T_REP_BY_SORT 32768L
+#define T_FAST 65536L
+#define T_READONLY 131072L
+#define T_MEDIUM T_READONLY*2
+#define T_AUTO_INC T_MEDIUM*2
+#define T_CHECK T_AUTO_INC*2
+#define T_UPDATE_STATE T_CHECK*2
+#define T_CHECK_ONLY_CHANGED T_UPDATE_STATE*2
+#define T_DONT_CHECK_CHECKSUM T_CHECK_ONLY_CHANGED*2
+
+#define O_NEW_INDEX 1 /* Bits set in out_flag */
+#define O_NEW_DATA 2
+
+/* these struct is used by my_check to tell it what to do */
+
+typedef struct st_sort_key_blocks { /* Used when sorting */
+ uchar *buff,*end_pos;
+ uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF];
+ uint last_length;
+ int inited;
+} SORT_KEY_BLOCKS;
+
+struct st_mi_check_param;
+
+typedef struct st_sort_info {
+ MI_INFO *info;
+ struct st_mi_check_param *param;
+ enum data_file_type new_data_file_type;
+ SORT_KEY_BLOCKS *key_block,*key_block_end;
+ uint key,find_length;
+ my_off_t pos,max_pos,filepos,start_recpos,filelength,dupp,buff_length;
+ ha_rows max_records;
+ ulonglong unique[MI_MAX_KEY_SEG+1];
+ my_bool fix_datafile;
+ char *record,*buff;
+ MI_KEYDEF *keyinfo;
+ MI_KEYSEG *keyseg;
+} SORT_INFO;
+
+
+typedef struct st_mi_check_param
+{
+ ulong use_buffers,read_buffer_length,write_buffer_length,
+ sort_buffer_length,sort_key_blocks;
+ uint out_flag,warning_printed,error_printed,
+ opt_rep_quick,verbose;
+ uint opt_sort_key,total_files,max_level;
+ uint8 language;
+ my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
+ uint testflag;
+ ha_rows total_records,total_deleted;
+ ulonglong auto_increment_value;
+ my_off_t search_after_block;
+ ulonglong max_data_file_length;
+ ulonglong keys_in_use;
+ my_off_t new_file_pos,key_file_blocks;
+ my_off_t keydata,totaldata,key_blocks;
+ ha_checksum record_checksum,glob_crc;
+ char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir;
+ int tmpfile_createflag;
+ myf myf_rw;
+ IO_CACHE read_cache;
+ SORT_INFO sort_info;
+ ulonglong unique_count[MI_MAX_KEY_SEG+1];
+ ha_checksum key_crc[MI_MAX_POSSIBLE_KEY];
+ ulong rec_per_key_part[MI_MAX_KEY_SEG*MI_MAX_POSSIBLE_KEY];
+ void* thd;
+ char* table_name;
+ char* op_name;
+} MI_CHECK;
+
+
+typedef struct st_mi_sortinfo {
+ uint key_length;
+ ha_rows max_records;
+ SORT_INFO *sort_info;
+ char *tmpdir;
+ int (*key_cmp)(SORT_INFO *info, const void *, const void *);
+ int (*key_read)(SORT_INFO *info,void *buff);
+ int (*key_write)(SORT_INFO *info, const void *buff);
+ void (*lock_in_memory)(MI_CHECK *info);
+} MI_SORT_PARAM;
+
+/* functions in mi_check */
+void myisamchk_init(MI_CHECK *param);
+int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag);
+int chk_size(MI_CHECK *param, MI_INFO *info);
+int chk_key(MI_CHECK *param, MI_INFO *info);
+int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
+int mi_repair(MI_CHECK *param, register MI_INFO *info,
+ my_string name, int rep_quick);
+int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name);
+int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
+ const char * name, int rep_quick);
+int change_to_newfile(const char * filename, const char * old_ext,
+ const char * new_ext, uint raid_chunks);
+int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
+ const char *filetype, const char *filename);
+void lock_memory(MI_CHECK *param);
+int flush_blocks(MI_CHECK *param, File file);
+ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
+ my_bool repair);
+int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
+int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
+ my_off_t length, const char *type);
+int movepoint(MI_INFO *info,byte *record,my_off_t oldpos,
+ my_off_t newpos, uint prot_key);
+int sort_write_record(SORT_INFO *sort_info);
+ int write_data_suffix(MI_CHECK *param, MI_INFO *info);
+int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
+ ulong);
+int test_if_almost_full(MI_INFO *info);
+int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/myisammrg.h b/include/myisammrg.h
new file mode 100644
index 00000000000..cf18e407962
--- /dev/null
+++ b/include/myisammrg.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file should be included when using merge_isam_funktions */
+
+#ifndef _myisammrg_h
+#define _myisammrg_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _my_base_h
+#include <my_base.h>
+#endif
+#ifndef _myisam_h
+#include <myisam.h>
+#endif
+
+#define MYRG_NAME_EXT ".MRG"
+
+ /* Param to/from myrg_info */
+
+typedef struct st_mymerge_info /* Struct from h_info */
+{
+ ulonglong records; /* Records in database */
+ ulonglong deleted; /* Deleted records in database */
+ ulonglong recpos; /* Pos for last used record */
+ ulonglong data_file_length;
+ uint reclength; /* Recordlength */
+ int errkey; /* With key was dupplicated on err */
+ uint options; /* HA_OPTIONS_... used */
+} MYMERGE_INFO;
+
+typedef struct st_myrg_table_info
+{
+ struct st_myisam_info *table;
+ ulonglong file_offset;
+} MYRG_TABLE;
+
+typedef struct st_myrg_info
+{
+ MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
+ ulonglong records; /* records in tables */
+ ulonglong del; /* Removed records */
+ ulonglong data_file_length;
+ uint tables,options,reclength;
+ my_bool cache_in_use;
+ LIST open_list;
+} MYRG_INFO;
+
+
+ /* Prototypes for merge-functions */
+
+extern int myrg_close(MYRG_INFO *file);
+extern int myrg_delete(MYRG_INFO *file,const byte *buff);
+extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked);
+extern int myrg_panic(enum ha_panic_function function);
+extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
+extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
+ uint key_len, enum ha_rkey_function search_flag);
+extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);
+extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx);
+extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec);
+extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
+extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
+extern int myrg_create(const char *name,const char **table_names);
+extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function);
+extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
+ const byte *start_key,uint start_key_len,
+ enum ha_rkey_function start_search_flag,
+ const byte *end_key,uint end_key_len,
+ enum ha_rkey_function end_search_flag);
+
+extern ulonglong myrg_position(MYRG_INFO *info);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/myisampack.h b/include/myisampack.h
new file mode 100644
index 00000000000..1e63b47fc48
--- /dev/null
+++ b/include/myisampack.h
@@ -0,0 +1,207 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ Storing of values in high byte first order.
+
+ integer keys and file pointers are stored with high byte first to get
+ better compression
+*/
+
+#define mi_sint2korr(A) (int16) (((int16) ((uchar) (A)[1])) +\
+ ((int16) ((int16) (A)[0]) << 8))
+#define mi_sint3korr(A) ((int32) ((((uchar) (A)[0]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[0]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[2])) : \
+ (((uint32) (uchar) (A)[0]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[2])))
+#define mi_sint4korr(A) (int32) (((int32) ((uchar) (A)[3])) +\
+ (((int32) ((uchar) (A)[2]) << 8)) +\
+ (((int32) ((uchar) (A)[1]) << 16)) +\
+ (((int32) ((int16) (A)[0]) << 24)))
+#define mi_sint8korr(A) (longlong) mi_uint8korr(A)
+#define mi_uint2korr(A) (uint16) (((uint16) ((uchar) (A)[1])) +\
+ ((uint16) ((uchar) (A)[0]) << 8))
+#define mi_uint3korr(A) (uint32) (((uint32) ((uchar) (A)[2])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[0])) << 16))
+#define mi_uint4korr(A) (uint32) (((uint32) ((uchar) (A)[3])) +\
+ (((uint32) ((uchar) (A)[2])) << 8) +\
+ (((uint32) ((uchar) (A)[1])) << 16) +\
+ (((uint32) ((uchar) (A)[0])) << 24))
+#define mi_uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[4])) +\
+ (((uint32) ((uchar) (A)[3])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[1])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[0])) << 32))
+#define mi_uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[5])) +\
+ (((uint32) ((uchar) (A)[4])) << 8) +\
+ (((uint32) ((uchar) (A)[3])) << 16) +\
+ (((uint32) ((uchar) (A)[2])) << 24)) +\
+ (((ulonglong) (((uint32) ((uchar) (A)[1])) +\
+ (((uint32) ((uchar) (A)[0]) << 8)))) <<\
+ 32))
+#define mi_uint7korr(A) ((ulonglong)(((uint32) ((uchar) (A)[6])) +\
+ (((uint32) ((uchar) (A)[5])) << 8) +\
+ (((uint32) ((uchar) (A)[4])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) (((uint32) ((uchar) (A)[2])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[0])) << 16))) <<\
+ 32))
+#define mi_uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[7])) +\
+ (((uint32) ((uchar) (A)[6])) << 8) +\
+ (((uint32) ((uchar) (A)[5])) << 16) +\
+ (((uint32) ((uchar) (A)[4])) << 24)) +\
+ (((ulonglong) (((uint32) ((uchar) (A)[3])) +\
+ (((uint32) ((uchar) (A)[2])) << 8) +\
+ (((uint32) ((uchar) (A)[1])) << 16) +\
+ (((uint32) ((uchar) (A)[0])) << 24))) <<\
+ 32))
+
+#define mi_int2store(T,A) { uint def_temp= (uint) (A) ;\
+ *((uchar*) ((T)+1))= (uchar)(def_temp); \
+ *((uchar*) ((T)+0))= (uchar)(def_temp >> 8); }
+#define mi_int3store(T,A) { /*lint -save -e734 */\
+ ulong def_temp= (ulong) (A);\
+ *(((T)+2))=(char) (def_temp);\
+ *((T)+1)= (char) (def_temp >> 8);\
+ *((T)+0)= (char) (def_temp >> 16);\
+ /*lint -restore */}
+#define mi_int4store(T,A) { ulong def_temp= (ulong) (A);\
+ *((T)+3)=(char) (def_temp);\
+ *((T)+2)=(char) (def_temp >> 8);\
+ *((T)+1)=(char) (def_temp >> 16);\
+ *((T)+0)=(char) (def_temp >> 24); }
+#define mi_int5store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ *((T)+4)=(char) (def_temp);\
+ *((T)+3)=(char) (def_temp >> 8);\
+ *((T)+2)=(char) (def_temp >> 16);\
+ *((T)+1)=(char) (def_temp >> 24);\
+ *((T)+0)=(char) (def_temp2); }
+#define mi_int6store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ *((T)+5)=(char) (def_temp);\
+ *((T)+4)=(char) (def_temp >> 8);\
+ *((T)+3)=(char) (def_temp >> 16);\
+ *((T)+2)=(char) (def_temp >> 24);\
+ *((T)+1)=(char) (def_temp2);\
+ *((T)+0)=(char) (def_temp2 >> 8); }
+#define mi_int7store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ *((T)+6)=(char) (def_temp);\
+ *((T)+5)=(char) (def_temp >> 8);\
+ *((T)+4)=(char) (def_temp >> 16);\
+ *((T)+3)=(char) (def_temp >> 24);\
+ *((T)+2)=(char) (def_temp2);\
+ *((T)+1)=(char) (def_temp2 >> 8);\
+ *((T)+0)=(char) (def_temp2 >> 16); }
+#define mi_int8store(T,A) { ulong def_temp3= (ulong) (A), \
+ def_temp4= (ulong) ((A) >> 32); \
+ mi_int4store((T),def_temp4); \
+ mi_int4store((T+4),def_temp3); \
+ }
+
+#ifdef WORDS_BIGENDIAN
+
+#define mi_float4store(T,A) { *(T)= ((byte *) &A)[0];\
+ *((T)+1)=(char) ((byte *) &A)[1];\
+ *((T)+2)=(char) ((byte *) &A)[2];\
+ *((T)+3)=(char) ((byte *) &A)[3]; }
+
+#define mi_float4get(V,M) { float def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; }
+
+#define mi_float8store(T,V) { *(T)= ((byte *) &V)[0];\
+ *((T)+1)=(char) ((byte *) &V)[1];\
+ *((T)+2)=(char) ((byte *) &V)[2];\
+ *((T)+3)=(char) ((byte *) &V)[3];\
+ *((T)+4)=(char) ((byte *) &V)[4];\
+ *((T)+5)=(char) ((byte *) &V)[5];\
+ *((T)+6)=(char) ((byte *) &V)[6];\
+ *((T)+7)=(char) ((byte *) &V)[7]; }
+
+#define mi_float8get(V,M) { double def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ ((byte*) &def_temp)[4]=(M)[4];\
+ ((byte*) &def_temp)[5]=(M)[5];\
+ ((byte*) &def_temp)[6]=(M)[6];\
+ ((byte*) &def_temp)[7]=(M)[7]; \
+ (V)=def_temp; }
+#else
+
+#define mi_float4store(T,A) { *(T)= ((byte *) &A)[3];\
+ *((T)+1)=(char) ((byte *) &A)[2];\
+ *((T)+2)=(char) ((byte *) &A)[1];\
+ *((T)+3)=(char) ((byte *) &A)[0]; }
+
+#define mi_float4get(V,M) { float def_temp;\
+ ((byte*) &def_temp)[0]=(M)[3];\
+ ((byte*) &def_temp)[1]=(M)[2];\
+ ((byte*) &def_temp)[2]=(M)[1];\
+ ((byte*) &def_temp)[3]=(M)[0];\
+ (V)=def_temp; }
+
+#define mi_float8store(T,V) { *(T)= ((byte *) &V)[7];\
+ *((T)+1)=(char) ((byte *) &V)[6];\
+ *((T)+2)=(char) ((byte *) &V)[5];\
+ *((T)+3)=(char) ((byte *) &V)[4];\
+ *((T)+4)=(char) ((byte *) &V)[3];\
+ *((T)+5)=(char) ((byte *) &V)[2];\
+ *((T)+6)=(char) ((byte *) &V)[1];\
+ *((T)+7)=(char) ((byte *) &V)[0];}
+
+#define mi_float8get(V,M) { double def_temp;\
+ ((byte*) &def_temp)[0]=(M)[7];\
+ ((byte*) &def_temp)[1]=(M)[6];\
+ ((byte*) &def_temp)[2]=(M)[5];\
+ ((byte*) &def_temp)[3]=(M)[4];\
+ ((byte*) &def_temp)[4]=(M)[3];\
+ ((byte*) &def_temp)[5]=(M)[2];\
+ ((byte*) &def_temp)[6]=(M)[1];\
+ ((byte*) &def_temp)[7]=(M)[0];\
+ (V)=def_temp; }
+#endif
+
+/* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */
+
+#ifdef BIG_TABLE
+#define mi_rowstore(T,A) mi_int8store(T,A)
+#define mi_rowkorr(T,A) mi_uint8korr(T)
+#else
+#define mi_rowstore(T,A) { mi_int4store(T,0); mi_int4store(((T)+4),A); }
+#define mi_rowkorr(T) mi_uint4korr((T)+4)
+#endif
+
+#if SIZEOF_OFF_T > 4
+#define mi_sizestore(T,A) mi_int8store(T,A)
+#define mi_sizekorr(T) mi_uint8korr(T)
+#else
+#define mi_sizestore(T,A) { if ((A) == HA_OFFSET_ERROR) bfill((char*) (T),8,255); else { mi_int4store((T),0); mi_int4store(((T)+4),A); }}
+#define mi_sizekorr(T) mi_uint4korr((T)+4)
+#endif
diff --git a/include/mysql.h b/include/mysql.h
new file mode 100644
index 00000000000..e83babb8fa8
--- /dev/null
+++ b/include/mysql.h
@@ -0,0 +1,293 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* defines for the libmysql library */
+
+#ifndef _mysql_h
+#define _mysql_h
+
+#ifndef MYSQL_SERVER
+#ifdef __cplusplus
+extern "C" {
+#endif
+#endif
+
+#ifndef _global_h /* If not standard header */
+#include <sys/types.h>
+typedef char my_bool;
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
+#define __WIN__
+#endif
+#if !defined(__WIN__)
+#define STDCALL
+#else
+#define STDCALL __stdcall
+#endif
+typedef char * gptr;
+
+#ifndef ST_USED_MEM_DEFINED
+#define ST_USED_MEM_DEFINED
+typedef struct st_used_mem { /* struct for once_alloc */
+ struct st_used_mem *next; /* Next block in use */
+ unsigned int left; /* memory left in block */
+ unsigned int size; /* size of block */
+} USED_MEM;
+typedef struct st_mem_root {
+ USED_MEM *free;
+ USED_MEM *used;
+ unsigned int min_malloc;
+ unsigned int block_size;
+ void (*error_handler)(void);
+} MEM_ROOT;
+#endif
+
+#ifndef my_socket_defined
+#ifdef __WIN__
+#define my_socket SOCKET
+#else
+typedef int my_socket;
+#endif
+#endif
+#endif
+#include "mysql_com.h"
+#include "mysql_version.h"
+
+extern unsigned int mysql_port;
+extern char *mysql_unix_port;
+
+#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
+#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
+#define IS_BLOB(n) ((n) & BLOB_FLAG)
+#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR)
+
+typedef struct st_mysql_field {
+ char *name; /* Name of column */
+ char *table; /* Table of column if column was a field */
+ char *def; /* Default value (set by mysql_list_fields) */
+ enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
+ unsigned int length; /* Width of column */
+ unsigned int max_length; /* Max width of selected set */
+ unsigned int flags; /* Div flags */
+ unsigned int decimals; /* Number of decimals in field */
+} MYSQL_FIELD;
+
+typedef char **MYSQL_ROW; /* return data as array of strings */
+typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
+
+#if defined(NO_CLIENT_LONG_LONG)
+typedef unsigned long my_ulonglong;
+#elif defined (__WIN__)
+typedef unsigned __int64 my_ulonglong;
+#else
+typedef unsigned long long my_ulonglong;
+#endif
+
+#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
+
+typedef struct st_mysql_rows {
+ struct st_mysql_rows *next; /* list of rows */
+ MYSQL_ROW data;
+} MYSQL_ROWS;
+
+typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
+
+typedef struct st_mysql_data {
+ my_ulonglong rows;
+ unsigned int fields;
+ MYSQL_ROWS *data;
+ MEM_ROOT alloc;
+} MYSQL_DATA;
+
+struct st_mysql_options {
+ unsigned int connect_timeout,client_flag;
+ my_bool compress,named_pipe;
+ unsigned int port;
+ char *host,*init_command,*user,*password,*unix_socket,*db;
+ char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
+ my_bool use_ssl; /* if to use SSL or not */
+ char *ssl_key; /* PEM key file */
+ char *ssl_cert; /* PEM cert file */
+ char *ssl_ca; /* PEM CA file */
+ char *ssl_capath; /* PEM directory of CA-s? */
+};
+
+enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS,
+ MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
+ MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
+ MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME};
+
+enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
+ MYSQL_STATUS_USE_RESULT};
+
+typedef struct st_mysql {
+ NET net; /* Communication parameters */
+ gptr connector_fd; /* ConnectorFd for SSL */
+ char *host,*user,*passwd,*unix_socket,*server_version,*host_info,
+ *info,*db;
+ unsigned int port,client_flag,server_capabilities;
+ unsigned int protocol_version;
+ unsigned int field_count;
+ unsigned int server_status;
+ unsigned long thread_id; /* Id for connection in server */
+ my_ulonglong affected_rows;
+ my_ulonglong insert_id; /* id if insert on table with NEXTNR */
+ my_ulonglong extra_info; /* Used by mysqlshow */
+ unsigned long packet_length;
+ enum mysql_status status;
+ MYSQL_FIELD *fields;
+ MEM_ROOT field_alloc;
+ my_bool free_me; /* If free in mysql_close */
+ my_bool reconnect; /* set to 1 if automatic reconnect */
+ struct st_mysql_options options;
+ char scramble_buff[9];
+ struct charset_info_st *charset;
+ unsigned int server_language;
+} MYSQL;
+
+
+typedef struct st_mysql_res {
+ my_ulonglong row_count;
+ unsigned int field_count, current_field;
+ MYSQL_FIELD *fields;
+ MYSQL_DATA *data;
+ MYSQL_ROWS *data_cursor;
+ MEM_ROOT field_alloc;
+ MYSQL_ROW row; /* If unbuffered read */
+ MYSQL_ROW current_row; /* buffer to current row */
+ unsigned long *lengths; /* column lengths of current row */
+ MYSQL *handle; /* for unbuffered reads */
+ my_bool eof; /* Used my mysql_fetch_row */
+} MYSQL_RES;
+
+/* Functions to get information from the MYSQL and MYSQL_RES structures */
+/* Should definitely be used if one uses shared libraries */
+
+my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
+unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
+my_bool STDCALL mysql_eof(MYSQL_RES *res);
+MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
+ unsigned int fieldnr);
+MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
+MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res);
+unsigned int STDCALL mysql_field_tell(MYSQL_RES *res);
+
+unsigned int STDCALL mysql_field_count(MYSQL *mysql);
+my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
+my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
+unsigned int STDCALL mysql_errno(MYSQL *mysql);
+char * STDCALL mysql_error(MYSQL *mysql);
+char * STDCALL mysql_info(MYSQL *mysql);
+unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
+const char * STDCALL mysql_character_set_name(MYSQL *mysql);
+
+MYSQL * STDCALL mysql_init(MYSQL *mysql);
+#ifdef HAVE_OPENSSL
+int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
+ const char *cert, const char *ca,
+ const char *capath);
+char * STDCALL mysql_ssl_cipher(MYSQL *mysql);
+int STDCALL mysql_ssl_clear(MYSQL *mysql);
+#endif /* HAVE_OPENSSL */
+MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
+ const char *user, const char *passwd);
+my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
+ const char *passwd, const char *db);
+#if MYSQL_VERSION_ID >= 32200
+MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
+ const char *user,
+ const char *passwd,
+ const char *db,
+ unsigned int port,
+ const char *unix_socket,
+ unsigned int clientflag);
+#else
+MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
+ const char *user,
+ const char *passwd,
+ unsigned int port,
+ const char *unix_socket,
+ unsigned int clientflag);
+#endif
+void STDCALL mysql_close(MYSQL *sock);
+int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
+int STDCALL mysql_query(MYSQL *mysql, const char *q);
+int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
+ unsigned int length);
+int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
+int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
+int STDCALL mysql_shutdown(MYSQL *mysql);
+int STDCALL mysql_dump_debug_info(MYSQL *mysql);
+int STDCALL mysql_refresh(MYSQL *mysql,
+ unsigned int refresh_options);
+int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
+int STDCALL mysql_ping(MYSQL *mysql);
+char * STDCALL mysql_stat(MYSQL *mysql);
+char * STDCALL mysql_get_server_info(MYSQL *mysql);
+char * STDCALL mysql_get_client_info(void);
+char * STDCALL mysql_get_host_info(MYSQL *mysql);
+unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
+MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
+MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
+MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
+ const char *wild);
+MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
+MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
+MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
+int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
+ const char *arg);
+void STDCALL mysql_free_result(MYSQL_RES *result);
+void STDCALL mysql_data_seek(MYSQL_RES *result,
+ my_ulonglong offset);
+MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET);
+MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
+ MYSQL_FIELD_OFFSET offset);
+MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
+unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
+MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
+unsigned long STDCALL mysql_escape_string(char *to,const char *from,
+ unsigned long from_length);
+unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
+ char *to,const char *from,
+ unsigned long length);
+void STDCALL mysql_debug(const char *debug);
+char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
+ char *to,
+ unsigned long to_length,
+ const char *from,
+ unsigned long from_length,
+ void *param,
+ char *
+ (*extend_buffer)
+ (void *, char *to,
+ unsigned long *length));
+void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
+unsigned int STDCALL mysql_thread_safe(void);
+
+
+#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
+
+/* new api functions */
+
+#define HAVE_MYSQL_REAL_CONNECT
+
+#ifndef MYSQL_SERVER
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif
diff --git a/include/mysql_com.h b/include/mysql_com.h
new file mode 100644
index 00000000000..2a1471f735d
--- /dev/null
+++ b/include/mysql_com.h
@@ -0,0 +1,242 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+** Common definition between mysql server & client
+*/
+
+#ifndef _mysql_com_h
+#define _mysql_com_h
+
+
+#define NAME_LEN 64 /* Field/table name length */
+#define HOSTNAME_LENGTH 60
+#define USERNAME_LENGTH 16
+
+#define LOCAL_HOST "localhost"
+#define LOCAL_HOST_NAMEDPIPE "."
+
+#if defined(__EMX__) || defined(__OS2__)
+#undef MYSQL_UNIX_ADDR
+#define MYSQL_OS2_ADDR "\\socket\\MySQL"
+#define MYSQL_UNIX_ADDR MYSQL_OS2_ADDR
+#endif
+#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
+#define MYSQL_NAMEDPIPE "MySQL"
+#define MYSQL_SERVICENAME "MySql"
+#endif /* __WIN__ */
+
+enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
+ COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
+ COM_SHUTDOWN,COM_STATISTICS,
+ COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
+ COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
+ COM_CHANGE_USER, COM_BINLOG_DUMP,
+ COM_TABLE_DUMP};
+
+#define NOT_NULL_FLAG 1 /* Field can't be NULL */
+#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
+#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
+#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
+#define BLOB_FLAG 16 /* Field is a blob */
+#define UNSIGNED_FLAG 32 /* Field is unsigned */
+#define ZEROFILL_FLAG 64 /* Field is zerofill */
+#define BINARY_FLAG 128
+/* The following are only sent to new clients */
+#define ENUM_FLAG 256 /* field is an enum */
+#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
+#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
+#define SET_FLAG 2048 /* field is a set */
+#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
+#define GROUP_FLAG 32768 /* Intern: Group field */
+#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
+
+#define REFRESH_GRANT 1 /* Refresh grant tables */
+#define REFRESH_LOG 2 /* Start on new log file */
+#define REFRESH_TABLES 4 /* close all tables */
+#define REFRESH_HOSTS 8 /* Flush host cache */
+#define REFRESH_STATUS 16 /* Flush status variables */
+#define REFRESH_THREADS 32 /* Flush status variables */
+#define REFRESH_SLAVE 64 /* Reset master info and restart slave
+ thread */
+#define REFRESH_MASTER 128 /* Remove all bin logs in the index
+ and truncate the index */
+
+/* The following can't be set with mysql_refresh() */
+#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
+#define REFRESH_FAST 32768 /* Intern flag */
+
+#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
+#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
+#define CLIENT_LONG_FLAG 4 /* Get all column flags */
+#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
+#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
+#define CLIENT_COMPRESS 32 /* Can use compression protocol */
+#define CLIENT_ODBC 64 /* Odbc client */
+#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
+#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
+#define CLIENT_CHANGE_USER 512 /* Support the mysql_change_user() */
+#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
+#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
+#define CLIENT_TRANSACTIONS 8196 /* Client knows about transactions */
+
+#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
+#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
+
+#define MYSQL_ERRMSG_SIZE 200
+#define NET_READ_TIMEOUT 30 /* Timeout on read */
+#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
+#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
+
+#ifndef Vio_defined
+#define Vio_defined
+#ifdef HAVE_VIO
+class Vio; /* Fill Vio class in C++ */
+#else
+struct st_vio; /* Only C */
+typedef struct st_vio Vio;
+#endif
+#endif
+
+typedef struct st_net {
+ Vio* vio;
+ my_socket fd; /* For Perl DBI/dbd */
+ int fcntl;
+ unsigned char *buff,*buff_end,*write_pos,*read_pos;
+ char last_error[MYSQL_ERRMSG_SIZE];
+ unsigned int last_errno,max_packet,timeout,pkt_nr;
+ unsigned char error;
+ my_bool return_errno,compress;
+ my_bool no_send_ok; /* needed if we are doing several
+ queries in one command ( as in LOAD TABLE ... FROM MASTER ),
+ and do not want to confuse the client with OK at the wrong time
+ */
+ unsigned long remain_in_buf,length, buf_length, where_b;
+ unsigned int *return_status;
+ unsigned char reading_or_writing;
+ char save_char;
+} NET;
+
+#define packet_error ((unsigned int) -1)
+
+enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
+ FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
+ FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
+ FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
+ FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
+ FIELD_TYPE_DATE, FIELD_TYPE_TIME,
+ FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
+ FIELD_TYPE_NEWDATE,
+ FIELD_TYPE_ENUM=247,
+ FIELD_TYPE_SET=248,
+ FIELD_TYPE_TINY_BLOB=249,
+ FIELD_TYPE_MEDIUM_BLOB=250,
+ FIELD_TYPE_LONG_BLOB=251,
+ FIELD_TYPE_BLOB=252,
+ FIELD_TYPE_VAR_STRING=253,
+ FIELD_TYPE_STRING=254
+};
+
+#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
+#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
+
+extern unsigned long max_allowed_packet;
+extern unsigned long net_buffer_length;
+
+#define net_new_transaction(net) ((net)->pkt_nr=0)
+
+int my_net_init(NET *net, Vio* vio);
+void net_end(NET *net);
+void net_clear(NET *net);
+int net_flush(NET *net);
+int my_net_write(NET *net,const char *packet,unsigned long len);
+int net_write_command(NET *net,unsigned char command,const char *packet,
+ unsigned long len);
+int net_real_write(NET *net,const char *packet,unsigned long len);
+unsigned int my_net_read(NET *net);
+
+struct rand_struct {
+ unsigned long seed1,seed2,max_value;
+ double max_value_dbl;
+};
+
+ /* The following is for user defined functions */
+
+enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
+
+typedef struct st_udf_args
+{
+ unsigned int arg_count; /* Number of arguments */
+ enum Item_result *arg_type; /* Pointer to item_results */
+ char **args; /* Pointer to argument */
+ unsigned long *lengths; /* Length of string arguments */
+ char *maybe_null; /* Set to 1 for all maybe_null args */
+} UDF_ARGS;
+
+ /* This holds information about the result */
+
+typedef struct st_udf_init
+{
+ my_bool maybe_null; /* 1 if function can return NULL */
+ unsigned int decimals; /* for real functions */
+ unsigned int max_length; /* For string functions */
+ char *ptr; /* free pointer for function data */
+ my_bool const_item; /* 0 if result is independent of arguments */
+} UDF_INIT;
+
+ /* Constants when using compression */
+#define NET_HEADER_SIZE 4 /* standard header size */
+#define COMP_HEADER_SIZE 3 /* compression header extra size */
+
+ /* Prototypes to password functions */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void randominit(struct rand_struct *,unsigned long seed1,
+ unsigned long seed2);
+double rnd(struct rand_struct *);
+void make_scrambled_password(char *to,const char *password);
+void get_salt_from_password(unsigned long *res,const char *password);
+void make_password_from_salt(char *to, unsigned long *hash_res);
+char *scramble(char *to,const char *message,const char *password,
+ my_bool old_ver);
+my_bool check_scramble(const char *, const char *message,
+ unsigned long *salt,my_bool old_ver);
+char *get_tty_password(char *opt_message);
+void hash_password(unsigned long *result, const char *password);
+#ifdef __cplusplus
+}
+#endif
+
+/* Some other useful functions */
+
+void my_init(void);
+void load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv);
+
+#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
+
+#ifdef __WIN__
+#define socket_errno WSAGetLastError()
+#else
+#define socket_errno errno
+#endif
+
+#endif
diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in
new file mode 100755
index 00000000000..7cfef34176e
--- /dev/null
+++ b/include/mysql_version.h.in
@@ -0,0 +1,20 @@
+/* Copyright Abandoned 1996,1999 TCX DataKonsult AB & Monty Program KB & Detron HB
+ This file is public domain and comes with NO WARRANTY of any kind */
+
+/* Version numbers for protocol & mysqld */
+
+#ifdef _CUSTOMCONFIG_
+ #include <custom_conf.h>
+#else
+#define PROTOCOL_VERSION @PROTOCOL_VERSION@
+#define MYSQL_SERVER_VERSION "@VERSION@"
+#define FRM_VER @DOT_FRM_VERSION@
+#define MYSQL_VERSION_ID @MYSQL_VERSION_ID@
+#define MYSQL_PORT @MYSQL_TCP_PORT@
+#define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
+
+/* mysqld compile time options */
+#ifndef MYSQL_CHARSET
+#define MYSQL_CHARSET "@default_charset@"
+#endif
+#endif
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
new file mode 100644
index 00000000000..9d3e879f4f5
--- /dev/null
+++ b/include/mysqld_error.h
@@ -0,0 +1,195 @@
+/* Definefile for errormessagenumbers */
+
+#define ER_HASHCHK 1000
+#define ER_NISAMCHK 1001
+#define ER_NO 1002
+#define ER_YES 1003
+#define ER_CANT_CREATE_FILE 1004
+#define ER_CANT_CREATE_TABLE 1005
+#define ER_CANT_CREATE_DB 1006
+#define ER_DB_CREATE_EXISTS 1007
+#define ER_DB_DROP_EXISTS 1008
+#define ER_DB_DROP_DELETE 1009
+#define ER_DB_DROP_RMDIR 1010
+#define ER_CANT_DELETE_FILE 1011
+#define ER_CANT_FIND_SYSTEM_REC 1012
+#define ER_CANT_GET_STAT 1013
+#define ER_CANT_GET_WD 1014
+#define ER_CANT_LOCK 1015
+#define ER_CANT_OPEN_FILE 1016
+#define ER_FILE_NOT_FOUND 1017
+#define ER_CANT_READ_DIR 1018
+#define ER_CANT_SET_WD 1019
+#define ER_CHECKREAD 1020
+#define ER_DISK_FULL 1021
+#define ER_DUP_KEY 1022
+#define ER_ERROR_ON_CLOSE 1023
+#define ER_ERROR_ON_READ 1024
+#define ER_ERROR_ON_RENAME 1025
+#define ER_ERROR_ON_WRITE 1026
+#define ER_FILE_USED 1027
+#define ER_FILSORT_ABORT 1028
+#define ER_FORM_NOT_FOUND 1029
+#define ER_GET_ERRNO 1030
+#define ER_ILLEGAL_HA 1031
+#define ER_KEY_NOT_FOUND 1032
+#define ER_NOT_FORM_FILE 1033
+#define ER_NOT_KEYFILE 1034
+#define ER_OLD_KEYFILE 1035
+#define ER_OPEN_AS_READONLY 1036
+#define ER_OUTOFMEMORY 1037
+#define ER_OUT_OF_SORTMEMORY 1038
+#define ER_UNEXPECTED_EOF 1039
+#define ER_CON_COUNT_ERROR 1040
+#define ER_OUT_OF_RESOURCES 1041
+#define ER_BAD_HOST_ERROR 1042
+#define ER_HANDSHAKE_ERROR 1043
+#define ER_DBACCESS_DENIED_ERROR 1044
+#define ER_ACCESS_DENIED_ERROR 1045
+#define ER_NO_DB_ERROR 1046
+#define ER_UNKNOWN_COM_ERROR 1047
+#define ER_BAD_NULL_ERROR 1048
+#define ER_BAD_DB_ERROR 1049
+#define ER_TABLE_EXISTS_ERROR 1050
+#define ER_BAD_TABLE_ERROR 1051
+#define ER_NON_UNIQ_ERROR 1052
+#define ER_SERVER_SHUTDOWN 1053
+#define ER_BAD_FIELD_ERROR 1054
+#define ER_WRONG_FIELD_WITH_GROUP 1055
+#define ER_WRONG_GROUP_FIELD 1056
+#define ER_WRONG_SUM_SELECT 1057
+#define ER_WRONG_VALUE_COUNT 1058
+#define ER_TOO_LONG_IDENT 1059
+#define ER_DUP_FIELDNAME 1060
+#define ER_DUP_KEYNAME 1061
+#define ER_DUP_ENTRY 1062
+#define ER_WRONG_FIELD_SPEC 1063
+#define ER_PARSE_ERROR 1064
+#define ER_EMPTY_QUERY 1065
+#define ER_NONUNIQ_TABLE 1066
+#define ER_INVALID_DEFAULT 1067
+#define ER_MULTIPLE_PRI_KEY 1068
+#define ER_TOO_MANY_KEYS 1069
+#define ER_TOO_MANY_KEY_PARTS 1070
+#define ER_TOO_LONG_KEY 1071
+#define ER_KEY_COLUMN_DOES_NOT_EXITS 1072
+#define ER_BLOB_USED_AS_KEY 1073
+#define ER_TOO_BIG_FIELDLENGTH 1074
+#define ER_WRONG_AUTO_KEY 1075
+#define ER_READY 1076
+#define ER_NORMAL_SHUTDOWN 1077
+#define ER_GOT_SIGNAL 1078
+#define ER_SHUTDOWN_COMPLETE 1079
+#define ER_FORCING_CLOSE 1080
+#define ER_IPSOCK_ERROR 1081
+#define ER_NO_SUCH_INDEX 1082
+#define ER_WRONG_FIELD_TERMINATORS 1083
+#define ER_BLOBS_AND_NO_TERMINATED 1084
+#define ER_TEXTFILE_NOT_READABLE 1085
+#define ER_FILE_EXISTS_ERROR 1086
+#define ER_LOAD_INFO 1087
+#define ER_ALTER_INFO 1088
+#define ER_WRONG_SUB_KEY 1089
+#define ER_CANT_REMOVE_ALL_FIELDS 1090
+#define ER_CANT_DROP_FIELD_OR_KEY 1091
+#define ER_INSERT_INFO 1092
+#define ER_INSERT_TABLE_USED 1093
+#define ER_NO_SUCH_THREAD 1094
+#define ER_KILL_DENIED_ERROR 1095
+#define ER_NO_TABLES_USED 1096
+#define ER_TOO_BIG_SET 1097
+#define ER_NO_UNIQUE_LOGFILE 1098
+#define ER_TABLE_NOT_LOCKED_FOR_WRITE 1099
+#define ER_TABLE_NOT_LOCKED 1100
+#define ER_BLOB_CANT_HAVE_DEFAULT 1101
+#define ER_WRONG_DB_NAME 1102
+#define ER_WRONG_TABLE_NAME 1103
+#define ER_TOO_BIG_SELECT 1104
+#define ER_UNKNOWN_ERROR 1105
+#define ER_UNKNOWN_PROCEDURE 1106
+#define ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107
+#define ER_WRONG_PARAMETERS_TO_PROCEDURE 1108
+#define ER_UNKNOWN_TABLE 1109
+#define ER_FIELD_SPECIFIED_TWICE 1110
+#define ER_INVALID_GROUP_FUNC_USE 1111
+#define ER_UNSUPPORTED_EXTENSION 1112
+#define ER_TABLE_MUST_HAVE_COLUMNS 1113
+#define ER_RECORD_FILE_FULL 1114
+#define ER_UNKNOWN_CHARACTER_SET 1115
+#define ER_TOO_MANY_TABLES 1116
+#define ER_TOO_MANY_FIELDS 1117
+#define ER_TOO_BIG_ROWSIZE 1118
+#define ER_STACK_OVERRUN 1119
+#define ER_WRONG_OUTER_JOIN 1120
+#define ER_NULL_COLUMN_IN_INDEX 1121
+#define ER_CANT_FIND_UDF 1122
+#define ER_CANT_INITIALIZE_UDF 1123
+#define ER_UDF_NO_PATHS 1124
+#define ER_UDF_EXISTS 1125
+#define ER_CANT_OPEN_LIBRARY 1126
+#define ER_CANT_FIND_DL_ENTRY 1127
+#define ER_FUNCTION_NOT_DEFINED 1128
+#define ER_HOST_IS_BLOCKED 1129
+#define ER_HOST_NOT_PRIVILEGED 1130
+#define ER_PASSWORD_ANONYMOUS_USER 1131
+#define ER_PASSWORD_NOT_ALLOWED 1132
+#define ER_PASSWORD_NO_MATCH 1133
+#define ER_UPDATE_INFO 1134
+#define ER_CANT_CREATE_THREAD 1135
+#define ER_WRONG_VALUE_COUNT_ON_ROW 1136
+#define ER_CANT_REOPEN_TABLE 1137
+#define ER_INVALID_USE_OF_NULL 1138
+#define ER_REGEXP_ERROR 1139
+#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
+#define ER_NONEXISTING_GRANT 1141
+#define ER_TABLEACCESS_DENIED_ERROR 1142
+#define ER_COLUMNACCESS_DENIED_ERROR 1143
+#define ER_ILLEGAL_GRANT_FOR_TABLE 1144
+#define ER_GRANT_WRONG_HOST_OR_USER 1145
+#define ER_NO_SUCH_TABLE 1146
+#define ER_NONEXISTING_TABLE_GRANT 1147
+#define ER_NOT_ALLOWED_COMMAND 1148
+#define ER_SYNTAX_ERROR 1149
+#define ER_DELAYED_CANT_CHANGE_LOCK 1150
+#define ER_TOO_MANY_DELAYED_THREADS 1151
+#define ER_ABORTING_CONNECTION 1152
+#define ER_NET_PACKET_TOO_LARGE 1153
+#define ER_NET_READ_ERROR_FROM_PIPE 1154
+#define ER_NET_FCNTL_ERROR 1155
+#define ER_NET_PACKETS_OUT_OF_ORDER 1156
+#define ER_NET_UNCOMPRESS_ERROR 1157
+#define ER_NET_READ_ERROR 1158
+#define ER_NET_READ_INTERRUPTED 1159
+#define ER_NET_ERROR_ON_WRITE 1160
+#define ER_NET_WRITE_INTERRUPTED 1161
+#define ER_TOO_LONG_STRING 1162
+#define ER_TABLE_CANT_HANDLE_BLOB 1163
+#define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
+#define ER_DELAYED_INSERT_TABLE_LOCKED 1165
+#define ER_WRONG_COLUMN_NAME 1166
+#define ER_WRONG_KEY_COLUMN 1167
+#define ER_WRONG_MRG_TABLE 1168
+#define ER_DUP_UNIQUE 1169
+#define ER_BLOB_KEY_WITHOUT_LENGTH 1170
+#define ER_PRIMARY_CANT_HAVE_NULL 1171
+#define ER_TOO_MANY_ROWS 1172
+#define ER_REQUIRES_PRIMARY_KEY 1173
+#define ER_NO_RAID_COMPILED 1174
+#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
+#define ER_KEY_DOES_NOT_EXITS 1176
+#define ER_CHECK_NO_SUCH_TABLE 1177
+#define ER_CHECK_NOT_IMPLEMENTED 1178
+#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
+#define ER_ERROR_DURING_COMMIT 1180
+#define ER_ERROR_DURING_ROLLBACK 1181
+#define ER_ERROR_DURING_FLUSH_LOGS 1182
+#define ER_ERROR_DURING_CHECKPOINT 1183
+#define ER_NEW_ABORTING_CONNECTION 1184
+#define ER_DUMP_NOT_IMPLEMENTED 1185
+#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186
+#define ER_INDEX_REBUILD 1187
+#define ER_MASTER 1188
+#define ER_MASTER_NET_READ 1189
+#define ER_MASTER_NET_WRITE 1190
+#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
+#define ER_ERROR_MESSAGES 192
diff --git a/include/mysys_err.h b/include/mysys_err.h
new file mode 100644
index 00000000000..7f5c3e1908b
--- /dev/null
+++ b/include/mysys_err.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _mysys_err_h
+#define _mysys_err_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GLOB 0 /* Error maps */
+#define GLOBERRS 23 /* Max number of error messages in map's */
+#define EE(X) globerrs[ X ] /* Defines to add error to right map */
+
+extern const char * NEAR globerrs[]; /* my_error_messages is here */
+
+/* Error message numbers in global map */
+#define EE_FILENOTFOUND 0
+#define EE_CANTCREATEFILE 1
+#define EE_READ 2
+#define EE_WRITE 3
+#define EE_BADCLOSE 4
+#define EE_OUTOFMEMORY 5
+#define EE_DELETE 6
+#define EE_LINK 7
+#define EE_EOFERR 9
+#define EE_CANTLOCK 10
+#define EE_CANTUNLOCK 11
+#define EE_DIR 12
+#define EE_STAT 13
+#define EE_CANT_CHSIZE 14
+#define EE_CANT_OPEN_STREAM 15
+#define EE_GETWD 16
+#define EE_SETWD 17
+#define EE_LINK_WARNING 18
+#define EE_OPEN_WARNING 19
+#define EE_DISK_FULL 20
+#define EE_CANT_MKDIR 21
+#define EE_UNKNOWN_CHARSET 22
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/nisam.h b/include/nisam.h
new file mode 100644
index 00000000000..77ca12bbc5c
--- /dev/null
+++ b/include/nisam.h
@@ -0,0 +1,213 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* This file should be included when using nisam_funktions */
+/* Author: Michael Widenius */
+
+#ifndef _nisam_h
+#define _nisam_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _my_base_h
+#include <my_base.h>
+#endif
+ /* defines used by nisam-funktions */
+
+#define N_MAXKEY 16 /* Max allowed keys */
+#define N_MAXKEY_SEG 16 /* Max segments for key */
+#define N_MAX_KEY_LENGTH 256 /* May be increased up to 500 */
+#define N_MAX_KEY_BUFF (N_MAX_KEY_LENGTH+N_MAXKEY_SEG+sizeof(double)-1)
+#define N_MAX_POSSIBLE_KEY_BUFF 500+9
+
+#define N_NAME_IEXT ".ISM"
+#define N_NAME_DEXT ".ISD"
+#define NI_POS_ERROR (~ (ulong) 0)
+
+
+ /* Param to/from nisam_info */
+
+typedef struct st_n_isaminfo /* Struct from h_info */
+{
+ ulong records; /* Records in database */
+ ulong deleted; /* Deleted records in database */
+ ulong recpos; /* Pos for last used record */
+ ulong newrecpos; /* Pos if we write new record */
+ ulong dupp_key_pos; /* Position to record with dupp key */
+ ulong data_file_length, /* Length of data file */
+ max_data_file_length,
+ index_file_length,
+ max_index_file_length,
+ delete_length;
+ uint reclength; /* Recordlength */
+ uint mean_reclength; /* Mean recordlength (if packed) */
+ uint keys; /* How many keys used */
+ uint options; /* HA_OPTIONS_... used */
+ int errkey, /* With key was dupplicated on err */
+ sortkey; /* clustered by this key */
+ File filenr; /* (uniq) filenr for datafile */
+ time_t create_time; /* When table was created */
+ time_t isamchk_time;
+ time_t update_time;
+ ulong *rec_per_key; /* for sql optimizing */
+} N_ISAMINFO;
+
+
+ /* Info saved on file for each info-part */
+
+#ifdef __WATCOMC__
+#pragma pack(2)
+#define uint uint16 /* Same format as in MSDOS */
+#endif
+
+#ifdef __ZTC__
+#pragma ZTC align 2
+#define uint uint16 /* Same format as in MSDOS */
+#endif
+
+typedef struct st_n_save_keyseg /* Key-portion */
+{
+ uint8 type; /* Typ av nyckel (f|r sort) */
+ uint8 flag; /* HA_DIFF_LENGTH */
+ uint16 start; /* Start of key in record */
+ uint16 length; /* Keylength */
+} N_SAVE_KEYSEG;
+
+typedef struct st_n_save_keydef /* Key definition with create & info */
+{
+ uint8 flag; /* NOSAME, PACK_USED */
+ uint8 keysegs; /* Number of key-segment */
+ uint16 block_length; /* Length of keyblock (auto) */
+ uint16 keylength; /* Tot length of keyparts (auto) */
+ uint16 minlength; /* min length of (packed) key (auto) */
+ uint16 maxlength; /* max length of (packed) key (auto) */
+} N_SAVE_KEYDEF;
+
+typedef struct st_n_save_recinfo /* Info of record */
+{
+ int16 type; /* en_fieldtype */
+ uint16 length; /* length of field */
+} N_SAVE_RECINFO;
+
+
+#ifdef __ZTC__
+#pragma ZTC align
+#undef uint
+#endif
+
+#ifdef __WATCOMC__
+#pragma pack()
+#undef uint
+#endif
+
+
+struct st_isam_info; /* For referense */
+
+#ifndef ISAM_LIBRARY
+typedef struct st_isam_info N_INFO;
+#endif
+
+typedef struct st_n_keyseg /* Key-portion */
+{
+ N_SAVE_KEYSEG base;
+} N_KEYSEG;
+
+
+typedef struct st_n_keydef /* Key definition with open & info */
+{
+ N_SAVE_KEYDEF base;
+ N_KEYSEG seg[N_MAXKEY_SEG+1];
+ int (*bin_search)(struct st_isam_info *info,struct st_n_keydef *keyinfo,
+ uchar *page,uchar *key,
+ uint key_len,uint comp_flag,uchar * *ret_pos,
+ uchar *buff);
+ uint (*get_key)(struct st_n_keydef *keyinfo,uint nod_flag,uchar * *page,
+ uchar *key);
+} N_KEYDEF;
+
+
+typedef struct st_decode_tree /* Decode huff-table */
+{
+ uint16 *table;
+ uint quick_table_bits;
+ byte *intervalls;
+} DECODE_TREE;
+
+
+struct st_bit_buff;
+
+typedef struct st_n_recinfo /* Info of record */
+{
+ N_SAVE_RECINFO base;
+#ifndef NOT_PACKED_DATABASES
+ void (*unpack)(struct st_n_recinfo *rec,struct st_bit_buff *buff,
+ uchar *start,uchar *end);
+ enum en_fieldtype base_type;
+ uint space_length_bits,pack_type;
+ DECODE_TREE *huff_tree;
+#endif
+} N_RECINFO;
+
+
+extern my_string nisam_log_filename; /* Name of logfile */
+extern uint nisam_block_size;
+extern my_bool nisam_flush;
+
+ /* Prototypes for nisam-functions */
+
+extern int nisam_close(struct st_isam_info *file);
+extern int nisam_delete(struct st_isam_info *file,const byte *buff);
+extern struct st_isam_info *nisam_open(const char *name,int mode,
+ uint wait_if_locked);
+extern int nisam_panic(enum ha_panic_function function);
+extern int nisam_rfirst(struct st_isam_info *file,byte *buf,int inx);
+extern int nisam_rkey(struct st_isam_info *file,byte *buf,int inx,
+ const byte *key,
+ uint key_len, enum ha_rkey_function search_flag);
+extern int nisam_rlast(struct st_isam_info *file,byte *buf,int inx);
+extern int nisam_rnext(struct st_isam_info *file,byte *buf,int inx);
+extern int nisam_rprev(struct st_isam_info *file,byte *buf,int inx);
+extern int nisam_rrnd(struct st_isam_info *file,byte *buf,ulong pos);
+extern int nisam_rsame(struct st_isam_info *file,byte *record,int inx);
+extern int nisam_rsame_with_pos(struct st_isam_info *file,byte *record,
+ int inx,ulong pos);
+extern int nisam_update(struct st_isam_info *file,const byte *old,
+ const byte *new_record);
+extern int nisam_write(struct st_isam_info *file,const byte *buff);
+extern int nisam_info(struct st_isam_info *file,N_ISAMINFO *x,int flag);
+extern ulong nisam_position(struct st_isam_info *info);
+extern int nisam_lock_database(struct st_isam_info *file,int lock_type);
+extern int nisam_create(const char *name,uint keys,N_KEYDEF *keyinfo,
+ N_RECINFO *recinfo,ulong records,
+ ulong reloc,uint flags,uint options,
+ ulong data_file_length);
+extern int nisam_extra(struct st_isam_info *file,
+ enum ha_extra_function function);
+extern ulong nisam_records_in_range(struct st_isam_info *info,int inx,
+ const byte *start_key,uint start_key_len,
+ enum ha_rkey_function start_search_flag,
+ const byte *end_key,uint end_key_len,
+ enum ha_rkey_function end_search_flag);
+extern int nisam_log(int activate_log);
+extern int nisam_is_changed(struct st_isam_info *info);
+extern uint _calc_blob_length(uint length , const byte *pos);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/queues.h b/include/queues.h
new file mode 100644
index 00000000000..99001bfbf6d
--- /dev/null
+++ b/include/queues.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ Code for generell handling of priority Queues.
+ Implemention of queues from "Algoritms in C" by Robert Sedgewick.
+ Copyright Monty Program KB.
+ By monty.
+*/
+
+#ifndef _queues_h
+#define _queues_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct st_queue {
+ byte **root;
+ void *first_cmp_arg;
+ uint elements;
+ uint max_elements;
+ uint offset_to_key; /* compare is done on element+offset */
+ int max_at_top; /* Set if queue_top gives max */
+ int (*compare)(void *, byte *,byte *);
+} QUEUE;
+
+#define queue_top(queue) ((queue)->root[1])
+#define queue_element(queue,index) ((queue)->root[index+1])
+#define queue_end(queue) ((queue)->root[(queue)->elements])
+#define queue_replaced(queue) _downheap(queue,1)
+
+int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
+ pbool max_at_top, int (*compare)(void *,byte *, byte *),
+ void *first_cmp_arg);
+void delete_queue(QUEUE *queue);
+void queue_insert(QUEUE *queue,byte *element);
+byte *queue_remove(QUEUE *queue,uint idx);
+void _downheap(QUEUE *queue,uint idx);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/raid.h b/include/raid.h
new file mode 100644
index 00000000000..119f2b9b3b8
--- /dev/null
+++ b/include/raid.h
@@ -0,0 +1,155 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Parser needs these defines always, even if USE_RAID is not defined */
+#define RAID_TYPE_0 1 // Striping
+#define RAID_TYPE_x 2 // Some new modes
+#define RAID_TYPE_y 3 //
+
+#define RAID_DEFAULT_CHUNKS 4
+#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */
+
+extern const char *raid_type_string[];
+
+#if defined(USE_RAID)
+
+#ifdef __GNUC__
+#pragma interface /* gcc class implementation */
+#endif
+#include "my_dir.h"
+
+/* Trap all occurences of my_...() in source and use our wrapper around this function */
+
+#ifdef MAP_TO_USE_RAID
+#define my_read(A,B,C,D) my_raid_read(A,B,C,D)
+#define my_write(A,B,C,D) my_raid_write(A,B,C,D)
+#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
+#define my_pread(A,B,C,D,E) my_raid_pread(A,B,C,D,E)
+#define my_chsize(A,B,C) my_raid_chsize(A,B,C)
+#define my_close(A,B) my_raid_close(A,B)
+#define my_tell(A,B) my_raid_tell(A,B)
+#define my_seek(A,B,C,D) my_raid_seek(A,B,C,D)
+#define my_lock(A,B,C,D,E) my_raid_lock(A,B,C,D,E)
+#define my_fstat(A,B,C) my_raid_fstat(A,B,C)
+#endif /* MAP_TO_USE_RAID */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void init_raid(void);
+ void end_raid(void);
+
+ bool is_raid(File fd);
+ File my_raid_create(const char *FileName, int CreateFlags, int access_flags,
+ uint raid_type, uint raid_chunks, ulong raid_chunksize,
+ myf MyFlags);
+ File my_raid_open(const char *FileName, int Flags,
+ uint raid_type, uint raid_chunks, ulong raid_chunksize,
+ myf MyFlags);
+ int my_raid_rename(const char *from, const char *to, uint raid_chunks,
+ myf MyFlags);
+ int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags);
+ int my_raid_redel(const char *old_name, const char *new_name,
+ uint raid_chunks, myf MyFlags);
+
+ my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags);
+ my_off_t my_raid_tell(File fd, myf MyFlags);
+
+ uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags);
+ uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags);
+
+ uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
+ myf MyFlags);
+ uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count,
+ my_off_t offset, myf MyFlags);
+
+ int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
+ myf MyFlags);
+ int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags);
+ int my_raid_close(File, myf MyFlags);
+ int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags);
+
+ const char *my_raid_type(int raid_type);
+
+#ifdef __cplusplus
+}
+
+class RaidName {
+ public:
+ RaidName(const char *FileName);
+ ~RaidName();
+ bool IsRaid();
+ int Rename(const char * from, const char * to, myf MyFlags);
+ private:
+ uint _raid_type; // RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5
+ uint _raid_chunks; // 1..n
+ ulong _raid_chunksize; // 1..n in bytes
+};
+
+class RaidFd {
+ public:
+ RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize);
+ ~RaidFd();
+ File Create(const char *FileName, int CreateFlags, int access_flags,
+ myf MyFlags);
+ File Open(const char *FileName, int Flags, myf MyFlags);
+ my_off_t Seek(my_off_t pos,int whence,myf MyFlags);
+ my_off_t Tell(myf MyFlags);
+ int Write(const byte *Buffer, uint Count, myf MyFlags);
+ int Read(const byte *Buffer, uint Count, myf MyFlags);
+ int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
+ int Chsize(File fd, my_off_t newlength, myf MyFlags);
+ int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
+ int Close(myf MyFlags);
+ static bool IsRaid(File fd);
+ static DYNAMIC_ARRAY _raid_map; /* Map of RaidFD* */
+ private:
+
+ uint _raid_type; // RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5
+ uint _raid_chunks; // 1..n
+ ulong _raid_chunksize; // 1..n in bytes
+
+ ulong _total_block; // We are operating with block no x (can be 0..many).
+ uint _this_block; // can be 0.._raid_chunks
+ uint _remaining_bytes; // Maximum bytes that can be written in this block
+
+ my_off_t _position;
+ my_off_t _size; // Cached file size for faster seek(SEEK_END)
+ File _fd;
+ File *_fd_vector; /* Array of File */
+ off_t *_seek_vector; /* Array of cached seek positions */
+
+ inline void Calculate()
+ {
+ DBUG_ENTER("RaidFd::_Calculate");
+ DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu",
+ (ulong) _position, _raid_chunksize, (ulong) _size));
+
+ _total_block = (ulong) (_position / _raid_chunksize);
+ _this_block = _total_block % _raid_chunks; // can be 0.._raid_chunks
+ _remaining_bytes = (uint) (_raid_chunksize -
+ (_position - _total_block * _raid_chunksize));
+ DBUG_PRINT("info",
+ ("_total_block: %d this_block: %d _remaining_bytes:%d",
+ _total_block, _this_block, _remaining_bytes));
+ DBUG_VOID_RETURN;
+ }
+};
+
+#endif /* __cplusplus */
+#endif /* USE_RAID */
diff --git a/include/sslopt-case.h b/include/sslopt-case.h
new file mode 100644
index 00000000000..db636176b5c
--- /dev/null
+++ b/include/sslopt-case.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifdef HAVE_OPENSSL
+ case OPT_SSL_SSL:
+ opt_use_ssl = 1; //true
+ break;
+ case OPT_SSL_KEY:
+ opt_use_ssl = 1; //true
+ my_free(opt_ssl_key, MYF(MY_ALLOW_ZERO_PTR));
+ opt_ssl_key = my_strdup(optarg, MYF(0));
+ break;
+ case OPT_SSL_CERT:
+ opt_use_ssl = 1; //true
+ my_free(opt_ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
+ opt_ssl_cert = my_strdup(optarg, MYF(0));
+ break;
+ case OPT_SSL_CA:
+ opt_use_ssl = 1; //true
+ my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
+ opt_ssl_ca = my_strdup(optarg, MYF(0));
+ break;
+ case OPT_SSL_CAPATH:
+ opt_use_ssl = 1; //true
+ my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
+ opt_ssl_ca = my_strdup(optarg, MYF(0));
+ break;
+#endif
diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h
new file mode 100644
index 00000000000..2f58f0e9265
--- /dev/null
+++ b/include/sslopt-longopts.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifdef HAVE_OPENSSL
+
+#define OPT_SSL_SSL 200
+#define OPT_SSL_KEY 201
+#define OPT_SSL_CERT 202
+#define OPT_SSL_CA 203
+#define OPT_SSL_CAPATH 204
+ {"ssl", no_argument, 0, OPT_SSL_SSL},
+ {"ssl-key", required_argument, 0, OPT_SSL_KEY},
+ {"ssl-cert", required_argument, 0, OPT_SSL_CERT},
+ {"ssl-ca", required_argument, 0, OPT_SSL_CA},
+ {"ssl-capath", required_argument, 0, OPT_SSL_CAPATH},
+
+#endif /* HAVE_OPENSSL */
diff --git a/include/sslopt-usage.h b/include/sslopt-usage.h
new file mode 100644
index 00000000000..5b2b4a88709
--- /dev/null
+++ b/include/sslopt-usage.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifdef OPEN_SSL
+ puts("\
+ --ssl Use SSL for connection (automatically set with other flags\n\
+ --ssl-key X509 key in PEM format (implies --ssl)\n\
+ --ssl-cert X509 cert in PEM format (implies --ssl)\n\
+ --ssl-ca CA file in PEM format (check OpenSSL docs, implies --ssl)\n\
+ --ssl-capath CA directory (check OpenSSL docs, implies --ssl)");
+#endif
diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h
new file mode 100644
index 00000000000..597ab4d9fa6
--- /dev/null
+++ b/include/sslopt-vars.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifdef HAVE_OPENSSL
+static my_bool opt_use_ssl = 0;
+static char *opt_ssl_key = 0;
+static char *opt_ssl_cert = 0;
+static char *opt_ssl_ca = 0;
+static char *opt_ssl_capath = 0;
+#endif
diff --git a/include/t_ctype.h b/include/t_ctype.h
new file mode 100644
index 00000000000..f6e799828e6
--- /dev/null
+++ b/include/t_ctype.h
@@ -0,0 +1,239 @@
+/*
+ Copyright (C) 1998, 1999 by Pruet Boonma, all rights reserved.
+ Copyright (C) 1998 by Theppitak Karoonboonyanan, all rights reserved.
+ Permission to use, copy, modify, distribute and sell this software
+ and its documentation for any purpose is hereby granted without fee,
+ provided that the above copyright notice appear in all copies.
+ Smaphan Raruenrom and Pruet Boonma makes no representations about
+ the suitability of this software for any purpose. It is provided
+ "as is" without express or implied warranty.
+*/
+
+/* LC_COLLATE category + Level information */
+
+#ifndef _t_ctype_h
+#define _t_ctype_h
+
+#define TOT_LEVELS 5
+#define LAST_LEVEL 4 /* TOT_LEVELS - 1 */
+
+#define IGNORE 0
+
+
+/* level 1 symbols & order */
+enum l1_symbols {
+ L1_08 = TOT_LEVELS,
+ L1_18,
+ L1_28,
+ L1_38,
+ L1_48,
+ L1_58,
+ L1_68,
+ L1_78,
+ L1_88,
+ L1_98,
+ L1_A8,
+ L1_B8,
+ L1_C8,
+ L1_D8,
+ L1_E8,
+ L1_F8,
+ L1_G8,
+ L1_H8,
+ L1_I8,
+ L1_J8,
+ L1_K8,
+ L1_L8,
+ L1_M8,
+ L1_N8,
+ L1_O8,
+ L1_P8,
+ L1_Q8,
+ L1_R8,
+ L1_S8,
+ L1_T8,
+ L1_U8,
+ L1_V8,
+ L1_W8,
+ L1_X8,
+ L1_Y8,
+ L1_Z8,
+ L1_KO_KAI,
+ L1_KHO_KHAI,
+ L1_KHO_KHUAT,
+ L1_KHO_KHWAI,
+ L1_KHO_KHON,
+ L1_KHO_RAKHANG,
+ L1_NGO_NGU,
+ L1_CHO_CHAN,
+ L1_CHO_CHING,
+ L1_CHO_CHANG,
+ L1_SO_SO,
+ L1_CHO_CHOE,
+ L1_YO_YING,
+ L1_DO_CHADA,
+ L1_TO_PATAK,
+ L1_THO_THAN,
+ L1_THO_NANGMONTHO,
+ L1_THO_PHUTHAO,
+ L1_NO_NEN,
+ L1_DO_DEK,
+ L1_TO_TAO,
+ L1_THO_THUNG,
+ L1_THO_THAHAN,
+ L1_THO_THONG,
+ L1_NO_NU,
+ L1_BO_BAIMAI,
+ L1_PO_PLA,
+ L1_PHO_PHUNG,
+ L1_FO_FA,
+ L1_PHO_PHAN,
+ L1_FO_FAN,
+ L1_PHO_SAMPHAO,
+ L1_MO_MA,
+ L1_YO_YAK,
+ L1_RO_RUA,
+ L1_RU,
+ L1_LO_LING,
+ L1_LU,
+ L1_WO_WAEN,
+ L1_SO_SALA,
+ L1_SO_RUSI,
+ L1_SO_SUA,
+ L1_HO_HIP,
+ L1_LO_CHULA,
+ L1_O_ANG,
+ L1_HO_NOKHUK,
+ L1_NKHIT,
+ L1_SARA_A,
+ L1_MAI_HAN_AKAT,
+ L1_SARA_AA,
+ L1_SARA_AM,
+ L1_SARA_I,
+ L1_SARA_II,
+ L1_SARA_UE,
+ L1_SARA_UEE,
+ L1_SARA_U,
+ L1_SARA_UU,
+ L1_SARA_E,
+ L1_SARA_AE,
+ L1_SARA_O,
+ L1_SARA_AI_MAIMUAN,
+ L1_SARA_AI_MAIMALAI
+};
+
+/* level 2 symbols & order */
+enum l2_symbols {
+ L2_BLANK = TOT_LEVELS,
+ L2_THAII,
+ L2_YAMAK,
+ L2_PINTHU,
+ L2_GARAN,
+ L2_TYKHU,
+ L2_TONE1,
+ L2_TONE2,
+ L2_TONE3,
+ L2_TONE4
+};
+
+/* level 3 symbols & order */
+enum l3_symbols {
+ L3_BLANK = TOT_LEVELS,
+ L3_SPACE,
+ L3_NB_SACE,
+ L3_LOW_LINE,
+ L3_HYPHEN,
+ L3_COMMA,
+ L3_SEMICOLON,
+ L3_COLON,
+ L3_EXCLAMATION,
+ L3_QUESTION,
+ L3_SOLIDUS,
+ L3_FULL_STOP,
+ L3_PAIYAN_NOI,
+ L3_MAI_YAMOK,
+ L3_GRAVE,
+ L3_CIRCUMFLEX,
+ L3_TILDE,
+ L3_APOSTROPHE,
+ L3_QUOTATION,
+ L3_L_PARANTHESIS,
+ L3_L_BRACKET,
+ L3_L_BRACE,
+ L3_R_BRACE,
+ L3_R_BRACKET,
+ L3_R_PARENTHESIS,
+ L3_AT,
+ L3_BAHT,
+ L3_DOLLAR,
+ L3_FONGMAN,
+ L3_ANGKHANKHU,
+ L3_KHOMUT,
+ L3_ASTERISK,
+ L3_BK_SOLIDUS,
+ L3_AMPERSAND,
+ L3_NUMBER,
+ L3_PERCENT,
+ L3_PLUS,
+ L3_LESS_THAN,
+ L3_EQUAL,
+ L3_GREATER_THAN,
+ L3_V_LINE
+};
+
+/* level 4 symbols & order */
+enum l4_symbols {
+ L4_BLANK = TOT_LEVELS,
+ L4_MIN,
+ L4_CAP,
+ L4_EXT
+};
+
+enum level_symbols {
+ L_UPRUPR = TOT_LEVELS,
+ L_UPPER,
+ L_MIDDLE,
+ L_LOWER
+};
+
+#define _is(c) (t_ctype[(c)][LAST_LEVEL])
+#define _level 8
+#define _consnt 16
+#define _ldvowel 32
+#define _fllwvowel 64
+#define _uprvowel 128
+#define _lwrvowel 256
+#define _tone 512
+#define _diacrt1 1024
+#define _diacrt2 2048
+#define _combine 4096
+#define _stone 8192
+#define _tdig 16384
+#define _rearvowel (_fllwvowel | _uprvowel | _lwrvowel)
+#define _diacrt (_diacrt1 | _diacrt2)
+#define levelof(c) ( _is(c) & _level )
+#define isthai(c) ( (c) >= 128 )
+#define istalpha(c) ( _is(c) & (_consnt|_ldvowel|_rearvowel|\
+ _tone|_diacrt1|_diacrt2) )
+#define isconsnt(c) ( _is(c) & _consnt )
+#define isldvowel(c) ( _is(c) & _ldvowel )
+#define isfllwvowel(c) ( _is(c) & _fllwvowel )
+#define ismidvowel(c) ( _is(c) & (_ldvowel|_fllwvowel) )
+#define isuprvowel(c) ( _is(c) & _uprvowel )
+#define islwrvowel(c) ( _is(c) & _lwrvowel )
+#define isuprlwrvowel(c) ( _is(c) & (_lwrvowel | _uprvowel))
+#define isrearvowel(c) ( _is(c) & _rearvowel )
+#define isvowel(c) ( _is(c) & (_ldvowel|_rearvowel) )
+#define istone(c) ( _is(c) & _tone )
+#define isunldable(c) ( _is(c) & (_rearvowel|_tone|_diacrt1|_diacrt2) )
+#define iscombinable(c) ( _is(c) & _combine )
+#define istdigit(c) ( _is(c) & _tdig )
+#define isstone(c) ( _is(c) & _stone )
+#define isdiacrt1(c) ( _is(c) & _diacrt1)
+#define isdiacrt2(c) ( _is(c) & _diacrt2)
+#define isdiacrt(c) ( _is(c) & _diacrt)
+
+/* Function prototype called by sql/field.cc */
+void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length);
+
+#endif
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
new file mode 100644
index 00000000000..931896855f3
--- /dev/null
+++ b/include/thr_alarm.h
@@ -0,0 +1,100 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Prototypes when using thr_alarm library functions */
+
+#ifndef _thr_alarm_h
+#define _thr_alarm_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct st_alarm {
+ ulong expire_time;
+ int alarmed; /* 1 when alarm is due */
+ pthread_t thread;
+ my_bool malloced;
+} ALARM;
+
+#ifndef USE_ALARM_THREAD
+#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
+#endif
+#ifdef HAVE_LINUXTHREADS
+#define THR_CLIENT_ALARM SIGALRM
+#else
+#define THR_CLIENT_ALARM SIGUSR1
+#endif
+#ifdef HAVE_rts_threads
+#undef USE_ONE_SIGNAL_HAND
+#define USE_ALARM_THREAD
+#define THR_SERVER_ALARM SIGUSR1
+#else
+#define THR_SERVER_ALARM SIGALRM
+#endif
+
+#ifdef DONT_USE_THR_ALARM
+
+#define USE_ALARM_THREAD
+#undef USE_ONE_SIGNAL_HAND
+
+typedef struct st_win_timer
+{
+ uint crono;
+} thr_alarm_t;
+
+#define thr_alarm_init(A) (A)->crono=0
+#define thr_alarm_in_use(A) (A).crono
+#define init_thr_alarm(A)
+#define thr_alarm_kill(A)
+#define end_thr_alarm()
+#define thr_alarm(A,B) (((A)->crono=1)-1)
+#define thr_got_alarm(A) (A).crono
+#define thr_end_alarm(A)
+
+#else
+
+#ifdef __WIN__
+typedef struct st_win_timer
+{
+ uint crono;
+} thr_alarm_t;
+
+bool thr_got_alarm(thr_alarm_t *alrm);
+#define thr_alarm_init(A) (A)->crono=0
+#define thr_alarm_in_use(A) (A)->crono
+#define init_thr_alarm(A)
+#define thr_alarm_kill(A)
+#else
+
+typedef int* thr_alarm_t;
+#define thr_got_alarm(thr_alarm) (*thr_alarm)
+#define thr_alarm_init(A) (*A)=0
+#define thr_alarm_in_use(A) ((A) != 0)
+void init_thr_alarm(uint max_alarm);
+void thr_alarm_kill(pthread_t thread_id);
+sig_handler process_alarm(int);
+#endif /* __WIN__ */
+
+bool thr_alarm(thr_alarm_t *alarmed,uint sec, ALARM *buff);
+void thr_end_alarm(thr_alarm_t *alarmed);
+void end_thr_alarm(void);
+#endif /* DONT_USE_THR_ALARM */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/thr_lock.h b/include/thr_lock.h
new file mode 100644
index 00000000000..288a762703d
--- /dev/null
+++ b/include/thr_lock.h
@@ -0,0 +1,89 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* For use with thr_lock:s */
+
+#ifndef _thr_lock_h
+#define _thr_lock_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <my_pthread.h>
+#include <my_list.h>
+
+struct st_thr_lock;
+
+enum thr_lock_type { TL_IGNORE=-1,
+ TL_UNLOCK, TL_READ, TL_READ_HIGH_PRIORITY,
+ TL_READ_NO_INSERT,
+ TL_WRITE_ALLOW_WRITE, TL_WRITE_ALLOW_READ,
+ TL_WRITE_CONCURRENT_INSERT,
+ TL_WRITE_DELAYED, TL_WRITE_LOW_PRIORITY, TL_WRITE,
+ TL_WRITE_ONLY};
+
+extern ulong max_write_lock_count;
+extern my_bool thr_lock_inited;
+
+typedef struct st_thr_lock_data {
+ pthread_t thread;
+ struct st_thr_lock_data *next,**prev;
+ struct st_thr_lock *lock;
+ pthread_cond_t *cond;
+ enum thr_lock_type type;
+ ulong thread_id;
+ void *status_param; /* Param to status functions */
+} THR_LOCK_DATA;
+
+struct st_lock_list {
+ THR_LOCK_DATA *data,**last;
+};
+
+typedef struct st_thr_lock {
+ LIST list;
+ pthread_mutex_t mutex;
+ struct st_lock_list read_wait;
+ struct st_lock_list read;
+ struct st_lock_list write_wait;
+ struct st_lock_list write;
+/* write_lock_count is incremented for write locks and reset on read locks */
+ ulong write_lock_count;
+ uint read_no_write_count;
+ void (*get_status)(void*); /* When one gets a lock */
+ void (*copy_status)(void*,void*);
+ void (*update_status)(void*); /* Before release of write */
+ my_bool (*check_status)(void *);
+} THR_LOCK;
+
+
+my_bool init_thr_lock(void); /* Must be called once/thread */
+void thr_lock_init(THR_LOCK *lock);
+void thr_lock_delete(THR_LOCK *lock);
+void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
+ void *status_param);
+int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type);
+void thr_unlock(THR_LOCK_DATA *data);
+int thr_multi_lock(THR_LOCK_DATA **data,uint count);
+void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
+void thr_abort_locks(THR_LOCK *lock);
+void thr_print_locks(void); /* For debugging */
+my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
+my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
+#ifdef __cplusplus
+}
+#endif
+#endif /* _thr_lock_h */
diff --git a/include/violite.h b/include/violite.h
new file mode 100644
index 00000000000..e7c3e8ede81
--- /dev/null
+++ b/include/violite.h
@@ -0,0 +1,115 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ * Vio Lite.
+ * Purpose: include file for Vio that will work with C and C++
+ */
+
+#ifndef vio_violite_h_
+#define vio_violite_h_
+
+#include "my_net.h" /* needed because of struct in_addr */
+
+#ifdef HAVE_VIO
+#include <Vio.h> /* Full VIO interface */
+#else
+
+/* Simple vio interface in C; The functions are implemented in violite.c */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef Vio_defined
+#define Vio_defined
+struct st_vio; /* Only C */
+typedef struct st_vio Vio;
+#endif
+
+enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
+ VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
+
+Vio* vio_new(my_socket sd,
+ enum enum_vio_type type,
+ my_bool localhost);
+#ifdef __WIN__
+Vio* vio_new_win32pipe(HANDLE hPipe);
+#endif
+void vio_delete(Vio* vio);
+
+/*
+ * vio_read and vio_write should have the same semantics
+ * as read(2) and write(2).
+ */
+int vio_read( Vio* vio,
+ gptr buf, int size);
+int vio_write( Vio* vio,
+ const gptr buf,
+ int size);
+/*
+ * Whenever the socket is set to blocking mode or not.
+ */
+int vio_blocking( Vio* vio,
+ my_bool onoff);
+my_bool vio_is_blocking( Vio* vio);
+/*
+ * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
+ */
+int vio_fastsend( Vio* vio,
+ my_bool onoff);
+/*
+ * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
+ */
+int vio_keepalive( Vio* vio,
+ my_bool onoff);
+/*
+ * Whenever we should retry the last read/write operation.
+ */
+my_bool vio_should_retry( Vio* vio);
+/*
+ * When the workday is over...
+ */
+int vio_close( Vio* vio);
+/*
+ * Short text description of the socket for those, who are curious..
+ */
+const char* vio_description( Vio* vio);
+
+/* Return the type of the connection */
+ enum enum_vio_type vio_type(Vio* vio);
+
+/* Return last error number */
+int vio_errno(Vio *vio);
+
+/* Get socket number */
+my_socket vio_fd(Vio *vio);
+
+/*
+ * Remote peer's address and name in text form.
+ */
+my_bool vio_peer_addr(Vio * vio, char *buf);
+
+/* Remotes in_addr */
+
+void vio_in_addr(Vio *vio, struct in_addr *in);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* HAVE_VIO */
+#endif /* vio_violite_h_ */