diff options
Diffstat (limited to 'include')
52 files changed, 2440 insertions, 1285 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 393dac3fd82..7a02b38020d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,28 +16,27 @@ # MA 02111-1307, USA BUILT_SOURCES = mysql_version.h m_ctype.h my_config.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_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 config-os2.h\ +pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \ + mysql.h mysql_com.h mysqld_error.h mysql_embed.h \ + my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ + errmsg.h my_global.h my_net.h my_alloc.h \ + my_getopt.h sslopt-longopts.h \ + sslopt-vars.h sslopt-case.h $(BUILT_SOURCES) +noinst_HEADERS = config-win.h config-os2.h config-netware.h \ nisam.h heap.h merge.h my_bitmap.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 + my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ + my_aes.h my_tree.h hash.h thr_alarm.h \ + thr_lock.h t_ctype.h violite.h md5.h mysql_version.h.in # mysql_version.h are generated -SUPERCLEANFILES = mysql_version.h my_global.h my_config.h +SUPERCLEANFILES = mysql_version.h my_config.h # Some include files that may be moved and patched by configure DISTCLEANFILES = sched.h -all-local: my_global.h my_config.h +all-local: my_config.h # Since we include my_config.h it better exist from the beginning link_sources: @@ -48,11 +47,6 @@ link_sources: 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 - $(RM) -f my_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: diff --git a/include/config-netware.h b/include/config-netware.h new file mode 100644 index 00000000000..57bf500da47 --- /dev/null +++ b/include/config-netware.h @@ -0,0 +1,86 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 */ + +/* Defines for netware compatible with MySQL */ + +/* required headers */ +#include <unistd.h> +#include <stdio.h> +#include <errno.h> +#include <screen.h> +#include <limits.h> +#include <nks/synch.h> +#include <nks/thread.h> +#include <signal.h> +#include <errno.h> +#include <stdbool.h> +#include <stdlib.h> +#include <nks/errno.h> +#include <sys/types.h> +#include <time.h> +#include <sys/time.h> +#include <nks/time.h> +#include <pthread.h> +#include <termios.h> + +/* required adjustments */ +#undef HAVE_READDIR_R +#undef HAVE_RWLOCK_INIT +#undef HAVE_SCHED_H +#undef HAVE_SYS_MMAN_H +#undef HAVE_SYNCH_H +#undef HAVE_CRYPT +#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 +#define HAVE_PTHREAD_SIGMASK 1 +#define HAVE_PTHREAD_YIELD_ZERO_ARG 1 +#define HAVE_BROKEN_REALPATH 1 + +/* no case sensitivity */ +#define FN_NO_CASE_SENCE 1 + +/* the thread alarm is not used */ +#define DONT_USE_THR_ALARM 1 + +/* signals do not interrupt sockets */ +#define SIGNALS_DONT_BREAK_READ 1 + +/* signal by closing the sockets */ +#define SIGNAL_WITH_VIO_CLOSE 1 + +/* default directory information */ +#define DEFAULT_MYSQL_HOME "sys:/mysql" +#define PACKAGE "mysql" +#define DEFAULT_BASEDIR "sys:/" +#define SHAREDIR "share/" +#define DEFAULT_CHARSET_HOME "sys:/mysql/" +#define DATADIR "data/" + +/* 64-bit file system calls */ +#define SIZEOF_OFF_T 8 +#define off_t off64_t +#define chsize chsize64 +#define ftruncate ftruncate64 +#define lseek lseek64 +#define pread pread64 +#define pwrite pwrite64 +#define tell tell64 + +/* do not use the extended time in LibC sys\stat.h */ +#define _POSIX_SOURCE + +/* Some macros for portability */ + +#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=(SEC); (ABSTIME).tv_nsec=0; } diff --git a/include/config-os2.h b/include/config-os2.h index e23f4eb75e8..7e9684ae3f5 100644 --- a/include/config-os2.h +++ b/include/config-os2.h @@ -67,10 +67,10 @@ #define NO_FCNTL_NONBLOCK #define EFBIG E2BIG -//#define ENFILE EMFILE -//#define ENAMETOOLONG (EOS2ERR+2) -//#define ETIMEDOUT 145 -//#define EPIPE 146 +/*#define ENFILE EMFILE */ +/*#define ENAMETOOLONG (EOS2ERR+2) */ +/*#define ETIMEDOUT 145 */ +/*#define EPIPE 146 */ #define EROFS 147 #define sleep(A) DosSleep((A)*1000) @@ -132,7 +132,7 @@ typedef unsigned long long os_off_t; #define HAVE_ALLOCA 1 /* Define if you have <alloca.h> and it should be used (not on Ultrix). */ -//#define HAVE_ALLOCA_H 1 +/* #define HAVE_ALLOCA_H 1 */ /* Define if you don't have vprintf but do have _doprnt. */ /* #undef HAVE_DOPRNT */ @@ -148,7 +148,7 @@ typedef unsigned long long os_off_t; #define HAVE_ST_RDEV 1 /* Define if you have <sys/wait.h> that is POSIX.1 compatible. */ -//#define HAVE_SYS_WAIT_H 1 +/* #define HAVE_SYS_WAIT_H 1 */ /* Define if you don't have tm_zone but do have the external array tzname. */ @@ -219,7 +219,7 @@ typedef unsigned long long os_off_t; #define HAVE_BOOL 1 /* Have berkeley db installed */ -//#define HAVE_BERKELEY_DB 1 +/* #define HAVE_BERKELEY_DB 1 */ /* DSB style signals ? */ /* #undef HAVE_BSD_SIGNALS */ @@ -398,7 +398,7 @@ typedef unsigned long long os_off_t; #define HAVE_CHSIZE 1 /* Define if you have the cuserid function. */ -//#define HAVE_CUSERID 1 +/* #define HAVE_CUSERID 1 */ /* Define if you have the dlerror function. */ #define HAVE_DLERROR 1 @@ -410,7 +410,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_FCHMOD */ /* Define if you have the fcntl function. */ -//#define HAVE_FCNTL 1 +/* #define HAVE_FCNTL 1 */ /* Define if you have the fconvert function. */ /* #undef HAVE_FCONVERT */ @@ -428,7 +428,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_FSEEKO */ /* Define if you have the ftruncate function. */ -//#define HAVE_FTRUNCATE 1 +/* #define HAVE_FTRUNCATE 1 */ /* Define if you have the getcwd function. */ #define HAVE_GETCWD 1 @@ -443,16 +443,16 @@ typedef unsigned long long os_off_t; #define HAVE_GETPAGESIZE 1 /* Define if you have the getpass function. */ -//#define HAVE_GETPASS 1 +/*#define HAVE_GETPASS 1 */ /* Define if you have the getpassphrase function. */ /* #undef HAVE_GETPASSPHRASE */ /* Define if you have the getpwnam function. */ -//#define HAVE_GETPWNAM 1 +/* #define HAVE_GETPWNAM 1 */ /* Define if you have the getpwuid function. */ -//#define HAVE_GETPWUID 1 +/* #define HAVE_GETPWUID 1 */ /* Define if you have the getrlimit function. */ /* #undef HAVE_GETRLIMIT */ @@ -494,7 +494,7 @@ typedef unsigned long long os_off_t; #define HAVE_MEMMOVE 1 /* Define if you have the mkstemp function. */ -//#define HAVE_MKSTEMP 1 +/* #define HAVE_MKSTEMP 1 */ /* Define if you have the mlockall function. */ /* #undef HAVE_MLOCKALL */ @@ -584,7 +584,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_SIGTHREADMASK */ /* Define if you have the snprintf function. */ -//#define HAVE_SNPRINTF 1 +/* #define HAVE_SNPRINTF 1 */ /* Define if you have the socket function. */ #define HAVE_SOCKET 1 @@ -638,7 +638,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_VIDATTR */ /* Define if you have the <alloca.h> header file. */ -//#define HAVE_ALLOCA_H 1 +/* #define HAVE_ALLOCA_H 1 */ /* Define if you have the <arpa/inet.h> header file. */ #define HAVE_ARPA_INET_H 1 @@ -650,10 +650,10 @@ typedef unsigned long long os_off_t; #define HAVE_CRYPT_H 1 /* Define if you have the <curses.h> header file. */ -//#define HAVE_CURSES_H 1 +/* #define HAVE_CURSES_H 1 */ /* Define if you have the <dirent.h> header file. */ -//#define HAVE_DIRENT_H 1 +/* #define HAVE_DIRENT_H 1 */ /* Define if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 @@ -665,7 +665,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_FLOATINGPOINT_H */ /* Define if you have the <grp.h> header file. */ -//#define HAVE_GRP_H 1 +/* #define HAVE_GRP_H 1 */ /* Define if you have the <ieeefp.h> header file. */ /* #undef HAVE_IEEEFP_H */ @@ -689,7 +689,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_PATHS_H */ /* Define if you have the <pwd.h> header file. */ -//#define HAVE_PWD_H 1 +/* #define HAVE_PWD_H 1 */ /* Define if you have the <sched.h> header file. */ /* #undef HAVE_SCHED_H */ @@ -710,16 +710,16 @@ typedef unsigned long long os_off_t; #define HAVE_STRING_H 1 /* Define if you have the <strings.h> header file. */ -//#define HAVE_STRINGS_H 1 +/* #define HAVE_STRINGS_H 1 */ /* Define if you have the <synch.h> header file. */ /* #undef HAVE_SYNCH_H */ /* Define if you have the <sys/dir.h> header file. */ -//#define HAVE_SYS_DIR_H 1 +/* #define HAVE_SYS_DIR_H 1 */ /* Define if you have the <sys/file.h> header file. */ -//#define HAVE_SYS_FILE_H 1 +/* #define HAVE_SYS_FILE_H 1 */ /* Define if you have the <sys/ioctl.h> header file. */ #define HAVE_SYS_IOCTL_H 1 @@ -761,7 +761,7 @@ typedef unsigned long long os_off_t; /* #undef HAVE_SYS_VADVISE_H */ /* Define if you have the <sys/wait.h> header file. */ -//#define HAVE_SYS_WAIT_H 1 +/* #define HAVE_SYS_WAIT_H 1 */ /* Define if you have the <term.h> header file. */ /* #undef HAVE_TERM_H */ @@ -770,13 +770,13 @@ typedef unsigned long long os_off_t; /* #undef HAVE_TERMBITS_H */ /* Define if you have the <termcap.h> header file. */ -//#define HAVE_TERMCAP_H 1 +/* #define HAVE_TERMCAP_H 1 */ /* Define if you have the <termio.h> header file. */ -//#define HAVE_TERMIO_H 1 +/* /#define HAVE_TERMIO_H 1 */ /* Define if you have the <termios.h> header file. */ -//#define HAVE_TERMIOS_H 1 +/* #define HAVE_TERMIOS_H 1 */ /* Define if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 @@ -829,4 +829,4 @@ typedef unsigned long long os_off_t; /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ -#endif // __CONFIG_OS2_H__ +#endif /* __CONFIG_OS2_H__ */ diff --git a/include/config-win.h b/include/config-win.h index 4e4088f07dd..74b2ae71017 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Defines for Win32 to make it compatible for MySQL */ @@ -25,14 +24,14 @@ #include <malloc.h> #if defined(__NT__) -#define SYSTEM_TYPE "NT" +#define SYSTEM_TYPE "NT" #elif defined(__WIN2000__) -#define SYSTEM_TYPE "WIN2000" +#define SYSTEM_TYPE "WIN2000" #else -#define SYSTEM_TYPE "Win95/Win98" +#define SYSTEM_TYPE "Win95/Win98" #endif -#ifdef _WIN64 +#if defined(_WIN64) || defined(WIN64) #define MACHINE_TYPE "ia64" /* Define to machine type name */ #else #define MACHINE_TYPE "i32" /* Define to machine type name */ @@ -44,23 +43,23 @@ #endif #endif /* _WIN64 */ #ifndef __WIN__ -#define __WIN__ /* To make it easier in VC++ */ +#define __WIN__ /* To make it easier in VC++ */ #endif /* File and lock constants */ -#define O_SHARE 0x1000 /* Open file in sharing mode */ +#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) */ +#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) */ +#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_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 */ @@ -71,15 +70,15 @@ #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 +#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 */ +#define SIGQUIT SIGTERM /* No SIGQUIT */ #undef _REENTRANT /* Crashes something for win32 */ #undef SAFE_MUTEX /* Can't be used on windows */ @@ -90,15 +89,15 @@ /* Type information */ -typedef unsigned short ushort; -typedef unsigned int uint; +typedef unsigned short ushort; +typedef unsigned int uint; typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ -typedef __int64 longlong; +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 long off_t; typedef __int64 os_off_t; #ifdef _WIN64 typedef UINT_PTR rf_SetTimer; @@ -110,7 +109,7 @@ typedef uint rf_SetTimer; #define Socket_defined #define my_socket SOCKET #define bool BOOL -#define SIGPIPE SIGINT +#define SIGPIPE SIGINT #define RETQSORTTYPE void #define QSORT_TYPE_IS_VOID #define RETSIGTYPE void @@ -119,7 +118,9 @@ typedef uint rf_SetTimer; #define bool_defined #define byte_defined #define HUGE_PTR -#define STDCALL __stdcall /* Used by libmysql.dll */ +#define STDCALL __stdcall /* Used by libmysql.dll */ +#define isnan(X) _isnan(X) +#define finite(X) _finite(X) #ifndef UNDEF_THREAD_HACK #define THREAD @@ -134,11 +135,16 @@ typedef uint rf_SetTimer; #define HAVE_NAMED_PIPE /* We can only create pipes on NT */ #endif +/* We need to close files to break connections on shutdown */ +#ifndef SIGNAL_WITH_VIO_CLOSE +#define SIGNAL_WITH_VIO_CLOSE +#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)) @@ -181,6 +187,8 @@ inline double ulonglong2double(ulonglong value) #define tell(A) _telli64(A) #endif +#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } + #define STACK_DIRECTION -1 /* Optimized store functions for Intel x86 */ @@ -202,7 +210,7 @@ inline double ulonglong2double(ulonglong value) (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[3])) << 24)) +\ - (((ulonglong) ((uchar) (A)[4])) << 32)) + (((ulonglong) ((uchar) (A)[4])) << 32)) #define uint8korr(A) (*((ulonglong *) (A))) #define sint8korr(A) (*((longlong *) (A))) #define int2store(T,A) *((uint16*) (T))= (uint16) (A) @@ -248,12 +256,18 @@ inline double ulonglong2double(ulonglong value) #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_RINT /* defined in this file */ +#define NO_FCNTL_NONBLOCK /* No FCNTL */ #define HAVE_ALLOCA #define HAVE_STRPBRK #define HAVE_STRSTR #define HAVE_COMPRESS +#define HAVE_CREATESEMAPHORE +#define HAVE_ISNAN +#define HAVE_FINITE +#define HAVE_ISAM /* We want to have support for ISAM in 4.0 */ +#define HAVE_QUERY_CACHE +#define SPRINTF_RETURNS_INT #ifdef NOT_USED #define HAVE_SNPRINTF /* Gave link error */ @@ -269,13 +283,14 @@ inline double ulonglong2double(ulonglong value) #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_MYSQL_HOME "c:\\mysql" +#define PACKAGE "mysql" #define DEFAULT_BASEDIR "C:\\" #define SHAREDIR "share" #define DEFAULT_CHARSET_HOME "C:/mysql/" @@ -301,6 +316,6 @@ inline double ulonglong2double(ulonglong value) 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) +#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 index 3c86cbb8ac2..5c88e2e42db 100644 --- a/include/dbug.h +++ b/include/dbug.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _dbug_h #define _dbug_h diff --git a/include/errmsg.h b/include/errmsg.h index 8087c526937..5136af5b87a 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Error messages for mysql clients */ /* error messages for the demon is in share/language/errmsg.sys */ @@ -29,7 +28,7 @@ extern const char *client_errors[]; /* Error messages */ #define CR_MIN_ERROR 2000 /* For easier client code */ #define CR_MAX_ERROR 2999 -#if defined(OS2) && defined( MYSQL_SERVER) +#if defined(OS2) && defined(MYSQL_SERVER) #define CER(X) client_errors[(X)-CR_MIN_ERROR] #else #define ER(X) client_errors[(X)-CR_MIN_ERROR] @@ -52,8 +51,16 @@ extern const char *client_errors[]; /* Error messages */ #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_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 +#define CR_EMBEDDED_CONNECTION 2021 +#define CR_PROBE_SLAVE_STATUS 2022 +#define CR_PROBE_SLAVE_HOSTS 2023 +#define CR_PROBE_SLAVE_CONNECT 2024 +#define CR_PROBE_MASTER_CONNECT 2025 +#define CR_SSL_CONNECTION_ERROR 2026 +#define CR_MALFORMED_PACKET 2027 + diff --git a/include/ft_global.h b/include/ft_global.h index 3937bd87c7f..9acdf6aaaf3 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,29 +27,39 @@ extern "C" { #endif #define FT_QUERY_MAXLEN 1024 +#define HA_FT_MAXLEN 254 -typedef struct ft_doc_rec { - my_off_t dpos; - double weight; -} FT_DOC; +typedef struct st_ft_info FT_INFO; +struct _ft_vft +{ + int (*read_next)(FT_INFO *, char *); + float (*find_relevance)(FT_INFO *, byte *, uint); + void (*close_search)(FT_INFO *); + float (*get_relevance)(FT_INFO *); + void (*reinit_search)(FT_INFO *); +}; -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; +#ifndef FT_CORE +struct st_ft_info +{ + struct _ft_vft *please; /* INTERCAL style :-) */ +}; +#endif +extern const char *ft_stopword_file; extern const char *ft_precompiled_stopwords[]; -int ft_init_stopwords(const char **); +extern ulong ft_min_word_len; +extern ulong ft_max_word_len; +extern ulong ft_max_word_len_for_sort; +extern const char *ft_boolean_syntax; + +int ft_init_stopwords(void); void ft_free_stopwords(void); -FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool); -int ft_read_next(FT_DOCLIST *, char *); -#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) -#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight) -#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1) +#define FT_NL 0 +#define FT_BOOL 1 +FT_INFO *ft_init_search(uint,void *, uint, byte *, uint, my_bool); #ifdef __cplusplus } diff --git a/include/getopt.h b/include/getopt.h deleted file mode 100644 index 790915b97df..00000000000 --- a/include/getopt.h +++ /dev/null @@ -1,135 +0,0 @@ -/* 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 __EMX__ -int getopt (int, char **, __const__ char *); -#elif defined( __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/hash.h b/include/hash.h index 2f6a424fb3c..e9c8c73c05b 100644 --- a/include/hash.h +++ b/include/hash.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Dynamic hashing of record with different key-length */ @@ -55,6 +54,7 @@ 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); +void hash_replace(HASH *hash, uint idx, byte *new_row); my_bool hash_check(HASH *hash); /* Only in debug library */ #define hash_clear(H) bzero((char*) (H),sizeof(*(H))) diff --git a/include/heap.h b/include/heap.h index 14698810297..02b04e2b3ec 100644 --- a/include/heap.h +++ b/include/heap.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This file should be included when using heap_database_funktions */ /* Author: Michael Widenius */ @@ -79,11 +78,13 @@ typedef struct st_hp_keyseg /* Key-portion */ uint start; /* Start of key in record (from 0) */ uint length; /* Keylength */ uint type; + uint null_bit; /* bit set in row+null_pos */ + uint null_pos; } HP_KEYSEG; typedef struct st_hp_keydef /* Key definition with open */ { - uint flag; /* NOSAME */ + uint flag; /* HA_NOSAME | HA_NULL_PART_KEY */ uint keysegs; /* Number of key-segment */ uint length; /* Length of key (automatic) */ HP_KEYSEG *seg; @@ -109,6 +110,7 @@ typedef struct st_heap_share THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ #endif + my_bool delete_on_close; LIST open_list; } HP_SHARE; @@ -144,7 +146,7 @@ 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_delete_table(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); diff --git a/include/m_ctype.h b/include/m_ctype.h index 645c07b79ae..fc983d1d580 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1,23 +1,22 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* A better inplementation of the UNIX ctype(3) library. - Notes: global.h should be included before ctype.h + Notes: my_global.h should be included before ctype.h */ #ifndef _m_ctype_h @@ -57,13 +56,12 @@ 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[]; +extern uint compiled_charset_number(const char *name); +extern const char *compiled_charset_name(uint charset_number); #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_H_ @@ -71,12 +69,32 @@ extern CHARSET_INFO compiled_charsets[]; #define __CTYPE_INCLUDED #define _CTYPE_USING /* Don't put names in global namespace. */ +/* Fix things, if ctype.h would have been included before */ +#undef toupper +#undef _toupper +#undef _tolower +#undef toupper +#undef tolower +#undef isalpha +#undef isupper +#undef islower +#undef isdigit +#undef isxdigit +#undef isalnum +#undef isspace +#undef ispunct +#undef isprint +#undef isgraph +#undef iscntrl +#undef isascii +#undef toascii + #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 _NMR 04 /* Numeral (digit) */ +#define _SPC 010 /* Spacing character */ +#define _PNT 020 /* Punctuation */ +#define _CTR 040 /* Control character */ #define _B 0100 /* Blank */ #define _X 0200 /* heXadecimal digit */ @@ -85,7 +103,6 @@ extern CHARSET_INFO compiled_charsets[]; #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)] @@ -94,14 +111,14 @@ extern CHARSET_INFO compiled_charsets[]; #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 isdigit(c) ((my_ctype+1)[(uchar) (c)] & _NMR) #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 isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _NMR)) +#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _SPC) +#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _PNT) +#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR | _B)) +#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR)) +#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _CTR) #define isascii(c) (!((c) & ~0177)) #define toascii(c) ((c) & 0177) @@ -109,19 +126,17 @@ extern CHARSET_INFO compiled_charsets[]; #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_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _NMR) #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 my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L | _NMR)) +#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _SPC) +#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _PNT) +#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR | _B)) +#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR)) +#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _CTR) #define use_strcoll(s) ((s)->strcoll != NULL) #define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply) diff --git a/include/m_string.h b/include/m_string.h index 7eb2f1fe690..c6943613b1a 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* There may be prolems include all of theese. Try to test in configure with ones are needed? */ @@ -132,11 +131,12 @@ extern void bzero(gptr dst,uint len); #if !defined(bcmp) && !defined(HAVE_BCMP) extern int bcmp(const char *s1,const char *s2,uint len); +#endif #ifdef HAVE_purify extern int my_bcmp(const char *s1,const char *s2,uint len); +#undef bcmp #define bcmp(A,B,C) my_bcmp((A),(B),(C)) #endif -#endif #ifndef bmove512 extern void bmove512(gptr dst,const gptr src,uint len); diff --git a/include/md5.h b/include/md5.h new file mode 100644 index 00000000000..aa4116ff17f --- /dev/null +++ b/include/md5.h @@ -0,0 +1,93 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 */ + + +/* MD5.H - header file for MD5C.C + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + */ + +/* GLOBAL.H - RSAREF types and constants + */ + +/* PROTOTYPES should be set to one if and only if the compiler supports + function argument prototyping. +The following makes PROTOTYPES default to 0 if it has not already + been defined with C compiler flags. + */ + +/* egcs 1.1.2 under linux didn't defined it.... :( */ + +#ifndef PROTOTYPES +#define PROTOTYPES 1 /* Assume prototypes */ +#endif + +/* POINTER defines a generic pointer type */ +typedef unsigned char *POINTER; + +/* UINT2 defines a two byte word */ +typedef uint16 UINT2; /* Fix for MySQL / Alpha */ + +/* UINT4 defines a four byte word */ +typedef uint32 UINT4; /* Fix for MySQL / Alpha */ + +/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. +If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it + returns an empty list. + */ +#if PROTOTYPES +#define PROTO_LIST(list) list +#else +#define PROTO_LIST(list) () +#endif +/* MD5 context. */ +typedef struct { + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} my_MD5_CTX; + +#ifdef __cplusplus +extern "C" { +#endif + void my_MD5Init PROTO_LIST ((my_MD5_CTX *)); + void my_MD5Update PROTO_LIST + ((my_MD5_CTX *, unsigned char *, unsigned int)); + void my_MD5Final PROTO_LIST ((unsigned char [16], my_MD5_CTX *)); + +#ifdef __cplusplus +} +#endif diff --git a/include/merge.h b/include/merge.h index c661e03a0c7..97cea5fabb1 100644 --- a/include/merge.h +++ b/include/merge.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This file should be included when using merge_isam_funktions */ /* Author: Michael Widenius */ diff --git a/include/my_aes.h b/include/my_aes.h new file mode 100644 index 00000000000..5852baa5892 --- /dev/null +++ b/include/my_aes.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2002 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 */ + + +/* Header file for my_aes.c */ +/* Wrapper to give simple interface for MySQL to AES standard encryption */ + +#include "rijndael.h" + +C_MODE_START + +#define AES_KEY_LENGTH 128 /* Must be 128 192 or 256 */ + +/* + my_aes_encrypt - Crypt buffer with AES encryption algorithm. + source - Pointer to data for encryption + source_length - size of encryption data + dest - buffer to place encrypted data (must be large enough) + key - Key to be used for encryption + kel_length - Length of the key. Will handle keys of any length + + returns - size of encrypted data, or negative in case of error. +*/ + +int my_aes_encrypt(const char *source, int source_length, char *dest, + const char *key, int key_length); + +/* + my_aes_decrypt - DeCrypt buffer with AES encryption algorithm. + source - Pointer to data for decryption + source_length - size of encrypted data + dest - buffer to place decrypted data (must be large enough) + key - Key to be used for decryption + kel_length - Length of the key. Will handle keys of any length + + returns - size of original data, or negative in case of error. +*/ + + +int my_aes_decrypt(const char *source, int source_length, char *dest, + const char *key, int key_length); + +/* + my_aes_get_size - get size of buffer which will be large enough for encrypted + data + source_length - length of data to be encrypted + + returns - size of buffer required to store encrypted data +*/ + +int my_aes_get_size(int source_length); + +C_MODE_END diff --git a/include/my_alarm.h b/include/my_alarm.h index b6c5ca6a3f4..fdfce9c65c9 100644 --- a/include/my_alarm.h +++ b/include/my_alarm.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* File to include when we want to use alarm or a loop_counter to display diff --git a/include/my_alloc.h b/include/my_alloc.h new file mode 100644 index 00000000000..a3dd35d7ea3 --- /dev/null +++ b/include/my_alloc.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 */ + +/* + Data structures for mysys/my_alloc.c (root memory allocator) +*/ + +#ifndef _my_alloc_h +#define _my_alloc_h + +#define ALLOC_MAX_BLOCK_TO_DROP 4096 +#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 + +typedef struct st_used_mem +{ /* struct for once_alloc (block) */ + 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; /* blocks with free memory in it */ + USED_MEM *used; /* blocks almost without free memory */ + USED_MEM *pre_alloc; /* preallocated block */ + /* if block have less memory it will be put in 'used' list */ + unsigned int min_malloc; + unsigned int block_size; /* initial block size */ + unsigned int block_num; /* allocated blocks counter */ + /* + first free block in queue test counter (if it exceed + MAX_BLOCK_USAGE_BEFORE_DROP block will be droped in 'used' list) + */ + unsigned int first_block_usage; + + void (*error_handler)(void); +} MEM_ROOT; +#endif diff --git a/include/my_base.h b/include/my_base.h index dff1553cf20..f91b45ee469 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This file includes constants used with all databases */ /* Author: Michael Widenius */ @@ -24,7 +23,7 @@ #ifndef stdin /* Included first in handler */ #define USES_TYPES /* my_dir with sys/types is included */ #define CHSIZE_USED -#include <global.h> +#include <my_global.h> #include <my_dir.h> /* This includes types */ #include <my_sys.h> #include <m_string.h> @@ -50,6 +49,21 @@ /* The following is parameter to ha_rkey() how to use key */ +/* We define a complete-field prefix of a key value as a prefix where the +last included field in the prefix contains the full field, not just some bytes +from the start of the field. A partial-field prefix is allowed to +contain only a few first bytes from the last included field. + +Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a +complete-field prefix of a key value as the search key. HA_READ_PREFIX +and HA_READ_PREFIX_LAST could also take a partial-field prefix, but +currently (4.0.10) they are only used with complete-field prefixes. MySQL uses +a padding trick to implement LIKE 'abc%' queries. + +NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a partial-field +prefix because InnoDB currently strips spaces from the end of varchar +fields! */ + enum ha_rkey_function { HA_READ_KEY_EXACT, /* Find first record else error */ HA_READ_KEY_OR_NEXT, /* Record or next record */ @@ -57,7 +71,22 @@ enum ha_rkey_function { 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 */ + HA_READ_PREFIX_LAST, /* Last key with the same prefix */ + HA_READ_MBR_CONTAIN, + HA_READ_MBR_INTERSECT, + HA_READ_MBR_WITHIN, + HA_READ_MBR_DISJOINT, + HA_READ_MBR_EQUAL +}; + + /* Key algorithm types */ + +enum ha_key_alg { + HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */ + HA_KEY_ALG_BTREE= 1, /* B-tree, default one */ + HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */ + HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */ + HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */ }; /* The following is parameter to ha_extra() */ @@ -91,7 +120,9 @@ enum ha_extra_function { HA_EXTRA_RESET_STATE, /* Reset positions */ HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/ HA_EXTRA_NO_IGNORE_DUP_KEY, - HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE /* Cursor will not be used for update */ + HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE, /* Cursor will not be used for update */ + HA_EXTRA_PREPARE_FOR_DELETE, + HA_EXTRA_PREPARE_FOR_UPDATE /* Remove read cache if problems */ }; /* The following is parameter to ha_panic() */ @@ -134,8 +165,10 @@ enum ha_base_keytype { #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 */ +#define HA_SPATIAL 1024 /* Alex Barkov: for spatial search */ #define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */ + /* Automatic bits in key-flag */ #define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */ @@ -157,6 +190,7 @@ enum ha_base_keytype { #define HA_BLOB_PART 32 #define HA_SWAP_KEY 64 #define HA_REVERSE_SORT 128 /* Sort key in reverse order */ +#define HA_NO_SORT 256 /* do not bother sorting on this keyseg */ /* optionbits for database */ #define HA_OPTION_PACK_RECORD 1 @@ -197,6 +231,7 @@ enum ha_base_keytype { #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_NOT_A_TABLE 130 /* not a MYI file - no signature */ #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() */ @@ -209,10 +244,10 @@ enum ha_base_keytype { #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 +#define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting MyISAM tables in MERGE */ #define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */ #define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */ -#define HA_ERR_LOCK_WAIT_TIMEOUT 146 +#define HA_ERR_LOCK_WAIT_TIMEOUT 146 #define HA_ERR_LOCK_TABLE_FULL 147 #define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */ #define HA_ERR_LOCK_DEADLOCK 149 @@ -223,6 +258,7 @@ enum ha_base_keytype { /* Other constants */ #define HA_NAMELEN 64 /* Max length of saved filename */ +#define NO_SUCH_KEY ((uint)~0) /* used as a key no. */ /* Intern constants in databases */ @@ -236,7 +272,14 @@ enum ha_base_keytype { #define SEARCH_UPDATE 64 #define SEARCH_PREFIX 128 #define SEARCH_LAST 256 +#define MBR_CONTAIN 512 +#define MBR_INTERSECT 1024 +#define MBR_WITHIN 2048 +#define MBR_DISJOINT 4096 +#define MBR_EQUAL 8192 +#define MBR_DATA 16384 #define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */ +#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */ /* bits in opt_flag */ #define QUICK_USED 1 @@ -261,8 +304,8 @@ enum ha_base_keytype { #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_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE, + FIELD_SKIP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO, FIELD_VARCHAR,FIELD_CHECK }; @@ -272,8 +315,10 @@ enum data_file_type { /* For number of records */ #ifdef BIG_TABLES +#define rows2double(A) ulonglong2double(A) typedef my_off_t ha_rows; #else +#define rows2double(A) (double) (A) typedef ulong ha_rows; #endif diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 3243e5f0b24..ca0037addfb 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _my_bitmap_h_ #define _my_bitmap_h_ diff --git a/include/my_dir.h b/include/my_dir.h index 1961ca79549..4ccda050914 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _my_dir_h #define _my_dir_h diff --git a/include/my_getopt.h b/include/my_getopt.h new file mode 100644 index 00000000000..3b4551b445e --- /dev/null +++ b/include/my_getopt.h @@ -0,0 +1,54 @@ +/* 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 */ + +C_MODE_START + +enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG, + GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC }; +enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; + +struct my_option +{ + const char *name; /* Name of the option */ + int id; /* unique id or short option */ + const char *comment; /* option comment, for autom. --help */ + gptr *value; /* The variable value */ + gptr *u_max_value; /* The user def. max variable value */ + const char **str_values; /* Pointer to possible values */ + enum get_opt_var_type var_type; + enum get_opt_arg_type arg_type; + longlong def_value; /* Default value */ + longlong min_value; /* Min allowed value */ + longlong max_value; /* Max allowed value */ + longlong sub_size; /* Subtract this from given value */ + long block_size; /* Value should be a mult. of this */ + int app_type; /* To be used by an application */ +}; + +extern char *disabled_my_option; +extern my_bool my_getopt_print_errors; + +extern int handle_options (int *argc, char ***argv, + const struct my_option *longopts, + my_bool (*get_one_option)(int, + const struct my_option *, + char *)); +extern void my_print_help(const struct my_option *options); +extern void my_print_variables(const struct my_option *options); + +ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp); +my_bool getopt_compare_strings(const char *s, const char *t, uint length); +C_MODE_END diff --git a/include/global.h b/include/my_global.h index 1737c60db30..49ca0e03f89 100644 --- a/include/global.h +++ b/include/my_global.h @@ -1,22 +1,20 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -/* This is the main include file that should included 'first' in every - C file. */ + 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 */ + +/* This is the include file that should be included 'first' in every C file. */ #ifndef _global_h #define _global_h @@ -40,11 +38,25 @@ #define HAVE_ERRNO_AS_DEFINE #endif /* __CYGWIN__ */ +/* Macros to make switching between C and C++ mode easier */ +#ifdef __cplusplus +#define C_MODE_START extern "C" { +#define C_MODE_END } +#else +#define C_MODE_START +#define C_MODE_END +#endif #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) #include <config-win.h> #elif defined(OS2) #include <config-os2.h> +#elif defined(__NETWARE__) +#include <my_config.h> +#include <config-netware.h> +#if defined(__cplusplus) && defined(inline) +#undef inline /* fix configure problem */ +#endif #else #include <my_config.h> #if defined(__cplusplus) && defined(inline) @@ -52,6 +64,23 @@ #endif #endif /* _WIN32... */ +/* + The macros below are borrowed from include/linux/compiler.h in the + Linux kernel. Use them to indicate the likelyhood of the truthfulness + of a condition. This serves two purposes - newer versions of gcc will be + able to optimize for branch predication, which could yield siginficant + performance gains in frequently executed sections of the code, and the + other reason to use them is for documentation +*/ + +#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +#define __builtin_expect(x, expected_value) (x) +#endif + +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) + + /* Fix problem with S_ISLNK() on Linux */ #if defined(HAVE_LINUXTHREADS) #undef _GNU_SOURCE @@ -80,7 +109,7 @@ #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ #endif -/* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */ + #if !defined(SCO) #define _REENTRANT 1 /* Some thread libraries require this */ #endif @@ -103,16 +132,12 @@ #ifdef _AIX /* By soren@t.dk */ #define _H_STRINGS #define _SYS_STREAM_H -#define _AIX32_CURSES +/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */ #define ulonglong2double(A) my_ulonglong2double(A) #define my_off_t2double(A) my_ulonglong2double(A) -#ifdef __cplusplus -extern "C" { -#endif +C_MODE_START double my_ulonglong2double(unsigned long long A); -#ifdef __cplusplus -} -#endif +C_MODE_END #endif /* _AIX */ #ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ @@ -134,6 +159,13 @@ double my_ulonglong2double(unsigned long long A); #undef HAVE_INITGROUPS #endif +/* gcc/egcs issues */ + +#if defined(__GNUC) && defined(__EXCEPTIONS) +#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile" +#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 ??? */ @@ -159,7 +191,7 @@ double my_ulonglong2double(unsigned long long A); #endif /* In Linux-ia64 including atomic.h will give us an error */ -#if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && (defined(__ia64__) || defined(__powerpc64__))) || !defined(THREAD) +#if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && (defined(__ia64__)||defined(__powerpc64__))) || !defined(THREAD) #undef HAVE_ATOMIC_ADD #undef HAVE_ATOMIC_SUB #endif @@ -209,7 +241,13 @@ double my_ulonglong2double(unsigned long long A); # endif #endif /* TIME_WITH_SYS_TIME */ #ifdef HAVE_UNISTD_H +#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) +#define crypt unistd_crypt +#endif #include <unistd.h> +#ifdef HAVE_OPENSSL +#undef crypt +#endif #endif #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) #undef HAVE_ALLOCA @@ -233,13 +271,24 @@ double my_ulonglong2double(unsigned long long A); #ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ #undef HAVE_FINITE #endif -#if defined(HPUX) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) +#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) /* Fix bug in setrlimit */ #undef setrlimit #define setrlimit cma_setrlimit64 #endif -/* We can not live without these */ +#ifdef __QNXNTO__ +/* This has to be after include limits.h */ +#define HAVE_ERRNO_AS_DEFINE +#define HAVE_FCNTL_LOCK +#undef HAVE_SYS_UN_H +#undef HAVE_FINITE +#undef HAVE_RINT +#undef LONGLONG_MIN /* These get wrongly defined in QNX 6.2 */ +#undef LONGLONG_MAX /* standard system library 'limits.h' */ +#endif + +/* We can not live without the following defines */ #define USE_MYFUNC 1 /* Must use syscall indirection */ #define MASTER 1 /* Compile without unireg */ @@ -248,7 +297,7 @@ double my_ulonglong2double(unsigned long long A); #define USE_REGEX 1 /* We want the use the regex library */ /* Do not define for ultra sparcs */ #ifndef OS2 -#define USE_BMOVE512 1 /* Use this unless the system bmove is faster */ +#define USE_BMOVE512 1 /* Use this unless system bmove is faster */ #endif /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */ @@ -257,10 +306,6 @@ double my_ulonglong2double(unsigned long long A); #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 @@ -297,6 +342,7 @@ typedef unsigned int uint; typedef unsigned short ushort; #endif +#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) #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) @@ -347,11 +393,6 @@ typedef unsigned short ushort; #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 */ @@ -366,7 +407,9 @@ typedef int my_socket; /* File descriptor for sockets */ #endif /* Type for fuctions that handles signals */ #define sig_handler RETSIGTYPE +C_MODE_START typedef void (*sig_return)();/* Returns type from signal */ +C_MODE_END #if defined(__GNUC__) && !defined(_lint) typedef char pchar; /* Mixed prototypes can take char */ typedef char puchar; /* Mixed prototypes can take char */ @@ -380,7 +423,10 @@ 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 +C_MODE_START typedef int (*qsort_cmp)(const void *,const void *); +typedef int (*qsort_cmp2)(void*, const void *,const void *); +C_MODE_END #ifdef HAVE_mit_thread #define qsort_t void #undef QSORT_TYPE_IS_VOID @@ -403,17 +449,20 @@ typedef SOCKET_SIZE_TYPE size_socket; /* file create flags */ -#ifndef O_SHARE +#ifndef O_SHARE /* Probably not windows */ #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 */ +#ifndef FILE_BINARY +#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */ +#endif #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 @@ -479,9 +528,6 @@ typedef SOCKET_SIZE_TYPE size_socket; /* 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 */ @@ -527,11 +573,6 @@ extern double my_atof(const char*); #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 @@ -643,14 +684,14 @@ 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 */ +typedef unsigned long ulong; /* Short for unsigned long */ #endif #ifndef longlong_defined #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ -typedef long long int longlong; +typedef long long int longlong; #else -typedef unsigned long ulonglong; /* ulong or unsigned long long */ +typedef unsigned long ulonglong; /* ulong or unsigned long long */ typedef long longlong; #endif #endif @@ -683,13 +724,14 @@ typedef off_t os_off_t; #if defined(__WIN__) #define socket_errno WSAGetLastError() -#define SOCKET_EINTR WSAEINTR +#define SOCKET_EINTR WSAEINTR #define SOCKET_EAGAIN WSAEINPROGRESS +#define SOCKET_EWOULDBLOCK WSAEINPROGRESS #define SOCKET_ENFILE ENFILE #define SOCKET_EMFILE EMFILE #elif defined(OS2) #define socket_errno sock_errno() -#define SOCKET_EINTR SOCEINTR +#define SOCKET_EINTR SOCEINTR #define SOCKET_EAGAIN SOCEINPROGRESS #define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK #define SOCKET_ENFILE SOCENFILE @@ -723,6 +765,14 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define INT32(v) (int32) (v) #define MYF(v) (myf) (v) +#ifndef LL +#ifdef HAVE_LONG_LONG +#define LL(A) A ## LL +#else +#define LL(A) A ## L +#endif +#endif + /* Defines to make it possible to prioritize register assignments. No longer that important with modern compilers. @@ -746,15 +796,40 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define reg16 register #endif +/* + Sometimes we want to make sure that the variable is not put into + a register in debugging mode so we can see its value in the core +*/ + +#ifndef DBUG_OFF +#define dbug_volatile volatile +#else +#define dbug_volatile +#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 */ +#ifndef set_timespec +#ifdef HAVE_TIMESPEC_TS_SEC +#define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; } +#else +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* HAVE_TIMESPEC_TS_SEC */ +#endif /* set_timespec */ + /* -** Define-funktions for reading and storing in machine independent format -** (low byte first) + Define-funktions for reading and storing in machine independent format + (low byte first) */ /* Optimized store functions for Intel x86 */ @@ -803,7 +878,7 @@ typedef union { #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__ */ +#endif /* __i386__ */ #ifndef sint2korr #define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ @@ -848,9 +923,9 @@ typedef union { *((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)); \ + *((uchar*)(T))=(uchar) ((A));\ + *((uchar*) (T)+1)=(uchar) (((A) >> 8));\ + *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \ /*lint -restore */} #define int4store(T,A) { *(T)=(char) ((A));\ *((T)+1)=(char) (((A) >> 8));\ @@ -988,7 +1063,7 @@ typedef union { #ifdef SPRINTF_RETURNS_PTR #define my_sprintf(buff,args) ((int)(sprintf args - buff)) #else -#define my_sprintf(buff,args) sprintf args,strlen(buff) +#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff)) #endif #endif @@ -1000,4 +1075,4 @@ typedef union { #define statistic_add(V,C,L) (V)+=(C) #endif -#endif /* _global_h */ +#endif /* my_global_h */ diff --git a/include/my_list.h b/include/my_list.h index 7391db70e27..0f56d4c532b 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _list_h_ #define _list_h_ diff --git a/include/my_net.h b/include/my_net.h index a4910d8af1d..28d862d8528 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -1,28 +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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__) + 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 */ + +/* + thread safe version of some common functions: + my_inet_ntoa + + This file is also used to make handling of sockets and ioctl() + portable accross systems. + +*/ + +#ifndef _my_net_h +#define _my_net_h +C_MODE_START + +#include <errno.h> #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif @@ -32,7 +37,33 @@ extern "C" { #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif -#endif /* !defined(MSDOS) && !defined(__WIN__) */ +#ifdef HAVE_POLL +#include <sys/poll.h> +#endif +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif + +#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__) +#include <netinet/in_systm.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#if !defined(alpha_linux_port) +#include <netinet/tcp.h> +#endif +#endif + +#if defined(__EMX__) +#include <sys/ioctl.h> +#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C))) +#undef HAVE_FCNTL +#endif /* defined(__EMX__) */ + +#if defined(MSDOS) || defined(__WIN__) +#define O_NONBLOCK 1 /* For emulation of fcntl() */ +#endif + +/* Thread safe or portable version of some functions */ void my_inet_ntoa(struct in_addr in, char *buf); @@ -40,7 +71,7 @@ void my_inet_ntoa(struct in_addr in, char *buf); Handling of gethostbyname_r() */ -#if !defined(HPUX) +#if !defined(HPUX10) struct hostent; #endif /* HPUX */ #if !defined(HAVE_GETHOSTBYNAME_R) @@ -53,7 +84,7 @@ struct hostent *my_gethostbyname_r(const char *name, struct hostent *result, char *buffer, int buflen, int *h_errnop); #define my_gethostbyname_r_free() -#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX) +#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10) #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */ @@ -78,6 +109,5 @@ struct hostent *my_gethostbyname_r(const char *name, #define h_errno errno #endif -#ifdef __cplusplus -} +C_MODE_END #endif diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h index 328086ec388..0a034f78192 100644 --- a/include/my_no_pthread.h +++ b/include/my_no_pthread.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This undefs some pthread mutex locks when one isn't using threads diff --git a/include/my_nosys.h b/include/my_nosys.h index 5991904f260..605906f0e07 100644 --- a/include/my_nosys.h +++ b/include/my_nosys.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Header to remove use of my_functions in functions where we need speed and diff --git a/include/my_pthread.h b/include/my_pthread.h index f31fa113064..a7fa38349dc 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Defines to make different thread packages compatible */ @@ -357,6 +356,14 @@ extern int my_pthread_cond_timedwait(pthread_cond_t *cond, #define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C)) #endif + +#ifdef __NETWARE__ +extern int my_pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, + struct timespec *abstime); +#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C)) +#endif /* __NETWARE__ */ + #if defined(OS2) #define my_pthread_getspecific(T,A) ((T) &(A)) #define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) @@ -423,19 +430,24 @@ struct tm *localtime_r(const time_t *clock, struct tm *res); #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 */ +#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */ #define HAVE_PTHREAD_KILL #endif #endif /* defined(__WIN__) */ -#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) +#if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) #undef pthread_cond_timedwait #define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c)) int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime); #endif +#if defined(HPUX10) +#define pthread_attr_getstacksize(A,B) my_pthread_attr_getstacksize(A,B) +void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); +#endif + #if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) #undef pthread_mutex_trylock #define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a)) @@ -444,15 +456,39 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); /* safe_mutex adds checking to mutex for easier debugging */ +#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) +#define SAFE_MUTEX_DETECT_DESTROY +#endif + typedef struct st_safe_mutex_t { pthread_mutex_t global,mutex; char *file; uint line,count; pthread_t thread; +#ifdef SAFE_MUTEX_DETECT_DESTROY + struct st_safe_mutex_info_t *info; /* to track destroying of mutexes */ +#endif } safe_mutex_t; -int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr); +#ifdef SAFE_MUTEX_DETECT_DESTROY +/* + Used to track the destroying of mutexes. This needs to be a seperate + structure because the safe_mutex_t structure could be freed before + the mutexes are destroyed. +*/ + +typedef struct st_safe_mutex_info_t +{ + struct st_safe_mutex_info_t *next; + struct st_safe_mutex_info_t *prev; + char *init_file; + uint32 init_line; +} safe_mutex_info_t; +#endif /* SAFE_MUTEX_DETECT_DESTROY */ + +int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, + const char *file, uint line); 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); @@ -460,6 +496,8 @@ 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); +void safe_mutex_global_init(void); +void safe_mutex_end(FILE *file); /* Wrappers if safe mutex is actually used */ #ifdef SAFE_MUTEX @@ -473,7 +511,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, #undef pthread_cond_wait #undef pthread_cond_timedwait #undef pthread_mutex_trylock -#define pthread_mutex_init(A,B) safe_mutex_init((A),(B)) +#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) #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__) @@ -488,6 +526,12 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, /* READ-WRITE thread locking */ +#ifdef HAVE_BROKEN_RWLOCK /* For OpenUnix */ +#undef HAVE_PTHREAD_RWLOCK_RDLOCK +#undef HAVE_RWLOCK_INIT +#undef HAVE_RWLOCK_T +#endif + #if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS) /* use these defs for simple mutex locking */ #define rw_lock_t pthread_mutex_t @@ -576,9 +620,13 @@ extern int pthread_dummy(int); #define THREAD_NAME_SIZE 10 #if defined(__ia64__) -#define DEFAULT_THREAD_STACK (128*1024) +/* + MySQL can survive with 32K, but some glibc libraries require > 128K stack + To resolve hostnames +*/ +#define DEFAULT_THREAD_STACK (192*1024L) #else -#define DEFAULT_THREAD_STACK (64*1024) +#define DEFAULT_THREAD_STACK (192*1024L) #endif struct st_my_thread_var @@ -601,6 +649,11 @@ struct st_my_thread_var 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 +/* + Keep track of shutdown,signal, and main threads so that my_end() will not + report errors with them +*/ +extern pthread_t shutdown_th, main_th, signal_th; /* statistics_xxx functions are for not essential statistic */ @@ -631,5 +684,4 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); #ifdef __cplusplus } #endif - #endif /* _my_ptread_h */ diff --git a/include/my_semaphore.h b/include/my_semaphore.h new file mode 100644 index 00000000000..3431212ec82 --- /dev/null +++ b/include/my_semaphore.h @@ -0,0 +1,59 @@ +/* + * Module: semaphore.h + * + * Purpose: + * Semaphores aren't actually part of the PThreads standard. + * They are defined by the POSIX Standard: + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright (C) 1998 + * + * 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 hacked by Monty to be included in mysys library */ + +#ifndef _my_semaphore_h_ +#define _my_semaphore_h_ + +C_MODE_START +#ifdef HAVE_SEMAPHORE_H +#include <semaphore.h> +#elif !defined(__bsdi__) +#ifdef __WIN__ +typedef HANDLE sem_t; +#else +typedef struct { + pthread_mutex_t mutex; + pthread_cond_t cond; + uint count; +} sem_t; +#endif /* __WIN__ */ + +int sem_init(sem_t * sem, int pshared, unsigned int value); +int sem_destroy(sem_t * sem); +int sem_trywait(sem_t * sem); +int sem_wait(sem_t * sem); +int sem_post(sem_t * sem); +int sem_post_multiple(sem_t * sem, unsigned int count); +int sem_getvalue(sem_t * sem, unsigned int * sval); + +#endif /* !__bsdi__ */ + +C_MODE_END +#endif /* !_my_semaphore_h_ */ diff --git a/include/my_sys.h b/include/my_sys.h index 924a6094416..c67a150f24f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1,25 +1,22 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _my_sys_h #define _my_sys_h -#ifdef __cplusplus -extern "C" { -#endif +C_MODE_START #ifdef HAVE_AIOWAIT #include <sys/asynch.h> /* Used by record-cache */ @@ -39,7 +36,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #include <m_ctype.h> /* for CHARSET_INFO */ #endif -#include <stdarg.h> +#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;} @@ -59,6 +56,9 @@ extern int NEAR my_errno; /* Last error in mysys */ #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_FULL_IO 512 /* For my_read - loop intil I/O + is complete + */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ #define MY_COPYTIME 64 /* my_redel() copys time */ @@ -91,6 +91,16 @@ extern int NEAR my_errno; /* Last error in mysys */ #define ME_COLOUR2 ((2 << ME_HIGHBYTE)) #define ME_COLOUR3 ((3 << ME_HIGHBYTE)) + /* Bits in last argument to fn_format */ +#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ +#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ +#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ +#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ +#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ +#define MY_RETURN_REAL_PATH 32 /* return full path for file */ +#define MY_SAFE_PATH 64 /* Return NULL if too long path */ +#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ + /* My seek flags */ #define MY_SEEK_SET 0 #define MY_SEEK_CUR 1 @@ -107,30 +117,34 @@ extern int NEAR my_errno; /* Last error in mysys */ #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 +#define DEFAULT_KEYCACHE_BLOCK_SIZE 1024 +#define MAX_KEYCACHE_BLOCK_SIZE 16384 /* root_alloc flags */ #define MY_KEEP_PREALLOC 1 +#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ /* defines when allocating data */ #ifdef SAFEMALLOC -#define my_malloc(SZ,FLAG) _mymalloc( SZ, __FILE__, __LINE__, FLAG ) -#define my_malloc_ci(SZ,FLAG) _mymalloc( SZ, sFile, uLine, FLAG ) -#define my_realloc(PTR,SZ,FLAG) _myrealloc( PTR, SZ, __FILE__, __LINE__, FLAG ) +#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) +#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, 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 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 my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__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; extern ulonglong safemalloc_mem_limit; + #define CALLER_INFO_PROTO , const char *sFile, uint uLine #define CALLER_INFO , __FILE__, __LINE__ #define ORIG_CALLER_INFO , sFile, uLine #else -#define my_checkmalloc() (0) +#define my_checkmalloc() #undef TERMINATE #define TERMINATE(A) {} #define QUICK_SAFEMALLOC @@ -140,7 +154,9 @@ 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); +extern char *my_strdup(const char *from,myf MyFlags); +extern char *my_strdup_with_length(const byte *from, uint length, + myf MyFlags); #define my_free(PTR,FG) my_no_flags_free(PTR) #define CALLER_INFO_PROTO /* nothing */ #define CALLER_INFO /* nothing */ @@ -206,9 +222,10 @@ extern char *get_charsets_dir(char *buf); /* statistics */ 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 ulong _my_blocks_used,_my_blocks_changed; +extern uint key_cache_block_size; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern my_bool key_cache_inited; +extern my_bool key_cache_inited, my_init_done; /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), @@ -240,13 +257,20 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */ typedef struct st_typelib { /* Different types saved here */ uint count; /* How many types */ - const char *name; /* Name of typelib */ + const char *name; /* Name of typelib */ const char **type_names; } TYPELIB; -enum cache_type {READ_CACHE,WRITE_CACHE,READ_FIFO,READ_NET,WRITE_NET}; -enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, - FLUSH_FORCE_WRITE}; +enum cache_type +{ + READ_CACHE,WRITE_CACHE, + SEQ_READ_APPEND /* sequential read or append */, + READ_FIFO, 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 */ { @@ -262,45 +286,168 @@ typedef struct st_record_cache /* Used when cacheing records */ enum cache_type type; } RECORD_CACHE; -enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, - STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP }; +enum file_type +{ + UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, + FILE_BY_MKSTEMP, FILE_BY_DUP +}; extern struct my_file_info { my_string name; enum file_type type; -#if defined(THREAD) && !defined(HAVE_PREAD) +#if defined(THREAD) && !defined(HAVE_PREAD) pthread_mutex_t mutex; #endif } my_file_info[MY_NFILE]; -typedef struct st_dynamic_array { +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 { +typedef struct st_dynamic_string +{ char *str; uint length,max_length,alloc_increment; } DYNAMIC_STRING; +struct st_io_cache; +typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); + +#ifdef THREAD +typedef struct st_io_cache_share +{ + /* to sync on reads into buffer */ + pthread_mutex_t mutex; + pthread_cond_t cond; + int count, total; + /* actual IO_CACHE that filled the buffer */ + struct st_io_cache *active; +#ifdef NOT_YET_IMPLEMENTED + /* whether the structure should be free'd */ + my_bool alloced; +#endif +} IO_CACHE_SHARE; +#endif typedef struct st_io_cache /* Used when cacheing files */ { - my_off_t pos_in_file,end_of_file; - byte *rc_pos,*rc_end,*buffer,*rc_request_pos; + /* Offset in file corresponding to the first byte of byte* buffer. */ + my_off_t pos_in_file; + /* + The offset of end of file for READ_CACHE and WRITE_CACHE. + For SEQ_READ_APPEND it the maximum of the actual end of file and + the position represented by read_end. + */ + my_off_t end_of_file; + /* Points to current read position in the buffer */ + byte *read_pos; + /* the non-inclusive boundary in the buffer for the currently valid read */ + byte *read_end; + byte *buffer; /* The read buffer */ + /* Used in ASYNC_IO */ + byte *request_pos; + + /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ + byte *write_buffer; + /* + Only used in SEQ_READ_APPEND, and points to the current read position + in the write buffer. Note that reads in SEQ_READ_APPEND caches can + happen from both read buffer (byte* buffer) and write buffer + (byte* write_buffer). + */ + byte *append_read_pos; + /* Points to current write position in the write buffer */ + byte *write_pos; + /* The non-inclusive boundary of the valid write area */ + byte *write_end; + + /* + Current_pos and current_end are convenience variables used by + my_b_tell() and other routines that need to know the current offset + current_pos points to &write_pos, and current_end to &write_end in a + WRITE_CACHE, and &read_pos and &read_end respectively otherwise + */ + byte **current_pos, **current_end; +#ifdef THREAD + /* + The lock is for append buffer used in SEQ_READ_APPEND cache + need mutex copying from append buffer to read buffer. + */ + pthread_mutex_t append_buffer_lock; + /* + The following is used when several threads are reading the + same file in parallel. They are synchronized on disk + accesses reading the cached part of the file asynchronously. + It should be set to NULL to disable the feature. Only + READ_CACHE mode is supported. + */ + IO_CACHE_SHARE *share; +#endif + /* + A caller will use my_b_read() macro to read from the cache + if the data is already in cache, it will be simply copied with + memcpy() and internal variables will be accordinging updated with + no functions invoked. However, if the data is not fully in the cache, + my_b_read() will call read_function to fetch the data. read_function + must never be invoked directly. + */ int (*read_function)(struct st_io_cache *,byte *,uint); + /* + Same idea as in the case of read_function, except my_b_write() needs to + be replaced with my_b_append() for a SEQ_READ_APPEND cache + */ + int (*write_function)(struct st_io_cache *,const byte *,uint); + /* + Specifies the type of the cache. Depending on the type of the cache + certain operations might not be available and yield unpredicatable + results. Details to be documented later + */ + enum cache_type type; + /* + Callbacks when the actual read I/O happens. These were added and + are currently used for binary logging of LOAD DATA INFILE - when a + block is read from the file, we create a block create/append event, and + when IO_CACHE is closed, we create an end event. These functions could, + of course be used for other things + */ + IO_CACHE_CALLBACK pre_read; + IO_CACHE_CALLBACK post_read; + IO_CACHE_CALLBACK pre_close; + void* arg; /* for use by pre/post_read */ char *file_name; /* if used with 'open_cached_file' */ char *dir,*prefix; - File file; + File file; /* file descriptor */ + /* + seek_not_done is set by my_b_seek() to inform the upcoming read/write + operation that a seek needs to be preformed prior to the actual I/O + error is 0 if the cache operation was successful, -1 if there was a + "hard" error, and the actual number of I/O-ed bytes if the read/write was + partial. + */ int seek_not_done,error; - uint buffer_length,read_length; + /* buffer_length is memory size allocated for buffer or write_buffer */ + uint buffer_length; + /* read_length is the same as buffer_length except when we use async io */ + uint read_length; myf myflags; /* Flags used to my_read/my_write */ - enum cache_type type; + /* + alloced_buffer is 1 if the buffer was allocated by init_io_cache() and + 0 if it was supplied by the user. + Currently READ_NET is the only one that will use a buffer allocated + somewhere else + */ + my_bool alloced_buffer; #ifdef HAVE_AIOWAIT + /* + As inidicated by ifdef, this is for async I/O, which is not currently + used (because it's not reliable on all systems) + */ uint inited; my_off_t aio_read_pos; my_aio_result aio_result; @@ -317,67 +464,41 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); #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_pos + (Count) <= (info)->read_end ?\ + (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \ + ((info)->read_pos+=(Count)),0) :\ (*(info)->read_function)((info),Buffer,Count)) +#define my_b_write(info,Buffer,Count) \ + ((info)->write_pos + (Count) <=(info)->write_end ?\ + (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ + ((info)->write_pos+=(Count)),0) : \ + (*(info)->write_function)((info),(Buffer),(Count))) + #define my_b_get(info) \ - ((info)->rc_pos != (info)->rc_end ?\ - ((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\ + ((info)->read_pos != (info)->read_end ?\ + ((info)->read_pos++, (int) (uchar) (info)->read_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)))) + (((info)->write_pos < (info)->write_end) ?\ + ((*(info)->write_pos++)=(chr)) :\ + (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr)))) #define my_b_fill_cache(info) \ - (((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0)) + (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) #define my_b_tell(info) ((info)->pos_in_file + \ - ((info)->rc_pos - (info)->rc_request_pos)) - -#define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos)) - -typedef struct st_changeable_var { - const char *name; /* Name of variable */ - long *varptr; /* Pointer to variable */ - long def_value, /* Default value */ - min_value, /* Min allowed value */ - max_value, /* Max allowed value */ - sub_size, /* Subtract this from given value */ - block_size; /* Value should be a mult. of this */ -} 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; - USED_MEM *pre_alloc; - unsigned int min_malloc; - unsigned int block_size; - - void (*error_handler)(void); -} MEM_ROOT; -#endif + (uint) (*(info)->current_pos - (info)->request_pos)) + +/* tell write offset in the SEQ_APPEND cache */ +my_off_t my_b_append_tell(IO_CACHE* info); + +#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ + *(info)->current_pos) + +#include <my_alloc.h> /* Prototypes for mysys and my_func functions */ @@ -397,6 +518,7 @@ extern File my_register_filename(File fd, const char *FileName, extern File my_create(const char *FileName,int CreateFlags, int AccsesFlags, myf MyFlags); extern int my_close(File Filedes,myf MyFlags); +extern File my_dup(File file, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_realpath(char *to, const char *filename, myf MyFlags); @@ -432,6 +554,10 @@ 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); +extern char *_my_strdup_with_length(const byte *from, uint length, + const char *sFile, uint uLine, + myf MyFlag); + #ifndef TERMINATE extern void TERMINATE(FILE *file); #endif @@ -439,7 +565,7 @@ extern void init_glob_errs(void); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); extern FILE *my_fdopen(File Filedes,const char *name, 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_chsize(File fd,my_off_t newlength, int filler, 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, ...) @@ -474,12 +600,12 @@ 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 char *convert_dirname(my_string name); +extern char *convert_dirname(char *to, const char *from, const char *from_end); 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 my_string fn_format(my_string to,const char *name,const char *dir, + const char *form, uint 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); @@ -517,7 +643,8 @@ 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 int init_key_cache(ulong use_mem); +extern int resize_key_cache(ulong use_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, @@ -538,17 +665,29 @@ 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); +#ifdef THREAD +extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); +extern void init_io_cache_share(IO_CACHE *info, + IO_CACHE_SHARE *s, uint num_threads); +extern void remove_io_thread(IO_CACHE *info); +#endif +extern int _my_b_seq_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_b_append(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 _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); + +#define flush_io_cache(info) _flush_io_cache((info),1) + extern int end_io_cache(IO_CACHE *info); extern uint my_b_fill(IO_CACHE *info); extern void my_b_seek(IO_CACHE *info,my_off_t pos); extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); +extern my_off_t my_b_filelength(IO_CACHE *info); extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, @@ -585,10 +724,6 @@ my_bool dynstr_append_mem(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); @@ -597,29 +732,33 @@ extern void my_free_lock(byte *ptr,myf flags); #define my_free_lock(A,B) my_free((A),(B)) #endif #define alloc_root_inited(A) ((A)->min_malloc != 0) -void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size); -gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); -void free_root(MEM_ROOT *root, myf MyFLAGS); -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 +extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, + uint pre_alloc_size); +extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); +extern void free_root(MEM_ROOT *root, myf MyFLAGS); +extern void set_prealloc_root(MEM_ROOT *root, char *ptr); +extern char *strdup_root(MEM_ROOT *root,const char *str); +extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); +extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); +extern void load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); +extern void free_defaults(char **argv); +extern void print_defaults(const char *conf_file, const char **groups); +extern my_bool my_compress(byte *, ulong *, ulong *); +extern my_bool my_uncompress(byte *, ulong *, ulong *); +extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); +extern ulong checksum(const byte *mem, uint count); +extern uint my_bit_log2(ulong value); +extern void my_sleep(ulong m_seconds); + #ifdef __WIN__ extern my_bool have_tcpip; /* Is set if tcpip is used */ #endif - -#ifdef __cplusplus -} +#ifdef __NETWARE__ +void netware_reg_user(const char *ip, const char *user, + const char *application); #endif + +C_MODE_END #include "raid.h" #endif /* _my_sys_h */ diff --git a/include/my_tree.h b/include/my_tree.h index 0a227ea3944..7cc7c615ba6 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _tree_h #define _tree_h @@ -32,6 +31,9 @@ typedef enum { left_root_right, right_root_left } TREE_WALK; typedef uint32 element_count; typedef int (*tree_walk_action)(void *,element_count,void *); +typedef enum { free_init, free_free, free_end } TREE_FREE; +typedef void (*tree_element_free)(void*, TREE_FREE, void *); + #ifdef MSDOS typedef struct st_tree_element { struct st_tree_element *left,*right; @@ -49,18 +51,22 @@ typedef struct st_tree_element { 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; + uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated; + qsort_cmp2 compare; + void* custom_arg; MEM_ROOT mem_root; my_bool with_delete; - void (*free)(void *); + tree_element_free free; } 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*)); + /* Functions on whole tree */ +void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, + int size, qsort_cmp2 compare, my_bool with_delete, + tree_element_free free_element, void *custom_arg); void delete_tree(TREE*); +void reset_tree(TREE*); + /* similar to delete tree, except we do not my_free() blocks in mem_root + */ #define is_tree_inited(tree) ((tree)->root != 0) /* Functions on leafs */ @@ -70,6 +76,8 @@ int tree_walk(TREE *tree,tree_walk_action action, void *argument, TREE_WALK visit); int tree_delete(TREE *tree,void *key); +#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*)) + #ifdef __cplusplus } #endif diff --git a/include/myisam.h b/include/myisam.h index 9ecb5ef4294..def8b492681 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This file should be included when using myisam_funktions */ @@ -46,6 +45,11 @@ extern "C" { /* Max extra space to use when sorting keys */ #define MI_MAX_TEMP_LENGTH 256*1024L*1024L +/* Possible values for myisam_block_size (must be power of 2) */ +#define MI_KEY_BLOCK_LENGTH 1024 /* default key block length */ +#define MI_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */ +#define MI_MAX_KEY_BLOCK_LENGTH 16384 + #define mi_portable_sizeof_char_ptr 8 typedef uint32 ha_checksum; @@ -68,6 +72,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ ulong mean_reclength; /* Mean recordlength (if packed) */ ulonglong auto_increment; ulonglong key_map; /* Which keys are used */ + char *data_file_name, *index_file_name; uint keys; /* Number of keys in use */ uint options; /* HA_OPTION_... used */ int errkey, /* With key was dupplicated on err */ @@ -86,6 +91,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ typedef struct st_mi_create_info { + char *index_file_name, *data_file_name; /* If using symlinks */ ha_rows max_rows; ha_rows reloc_rows; ulonglong auto_increment; @@ -94,6 +100,7 @@ typedef struct st_mi_create_info ulong raid_chunksize; uint old_options; uint8 language; + my_bool with_auto_increment; } MI_CREATE_INFO; struct st_myisam_info; /* For referense */ @@ -120,6 +127,7 @@ typedef struct st_mi_keydef /* Key definition with open & info */ uint16 keysegs; /* Number of key-segment */ uint16 flag; /* NOSAME, PACK_USED */ + uint8 key_alg; /* BTREE, RTREE */ uint16 block_length; /* Length of keyblock (auto) */ uint16 underflow_block_length; /* When to execute underflow */ uint16 keylength; /* Tot length of keyparts (auto) */ @@ -163,9 +171,11 @@ typedef struct st_mi_decode_tree /* Decode huff-table */ 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 */ +/* + 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 */ { @@ -184,12 +194,15 @@ typedef struct st_columndef /* column information */ #endif } MI_COLUMNDEF; +/* invalidator function reference for Query Cache */ +typedef void (* invalidator_by_filename)(const char * filename); extern my_string myisam_log_filename; /* Name of logfile */ extern uint myisam_block_size; -extern my_bool myisam_flush,myisam_delay_key_write; +extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user; extern my_bool myisam_concurrent_insert; extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length; +extern ulong myisam_bulk_insert_tree_size; /* Prototypes for myisam-functions */ @@ -219,13 +232,14 @@ 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 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); + enum ha_extra_function function, + void *extra_arg); 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, @@ -239,42 +253,60 @@ 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 T_TRUST_HEADER T_DONT_CHECK_CHECKSUM*2 -#define T_CREATE_MISSING_KEYS T_TRUST_HEADER*2 -#define T_SAFE_REPAIR T_CREATE_MISSING_KEYS*2 -#define T_AUTO_REPAIR T_SAFE_REPAIR*2 -#define T_BACKUP_DATA T_AUTO_REPAIR*2 -#define T_CALC_CHECKSUM T_BACKUP_DATA*2 +#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */ +#define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */ + +/* + Definitions needed for myisamchk.c + + Entries marked as "QQ to be removed" are NOT used to + pass check/repair options to mi_check.c. They are used + internally by myisamchk.c or/and ha_myisam.cc and should NOT + be stored together with other flags. They should be removed + from the following list to make addition of new flags possible. +*/ + +#define T_AUTO_INC 1 +#define T_AUTO_REPAIR 2 /* QQ to be removed */ +#define T_BACKUP_DATA 4 +#define T_CALC_CHECKSUM 8 +#define T_CHECK 16 /* QQ to be removed */ +#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */ +#define T_CREATE_MISSING_KEYS 64 +#define T_DESCRIPT 128 +#define T_DONT_CHECK_CHECKSUM 256 +#define T_EXTEND 512 +#define T_FAST (1L << 10) /* QQ to be removed */ +#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */ +#define T_FORCE_UNIQUENESS (1L << 12) +#define T_INFO (1L << 13) +#define T_MEDIUM (1L << 14) +#define T_QUICK (1L << 15) /* QQ to be removed */ +#define T_READONLY (1L << 16) /* QQ to be removed */ +#define T_REP (1L << 17) +#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */ +#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */ +#define T_RETRY_WITHOUT_QUICK (1L << 20) +#define T_SAFE_REPAIR (1L << 21) +#define T_SILENT (1L << 22) +#define T_SORT_INDEX (1L << 23) /* QQ to be removed */ +#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */ +#define T_STATISTICS (1L << 25) +#define T_UNPACK (1L << 26) +#define T_UPDATE_STATE (1L << 27) +#define T_VERBOSE (1L << 28) +#define T_VERY_SILENT (1L << 29) +#define T_WAIT_FOREVER (1L << 30) +#define T_WRITE_LOOP ((ulong) 1L << 31) + +#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL) + +/* + Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed + to mi_check.c follows: +*/ + +#define TT_USEFRM 1 #define O_NEW_INDEX 1 /* Bits set in out_flag */ #define O_NEW_DATA 2 @@ -282,31 +314,14 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); /* these struct is used by my_check to tell it what to do */ -typedef struct st_sort_key_blocks { /* Used when sorting */ +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 { ulonglong auto_increment_value; @@ -319,18 +334,16 @@ typedef struct st_mi_check_param ha_checksum record_checksum,glob_crc; 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 out_flag,warning_printed,error_printed,verbose; uint opt_sort_key,total_files,max_level; uint testflag; uint8 language; my_bool using_global_keycache, opt_lock_memory, opt_follow_links; - my_bool retry_repair,retry_without_quick, force_sort, calc_checksum; + my_bool retry_repair, force_sort, calc_checksum; 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]; @@ -340,18 +353,48 @@ typedef struct st_mi_check_param } MI_CHECK; -typedef struct st_mi_sortinfo { +typedef struct st_sort_info +{ + my_off_t filelength,dupp,buff_length; ha_rows max_records; + uint current_key, total_keys; + myf myf_rw; + enum data_file_type new_data_file_type; + MI_INFO *info; + MI_CHECK *param; + char *buff; + SORT_KEY_BLOCKS *key_block,*key_block_end; + /* sync things*/ + uint got_error, threads_running; + pthread_mutex_t mutex; + pthread_cond_t cond; +} SORT_INFO; + + +typedef struct st_mi_sort_param +{ + pthread_t thr; + IO_CACHE read_cache, tempfile, tempfile_for_exceptions; + DYNAMIC_ARRAY buffpek; + ulonglong unique[MI_MAX_KEY_SEG+1]; + my_off_t pos,max_pos,filepos,start_recpos; + uint key, key_length,real_key_length,sortbuff_size; + uint maxbuffers, keys, find_length, sort_keys_length; + my_bool fix_datafile, master; + MI_KEYDEF *keyinfo; SORT_INFO *sort_info; + uchar **sort_keys; + byte *rec_buff; + void *wordlist, *wordptr; + char *record; 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); - uint key_length; - myf myf_rw; + int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); + int (*key_read)(struct st_mi_sort_param *,void *); + int (*key_write)(struct st_mi_sort_param *, const void *); + void (*lock_in_memory)(MI_CHECK *); } MI_SORT_PARAM; + /* functions in mi_check */ void myisamchk_init(MI_CHECK *param); int chk_status(MI_CHECK *param, MI_INFO *info); @@ -364,6 +407,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, 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 mi_repair_parallel(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, myf myflags); @@ -374,20 +419,25 @@ 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); +void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, + ulonglong *unique, ulonglong records); 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 sort_write_record(MI_SORT_PARAM *sort_param); +int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile); +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); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map, my_bool force); +int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows); +void mi_flush_bulk_insert(MI_INFO *info, uint inx); +void mi_end_bulk_insert(MI_INFO *info); + #ifdef __cplusplus } #endif diff --git a/include/myisammrg.h b/include/myisammrg.h index a797c954614..ea882450eef 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -1,19 +1,18 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000 MySQL 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 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 library is distributed in the hope that it will be useful, + 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 - Library General Public License for more details. + 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 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 */ + 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 */ /* This file should be included when using merge_isam_funktions */ @@ -34,6 +33,13 @@ extern "C" { #define MYRG_NAME_EXT ".MRG" +/* In which table to INSERT rows */ +#define MERGE_INSERT_DISABLED 0 +#define MERGE_INSERT_TO_FIRST 1 +#define MERGE_INSERT_TO_LAST 2 + +extern TYPELIB merge_insert_method; + /* Param to/from myrg_info */ typedef struct st_mymerge_info /* Struct from h_info */ @@ -44,7 +50,8 @@ typedef struct st_mymerge_info /* Struct from h_info */ ulonglong data_file_length; uint reclength; /* Recordlength */ int errkey; /* With key was dupplicated on err */ - uint options; /* HA_OPTIONS_... used */ + uint options; /* HA_OPTION_... used */ + ulong *rec_per_key; /* for sql optimizing */ } MYMERGE_INFO; typedef struct st_myrg_table_info @@ -59,10 +66,13 @@ typedef struct st_myrg_info ulonglong records; /* records in tables */ ulonglong del; /* Removed records */ ulonglong data_file_length; + ulong cache_size; + uint merge_insert_method; uint tables,options,reclength,keys; my_bool cache_in_use; - LIST open_list; - QUEUE by_key; + LIST open_list; + QUEUE by_key; + ulong *rec_per_key_part; /* for sql optimizing */ } MYRG_INFO; @@ -81,11 +91,14 @@ extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key, 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_write(MYRG_INFO *info,byte *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, - my_bool fix_names); -extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function); +extern int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names); +extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function, + void *extra_arg); +extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv); 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, diff --git a/include/myisampack.h b/include/myisampack.h index a51cdc7e6eb..6004177cfb0 100644 --- a/include/myisampack.h +++ b/include/myisampack.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Storing of values in high byte first order. @@ -213,9 +212,9 @@ /* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */ -#ifdef BIG_TABLE +#ifdef BIG_TABLES #define mi_rowstore(T,A) mi_int8store(T,A) -#define mi_rowkorr(T,A) mi_uint8korr(T) +#define mi_rowkorr(T) 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) diff --git a/include/mysql.h b/include/mysql.h index 0bd5b7092b8..fb650343399 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -1,21 +1,18 @@ -/* 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, +/* Copyright (C) 2000-2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -/* defines for the libmysql library */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _mysql_h #define _mysql_h @@ -28,12 +25,10 @@ #undef __WIN__ #endif -#ifndef MYSQL_SERVER #ifdef __cplusplus extern "C" { #endif -#endif - + #ifndef _global_h /* If not standard header */ #include <sys/types.h> #ifdef __LCC__ @@ -50,38 +45,25 @@ typedef char my_bool; #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; - USED_MEM *pre_alloc; - 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 +#endif /* __WIN__ */ +#endif /* my_socket_defined */ +#endif /* _global_h */ + #include "mysql_com.h" #include "mysql_version.h" extern unsigned int mysql_port; extern char *mysql_unix_port; +#ifdef __NETWARE__ +#pragma pack(push, 8) /* 8 byte alignment */ +#endif + #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) @@ -92,12 +74,14 @@ extern char *mysql_unix_port; typedef struct st_mysql_field { char *name; /* Name of column */ char *table; /* Table of column if column was a field */ + char *org_table; /* Org table name if table was an alias */ + char *db; /* Database for table */ 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 long length; /* Width of column */ + unsigned long max_length; /* Max width of selected set */ unsigned int flags; /* Div flags */ unsigned int decimals; /* Number of decimals in field */ + enum enum_field_types type; /* Type of field. Se mysql_com.h for types */ } MYSQL_FIELD; typedef char **MYSQL_ROW; /* return data as array of strings */ @@ -120,6 +104,8 @@ typedef struct st_mysql_rows { typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ +#include "my_alloc.h" + typedef struct st_mysql_data { my_ulonglong rows; unsigned int fields; @@ -129,15 +115,32 @@ typedef struct st_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? */ + char *ssl_cipher; /* cipher to use */ + unsigned long max_allowed_packet; + my_bool use_ssl; /* if to use SSL or not */ + my_bool compress,named_pipe; + /* + On connect, find out the replication role of the server, and + establish connections to all the peers + */ + my_bool rpl_probe; + /* + Each call to mysql_real_query() will parse it to tell if it is a read + or a write, and direct it to the slave or the master + */ + my_bool rpl_parse; + /* + If set, never read from a master,only from slave, when doing + a read that is replication-aware + */ + my_bool no_master_reads; }; enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, @@ -149,48 +152,116 @@ enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT}; +/* + There are three types of queries - the ones that have to go to + the master, the ones that go to a slave, and the adminstrative + type which must happen on the pivot connectioin +*/ +enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, + MYSQL_RPL_ADMIN }; + + 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 */ + struct charset_info_st *charset; + MYSQL_FIELD *fields; + MEM_ROOT field_alloc; my_ulonglong affected_rows; my_ulonglong insert_id; /* id if insert on table with NEXTNR */ my_ulonglong extra_info; /* Used by mysqlshow */ + unsigned long thread_id; /* Id for connection in server */ unsigned long packet_length; + unsigned int port,client_flag,server_capabilities; + unsigned int protocol_version; + unsigned int field_count; + unsigned int server_status; + unsigned int server_language; + struct st_mysql_options options; 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; + + /* + Set if this is the original connection, not a master or a slave we have + added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() + */ + my_bool rpl_pivot; + /* + Pointers to the master, and the next slave connections, points to + itself if lone connection. + */ + struct st_mysql* master, *next_slave; + + struct st_mysql* last_used_slave; /* needed for round-robin slave pick */ + /* needed for send/read/store/use result to work correctly with replication */ + struct st_mysql* last_used_con; } 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; + unsigned long *lengths; /* column lengths of current row */ + MYSQL *handle; /* for unbuffered reads */ MEM_ROOT field_alloc; + unsigned int field_count, current_field; 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 */ + my_bool eof; /* Used by 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 */ +#define MAX_MYSQL_MANAGER_ERR 256 +#define MAX_MYSQL_MANAGER_MSG 256 + +#define MANAGER_OK 200 +#define MANAGER_INFO 250 +#define MANAGER_ACCESS 401 +#define MANAGER_CLIENT_ERR 450 +#define MANAGER_INTERNAL_ERR 500 + + + +typedef struct st_mysql_manager +{ + NET net; + char *host,*user,*passwd; + unsigned int port; + my_bool free_me; + my_bool eof; + int cmd_status; + int last_errno; + char* net_buf,*net_buf_pos,*net_data_end; + int net_buf_size; + char last_error[MAX_MYSQL_MANAGER_ERR]; +} MYSQL_MANAGER; + +/* + Set up and bring down the server; to ensure that applications will + work when linked against either the standard client library or the + embedded server library, these functions should be called. +*/ +int STDCALL mysql_server_init(int argc, char **argv, char **groups); +void STDCALL mysql_server_end(void); + +/* + Set up and bring down a thread; these function should be called + for each thread in an application which opens at least one MySQL + connection. All uses of the connection(s) should be between these + function calls. +*/ +my_bool STDCALL mysql_thread_init(void); +void STDCALL mysql_thread_end(void); + +/* + 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); @@ -198,31 +269,24 @@ 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); +MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res); +MYSQL_FIELD_OFFSET 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); +const char * STDCALL mysql_error(MYSQL *mysql); +const 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); + const char *capath, const char *cipher); 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, @@ -230,34 +294,65 @@ MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 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_send_query(MYSQL *mysql, const char *q, - unsigned int length); + unsigned long length); int STDCALL mysql_read_query_result(MYSQL *mysql); 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); + unsigned long length); +/* perform query on master */ +int STDCALL mysql_master_query(MYSQL *mysql, const char *q, + unsigned long length); +int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, + unsigned long length); +/* perform query on slave */ +int STDCALL mysql_slave_query(MYSQL *mysql, const char *q, + unsigned long length); +int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, + unsigned long length); + +/* + enable/disable parsing of all queries to decide if they go on master or + slave +*/ +void STDCALL mysql_enable_rpl_parse(MYSQL* mysql); +void STDCALL mysql_disable_rpl_parse(MYSQL* mysql); +/* get the value of the parse flag */ +int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql); + +/* enable/disable reads from master */ +void STDCALL mysql_enable_reads_from_master(MYSQL* mysql); +void STDCALL mysql_disable_reads_from_master(MYSQL* mysql); +/* get the value of the master read flag */ +int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql); + +enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len); + +/* discover the master and its slaves */ +int STDCALL mysql_rpl_probe(MYSQL* mysql); + +/* set the master, close/free the old one, if it is not a pivot */ +int STDCALL mysql_set_master(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); +int STDCALL mysql_add_slave(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); + 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); +const char * STDCALL mysql_stat(MYSQL *mysql); +const char * STDCALL mysql_get_server_info(MYSQL *mysql); +const char * STDCALL mysql_get_client_info(void); +const 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); @@ -271,7 +366,8 @@ int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, 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_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, + MYSQL_ROW_OFFSET offset); MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset); MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); @@ -295,18 +391,45 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql, unsigned long *length)); void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name); unsigned int STDCALL mysql_thread_safe(void); - - +MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con); +MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con, + const char* host, + const char* user, + const char* passwd, + unsigned int port); +void STDCALL mysql_manager_close(MYSQL_MANAGER* con); +int STDCALL mysql_manager_command(MYSQL_MANAGER* con, + const char* cmd, int cmd_len); +int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, + char* res_buf, + int res_buf_size); #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) -/* new api functions */ - +#ifdef USE_OLD_FUNCTIONS +MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, + const char *user, const char *passwd); +int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); +int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); +#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) +#endif #define HAVE_MYSQL_REAL_CONNECT -#ifndef MYSQL_SERVER +/* + The following functions are mainly exported because of mysqlbinlog; + They are not for general usage +*/ + +int simple_command(MYSQL *mysql,enum enum_server_command command, + const char *arg, unsigned long length, my_bool skipp_check); +unsigned long net_safe_read(MYSQL* mysql); +void mysql_once_init(void); + +#ifdef __NETWARE__ +#pragma pack(pop) /* restore alignment */ +#endif + #ifdef __cplusplus } #endif -#endif -#endif +#endif /* _mysql_h */ diff --git a/include/mysql_com.h b/include/mysql_com.h index fcc9abc5bcd..963c1212794 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* ** Common definition between mysql server & client @@ -22,7 +21,6 @@ #ifndef _mysql_com_h #define _mysql_com_h - #define NAME_LEN 64 /* Field/table name length */ #define HOSTNAME_LENGTH 60 #define USERNAME_LENGTH 16 @@ -36,13 +34,14 @@ #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, COM_CONNECT_OUT}; +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, COM_CONNECT_OUT, COM_REGISTER_SLAVE, + COM_END /* Must be last! */ +}; #define NOT_NULL_FLAG 1 /* Field can't be NULL */ #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ @@ -77,6 +76,12 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, #define REFRESH_READ_LOCK 16384 /* Lock tables for read */ #define REFRESH_FAST 32768 /* Intern flag */ +/* RESET (remove all queries) from query cache */ +#define REFRESH_QUERY_CACHE 65536 +#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ +#define REFRESH_DES_KEY_FILE 0x40000L +#define REFRESH_USER_RESOURCES 0x80000L + #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 */ @@ -86,7 +91,6 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, #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 */ @@ -100,39 +104,37 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, #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 #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ #define MAX_BLOB_WIDTH 8192 /* Default width for blob */ typedef struct st_net { Vio* vio; + unsigned char *buff,*buff_end,*write_pos,*read_pos; my_socket fd; /* For Perl DBI/dbd */ + unsigned long max_packet,max_packet_size; + unsigned int last_errno,pkt_nr,compress_pkt_nr; + unsigned int write_timeout, read_timeout, retry_count; 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 - */ + /* + The following variable is set 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; + my_bool no_send_ok; + gptr query_cache_query; } NET; -#define packet_error ((unsigned int) -1) +#define packet_error (~(unsigned long) 0) enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY, FIELD_TYPE_SHORT, FIELD_TYPE_LONG, @@ -149,18 +151,21 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY, FIELD_TYPE_LONG_BLOB=251, FIELD_TYPE_BLOB=252, FIELD_TYPE_VAR_STRING=253, - FIELD_TYPE_STRING=254 + FIELD_TYPE_STRING=254, + FIELD_TYPE_GEOMETRY=255 }; #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) +#ifdef __cplusplus +extern "C" { +#endif + int my_net_init(NET *net, Vio* vio); +void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net); int net_flush(NET *net); @@ -168,13 +173,22 @@ 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); +unsigned long my_net_read(NET *net); + +/* The following function is not meant for normal usage */ +struct sockaddr; +int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, + unsigned int timeout); struct rand_struct { unsigned long seed1,seed2,max_value; double max_value_dbl; }; +#ifdef __cplusplus +} +#endif + /* The following is for user defined functions */ enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT}; @@ -194,7 +208,7 @@ 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 */ + unsigned long 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; @@ -208,7 +222,10 @@ typedef struct st_udf_init #ifdef __cplusplus extern "C" { #endif - + +extern unsigned long max_allowed_packet; +extern unsigned long net_buffer_length; + void randominit(struct rand_struct *,unsigned long seed1, unsigned long seed2); double rnd(struct rand_struct *); diff --git a/include/mysql_embed.h b/include/mysql_embed.h new file mode 100644 index 00000000000..bc75c3fbcb8 --- /dev/null +++ b/include/mysql_embed.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 */ + +/* Defines that are unique to the embedded version of MySQL */ + +#ifdef EMBEDDED_LIBRARY + +/* Things we don't need in the embedded version of MySQL */ + +#undef HAVE_PSTACK /* No stacktrace */ +#undef HAVE_DLOPEN /* No udf functions */ +#undef HAVE_OPENSSL +#undef HAVE_VIO +#undef HAVE_ISAM + +#define DONT_USE_RAID + +#undef MYSQL_SERVER_SUFFIX +#define MYSQL_SERVER_SUFFIX "-embedded" + +#endif /* EMBEDDED_LIBRARY */ diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index 989b1a95494..793bf36e9fe 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -3,12 +3,16 @@ /* Version numbers for protocol & mysqld */ +#ifndef _mysql_version_h +#define _mysql_version_h #ifdef _CUSTOMCONFIG_ #include <custom_conf.h> #else #define PROTOCOL_VERSION @PROTOCOL_VERSION@ #define MYSQL_SERVER_VERSION "@VERSION@" +#ifndef MYSQL_SERVER_SUFFIX #define MYSQL_SERVER_SUFFIX "@MYSQL_SERVER_SUFFIX@" +#endif #define FRM_VER @DOT_FRM_VERSION@ #define MYSQL_VERSION_ID @MYSQL_VERSION_ID@ #define MYSQL_PORT @MYSQL_TCP_PORT@ @@ -18,5 +22,6 @@ /* mysqld compile time options */ #ifndef MYSQL_CHARSET #define MYSQL_CHARSET "@default_charset@" -#endif -#endif +#endif /* MYSQL_CHARSET */ +#endif /* _CUSTOMCONFIG_ */ +#endif /* _mysql_version_h */ diff --git a/include/mysqld_error.h b/include/mysqld_error.h index f0fb11c1832..0898b3d576f 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -234,4 +234,23 @@ #define ER_CANNOT_ADD_FOREIGN 1215 #define ER_NO_REFERENCED_ROW 1216 #define ER_ROW_IS_REFERENCED 1217 -#define ER_ERROR_MESSAGES 218 +#define ER_CONNECT_TO_MASTER 1218 +#define ER_QUERY_ON_MASTER 1219 +#define ER_ERROR_WHEN_EXECUTING_COMMAND 1220 +#define ER_WRONG_USAGE 1221 +#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222 +#define ER_CANT_UPDATE_WITH_READLOCK 1223 +#define ER_MIXING_NOT_ALLOWED 1224 +#define ER_DUP_ARGUMENT 1225 +#define ER_USER_LIMIT_REACHED 1226 +#define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227 +#define ER_LOCAL_VARIABLE 1228 +#define ER_GLOBAL_VARIABLE 1229 +#define ER_NO_DEFAULT 1230 +#define ER_WRONG_VALUE_FOR_VAR 1231 +#define ER_WRONG_TYPE_FOR_VAR 1232 +#define ER_VAR_CANT_BE_READ 1233 +#define ER_CANT_USE_OPTION_HERE 1234 +#define ER_NOT_SUPPORTED_YET 1235 +#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 +#define ER_ERROR_MESSAGES 237 diff --git a/include/mysys_err.h b/include/mysys_err.h index 2d23ead36b6..a86765c74fd 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _mysys_err_h #define _mysys_err_h @@ -55,7 +54,23 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ #define EE_CANT_SYMLINK 25 #define EE_REALPATH 26 + /* exit codes for all MySQL programs */ + +#define EXIT_UNSPECIFIED_ERROR 1 +#define EXIT_UNKNOWN_OPTION 2 +#define EXIT_AMBIGUOUS_OPTION 3 +#define EXIT_NO_ARGUMENT_ALLOWED 4 +#define EXIT_ARGUMENT_REQUIRED 5 +#define EXIT_VAR_PREFIX_NOT_UNIQUE 6 +#define EXIT_UNKNOWN_VARIABLE 7 +#define EXIT_OUT_OF_MEMORY 8 +#define EXIT_UNKNOWN_SUFFIX 9 +#define EXIT_NO_PTR_TO_VARIABLE 10 +#define EXIT_CANNOT_CONNECT_TO_SERVICE 11 + + #ifdef __cplusplus } #endif #endif + diff --git a/include/nisam.h b/include/nisam.h index 7ce2b44ee79..e8f29991a4e 100644 --- a/include/nisam.h +++ b/include/nisam.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* This file should be included when using nisam_funktions */ /* Author: Michael Widenius */ diff --git a/include/queues.h b/include/queues.h index 66125e650ca..699705d0869 100644 --- a/include/queues.h +++ b/include/queues.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Code for generell handling of priority Queues. @@ -42,17 +41,19 @@ typedef struct st_queue { #define queue_element(queue,index) ((queue)->root[index+1]) #define queue_end(queue) ((queue)->root[(queue)->elements]) #define queue_replaced(queue) _downheap(queue,1) +typedef int (*queue_compare)(void *,byte *, byte *); int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key, - pbool max_at_top, int (*compare)(void *,byte *, byte *), + pbool max_at_top, queue_compare compare, void *first_cmp_arg); int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key, - pbool max_at_top, int (*compare)(void *,byte *, byte *), + pbool max_at_top, queue_compare compare, 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); +void queue_fix(QUEUE *queue); #define is_queue_inited(queue) ((queue)->root != 0) #ifdef __cplusplus diff --git a/include/raid.h b/include/raid.h index 8cbd0f1a442..b5a5e665824 100644 --- a/include/raid.h +++ b/include/raid.h @@ -1,19 +1,18 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2000 MySQL 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 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 library is distributed in the hope that it will be useful, + 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 - Library General Public License for more details. + 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 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 */ + 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 */ /* Parser needs these defines always, even if USE_RAID is not defined */ #define RAID_TYPE_0 1 /* Striping */ @@ -23,17 +22,15 @@ #define RAID_DEFAULT_CHUNKS 4 #define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */ +C_MODE_START +#define my_raid_type(raid_type) raid_type_string[(int)(raid_type)] extern const char *raid_type_string[]; +C_MODE_END -#ifdef __cplusplus -extern "C" { -#endif -const char *my_raid_type(int raid_type); -#ifdef __cplusplus -} +#ifdef DONT_USE_RAID +#undef USE_RAID #endif - -#if defined(USE_RAID) && !defined(DONT_USE_RAID) +#if defined(USE_RAID) #ifdef __GNUC__ #pragma interface /* gcc class implementation */ @@ -47,7 +44,7 @@ const char *my_raid_type(int raid_type); #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_chsize(A,B,C,D) my_raid_chsize(A,B,C,D) #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) @@ -88,7 +85,7 @@ extern "C" { 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_chsize(File fd, my_off_t newlength, int filler, myf MyFlags); int my_raid_close(File, myf MyFlags); int my_raid_fstat(int Filedes, struct stat *buf, myf MyFlags); @@ -119,7 +116,7 @@ class RaidFd { 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 Chsize(File fd, my_off_t newlength, int filler, myf MyFlags); int Fstat(int fd, MY_STAT *stat_area, myf MyFlags ); int Close(myf MyFlags); static bool IsRaid(File fd); diff --git a/include/rijndael.h b/include/rijndael.h new file mode 100644 index 00000000000..e286c89cbdc --- /dev/null +++ b/include/rijndael.h @@ -0,0 +1,42 @@ +/* Copyright (C) 2002 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 */ + + +/* + rijndael-alg-fst.h + + @version 3.0 (December 2000) + Optimised ANSI C code for the Rijndael cipher (now AES) + @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> + @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> + @author Paulo Barreto <paulo.barreto@terra.com.br> + + This code is hereby placed in the public domain. + Modified by Peter Zaitsev to fit MySQL coding style. + */ + +#define AES_MAXKC (256/32) +#define AES_MAXKB (256/8) +#define AES_MAXNR 14 + +int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[], + int keyBits); +int rijndaelKeySetupDec(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[], + int keyBits); +void rijndaelEncrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr, + const uint8 pt[16], uint8 ct[16]); +void rijndaelDecrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr, + const uint8 ct[16], uint8 pt[16]); diff --git a/include/sha1.h b/include/sha1.h new file mode 100644 index 00000000000..1c345469d3c --- /dev/null +++ b/include/sha1.h @@ -0,0 +1,67 @@ +/* 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 */ + +/* + This is the header file for code which implements the Secure + Hashing Algorithm 1 as defined in FIPS PUB 180-1 published + April 17, 1995. + + Many of the variable names in this code, especially the + single character names, were used because those were the names + used in the publication. + + Please read the file sha1.c for more information. + + Modified 2002 by Peter Zaitsev to better follow MySQL standards +*/ + + +enum sha_result_codes +{ + SHA_SUCCESS = 0, + SHA_NULL, /* Null pointer parameter */ + SHA_INPUT_TOO_LONG, /* input data too long */ + SHA_STATE_ERROR /* called Input after Result */ +}; + +#define SHA1_HASH_SIZE 20 /* Hash size in bytes */ + +/* + This structure will hold context information for the SHA-1 + hashing operation +*/ + +typedef struct SHA1_CONTEXT +{ + ulonglong Length; /* Message length in bits */ + uint32 Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest */ + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corrupted? */ + int16 Message_Block_Index; /* Index into message block array */ + uint8 Message_Block[64]; /* 512-bit message blocks */ +} SHA1_CONTEXT; + +/* + Function Prototypes +*/ + +C_MODE_START + +int sha1_reset( SHA1_CONTEXT* ); +int sha1_input( SHA1_CONTEXT*, const uint8 *, unsigned int ); +int sha1_result( SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE] ); + +C_MODE_END diff --git a/include/sslopt-case.h b/include/sslopt-case.h index d995e31044e..ea23c31aa82 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -1,42 +1,29 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ #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)); + case OPT_SSL_CIPHER: + /* + Enable use of SSL if we are using any ssl option + One can disable SSL later by using --skip-ssl or --ssl=0 + */ + opt_use_ssl= 1; break; #endif diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index 2f58f0e9265..397d8baa9d6 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -1,31 +1,41 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ #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}, + {"ssl", OPT_SSL_SSL, + "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl", + (gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, + 0, 0, 0}, + {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl)", + (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl)", + (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + {"ssl-ca", OPT_SSL_CA, + "CA file in PEM format (check OpenSSL docs, implies --ssl)", + (gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + {"ssl-capath", OPT_SSL_CAPATH, + "CA directory (check OpenSSL docs, implies --ssl)", + (gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl)", + (gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, #endif /* HAVE_OPENSSL */ diff --git a/include/sslopt-usage.h b/include/sslopt-usage.h deleted file mode 100644 index 406d94572b8..00000000000 --- a/include/sslopt-usage.h +++ /dev/null @@ -1,25 +0,0 @@ -/* 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 - 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 index 597ab4d9fa6..164cf541381 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ #ifdef HAVE_OPENSSL static my_bool opt_use_ssl = 0; @@ -21,4 +20,5 @@ static char *opt_ssl_key = 0; static char *opt_ssl_cert = 0; static char *opt_ssl_ca = 0; static char *opt_ssl_capath = 0; +static char *opt_ssl_cipher = 0; #endif diff --git a/include/t_ctype.h b/include/t_ctype.h index f6e799828e6..3e190977e6c 100644 --- a/include/t_ctype.h +++ b/include/t_ctype.h @@ -1,3 +1,19 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 */ + /* Copyright (C) 1998, 1999 by Pruet Boonma, all rights reserved. Copyright (C) 1998 by Theppitak Karoonboonyanan, all rights reserved. @@ -121,7 +137,7 @@ enum l1_symbols { L1_SARA_AI_MAIMUAN, L1_SARA_AI_MAIMALAI }; - + /* level 2 symbols & order */ enum l2_symbols { L2_BLANK = TOT_LEVELS, @@ -135,7 +151,7 @@ enum l2_symbols { L2_TONE3, L2_TONE4 }; - + /* level 3 symbols & order */ enum l3_symbols { L3_BLANK = TOT_LEVELS, diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 1f3fed1d29b..30825d49158 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* Prototypes when using thr_alarm library functions */ @@ -39,24 +38,32 @@ extern "C" { #define THR_SERVER_ALARM SIGALRM #endif -#if defined(DONT_USE_THR_ALARM) +typedef struct st_alarm_info +{ + ulong next_alarm_time; + uint active_alarms; + uint max_used_alarms; +} ALARM_INFO; + +void thr_alarm_info(ALARM_INFO *info); + +#if defined(DONT_USE_THR_ALARM) || !defined(THREAD) #define USE_ALARM_THREAD #undef USE_ONE_SIGNAL_HAND -typedef struct st_thr_alarm_entry -{ - uint crono; -} thr_alarm_entry; +typedef my_bool thr_alarm_t; +typedef my_bool ALARM; -#define thr_alarm_init(A) (A)->crono=0 -#define thr_alarm_in_use(A) (A)->crono +#define thr_alarm_init(A) (*(A))=0 +#define thr_alarm_in_use(A) (*(A) != 0) +#define thr_end_alarm(A) +#define thr_alarm(A,B,C) ((*(A)=1)-1) +/* The following should maybe be (*(A)) */ +#define thr_got_alarm(A) 0 #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 #if defined(__WIN__) @@ -109,4 +116,3 @@ bool thr_got_alarm(thr_alarm_t *alrm); } #endif /* __cplusplus */ #endif /* _thr_alarm_h */ - diff --git a/include/thr_lock.h b/include/thr_lock.h index 6dd59f80e64..f1bda0ce6b4 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* For use with thr_lock:s */ @@ -28,7 +27,7 @@ extern "C" { struct st_thr_lock; extern ulong locks_immediate,locks_waited ; - + enum thr_lock_type { TL_IGNORE=-1, TL_UNLOCK, /* UNLOCK ANY LOCK */ TL_READ, /* Read lock */ @@ -44,8 +43,8 @@ enum thr_lock_type { TL_IGNORE=-1, */ TL_WRITE_ALLOW_WRITE, /* - Write lock, but allow other threads to read / write. - Used by ALTER TABLE in MySQL to mark to allow readers + Write lock, but allow other threads to read. + Used by ALTER TABLE in MySQL to allow readers to use the table until ALTER TABLE is finished. */ TL_WRITE_ALLOW_READ, @@ -108,6 +107,7 @@ 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_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread); 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); diff --git a/include/violite.h b/include/violite.h index 49df6994d53..a328e51253a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -1,19 +1,18 @@ -/* 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, +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; 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 - 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 */ + 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 */ /* * Vio Lite. @@ -25,9 +24,6 @@ #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 */ @@ -35,83 +31,208 @@ 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); +#ifndef __WIN__ +#define HANDLE void * +#endif + +Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost); #ifdef __WIN__ -Vio* vio_new_win32pipe(HANDLE hPipe); +Vio* vio_new_win32pipe(HANDLE hPipe); +#endif +void vio_delete(Vio* vio); + +#ifdef EMBEDDED_LIBRARY +void vio_reset(Vio *vio); +#else +void vio_reset(Vio* vio, enum enum_vio_type type, + my_socket sd, HANDLE hPipe, my_bool localhost); #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); +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); +int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); +my_bool vio_is_blocking(Vio *vio); /* * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ - int vio_fastsend( Vio* vio); +int vio_fastsend(Vio *vio); /* * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ -int vio_keepalive( Vio* vio, - my_bool onoff); +int vio_keepalive(Vio *vio, my_bool onoff); /* * Whenever we should retry the last read/write operation. */ -my_bool vio_should_retry( Vio* vio); +my_bool vio_should_retry(Vio *vio); /* * When the workday is over... */ -int vio_close( Vio* vio); +int vio_close(Vio* vio); /* * Short text description of the socket for those, who are curious.. */ -const char* vio_description( Vio* vio); +const char* vio_description(Vio *vio); /* Return the type of the connection */ - enum enum_vio_type vio_type(Vio* vio); +enum enum_vio_type vio_type(Vio* vio); /* Return last error number */ -int vio_errno(Vio *vio); +int vio_errno(Vio*vio); /* Get socket number */ -my_socket vio_fd(Vio *vio); +my_socket vio_fd(Vio*vio); /* * Remote peer's address and name in text form. */ -my_bool vio_peer_addr(Vio * vio, char *buf); +my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); /* Remotes in_addr */ void vio_in_addr(Vio *vio, struct in_addr *in); - /* Return 1 if there is data to be read */ my_bool vio_poll_read(Vio *vio,uint timeout); #ifdef __cplusplus } #endif + +#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO) +#define vio_delete(vio) (vio)->viodelete(vio) +#define vio_errno(vio) (vio)->vioerrno(vio) +#define vio_read(vio, buf, size) (vio)->read(vio,buf,size) +#define vio_write(vio, buf, size) (vio)->write(vio, buf, size) +#define vio_blocking(vio, set_blocking_mode, old_mode)\ + (vio)->vioblocking(vio, set_blocking_mode, old_mode) +#define vio_is_blocking(vio) (vio)->is_blocking(vio) +#define vio_fastsend(vio) (vio)->fastsend(vio) +#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive) +#define vio_should_retry(vio) (vio)->should_retry(vio) +#define vio_close(vio) ((vio)->vioclose)(vio) +#define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt) +#define vio_in_addr(vio, in) (vio)->in_addr(vio, in) +#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */ + +#ifdef HAVE_OPENSSL +#define HEADER_DES_LOCL_H dummy_something +#include <openssl/ssl.h> +#include <openssl/err.h> +#include "my_net.h" /* needed because of struct in_addr */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void vio_ssl_delete(Vio* vio); + +int vio_ssl_read(Vio* vio,gptr buf, int size); +int vio_ssl_write(Vio* vio,const gptr buf,int size); + +/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ + int vio_ssl_fastsend(Vio* vio); +/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ +int vio_ssl_keepalive(Vio* vio, my_bool onoff); +/* Whenever we should retry the last read/write operation. */ +my_bool vio_ssl_should_retry(Vio* vio); +/* When the workday is over... */ +int vio_ssl_close(Vio* vio); +/* Return last error number */ +int vio_ssl_errno(Vio *vio); +my_bool vio_ssl_peer_addr(Vio* vio, char *buf); +void vio_ssl_in_addr(Vio *vio, struct in_addr *in); +int vio_ssl_blocking(Vio * vio, my_bool set_blocking_mode, my_bool *old_mode); + +/* Single copy for server */ +enum vio_ssl_acceptorfd_state +{ + state_connect = 1, + state_accept = 2 +}; + +struct st_VioSSLAcceptorFd +{ + SSL_CTX* ssl_context_; + SSL_METHOD* ssl_method_; + struct st_VioSSLAcceptorFd* session_id_context_; +}; + +/* One copy for client */ +struct st_VioSSLConnectorFd +{ + SSL_CTX* ssl_context_; + /* function pointers which are only once for SSL client */ + SSL_METHOD* ssl_method_; +}; + +int sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout); +int sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout); + +struct st_VioSSLConnectorFd +*new_VioSSLConnectorFd(const char* key_file, const char* cert_file, + const char* ca_file, const char* ca_path, + const char* cipher); +struct st_VioSSLAcceptorFd +*new_VioSSLAcceptorFd(const char* key_file, const char* cert_file, + const char* ca_file,const char* ca_path, + const char* cipher); +Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); + +#ifdef __cplusplus +} +#endif +#endif /* HAVE_OPENSSL */ + +/* This enumerator is used in parser - should be always visible */ +enum SSL_type +{ + SSL_TYPE_NOT_SPECIFIED= -1, + SSL_TYPE_NONE, + SSL_TYPE_ANY, + SSL_TYPE_X509, + SSL_TYPE_SPECIFIED +}; + +#ifndef EMBEDDED_LIBRARY +/* This structure is for every connection on both sides */ +struct st_vio +{ + my_socket sd; /* my_socket - real or imaginary */ + HANDLE hPipe; + my_bool localhost; /* Are we from localhost? */ + int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */ + struct sockaddr_in local; /* Local internet address */ + struct sockaddr_in remote; /* Remote internet address */ + enum enum_vio_type type; /* Type of connection */ + char desc[30]; /* String description */ +#ifdef HAVE_VIO + /* function pointers. They are similar for socket/SSL/whatever */ + void (*viodelete)(Vio*); + int (*vioerrno)(Vio*); + int (*read)(Vio*, gptr, int); + int (*write)(Vio*, gptr, int); + int (*vioblocking)(Vio*, my_bool, my_bool *); + my_bool (*is_blocking)(Vio*); + int (*viokeepalive)(Vio*, my_bool); + int (*fastsend)(Vio*); + my_bool (*peer_addr)(Vio*, gptr, uint16*); + void (*in_addr)(Vio*, struct in_addr*); + my_bool (*should_retry)(Vio*); + int (*vioclose)(Vio*); + +#ifdef HAVE_OPENSSL + SSL* ssl_; +#endif /* HAVE_OPENSSL */ #endif /* HAVE_VIO */ +}; +#endif /* EMBEDDED_LIBRARY */ #endif /* vio_violite_h_ */ |