diff options
47 files changed, 514 insertions, 635 deletions
diff --git a/ext/mysql/libmysql/charset.c b/ext/mysql/libmysql/charset.c index a6b4db893a..29df5c5bdf 100644 --- a/ext/mysql/libmysql/charset.c +++ b/ext/mysql/libmysql/charset.c @@ -289,8 +289,7 @@ static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table, const char *name return NULL; } -static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name, - myf flags) +static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name) { CHARSET_INFO tmp_cs,*cs; uchar tmp_ctype[CTYPE_TABLE_SIZE]; @@ -305,7 +304,7 @@ static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name, cs->to_lower=tmp_to_lower; cs->to_upper=tmp_to_upper; cs->sort_order=tmp_sort_order; - if (read_charset_file(cs_number, cs, flags)) + if (read_charset_file(cs_number, cs, MYF(MY_WME))) return NULL; cs = (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO), @@ -327,7 +326,7 @@ static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name, return cs; } -static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) +static CHARSET_INFO *get_internal_charset(uint cs_number) { CHARSET_INFO *cs; /* @@ -338,13 +337,13 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) if (!(cs = find_charset((CHARSET_INFO**) cs_info_table.buffer, cs_number, cs_info_table.elements))) if (!(cs = find_compiled_charset(cs_number))) - cs=add_charset(cs_number, get_charset_name(cs_number), flags); + cs=add_charset(cs_number, get_charset_name(cs_number)); pthread_mutex_unlock(&THR_LOCK_charset); return cs; } -static CHARSET_INFO *get_internal_charset_by_name(const char *name, myf flags) +static CHARSET_INFO *get_internal_charset_by_name(const char *name) { CHARSET_INFO *cs; /* @@ -355,7 +354,7 @@ static CHARSET_INFO *get_internal_charset_by_name(const char *name, myf flags) if (!(cs = find_charset_by_name((CHARSET_INFO**) cs_info_table.buffer, name, cs_info_table.elements))) if (!(cs = find_compiled_charset_by_name(name))) - cs=add_charset(get_charset_number(name), name, flags); + cs=add_charset(get_charset_number(name), name); pthread_mutex_unlock(&THR_LOCK_charset); return cs; } @@ -365,7 +364,7 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags) { CHARSET_INFO *cs; (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - cs=get_internal_charset(cs_number, flags); + cs=get_internal_charset(cs_number); if (!cs && (flags & MY_WME)) { @@ -380,16 +379,16 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags) my_bool set_default_charset(uint cs, myf flags) { - CHARSET_INFO *new; + CHARSET_INFO *new_charset; DBUG_ENTER("set_default_charset"); DBUG_PRINT("enter",("character set: %d",(int) cs)); - new = get_charset(cs, flags); - if (!new) + new_charset = get_charset(cs, flags); + if (!new_charset) { DBUG_PRINT("error",("Couldn't set default character set")); DBUG_RETURN(TRUE); /* error */ } - default_charset_info = new; + default_charset_info = new_charset; DBUG_RETURN(FALSE); } @@ -397,7 +396,7 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags) { CHARSET_INFO *cs; (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - cs=get_internal_charset_by_name(cs_name, flags); + cs=get_internal_charset_by_name(cs_name); if (!cs && (flags & MY_WME)) { @@ -411,17 +410,17 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags) my_bool set_default_charset_by_name(const char *cs_name, myf flags) { - CHARSET_INFO *new; + CHARSET_INFO *new_charset; DBUG_ENTER("set_default_charset_by_name"); DBUG_PRINT("enter",("character set: %s", cs_name)); - new = get_charset_by_name(cs_name, flags); - if (!new) + new_charset = get_charset_by_name(cs_name, flags); + if (!new_charset) { DBUG_PRINT("error",("Couldn't set default character set")); DBUG_RETURN(TRUE); /* error */ } - default_charset_info = new; + default_charset_info = new_charset; DBUG_RETURN(FALSE); } diff --git a/ext/mysql/libmysql/config-win.h b/ext/mysql/libmysql/config-win.h index 5d4d40d98b..2b0e520bcd 100644 --- a/ext/mysql/libmysql/config-win.h +++ b/ext/mysql/libmysql/config-win.h @@ -239,7 +239,7 @@ inline double ulonglong2double(ulonglong value) #define HAVE_ALLOCA #define HAVE_STRPBRK #define HAVE_STRSTR -/* #define HAVE_COMPRESS -- not with PHP, please */ +#define HAVE_COMPRESS #ifdef NOT_USED #define HAVE_SNPRINTF /* Gave link error */ @@ -273,7 +273,6 @@ inline double ulonglong2double(ulonglong value) #define FN_ROOTDIR "\\" #define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ #define FN_NO_CASE_SENCE /* Files are not case-sensitive */ -#define FN_LOWER_CASE TRUE /* Files are represented in lower case */ #define MY_NFILE 1024 #define DO_NOT_REMOVE_THREAD_WRAPPERS diff --git a/ext/mysql/libmysql/ctype.c b/ext/mysql/libmysql/ctype.c index 151266ce0e..49827a16ab 100644 --- a/ext/mysql/libmysql/ctype.c +++ b/ext/mysql/libmysql/ctype.c @@ -2,8 +2,8 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <global.h> - #include <m_ctype.h> +#include <m_string.h> /* generated by make, using conf_to_src */ #include "ctype_extra_sources.c" @@ -33,7 +33,7 @@ CHARSET_INFO *find_compiled_charset_by_name(const char *name) return NULL; } -uint8 compiled_charset_number(const char *name) +uint compiled_charset_number(const char *name) { CHARSET_INFO *cs; for (cs = compiled_charsets; cs->number > 0; cs++) @@ -43,7 +43,7 @@ uint8 compiled_charset_number(const char *name) return 0; /* this mimics find_type() */ } -const char *compiled_charset_name(uint8 charset_number) +const char *compiled_charset_name(uint charset_number) { CHARSET_INFO *cs; for (cs = compiled_charsets; cs->number > 0; cs++) diff --git a/ext/mysql/libmysql/dbug.c b/ext/mysql/libmysql/dbug.c index f600b28100..cfe4ca161c 100644 --- a/ext/mysql/libmysql/dbug.c +++ b/ext/mysql/libmysql/dbug.c @@ -307,6 +307,7 @@ static char *static_strtok(char *s1,pchar chr); * Macros and defines for testing file accessibility under UNIX and MSDOS. */ +#undef EXISTS #if !defined(HAVE_ACCESS) || defined(MSDOS) #define EXISTS(pathname) (FALSE) /* Assume no existance */ #define Writable(name) (TRUE) @@ -489,8 +490,7 @@ static CODE_STATE static_code_state = { 0,0,"?func","?file",NULL,0,NULL, * */ -void _db_push_ (control) -const char *control; +void _db_push_ (const char *control) { reg1 char *scan; reg2 struct link *temp; @@ -691,15 +691,14 @@ void _db_pop_ () * */ -void _db_enter_ (_func_, _file_, _line_, _sfunc_, _sfile_, _slevel_, - _sframep_) -const char *_func_; -const char *_file_; -uint _line_; -const char **_sfunc_; -const char **_sfile_; -uint *_slevel_; -char ***_sframep_ __attribute__((unused)); +void _db_enter_ ( +const char *_func_, +const char *_file_, +uint _line_, +const char **_sfunc_, +const char **_sfile_, +uint *_slevel_, +char ***_sframep_ __attribute__((unused))) { reg1 CODE_STATE *state; @@ -777,11 +776,11 @@ char ***_sframep_ __attribute__((unused)); * */ -void _db_return_ (_line_, _sfunc_, _sfile_, _slevel_) -uint _line_; -const char **_sfunc_; -const char **_sfile_; -uint *_slevel_; +void _db_return_ ( +uint _line_, +const char **_sfunc_, +const char **_sfile_, +uint *_slevel_) { CODE_STATE *state; @@ -851,9 +850,9 @@ uint *_slevel_; * */ -void _db_pargs_ (_line_, keyword) -uint _line_; -const char *keyword; +void _db_pargs_ ( +uint _line_, +const char *keyword) { CODE_STATE *state=code_state(); state->u_line = _line_; @@ -934,10 +933,11 @@ void _db_doprnt_ (const char *format,...) * Is used to examine corrputed memory or arrays. */ -void _db_dump_(_line_,keyword,memory,length) -uint _line_,length; -const char *keyword; -const char *memory; +void _db_dump_( +uint _line_, +const char *keyword, +const char *memory, +uint length) { int pos; char dbuff[90]; @@ -1004,11 +1004,11 @@ const char *memory; * */ -static struct link *ListParse (ctlp) -char *ctlp; +static struct link *ListParse ( +char *ctlp) { REGISTER char *start; - REGISTER struct link *new; + REGISTER struct link *new_malloc; REGISTER struct link *head; head = NULL; @@ -1020,10 +1020,10 @@ char *ctlp; if (*ctlp == ',') { *ctlp++ = EOS; } - new = (struct link *) DbugMalloc (sizeof (struct link)); - new -> str = StrDup (start); - new -> next_link = head; - head = new; + new_malloc = (struct link *) DbugMalloc (sizeof (struct link)); + new_malloc -> str = StrDup (start); + new_malloc -> next_link = head; + head = new_malloc; } return (head); } @@ -1052,9 +1052,9 @@ char *ctlp; * */ -static BOOLEAN InList (linkp, cp) -struct link *linkp; -const char *cp; +static BOOLEAN InList ( +struct link *linkp, +const char *cp) { REGISTER struct link *scan; REGISTER BOOLEAN result; @@ -1098,7 +1098,7 @@ const char *cp; static void PushState () { - REGISTER struct state *new; + REGISTER struct state *new_malloc; if (!init_done) { @@ -1106,19 +1106,19 @@ static void PushState () init_done=TRUE; } (void) code_state(); /* Alloc memory */ - new = (struct state *) DbugMalloc (sizeof (struct state)); - new -> flags = 0; - new -> delay = 0; - new -> maxdepth = MAXDEPTH; - new -> sub_level=0; - new -> out_file = stderr; - new -> prof_file = (FILE*) 0; - new -> functions = NULL; - new -> p_functions = NULL; - new -> keywords = NULL; - new -> processes = NULL; - new -> next_state = stack; - stack=new; + new_malloc = (struct state *) DbugMalloc (sizeof (struct state)); + new_malloc -> flags = 0; + new_malloc -> delay = 0; + new_malloc -> maxdepth = MAXDEPTH; + new_malloc -> sub_level=0; + new_malloc -> out_file = stderr; + new_malloc -> prof_file = (FILE*) 0; + new_malloc -> functions = NULL; + new_malloc -> p_functions = NULL; + new_malloc -> keywords = NULL; + new_malloc -> processes = NULL; + new_malloc -> next_state = stack; + stack=new_malloc; } @@ -1216,8 +1216,8 @@ static BOOLEAN DoProfile () * */ -BOOLEAN _db_keyword_ (keyword) -const char *keyword; +BOOLEAN _db_keyword_ ( +const char *keyword) { REGISTER BOOLEAN result; CODE_STATE *state; @@ -1256,8 +1256,8 @@ const char *keyword; * */ -static void Indent (indent) -int indent; +static void Indent ( +int indent) { REGISTER int count; @@ -1289,8 +1289,8 @@ int indent; * */ -static void FreeList (linkp) -struct link *linkp; +static void FreeList ( +struct link *linkp) { REGISTER struct link *old; @@ -1325,13 +1325,13 @@ struct link *linkp; */ -static char *StrDup (str) -const char *str; +static char *StrDup ( +const char *str) { - reg1 char *new; - new = DbugMalloc ((int) strlen (str) + 1); - (void) strcpy (new, str); - return (new); + reg1 char *new_malloc; + new_malloc = DbugMalloc ((int) strlen (str) + 1); + (void) strcpy (new_malloc, str); + return (new_malloc); } @@ -1354,8 +1354,8 @@ const char *str; * */ -static void DoPrefix (_line_) -uint _line_; +static void DoPrefix ( +uint _line_) { CODE_STATE *state; state=code_state(); @@ -1365,7 +1365,7 @@ uint _line_; #ifdef THREAD (void) fprintf (_db_fp_, "%-7s: ", my_thread_name()); #else - (void) fprintf (_db_fp_, "%5d: ", getpid ()); + (void) fprintf (_db_fp_, "%5d: ", (int) getpid ()); #endif } if (stack -> flags & NUMBER_ON) { @@ -1419,7 +1419,7 @@ static void DBUGOpenFile (const char *name,int append) } else { - if (!Writable(name)) + if (!Writable((char*)name)) { (void) fprintf (stderr, ERR_OPEN, _db_process_, name); perror (""); @@ -1528,8 +1528,8 @@ static FILE *OpenProfile (const char *name) * */ -static void CloseFile (fp) -FILE *fp; +static void CloseFile ( +FILE *fp) { if (fp != stderr && fp != stdout) { if (fclose (fp) == EOF) { @@ -1590,14 +1590,14 @@ static void DbugExit (const char *why) * */ -static char *DbugMalloc (size) -int size; +static char *DbugMalloc ( +int size) { - register char *new; + register char *new_malloc; - if (!(new = malloc ((unsigned int) size))) + if (!(new_malloc = (char*) malloc ((unsigned int) size))) DbugExit ("out of memory"); - return (new); + return (new_malloc); } @@ -1606,9 +1606,9 @@ int size; * separator (to allow directory-paths in dos). */ -static char *static_strtok (s1, separator) -char *s1; -pchar separator; +static char *static_strtok ( +char *s1, +pchar separator) { static char *end = NULL; reg1 char *rtnval,*cpy; @@ -1692,8 +1692,8 @@ static char *BaseName (const char *pathname) #ifndef Writable -static BOOLEAN Writable (pathname) -char *pathname; +static BOOLEAN Writable ( +char *pathname) { REGISTER BOOLEAN granted; REGISTER char *lastslash; @@ -1746,8 +1746,8 @@ char *pathname; */ #ifndef ChangeOwner -static void ChangeOwner (pathname) -char *pathname; +static void ChangeOwner ( +char *pathname) { if (chown (pathname, getuid (), getgid ()) == -1) { @@ -1847,8 +1847,8 @@ EXPORT void _db_longjmp_ () #define HZ (50) /* Probably in some header somewhere */ #endif -static int DelayArg (value) -int value; +static int DelayArg ( +int value) { uint delayarg = 0; @@ -1868,8 +1868,8 @@ int value; */ #if ! defined(Delay) && ! defined(AMIGA) -static int Delay (ticks) -int ticks; +static int Delay ( +int ticks) { return ticks; } @@ -1969,12 +1969,13 @@ void _db_unlock_file() * own for whatever system that you have. */ -#ifdef HAVE_GETRUSAGE +#ifndef THREAD +#if defined(HAVE_GETRUSAGE) #include <sys/param.h> #include <sys/resource.h> -/* extern int getrusage(int, struct rusage *); */ +/* extern int getrusage(int, struct rusage *); */ /* * Returns the user time in milliseconds used by this process so @@ -1989,15 +1990,13 @@ static unsigned long Clock () return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000)); } -#else -#if defined(MSDOS) || defined(__WIN__) +#elif defined(MSDOS) || defined(__WIN__) || defined(OS2) static ulong Clock() { return clock()*(1000/CLOCKS_PER_SEC); } -#else -#ifdef amiga +#elif defined (amiga) struct DateStamp { /* Yes, this is a hack, but doing it right */ long ds_Days; /* is incredibly ugly without splitting this */ @@ -2030,19 +2029,13 @@ static unsigned long Clock () } return (millisec); } - #else - -#ifndef THREAD static unsigned long Clock () { return (0); } -#endif -#endif /* amiga */ -#endif /* MSDOS || __WIN__ */ #endif /* RUSAGE */ - +#endif /* THREADS */ #ifdef NO_VARARGS diff --git a/ext/mysql/libmysql/dbug.h b/ext/mysql/libmysql/dbug.h index d811b584a5..aa45079eab 100644 --- a/ext/mysql/libmysql/dbug.h +++ b/ext/mysql/libmysql/dbug.h @@ -52,7 +52,7 @@ extern void _db_unlock_file(); #define DEBUGGER_ON _no_db_=0 #define DBUG_LOCK_FILE { _db_lock_file(); } #define DBUG_UNLOCK_FILE { _db_unlock_file(); } -#define DBUG_ASSERT(A) A +#define DBUG_ASSERT(A) assert(A) #else /* No debugger */ #define DBUG_ENTER(a1) diff --git a/ext/mysql/libmysql/default.c b/ext/mysql/libmysql/default.c index d9dbfcf1c6..63aea98212 100644 --- a/ext/mysql/libmysql/default.c +++ b/ext/mysql/libmysql/default.c @@ -132,7 +132,7 @@ void load_defaults(const char *conf_file, const char **groups, &group)) goto err; #endif -#ifdef __EMX__ +#if defined(__EMX__) || defined(OS2) if (getenv("ETC") && search_default_file(&args, &alloc, getenv("ETC"), conf_file, default_ext, &group)) @@ -208,7 +208,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *config_file, const char *ext, TYPELIB *group) { - char name[FN_REFLEN+10],buff[FN_REFLEN+1],*ptr,*end,*value,*tmp; + char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp; FILE *fp; uint line=0; my_bool read_values=0,found_group=0; @@ -349,7 +349,7 @@ void print_defaults(const char *conf_file, const char **groups) GetWindowsDirectory(name,sizeof(name)); printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext); #endif -#ifdef __EMX__ +#if defined(__EMX__) || defined(OS2) if (getenv("ETC")) printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext); #endif diff --git a/ext/mysql/libmysql/dll.c b/ext/mysql/libmysql/dll.c index fb666c0f3b..e69de29bb2 100644 --- a/ext/mysql/libmysql/dll.c +++ b/ext/mysql/libmysql/dll.c @@ -1,98 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/* -** Handling initialization of the dll library -*/ - -#include <global.h> -#include <my_sys.h> -#include <my_pthread.h> - -static bool libmysql_inited=0; - -void libmysql_init(void) -{ - if (libmysql_inited) - return; - libmysql_inited=1; - my_init(); - { - DBUG_ENTER("libmysql_init"); -#ifdef LOG_ALL - DBUG_PUSH("d:t:S:O,c::\\tmp\\libmysql.log"); -#else - if (getenv("LIBMYSQL_LOG") != NULL) - DBUG_PUSH(getenv("LIBMYSQL_LOG")); -#endif - DBUG_VOID_RETURN; - } -} - -#ifdef __WIN__ - -static int inited=0,threads=0; -HINSTANCE NEAR s_hModule; /* Saved module handle */ -DWORD main_thread; - -BOOL APIENTRY LibMain(HANDLE hInst,DWORD ul_reason_being_called, - LPVOID lpReserved) -{ - switch (ul_reason_being_called) { - case DLL_PROCESS_ATTACH: /* case of libentry call in win 3.x */ - if (!inited++) - { - s_hModule=hInst; - libmysql_init(); - main_thread=GetCurrentThreadId(); - } - break; - case DLL_THREAD_ATTACH: - threads++; - my_thread_init(); - break; - case DLL_PROCESS_DETACH: /* case of wep call in win 3.x */ - if (!--inited) /* Safety */ - { - /* my_thread_init() */ /* This may give extra safety */ - my_end(0); - } - break; - case DLL_THREAD_DETACH: - /* Main thread will free by my_end() */ - threads--; - if (main_thread != GetCurrentThreadId()) - my_thread_end(); - break; - default: - break; - } /* switch */ - - return TRUE; - - UNREFERENCED_PARAMETER(lpReserved); -} /* LibMain */ - -int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved) -{ - return LibMain(hInst,ul_reason_being_called,lpReserved); -} - -#elif defined(WINDOWS) - -/**************************************************************************** -** This routine is called by LIBSTART.ASM at module load time. All it -** does in this sample is remember the DLL module handle. The module -** handle is needed if you want to do things like load stuff from the -** resource file (for instance string resources). -****************************************************************************/ - -int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize, - UCHAR FAR *lszCmdLine) -{ - s_hModule = hModule; - libmysql_init(); - return TRUE; -} - -#endif diff --git a/ext/mysql/libmysql/errmsg.c b/ext/mysql/libmysql/errmsg.c index 216693042d..18e13b9c11 100644 --- a/ext/mysql/libmysql/errmsg.c +++ b/ext/mysql/libmysql/errmsg.c @@ -34,6 +34,34 @@ const char *client_errors[]= "Got packet bigger than 'max_allowed_packet'" }; +/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ + +#elif defined PORTUGUESE +const char *client_errors[]= +{ + "Erro desconhecido do MySQL", + "Não pode criar 'UNIX socket' (%d)", + "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.64s' (%d)", + "Não pode se conectar ao servidor MySQL em '%-.64s' (%d)", + "Não pode criar 'socket TCP/IP' (%d)", + "'Host' servidor MySQL '%-.64s' (%d) desconhecido", + "Servidor MySQL desapareceu", + "Incompatibilidade de protocolos. Versão do Servidor: %d - Versão do Cliente: %d", + "Cliente do MySQL com falta de memória", + "Informação inválida de 'host'", + "Localhost via 'UNIX socket'", + "%-.64s via 'TCP/IP'", + "Erro na negociação de acesso ao servidor", + "Conexão perdida com servidor MySQL durante 'query'", + "Comandos fora de sincronismo. Você não pode executar este comando agora", + "%-.64s via 'named pipe'", + "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", + "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", + "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", + "Não pode inicializar conjunto de caracteres %-.64s (caminho %-.64s)", + "Obteve pacote maior do que 'max_allowed_packet'" +}; + #else /* ENGLISH */ const char *client_errors[]= { diff --git a/ext/mysql/libmysql/errmsg.h b/ext/mysql/libmysql/errmsg.h index f81bf962db..233abfca59 100644 --- a/ext/mysql/libmysql/errmsg.h +++ b/ext/mysql/libmysql/errmsg.h @@ -15,7 +15,11 @@ 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) +#define CER(X) client_errors[(X)-CR_MIN_ERROR] +#else #define ER(X) client_errors[(X)-CR_MIN_ERROR] +#endif #define CLIENT_ERRMAP 2 /* Errormap used by my_error() */ #define CR_UNKNOWN_ERROR 2000 diff --git a/ext/mysql/libmysql/get_password.c b/ext/mysql/libmysql/get_password.c index c0c6f90406..9d39beac01 100644 --- a/ext/mysql/libmysql/get_password.c +++ b/ext/mysql/libmysql/get_password.c @@ -21,7 +21,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <pwd.h> #endif /* HAVE_PWD_H */ #else /* ! HAVE_GETPASS */ -#ifndef __WIN__ +#if !defined( __WIN__) && !defined(OS2) #include <sys/ioctl.h> #ifdef HAVE_TERMIOS_H /* For tty-password */ #include <termios.h> @@ -48,9 +48,8 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define getpass(A) getpassphrase(A) #endif -#ifdef __WIN__ -/* were just going to fake it here and get input from - the keyboard */ +#if defined( __WIN__) || defined(OS2) +/* were just going to fake it here and get input from the keyboard */ char *get_tty_password(char *opt_message) { diff --git a/ext/mysql/libmysql/global.h b/ext/mysql/libmysql/global.h index 2257c49969..968c2bddb6 100644 --- a/ext/mysql/libmysql/global.h +++ b/ext/mysql/libmysql/global.h @@ -29,14 +29,14 @@ This file is public domain and comes with NO WARRANTY of any kind */ #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) #include <config-win.h> +#elif defined(OS2) +#include <config-os2.h> #else #include <my_config.h> -#endif -#if defined(__cplusplus) -#if defined(inline) +#if defined(__cplusplus) && defined(inline) #undef inline /* fix configure problem */ #endif -#endif /* _cplusplus */ +#endif /* _WIN32... */ /* Fix problem with S_ISLNK() on Linux */ #if defined(HAVE_LINUXTHREADS) @@ -62,7 +62,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define __STDC_EXT__ 1 /* To get large file support on hpux */ #endif -#if defined(THREAD) && !defined(__WIN__) +#if defined(THREAD) && !defined(__WIN__) && !defined(OS2) #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ #endif @@ -197,6 +197,11 @@ This file is public domain and comes with NO WARRANTY of any kind */ #ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ #undef HAVE_FINITE #endif +#if defined(HPUX) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) +/* Fix bug in setrlimit */ +#undef setrlimit +#define setrlimit cma_setrlimit64 +#endif /* We can not live without these */ @@ -206,7 +211,9 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ #define USE_REGEX 1 /* We want the use the regex library */ /* Do not define for ultra sparcs */ +#ifndef OS2 #define USE_BMOVE512 1 /* Use this unless the system bmove is faster */ +#endif /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */ #ifdef I_AM_PARANOID @@ -250,12 +257,8 @@ int __void__; #endif #if defined(__EMX__) || !defined(HAVE_UINT) -#undef uint -#undef ushort -#undef ulong typedef unsigned int uint; typedef unsigned short ushort; -typedef unsigned long ulong; #endif #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) @@ -460,7 +463,11 @@ extern double my_atof(const char*); #endif #undef remove /* Crashes MySQL on SCO 5.0.0 */ #ifndef __WIN__ +#ifdef OS2 +#define closesocket(A) soclose(A) +#else #define closesocket(A) close(A) +#endif #ifndef ulonglong2double #define ulonglong2double(A) ((double) (A)) #define my_off_t2double(A) ((double) (A)) @@ -549,9 +556,13 @@ typedef long my_ptrdiff_t; #ifndef NEAR #define NEAR /* Who needs segments ? */ #define FAR /* On a good machine */ +#ifndef HUGE_PTR #define HUGE_PTR #endif -#ifndef STDCALL +#endif +#if defined(__IBMC__) || defined(__IBMCPP__) +#define STDCALL _System _Export +#elif !defined( STDCALL) #define STDCALL #endif @@ -591,8 +602,8 @@ typedef unsigned long ulong; /* Short for unsigned long */ #endif #ifndef longlong_defined #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 -typedef unsigned long long ulonglong; /* ulong or unsigned long long */ -typedef long long longlong; +typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ +typedef long long int longlong; #else typedef unsigned long ulonglong; /* ulong or unsigned long long */ typedef long longlong; @@ -619,10 +630,34 @@ typedef ulonglong my_off_t; typedef unsigned long my_off_t; #endif #define MY_FILEPOS_ERROR (~(my_off_t) 0) -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) typedef off_t os_off_t; #endif +#if defined(__WIN__) +#define socket_errno WSAGetLastError() +#define SOCKET_EINTR WSAEINTR +#define SOCKET_EAGAIN WSAEINPROGRESS +#define SOCKET_ENFILE ENFILE +#define SOCKET_EMFILE EMFILE +#elif defined(OS2) +#define socket_errno sock_errno() +#define SOCKET_EINTR SOCEINTR +#define SOCKET_EAGAIN SOCEINPROGRESS +#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK +#define SOCKET_ENFILE SOCENFILE +#define SOCKET_EMFILE SOCEMFILE +#define closesocket(A) soclose(A) +#else /* Unix */ +#define socket_errno errno +#define closesocket(A) close(A) +#define SOCKET_EINTR EINTR +#define SOCKET_EAGAIN EAGAIN +#define SOCKET_EWOULDBLOCK EWOULDBLOCK +#define SOCKET_ENFILE ENFILE +#define SOCKET_EMFILE EMFILE +#endif + typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ typedef short int15; /* Most effective integer 0 <= x <= 32767 */ typedef char *my_string; /* String of characters */ diff --git a/ext/mysql/libmysql/libmysql.c b/ext/mysql/libmysql/libmysql.c index 0ffaabc852..e4ddc14952 100644 --- a/ext/mysql/libmysql/libmysql.c +++ b/ext/mysql/libmysql/libmysql.c @@ -1,7 +1,6 @@ /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */ -#define DONT_USE_RAID #include <global.h> #if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) #include <winsock.h> @@ -25,9 +24,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #if !defined(MSDOS) && !defined(__WIN__) #include <sys/socket.h> #include <netinet/in.h> -#ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> -#endif #include <netdb.h> #ifdef HAVE_SELECT_H # include <select.h> @@ -50,7 +47,7 @@ static my_bool mysql_client_init=0; uint mysql_port=0; my_string mysql_unix_port=0; -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS) +#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS) #ifdef __WIN__ #define CONNECT_TIMEOUT 20 @@ -59,14 +56,12 @@ my_string mysql_unix_port=0; #endif #if defined(MSDOS) || defined(__WIN__) -#define ERRNO WSAGetLastError() +// socket_errno is defined in global.h for all platforms #define perror(A) #else #include <errno.h> -#define ERRNO errno #define SOCKET_ERROR -1 -#define closesocket(A) close(A) -#endif +#endif /* __WIN__ */ static void mysql_once_init(void); static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields, @@ -109,7 +104,7 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, static int connect2(my_socket s, const struct sockaddr *name, uint namelen, uint timeout) { -#if defined(__WIN__) +#if defined(__WIN__) || defined(OS2) return connect(s, (struct sockaddr*) name, namelen); #else int flags, res, s_err; @@ -275,7 +270,7 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, ** or packet is an error message *****************************************************************************/ -static uint +uint net_safe_read(MYSQL *mysql) { NET *net= &mysql->net; @@ -405,7 +400,7 @@ static void free_rows(MYSQL_DATA *cur) } -static int +int simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, uint length, my_bool skipp_check) { @@ -441,7 +436,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, if (net_write_command(net,(uchar) command,arg, length ? length : (ulong) strlen(arg))) { - DBUG_PRINT("error",("Can't send command to server. Error: %d",errno)); + DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno)); end_server(mysql); if (mysql_reconnect(mysql) || net_write_command(net,(uchar) command,arg, @@ -478,7 +473,7 @@ struct passwd *getpwuid(uid_t); char* getlogin(void); #endif -#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) +#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2) static void read_user_name(char *name) { DBUG_ENTER("read_user_name"); @@ -662,11 +657,12 @@ mysql_free_result(MYSQL_RES *result) ****************************************************************************/ static const char *default_options[]= -{"port","socket","compress","password","pipe", "timeout", "user", - "init-command", "host", "database", "debug", "return-found-rows", - "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", - "character-set-dir", "default-character-set", "interactive-timeout", - "connect_timeout", +{ + "port","socket","compress","password","pipe", "timeout", "user", + "init-command", "host", "database", "debug", "return-found-rows", + "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", + "character-set-dir", "default-character-set", "interactive-timeout", + "connect-timeout", "local-infile", "disable-local-infile", NullS }; @@ -701,6 +697,9 @@ static void mysql_read_default_options(struct st_mysql_options *options, opt_arg=end+1; *end=0; /* Remove '=' */ } + /* Change all '_' in variable name to '-' */ + for (end= *option ; (end= strcend(end,'_')) ; ) + *end= '-'; switch (find_type(*option+2,&option_types,2)) { case 1: /* port */ if (opt_arg) @@ -798,7 +797,16 @@ static void mysql_read_default_options(struct st_mysql_options *options, options->charset_name = my_strdup(opt_arg, MYF(MY_WME)); break; case 19: /* Interactive-timeout */ - options->client_flag|=CLIENT_INTERACTIVE; + options->client_flag|= CLIENT_INTERACTIVE; + break; + case 21: + if (!opt_arg || atoi(opt_arg) != 0) + options->client_flag|= CLIENT_LOCAL_FILES; + else + options->client_flag&= ~CLIENT_LOCAL_FILES; + break; + case 22: + options->client_flag&= CLIENT_LOCAL_FILES; break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); @@ -993,10 +1001,18 @@ mysql_init(MYSQL *mysql) else bzero((char*) (mysql),sizeof(*(mysql))); mysql->options.connect_timeout=CONNECT_TIMEOUT; -#if defined(SIGPIPE) && defined(THREAD) +#if defined(SIGPIPE) && defined(THREAD) && !defined(__WIN__) if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE)) (void) signal(SIGPIPE,pipe_sig_handler); #endif + +/* + Only enable LOAD DATA INFILE by default if configured with + --with-enabled-local-inflile +*/ +#ifdef ENABLED_LOCAL_INFILE + mysql->options.client_flag|= CLIENT_LOCAL_FILES; +#endif return mysql; } @@ -1034,7 +1050,7 @@ static void mysql_once_init() mysql_unix_port = env; } mysql_debug(NullS); -#if defined(SIGPIPE) && !defined(THREAD) +#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__) (void) signal(SIGPIPE,SIG_IGN); #endif } @@ -1203,7 +1219,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) { net->last_errno=CR_SOCKET_CREATE_ERROR; - sprintf(net->last_error,ER(net->last_errno),ERRNO); + sprintf(net->last_error,ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); @@ -1213,9 +1229,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), mysql->options.connect_timeout) <0) { - DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO)); + DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno)); net->last_errno=CR_CONNECTION_ERROR; - sprintf(net->last_error,ER(net->last_errno),unix_socket,ERRNO); + sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); goto error; } } @@ -1266,7 +1282,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) { net->last_errno=CR_IPSOCK_ERROR; - sprintf(net->last_error,ER(net->last_errno),ERRNO); + sprintf(net->last_error,ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); @@ -1303,7 +1319,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (!(hp=gethostbyname(host))) { net->last_errno=CR_UNKNOWN_HOST; - sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, errno); + sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno); goto error; } memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); @@ -1313,9 +1329,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), mysql->options.connect_timeout) <0) { - DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host)); + DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,host)); net->last_errno= CR_CONN_HOST_ERROR; - sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO); + sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); goto error; } } @@ -1385,7 +1401,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, charset_name=charset_name_buff; sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */ if (!(mysql->charset = - get_charset((uint8) mysql->server_language, MYF(0)))) + get_charset((uint8) mysql->server_language, MYF(MY_WME)))) mysql->charset = default_charset_info; /* shouldn't be fatal */ } @@ -1444,7 +1460,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if (mysql->options.use_ssl) client_flag|=CLIENT_SSL; #endif /* HAVE_OPENSSL */ - if (db) client_flag|=CLIENT_CONNECT_WITH_DB; #ifdef HAVE_COMPRESS @@ -1563,13 +1578,13 @@ static my_bool mysql_reconnect(MYSQL *mysql) } mysql_init(&tmp_mysql); tmp_mysql.options=mysql->options; + bzero((char*) &mysql->options,sizeof(mysql->options)); if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, mysql->client_flag)) DBUG_RETURN(1); tmp_mysql.free_me=mysql->free_me; mysql->free_me=0; - bzero((char*) &mysql->options,sizeof(mysql->options)); mysql_close(mysql); *mysql=tmp_mysql; net_clear(&mysql->net); @@ -1800,7 +1815,7 @@ send_file_to_server(MYSQL *mysql, const char *filename) if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net)) { mysql->net.last_errno=CR_SERVER_LOST; - sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno); + sprintf(mysql->net.last_error,ER(mysql->net.last_errno),socket_errno); my_free(tmp_name,MYF(0)); DBUG_RETURN(-1); } @@ -1946,6 +1961,8 @@ mysql_fetch_row(MYSQL_RES *res) DBUG_PRINT("info",("end of data")); res->eof=1; res->handle->status=MYSQL_STATUS_READY; + /* Don't clear handle in mysql_free_results */ + res->handle=0; } } DBUG_RETURN((MYSQL_ROW) NULL); @@ -2256,11 +2273,17 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) mysql->options.connect_timeout= *(uint*) arg; break; case MYSQL_OPT_COMPRESS: - mysql->options.compress=1; /* Remember for connect */ + mysql->options.compress= 1; /* Remember for connect */ break; case MYSQL_OPT_NAMED_PIPE: mysql->options.named_pipe=1; /* Force named pipe */ break; + case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/ + if (!arg || test(*(uint*) arg)) + mysql->options.client_flag|= CLIENT_LOCAL_FILES; + else + mysql->options.client_flag&= ~CLIENT_LOCAL_FILES; + break; case MYSQL_INIT_COMMAND: my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR)); mysql->options.init_command=my_strdup(arg,MYF(MY_WME)); diff --git a/ext/mysql/libmysql/list.c b/ext/mysql/libmysql/list.c index 79bc7da4c5..fce5455ab8 100644 --- a/ext/mysql/libmysql/list.c +++ b/ext/mysql/libmysql/list.c @@ -58,11 +58,11 @@ void list_free(LIST *root, pbool free_data) LIST *list_cons(void *data, LIST *list) { - LIST *new=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE)); - if (!new) + LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE)); + if (!new_charset) return 0; - new->data=data; - return list_add(list,new); + new_charset->data=data; + return list_add(list,new_charset); } diff --git a/ext/mysql/libmysql/m_string.h b/ext/mysql/libmysql/m_string.h index 1bc3144fdb..64aa183a7d 100644 --- a/ext/mysql/libmysql/m_string.h +++ b/ext/mysql/libmysql/m_string.h @@ -55,10 +55,6 @@ This file is public domain and comes with NO WARRANTY of any kind */ # define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */ #endif -#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread) -#define strmov(A,B) stpcpy((A),(B)) -#endif - /* Unixware 7 */ #if !defined(HAVE_BFILL) # define bfill(A,B,C) memset((A),(C),(B)) @@ -72,10 +68,17 @@ This file is public domain and comes with NO WARRANTY of any kind */ # define bmove_allign(A,B,C) memcpy((A),(B),(C)) #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(OS2) extern "C" { #endif +#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread) +#define strmov(A,B) stpcpy((A),(B)) +#ifndef stpcpy +extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */ +#endif +#endif + extern char NEAR _dig_vec[]; /* Declared in int2str() */ #ifdef BAD_STRING_COMPILER @@ -134,7 +137,7 @@ extern void bchange(char *dst,uint old_len,const char *src, uint new_len,uint tot_len); extern void strappend(char *s,uint len,pchar fill); extern char *strend(const char *s); -extern char *strcend(const char *, pchar); +extern char *strcend(const char *, pchar); extern char *strfield(char *src,int fields,int chars,int blanks, int tabch); extern char *strfill(my_string s,uint len,pchar fill); @@ -221,7 +224,7 @@ extern ulonglong strtoull(const char *str, char **ptr, int base); #endif #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(OS2) } #endif #endif diff --git a/ext/mysql/libmysql/mf_casecnv.c b/ext/mysql/libmysql/mf_casecnv.c index 3b8e6c6a75..3abc6ae0f0 100644 --- a/ext/mysql/libmysql/mf_casecnv.c +++ b/ext/mysql/libmysql/mf_casecnv.c @@ -11,20 +11,23 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include "mysys_priv.h" #include <m_ctype.h> +#include <m_string.h> /* string to uppercase */ void caseup_str(my_string str) { #ifdef USE_MB - register uint32 l; - register char *end=str+(uint) strlen(str); if (use_mb(default_charset_info)) + { + register uint32 l; + register char *end=str+(uint) strlen(str); while (*str) { if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; else *str=toupper(*str),++str; } + } else #endif while ((*str = toupper(*str)) != 0) @@ -36,14 +39,16 @@ void caseup_str(my_string str) void casedn_str(my_string str) { #ifdef USE_MB - register uint32 l; - register char *end=str+(uint) strlen(str); if (use_mb(default_charset_info)) + { + register uint32 l; + register char *end=str+(uint) strlen(str); while (*str) { if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; else *str=tolower(*str),++str; } + } else #endif while ((*str= tolower(*str)) != 0) @@ -56,14 +61,16 @@ void casedn_str(my_string str) void caseup(my_string str, uint length) { #ifdef USE_MB - register uint32 l; - register char *end=str+length; if (use_mb(default_charset_info)) + { + register uint32 l; + register char *end=str+length; while (str<end) { if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; else *str=toupper(*str),++str; } + } else #endif for ( ; length>0 ; length--, str++) @@ -75,14 +82,16 @@ void caseup(my_string str, uint length) void casedn(my_string str, uint length) { #ifdef USE_MB - register uint32 l; - register char *end=str+length; if (use_mb(default_charset_info)) + { + register uint32 l; + register char *end=str+length; while (str<end) { if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; else *str=tolower(*str),++str; } + } else #endif for ( ; length>0 ; length--, str++) @@ -129,10 +138,10 @@ skipp: int my_strcasecmp(const char *s, const char *t) { #ifdef USE_MB - register uint32 l; - register const char *end=s+(uint) strlen(s); if (use_mb(default_charset_info)) { + register uint32 l; + register const char *end=s+(uint) strlen(s); while (s<end) { if ((l=my_ismbchar(default_charset_info, s,end))) @@ -158,10 +167,10 @@ int my_strcasecmp(const char *s, const char *t) int my_casecmp(const char *s, const char *t, uint len) { #ifdef USE_MB - register uint32 l; - register const char *end=s+len; if (use_mb(default_charset_info)) { + register uint32 l; + register const char *end=s+len; while (s<end) { if ((l=my_ismbchar(default_charset_info, s,end))) diff --git a/ext/mysql/libmysql/mf_dirname.c b/ext/mysql/libmysql/mf_dirname.c index f4a330ad1b..88f6101cbe 100644 --- a/ext/mysql/libmysql/mf_dirname.c +++ b/ext/mysql/libmysql/mf_dirname.c @@ -10,7 +10,7 @@ uint dirname_length(const char *name) { register my_string pos,gpos; #ifdef FN_DEVCHAR - if ((pos=strrchr(name,FN_DEVCHAR)) == 0) + if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0) #endif pos=(char*) name-1; diff --git a/ext/mysql/libmysql/mf_format.c b/ext/mysql/libmysql/mf_format.c index 21ba545797..7b2336e36e 100644 --- a/ext/mysql/libmysql/mf_format.c +++ b/ext/mysql/libmysql/mf_format.c @@ -51,7 +51,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk, pack_dirname(dev,dev); /* Put in ./.. and ~/.. */ if (flag & 4) (void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */ - if ((pos=strchr(name,FN_EXTCHAR)) != NullS) + if ((pos=(char*)strchr(name,FN_EXTCHAR)) != NullS) { if ((flag & 2) == 0) /* Skall vi byta extension ? */ { diff --git a/ext/mysql/libmysql/mf_path.c b/ext/mysql/libmysql/mf_path.c index c81bfaee04..6258c28df9 100644 --- a/ext/mysql/libmysql/mf_path.c +++ b/ext/mysql/libmysql/mf_path.c @@ -60,7 +60,7 @@ my_string my_path(my_string to, const char *progname, /* test if file without filename is found in path */ /* Returns to if found and to has dirpart if found, else NullS */ -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) #define F_OK 0 #define PATH_SEP ';' #define PROGRAM_EXTENSION ".exe" diff --git a/ext/mysql/libmysql/my_compress.c b/ext/mysql/libmysql/my_compress.c index 3aa7ba9491..79e8ceac7c 100644 --- a/ext/mysql/libmysql/my_compress.c +++ b/ext/mysql/libmysql/my_compress.c @@ -6,6 +6,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <global.h> #ifdef HAVE_COMPRESS #include <my_sys.h> +#include <m_string.h> #include <zlib.h> /* diff --git a/ext/mysql/libmysql/my_create.c b/ext/mysql/libmysql/my_create.c index a0a24f6ad9..a779b3f142 100644 --- a/ext/mysql/libmysql/my_create.c +++ b/ext/mysql/libmysql/my_create.c @@ -6,7 +6,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <my_dir.h> #include "mysys_err.h" #include <errno.h> -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) #include <share.h> #endif @@ -34,7 +34,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags, #elif defined(VMS) fd = open((my_string) FileName, access_flags | O_CREAT, 0, "ctx=stm","ctx=bin"); -#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) if (access_flags & O_SHARE) fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); diff --git a/ext/mysql/libmysql/my_getwd.c b/ext/mysql/libmysql/my_getwd.c index 9e87c4d201..9b5869e8f0 100644 --- a/ext/mysql/libmysql/my_getwd.c +++ b/ext/mysql/libmysql/my_getwd.c @@ -14,6 +14,9 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <dos.h> #include <direct.h> #endif +#if defined(OS2) +#include <direct.h> +#endif #ifdef __EMX__ // chdir2 support also drive change @@ -79,16 +82,16 @@ int my_setwd(const char *dir, myf MyFlags) int res; size_s length; my_string start,pos; -#if defined(VMS) || defined(MSDOS) +#if defined(VMS) || defined(MSDOS) || defined(OS2) char buff[FN_REFLEN]; #endif DBUG_ENTER("my_setwd"); DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags)); start=(my_string) dir; -#if defined(MSDOS) /* MSDOS chdir can't change drive */ +#if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */ #if !defined(_DDL) && !defined(WIN32) - if ((pos=strchr(dir,FN_DEVCHAR)) != 0) + if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0) { uint drive,drives; @@ -96,8 +99,13 @@ int my_setwd(const char *dir, myf MyFlags) drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1; if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32) { +#ifdef OS2 + _chdrive(drive); + drives = _getdrive(); +#else _dos_setdrive(drive,&drives); _dos_getdrive(&drives); +#endif } if (drive != drives) { diff --git a/ext/mysql/libmysql/my_init.c b/ext/mysql/libmysql/my_init.c index 9bccb2c652..472721c952 100644 --- a/ext/mysql/libmysql/my_init.c +++ b/ext/mysql/libmysql/my_init.c @@ -60,7 +60,7 @@ void my_init(void) pthread_init(); /* Must be called before DBUG_ENTER */ #endif my_thread_global_init(); -#ifndef __WIN__ +#if !defined( __WIN__) && !defined(OS2) sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif #endif /* THREAD */ @@ -112,6 +112,7 @@ void my_end(int infoflag) DBUG_PRINT("error",("%s",errbuff[0])); } } + free_charsets(); if (infoflag & MY_GIVE_INFO || info_file != stderr) { #ifdef HAVE_GETRUSAGE @@ -136,7 +137,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", #if defined(MSDOS) && !defined(__WIN__) fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif - free_charsets(); #if defined(SAFEMALLOC) TERMINATE(stderr); /* Give statistic on screen */ #elif defined(__WIN__) && defined(_MSC_VER) diff --git a/ext/mysql/libmysql/my_lib.c b/ext/mysql/libmysql/my_lib.c index 764309d120..259a7222b4 100644 --- a/ext/mysql/libmysql/my_lib.c +++ b/ext/mysql/libmysql/my_lib.c @@ -13,7 +13,9 @@ This file is public domain and comes with NO WARRANTY of any kind */ # include <dirent.h> # define NAMLEN(dirent) strlen((dirent)->d_name) #else +#ifndef OS2 # define dirent direct +#endif # define NAMLEN(dirent) (dirent)->d_namlen # if defined(HAVE_SYS_NDIR_H) # include <sys/ndir.h> @@ -36,6 +38,11 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <iodef.h> #include <descrip.h> #endif + +#ifdef OS2 +#include "my_os2dirsrch.h" +#endif + #if defined(THREAD) && defined(HAVE_READDIR_R) #define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C) #else @@ -323,9 +330,7 @@ my_string directory_file_name (my_string dst, const char *src) ***************************************************************************** */ -MY_DIR *my_dir(path, MyFlags) -const char *path; -myf MyFlags; +MY_DIR *my_dir(const char *path, myf MyFlags) { struct fileinfo *fnames; char *buffer, *obuffer, *tempptr; @@ -461,9 +466,7 @@ error: ** At MSDOS you always get stat of files, but time is in packed MSDOS-format ******************************************************************************/ -MY_DIR *my_dir(path, MyFlags) -const char *path; -myf MyFlags; +MY_DIR *my_dir(const char* path, myf MyFlags) { struct fileinfo *fnames; char *buffer, *obuffer, *tempptr; diff --git a/ext/mysql/libmysql/my_malloc.c b/ext/mysql/libmysql/my_malloc.c index 46c874aa66..cb006e31e4 100644 --- a/ext/mysql/libmysql/my_malloc.c +++ b/ext/mysql/libmysql/my_malloc.c @@ -19,7 +19,7 @@ gptr my_malloc(unsigned int Size, myf MyFlags) if (!Size) Size=1; /* Safety */ - if ((point = malloc(Size)) == NULL) + if ((point = (char*)malloc(Size)) == NULL) { my_errno=errno; if (MyFlags & MY_FAE) diff --git a/ext/mysql/libmysql/my_open.c b/ext/mysql/libmysql/my_open.c index 49d7735818..901f0122c8 100644 --- a/ext/mysql/libmysql/my_open.c +++ b/ext/mysql/libmysql/my_open.c @@ -6,7 +6,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include "mysys_err.h" #include <my_dir.h> #include <errno.h> -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) #include <share.h> #endif @@ -21,7 +21,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags) DBUG_ENTER("my_open"); DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", FileName, Flags, MyFlags)); -#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) if (Flags & O_SHARE) fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); @@ -61,8 +61,8 @@ int my_close(File fd, myf MyFlags) pthread_mutex_destroy(&my_file_info[fd].mutex); #endif my_file_info[fd].type = UNOPEN; - my_file_opened--; } + my_file_opened--; pthread_mutex_unlock(&THR_LOCK_open); DBUG_RETURN(err); } /* my_close */ @@ -82,9 +82,8 @@ File my_register_filename(File fd, const char *FileName, enum file_type my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG), FileName, my_errno); return(-1); -#else - thread_safe_increment(my_file_opened,&THR_LOCK_open); #endif + thread_safe_increment(my_file_opened,&THR_LOCK_open); return(fd); /* safeguard */ } pthread_mutex_lock(&THR_LOCK_open); diff --git a/ext/mysql/libmysql/my_pthread.c b/ext/mysql/libmysql/my_pthread.c index 367542ee8d..d1f580071b 100644 --- a/ext/mysql/libmysql/my_pthread.c +++ b/ext/mysql/libmysql/my_pthread.c @@ -131,7 +131,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res) ** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty ****************************************************************************/ -#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) +#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(OS2) #if !defined(DONT_USE_SIGSUSPEND) diff --git a/ext/mysql/libmysql/my_pthread.h b/ext/mysql/libmysql/my_pthread.h index 3b451dca51..655ebbf703 100644 --- a/ext/mysql/libmysql/my_pthread.h +++ b/ext/mysql/libmysql/my_pthread.h @@ -11,9 +11,23 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define ETIME ETIMEDOUT /* For FreeBSD */ #endif -#if defined(__WIN__) +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#if defined(__WIN__) || defined(OS2) + +#ifdef OS2 +typedef ULONG HANDLE; +typedef ULONG DWORD; +typedef int sigset_t; +#endif + +#ifdef OS2 +typedef HMTX pthread_mutex_t; +#else typedef CRITICAL_SECTION pthread_mutex_t; +#endif typedef HANDLE pthread_t; typedef struct thread_attr { DWORD dwStackSize ; @@ -32,19 +46,30 @@ typedef struct st_pthread_link { typedef struct { uint32 waiting; +#ifdef OS2 + HEV semaphore; +#else HANDLE semaphore; +#endif } pthread_cond_t; +#ifndef OS2 struct timespec { /* For pthread_cond_timedwait() */ time_t tv_sec; long tv_nsec; }; +#endif typedef int pthread_mutexattr_t; #define win_pthread_self my_thread_var->pthread_self +#ifdef OS2 +#define pthread_handler_decl(A,B) void * _Optlink A(void *B) +typedef void * (_Optlink *pthread_handler)(void *); +#else #define pthread_handler_decl(A,B) void * __cdecl A(void *B) typedef void * (__cdecl *pthread_handler)(void *); +#endif void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); @@ -64,12 +89,14 @@ struct tm *localtime_r(const time_t *timep,struct tm *tmp); void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ +#ifndef OS2 #define ETIMEDOUT 145 /* Win32 doesn't have this */ #define getpid() GetCurrentThreadId() +#endif #define pthread_self() win_pthread_self -#define HAVE_LOCALTIME_R -#define _REENTRANT -#define HAVE_PTHREAD_ATTR_SETSTACKSIZE +#define HAVE_LOCALTIME_R 1 +#define _REENTRANT 1 +#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #ifdef USE_TLS /* For LIBMYSQL.DLL */ #undef SAFE_MUTEX /* This will cause conflicts */ @@ -91,13 +118,24 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ #endif /* USE_TLS */ #define pthread_equal(A,B) ((A) == (B)) +#ifdef OS2 +int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *); +int pthread_mutex_lock (pthread_mutex_t *); +int pthread_mutex_unlock (pthread_mutex_t *); +int pthread_mutex_destroy (pthread_mutex_t *); +#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A) +#define pthread_kill(A,B) raise(B) +#define pthread_exit(A) pthread_dummy() +#else #define pthread_mutex_init(A,B) InitializeCriticalSection(A) #define pthread_mutex_lock(A) (EnterCriticalSection(A),0) #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) -/* Dummy defines for easier code */ #define pthread_kill(A,B) pthread_dummy(0) +#endif /* OS2 */ + +/* Dummy defines for easier code */ #define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B) #define pthread_attr_setscope(A,B) @@ -297,12 +335,15 @@ extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority); #undef HAVE_GETHOSTBYADDR_R /* No definition */ #endif -#ifndef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC +#if defined(OS2) +#define my_pthread_getspecific(T,A) ((T) &(A)) +#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A)) +#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC) #define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B)) #else #define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B)) void *my_pthread_getspecific_imp(pthread_key_t key); -#endif +#endif /* OS2 */ #ifndef HAVE_LOCALTIME_R struct tm *localtime_r(const time_t *clock, struct tm *res); @@ -521,12 +562,14 @@ extern int pthread_dummy(int); struct st_my_thread_var { int thr_errno; - pthread_cond_t suspend, *current_cond; - pthread_mutex_t mutex, *current_mutex; + pthread_cond_t suspend; + pthread_mutex_t mutex; + pthread_mutex_t * volatile current_mutex; + pthread_cond_t * volatile current_cond; pthread_t pthread_self; long id; int cmp_length; - volatile int abort; + int volatile abort; #ifndef DBUG_OFF gptr dbug; char name[THREAD_NAME_SIZE+1]; @@ -562,4 +605,9 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); #endif /* SAFE_STATISTICS */ #endif /* HAVE_ATOMIC_ADD */ #endif /* thread_safe_increment */ + +#ifdef __cplusplus +} +#endif + #endif /* _my_ptread_h */ diff --git a/ext/mysql/libmysql/my_realloc.c b/ext/mysql/libmysql/my_realloc.c index 48df8d3651..7e85c1c861 100644 --- a/ext/mysql/libmysql/my_realloc.c +++ b/ext/mysql/libmysql/my_realloc.c @@ -35,7 +35,7 @@ gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags) free(oldpoint); } #else - if ((point = realloc(oldpoint,Size)) == NULL) + if ((point = (char*)realloc(oldpoint,Size)) == NULL) { if (MyFlags & MY_FREE_ON_ERROR) my_free(oldpoint,MyFLAGS); diff --git a/ext/mysql/libmysql/my_static.c b/ext/mysql/libmysql/my_static.c index 418345fa77..92cdac6d93 100644 --- a/ext/mysql/libmysql/my_static.c +++ b/ext/mysql/libmysql/my_static.c @@ -6,7 +6,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ a shared library */ -#ifndef stdin +#if !defined(stdin) || defined(OS2) #include "mysys_priv.h" #include "my_static.h" #include "my_alarm.h" @@ -83,4 +83,5 @@ int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= my_bool NEAR my_disable_locking=0; my_bool NEAR my_disable_async_io=0; my_bool NEAR my_disable_flush_key_blocks=0; +my_bool NEAR my_disable_symlinks=0; my_bool NEAR mysys_uses_curses=0; diff --git a/ext/mysql/libmysql/my_sys.h b/ext/mysql/libmysql/my_sys.h index 5a2689da2a..8f9f0c35fd 100644 --- a/ext/mysql/libmysql/my_sys.h +++ b/ext/mysql/libmysql/my_sys.h @@ -112,6 +112,7 @@ extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; extern ulonglong safemalloc_mem_limit; #else #define my_checkmalloc() (0) +#undef TERMINATE #define TERMINATE(A) {} #define QUICK_SAFEMALLOC #define NORMAL_SAFEMALLOC @@ -194,7 +195,7 @@ extern long lCurMemory,lMaxMemory; /* from safemalloc */ extern ulong my_default_record_cache_size; extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, - NEAR my_disable_flush_key_blocks; + NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; extern char wild_many,wild_one,wild_prefix; extern const char *charsets_dir; extern char *defaults_extra_file; @@ -371,6 +372,8 @@ extern int my_realpath(char *to, const char *filename, myf MyFlags); extern File my_create_with_symlink(const char *linkname, const char *filename, int createflags, int access_flags, myf MyFlags); +extern int my_delete_with_symlink(const char *name, myf MyFlags); +extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); extern int my_symlink(const char *content, const char *linkname, myf MyFlags); extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, diff --git a/ext/mysql/libmysql/my_tempnam.c b/ext/mysql/libmysql/my_tempnam.c index f6296398ee..6dca387fa1 100644 --- a/ext/mysql/libmysql/my_tempnam.c +++ b/ext/mysql/libmysql/my_tempnam.c @@ -1,6 +1,13 @@ /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */ +/* + This function is only used by some old ISAM code. + When we remove ISAM support from MySQL, we should also delete this file + + One should instead use the functions in mf_tempfile.c +*/ + #include "mysys_priv.h" #include <m_string.h> #include "my_static.h" @@ -12,7 +19,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #endif #ifdef HAVE_TEMPNAM -#ifndef MSDOS +#if !defined( MSDOS) && !defined(OS2) extern char **environ; #endif #endif @@ -77,14 +84,26 @@ my_string my_tempnam(const char *dir, const char *pfx, temp[1]= 0; dir=temp; } - old_env=environ; +#ifdef OS2 + // changing environ variable doesn't work with VACPP + char buffer[256]; + sprintf( buffer, "TMP=%s", dir); + // remove ending backslash + if (buffer[strlen(buffer)-1] == '\\') + buffer[strlen(buffer)-1] = '\0'; + putenv( buffer); +#else + old_env=(char**)environ; if (dir) { /* Don't use TMPDIR if dir is given */ - environ=temp_env; + environ=(const char**)temp_env; /* May give warning */ temp_env[0]=0; } +#endif res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */ - environ=old_env; +#ifndef OS2 + environ=(const char**)old_env; /* May give warning */ +#endif if (!res) DBUG_PRINT("error",("Got error: %d from tempnam",errno)); return res; diff --git a/ext/mysql/libmysql/my_thr_init.c b/ext/mysql/libmysql/my_thr_init.c index 0d0e755bcd..a5b40a2d61 100644 --- a/ext/mysql/libmysql/my_thr_init.c +++ b/ext/mysql/libmysql/my_thr_init.c @@ -58,7 +58,7 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) win_pthread_init(); #endif #ifndef HAVE_LOCALTIME_R @@ -146,11 +146,11 @@ void my_thread_end(void) pthread_cond_destroy(&tmp->suspend); #endif pthread_mutex_destroy(&tmp->mutex); -#if !defined(__WIN__) || defined(USE_TLS) +#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) free(tmp); #endif } -#if !defined(__WIN__) || defined(USE_TLS) +#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) pthread_setspecific(THR_KEY_mysys,0); #endif } diff --git a/ext/mysql/libmysql/my_wincond.c b/ext/mysql/libmysql/my_wincond.c index 555ab3bcf7..e69de29bb2 100644 --- a/ext/mysql/libmysql/my_wincond.c +++ b/ext/mysql/libmysql/my_wincond.c @@ -1,128 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/***************************************************************************** -** The following is a simple implementation of posix conditions -*****************************************************************************/ - -#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */ -#include "mysys_priv.h" -#if defined(THREAD) && defined(__WIN__) -#include <m_string.h> -#undef getpid -#include <process.h> -#include <sys/timeb.h> - -int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) -{ - cond->waiting=0; - cond->semaphore=CreateSemaphore(NULL,0,0x7FFFFFFF,NullS); - if (!cond->semaphore) - return ENOMEM; - return 0; -} - -int pthread_cond_destroy(pthread_cond_t *cond) -{ - return CloseHandle(cond->semaphore) ? 0 : EINVAL; -} - - -int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) -{ - InterlockedIncrement(&cond->waiting); - LeaveCriticalSection(mutex); - WaitForSingleObject(cond->semaphore,INFINITE); - InterlockedDecrement(&cond->waiting); - EnterCriticalSection(mutex); - return 0 ; -} - -int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime) -{ - struct _timeb curtime; - int result; - long timeout; - _ftime(&curtime); - timeout= ((long) (abstime->tv_sec - curtime.time)*1000L + - (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L); - if (timeout < 0) /* Some safety */ - timeout = 0L; - InterlockedIncrement(&cond->waiting); - LeaveCriticalSection(mutex); - result=WaitForSingleObject(cond->semaphore,timeout); - InterlockedDecrement(&cond->waiting); - EnterCriticalSection(mutex); - - return result == WAIT_TIMEOUT ? ETIMEDOUT : 0; -} - - -int pthread_cond_signal(pthread_cond_t *cond) -{ - long prev_count; - if (cond->waiting) - ReleaseSemaphore(cond->semaphore,1,&prev_count); - return 0; -} - - -int pthread_cond_broadcast(pthread_cond_t *cond) -{ - long prev_count; - if (cond->waiting) - ReleaseSemaphore(cond->semaphore,cond->waiting,&prev_count); - return 0 ; -} - - -int pthread_attr_init(pthread_attr_t *connect_att) -{ - connect_att->dwStackSize = 0; - connect_att->dwCreatingFlag = 0; - connect_att->priority = 0; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack) -{ - connect_att->dwStackSize=stack; - return 0; -} - -int pthread_attr_setprio(pthread_attr_t *connect_att,int priority) -{ - connect_att->priority=priority; - return 0; -} - -int pthread_attr_destroy(pthread_attr_t *connect_att) -{ - bzero((gptr) connect_att,sizeof(*connect_att)); - return 0; -} - -/**************************************************************************** -** Fix localtime_r() to be a bit safer -****************************************************************************/ - -struct tm *localtime_r(const time_t *timep,struct tm *tmp) -{ - if (*timep == (time_t) -1) /* This will crash win32 */ - { - bzero(tmp,sizeof(*tmp)); - } - else - { - struct tm *res=localtime(timep); - if (!res) /* Wrong date */ - { - bzero(tmp,sizeof(*tmp)); /* Keep things safe */ - return 0; - } - *tmp= *res; - } - return tmp; -} -#endif /* __WIN__ */ diff --git a/ext/mysql/libmysql/my_winthread.c b/ext/mysql/libmysql/my_winthread.c index 5d06b698ee..e69de29bb2 100644 --- a/ext/mysql/libmysql/my_winthread.c +++ b/ext/mysql/libmysql/my_winthread.c @@ -1,105 +0,0 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -This file is public domain and comes with NO WARRANTY of any kind */ - -/***************************************************************************** -** Simulation of posix threads calls for WIN95 and NT -*****************************************************************************/ - -/* SAFE_MUTEX will not work until the thread structure is up to date */ -#undef SAFE_MUTEX - -#include "mysys_priv.h" -#if defined(THREAD) && defined(__WIN__) -#include <m_string.h> -#undef getpid -#include <process.h> - -static pthread_mutex_t THR_LOCK_thread; - -struct pthread_map -{ - HANDLE pthreadself; - pthread_handler func; - void *param; -}; - -void win_pthread_init(void) -{ - pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); -} - -/* -** We have tried to use '_beginthreadex' instead of '_beginthread' here -** but in this case the program leaks about 512 characters for each -** created thread ! -** As we want to save the created thread handler for other threads to -** use and to be returned by pthread_self() (instead of the Win32 pseudo -** handler), we have to go trough pthread_start() to catch the returned handler -** in the new thread. -*/ - -static pthread_handler_decl(pthread_start,param) -{ - pthread_handler func=((struct pthread_map *) param)->func; - void *func_param=((struct pthread_map *) param)->param; - my_thread_init(); /* Will always succeed in windows */ - pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */ - win_pthread_self=((struct pthread_map *) param)->pthreadself; - pthread_mutex_unlock(&THR_LOCK_thread); - free((char*) param); /* Free param from create */ - pthread_exit((void*) (*func)(func_param)); - return 0; /* Safety */ -} - - -int pthread_create(pthread_t *thread_id, pthread_attr_t *attr, - pthread_handler func, void *param) -{ - HANDLE hThread; - struct pthread_map *map; - DBUG_ENTER("pthread_create"); - - if (!(map=malloc(sizeof(*map)))) - DBUG_RETURN(-1); - map->func=func; - map->param=param; - pthread_mutex_lock(&THR_LOCK_thread); -#ifdef __BORLANDC__ - hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#else - hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#endif - DBUG_PRINT("info", ("hThread=%lu",(long) hThread)); - *thread_id=map->pthreadself=hThread; - pthread_mutex_unlock(&THR_LOCK_thread); - - if (hThread == (HANDLE) -1) - { - int error=errno; - DBUG_PRINT("error", - ("Can't create thread to handle request (error %d)",error)); - DBUG_RETURN(error ? error : -1); - } - VOID(SetThreadPriority(hThread, attr->priority)) ; - DBUG_RETURN(0); -} - - -void pthread_exit(void *a) -{ - _endthread(); -} - -/* This is neaded to get the macro pthread_setspecific to work */ - -int win_pthread_setspecific(void *a,void *b,uint length) -{ - memcpy(a,b,length); - return 0; -} - -#endif diff --git a/ext/mysql/libmysql/my_write.c b/ext/mysql/libmysql/my_write.c index d66e1da031..0aec283acc 100644 --- a/ext/mysql/libmysql/my_write.c +++ b/ext/mysql/libmysql/my_write.c @@ -5,6 +5,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include "mysys_err.h" #include <errno.h> + /* Write a chunk of bytes to a file */ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) diff --git a/ext/mysql/libmysql/mysql.h b/ext/mysql/libmysql/mysql.h index f44252c9c7..11e099e531 100644 --- a/ext/mysql/libmysql/mysql.h +++ b/ext/mysql/libmysql/mysql.h @@ -22,6 +22,9 @@ extern "C" { #ifndef _global_h /* If not standard header */ #include <sys/types.h> +#ifdef __LCC__ +#include <winsock.h> /* For windows */ +#endif typedef char my_bool; #if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) #define __WIN__ @@ -126,7 +129,8 @@ struct st_mysql_options { enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, - MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME}; + MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, + MYSQL_OPT_LOCAL_INFILE}; enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT}; diff --git a/ext/mysql/libmysql/mysql_com.h b/ext/mysql/libmysql/mysql_com.h index 0f6b5928db..75a07202c7 100644 --- a/ext/mysql/libmysql/mysql_com.h +++ b/ext/mysql/libmysql/mysql_com.h @@ -204,22 +204,19 @@ my_bool check_scramble(const char *, const char *message, unsigned long *salt,my_bool old_ver); char *get_tty_password(char *opt_message); void hash_password(unsigned long *result, const char *password); -#ifdef __cplusplus -} -#endif /* Some other useful functions */ void my_init(void); void load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv); +my_bool my_thread_init(void); +void my_thread_end(void); -#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ - -#ifdef __WIN__ -#define socket_errno WSAGetLastError() -#else -#define socket_errno errno +#ifdef __cplusplus +} #endif +#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ + #endif diff --git a/ext/mysql/libmysql/mysql_version.h b/ext/mysql/libmysql/mysql_version.h index 1587579818..27552b0db7 100644 --- a/ext/mysql/libmysql/mysql_version.h +++ b/ext/mysql/libmysql/mysql_version.h @@ -7,18 +7,12 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <custom_conf.h> #else #define PROTOCOL_VERSION 10 -#define MYSQL_SERVER_VERSION "3.23.39" +#define MYSQL_SERVER_VERSION "3.23.49" #define MYSQL_SERVER_SUFFIX "" #define FRM_VER 6 -#define MYSQL_VERSION_ID 32339 - -#ifndef MYSQL_PORT +#define MYSQL_VERSION_ID 32349 #define MYSQL_PORT 3306 -#endif - -#ifndef MYSQL_UNIX_ADDR #define MYSQL_UNIX_ADDR "/tmp/mysql.sock" -#endif /* mysqld compile time options */ #ifndef MYSQL_CHARSET diff --git a/ext/mysql/libmysql/mysqld_error.h b/ext/mysql/libmysql/mysqld_error.h index e412f95a8e..81e0dd1d06 100644 --- a/ext/mysql/libmysql/mysqld_error.h +++ b/ext/mysql/libmysql/mysqld_error.h @@ -208,4 +208,14 @@ #define ER_LOCK_WAIT_TIMEOUT 1205 #define ER_LOCK_TABLE_FULL 1206 #define ER_READ_ONLY_TRANSACTION 1207 -#define ER_ERROR_MESSAGES 208 +#define ER_DROP_DB_WITH_READ_LOCK 1208 +#define ER_CREATE_DB_WITH_READ_LOCK 1209 +#define ER_WRONG_ARGUMENTS 1210 +#define ER_NO_PERMISSION_TO_CREATE_USER 1211 +#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 +#define ER_LOCK_DEADLOCK 1213 +#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214 +#define ER_CANNOT_ADD_FOREIGN 1215 +#define ER_NO_REFERENCED_ROW 1216 +#define ER_ROW_IS_REFERENCED 1217 +#define ER_ERROR_MESSAGES 218 diff --git a/ext/mysql/libmysql/net.c b/ext/mysql/libmysql/net.c index 0dc0c06ffa..161fba4ace 100644 --- a/ext/mysql/libmysql/net.c +++ b/ext/mysql/libmysql/net.c @@ -20,6 +20,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <signal.h> #include <errno.h> #include <sys/types.h> +#include <violite.h> #ifdef MYSQL_SERVER ulong max_allowed_packet=65536; @@ -53,13 +54,19 @@ void sql_print_error(const char *format,...); #define RETRY_COUNT mysqld_net_retry_count extern ulong mysqld_net_retry_count; #else + +#ifdef OS2 /* avoid name conflict */ +#define thr_alarm_t thr_alarm_t_net +#define ALARM ALARM_net +#endif + typedef my_bool thr_alarm_t; typedef my_bool ALARM; -#define thr_alarm_init(A) (*A)=0 -#define thr_alarm_in_use(A) (*(A)) +#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) local_thr_alarm((A),(B),(C)) -static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) +inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) { *A=1; return 0; @@ -109,7 +116,7 @@ int my_net_init(NET *net, Vio* vio) if (vio != 0) /* If real connection */ { net->fd = vio_fd(vio); /* For perl DBI/DBD */ -#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) +#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) if (!(test_flags & TEST_BLOCKING)) vio_blocking(vio, FALSE); #endif @@ -256,7 +263,7 @@ net_real_write(NET *net,const char *packet,ulong len) int length; char *pos,*end; thr_alarm_t alarmed; -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) ALARM alarm_buff; #endif uint retry_count=0; @@ -314,7 +321,7 @@ net_real_write(NET *net,const char *packet,ulong len) if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0) { my_bool interrupted = vio_should_retry(net->vio); -#if (!defined(__WIN__) && !defined(__EMX__)) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed)) { if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff)) @@ -351,7 +358,7 @@ net_real_write(NET *net,const char *packet,ulong len) #endif /* EXTRA_DEBUG */ } #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) - if (vio_errno(net->vio) == EINTR) + if (vio_errno(net->vio) == SOCKET_EINTR) { DBUG_PRINT("warning",("Interrupted write. Retrying...")); continue; @@ -411,7 +418,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L) { my_bool interrupted = vio_should_retry(net->vio); - if (!thr_got_alarm(&alarmed) && interrupted) + if (!thr_got_alarm(alarmed) && interrupted) { /* Probably in MIT threads */ if (retry_count++ < RETRY_COUNT) continue; @@ -433,7 +440,7 @@ my_real_read(NET *net, ulong *complen) uint i,retry_count=0; ulong len=packet_error; thr_alarm_t alarmed; -#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) ALARM alarm_buff; #endif my_bool net_blocking=vio_is_blocking(net->vio); @@ -460,7 +467,7 @@ my_real_read(NET *net, ulong *complen) DBUG_PRINT("info",("vio_read returned %d, errno: %d", length, vio_errno(net->vio))); -#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) /* We got an error that there was no data on the socket. We now set up an alarm to not 'read forever', change the socket to non blocking diff --git a/ext/mysql/libmysql/raid.h b/ext/mysql/libmysql/raid.h index f6f5306392..caa9f743c6 100644 --- a/ext/mysql/libmysql/raid.h +++ b/ext/mysql/libmysql/raid.h @@ -19,7 +19,7 @@ const char *my_raid_type(int raid_type); } #endif -#ifdef USE_RAID +#if defined(USE_RAID) && !defined(DONT_USE_RAID) #ifdef __GNUC__ #pragma interface /* gcc class implementation */ diff --git a/ext/mysql/libmysql/strmake.c b/ext/mysql/libmysql/strmake.c index 789b9c6be9..8bfe104aa5 100644 --- a/ext/mysql/libmysql/strmake.c +++ b/ext/mysql/libmysql/strmake.c @@ -8,7 +8,8 @@ This file is public domain and comes with NO WARRANTY of any kind */ strmake(dst,src,length) moves length characters, or until end, of src to dst and appends a closing NUL to dst. - strmake() returns pointer to closing null; + Note that is strlen(src) >= length then dst[length] will be set to \0 + strmake() returns pointer to closing null */ #include <global.h> diff --git a/ext/mysql/libmysql/strto.c b/ext/mysql/libmysql/strto.c index 0e1af5d2e7..b858ef19ea 100644 --- a/ext/mysql/libmysql/strto.c +++ b/ext/mysql/libmysql/strto.c @@ -28,13 +28,17 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include "my_sys.h" /* defines errno */ #include <errno.h> -#ifdef MYSQL_LONGLONG +#undef strtoull +#undef strtoll +#undef strtoul +#undef strtol +#ifdef USE_LONGLONG #define UTYPE_MAX (~(ulonglong) 0) #define TYPE_MIN LONGLONG_MIN #define TYPE_MAX LONGLONG_MAX #define longtype longlong #define ulongtype ulonglong -#ifdef UNSIGNED +#ifdef USE_UNSIGNED #define function ulongtype strtoull #else #define function longtype strtoll @@ -45,7 +49,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define TYPE_MAX LONG_MAX #define longtype long #define ulongtype unsigned long -#ifdef UNSIGNED +#ifdef USE_UNSIGNED #define function ulongtype strtoul #else #define function longtype strtol @@ -156,7 +160,7 @@ function (const char *nptr,char **endptr,int base) if (endptr != NULL) *endptr = (char *) s; -#ifndef UNSIGNED +#ifndef USE_UNSIGNED /* Check for a value that is within the range of `unsigned long int', but outside the range of `long int'. */ if (negative) @@ -171,7 +175,7 @@ function (const char *nptr,char **endptr,int base) if (overflow) { my_errno=ERANGE; -#ifdef UNSIGNED +#ifdef USE_UNSIGNED return UTYPE_MAX; #else return negative ? TYPE_MIN : TYPE_MAX; @@ -179,7 +183,7 @@ function (const char *nptr,char **endptr,int base) } /* Return the result of the appropriate sign. */ - return (negative ? -((longtype) i) : i); + return (negative ? -((longtype) i) : (longtype) i); noconv: /* There was no number to convert. */ diff --git a/ext/mysql/libmysql/strtoll.c b/ext/mysql/libmysql/strtoll.c index 6acb8ff84d..d1d1e1e8b6 100644 --- a/ext/mysql/libmysql/strtoll.c +++ b/ext/mysql/libmysql/strtoll.c @@ -5,7 +5,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <global.h> #include <m_string.h> -#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG) -#define MYSQL_LONGLONG +#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG) +#define USE_LONGLONG #include "strto.c" #endif diff --git a/ext/mysql/libmysql/strtoull.c b/ext/mysql/libmysql/strtoull.c index 8ab99fb0c2..9dea75fd28 100644 --- a/ext/mysql/libmysql/strtoull.c +++ b/ext/mysql/libmysql/strtoull.c @@ -6,7 +6,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #include <global.h> #include <m_string.h> #if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG) -#define UNSIGNED -#define MYSQL_LONGLONG +#define USE_UNSIGNED +#define USE_LONGLONG #include "strto.c" #endif diff --git a/ext/mysql/libmysql/thr_alarm.h b/ext/mysql/libmysql/thr_alarm.h index b1f0b3e43b..c6d70029c5 100644 --- a/ext/mysql/libmysql/thr_alarm.h +++ b/ext/mysql/libmysql/thr_alarm.h @@ -51,7 +51,7 @@ typedef struct st_thr_alarm_entry rf_SetTimer crono; } thr_alarm_entry; -#elif defined(__EMX__) +#elif defined(__EMX__) || defined(OS2) typedef struct st_thr_alarm_entry { diff --git a/ext/mysql/libmysql/violite.c b/ext/mysql/libmysql/violite.c index e73efb7e8d..957f8400ac 100644 --- a/ext/mysql/libmysql/violite.c +++ b/ext/mysql/libmysql/violite.c @@ -21,25 +21,30 @@ This file is public domain and comes with NO WARRANTY of any kind */ #ifdef HAVE_POLL #include <sys/poll.h> #endif - -#if defined(__EMX__) +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> +#endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__FreeBSD__) +#include <netinet/in_systm.h> +#include <netinet/ip.h> +#if !defined(alpha_linux_port) +#include <netinet/tcp.h> +#endif +#endif + +#if defined(__EMX__) || defined(OS2) #define ioctlsocket ioctl -#endif /* defined(__EMX__) */ +#endif /* defined(__EMX__) */ #if defined(MSDOS) || defined(__WIN__) -#ifdef __WIN__ -#undef errno -#undef EINTR -#undef EAGAIN -#define errno WSAGetLastError() -#define EINTR WSAEINTR -#define EAGAIN WSAEINPROGRESS -#endif /* __WIN__ */ #define O_NONBLOCK 1 /* For emulation of fcntl() */ #endif #ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN +#define SOCKET_EWOULDBLOCK SOCKET_EAGAIN #endif #ifndef __WIN__ @@ -89,9 +94,12 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) sprintf(vio->desc, (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"), vio->sd); -#if !defined(___WIN__) && !defined(__EMX__) +#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) vio->fcntl_mode = fcntl(sd, F_GETFL); +#elif defined(HAVE_SYS_IOCTL_H) /* hpux */ + /* Non blocking sockets doesn't work good on HPUX 11.0 */ + (void) ioctl(sd,FIOSNBIO,0); #endif #else /* !defined(__WIN__) && !defined(__EMX__) */ { @@ -135,7 +143,7 @@ void vio_delete(Vio * vio) int vio_errno(Vio *vio __attribute__((unused))) { - return errno; /* On Win32 this mapped to WSAGetLastError() */ + return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ } @@ -143,13 +151,18 @@ int vio_read(Vio * vio, gptr buf, int size) { int r; DBUG_ENTER("vio_read"); - DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); -#ifdef __WIN__ + DBUG_PRINT("enter", ("sd=%d size=%d", vio->sd, size)); +#if defined( __WIN__) || defined(OS2) if (vio->type == VIO_TYPE_NAMEDPIPE) { DWORD length; +#ifdef OS2 + if (!DosRead((HFILE)vio->hPipe, buf, size, &length)) + DBUG_RETURN(-1); +#else if (!ReadFile(vio->hPipe, buf, size, &length, NULL)) DBUG_RETURN(-1); +#endif DBUG_RETURN(length); } r = recv(vio->sd, buf, size,0); @@ -160,7 +173,7 @@ int vio_read(Vio * vio, gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("error", ("Got error %d during read",errno)); + DBUG_PRINT("vio_error", ("Got error %d during read",socket_errno)); } #endif /* DBUG_OFF */ DBUG_PRINT("exit", ("%d", r)); @@ -172,13 +185,18 @@ int vio_write(Vio * vio, const gptr buf, int size) { int r; DBUG_ENTER("vio_write"); - DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); -#ifdef __WIN__ + DBUG_PRINT("enter", ("sd=%d size=%d", vio->sd, size)); +#if defined( __WIN__) || defined(OS2) if ( vio->type == VIO_TYPE_NAMEDPIPE) { DWORD length; +#ifdef OS2 + if (!DosWrite((HFILE)vio->hPipe, (char*) buf, size, &length)) + DBUG_RETURN(-1); +#else if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL)) DBUG_RETURN(-1); +#endif DBUG_RETURN(length); } r = send(vio->sd, buf, size,0); @@ -188,7 +206,7 @@ int vio_write(Vio * vio, const gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("error", ("Got error on write: %d",errno)); + DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno)); } #endif /* DBUG_OFF */ DBUG_PRINT("exit", ("%d", r)); @@ -202,7 +220,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode) DBUG_ENTER("vio_blocking"); DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode)); -#if !defined(___WIN__) && !defined(__EMX__) +#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) if (vio->sd >= 0) @@ -282,7 +300,7 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) int r=0; uint opt = 0; DBUG_ENTER("vio_keepalive"); - DBUG_PRINT("enter", ("sd=%d, set_keep_alive=%d", vio->sd, (int) + DBUG_PRINT("enter", ("sd=%d set_keep_alive=%d", vio->sd, (int) set_keep_alive)); if (vio->type != VIO_TYPE_NAMEDPIPE) { @@ -298,8 +316,8 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) my_bool vio_should_retry(Vio * vio __attribute__((unused))) { - int en = errno; - return en == EAGAIN || en == EINTR || en == EWOULDBLOCK; + int en = socket_errno; + return en == SOCKET_EAGAIN || en == SOCKET_EINTR || en == SOCKET_EWOULDBLOCK; } @@ -327,7 +345,7 @@ int vio_close(Vio * vio) } if (r) { - DBUG_PRINT("error", ("close() failed, error: %d",errno)); + DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno)); /* FIXME: error handling (not critical for MySQL) */ } vio->type= VIO_CLOSED; @@ -366,7 +384,7 @@ my_bool vio_peer_addr(Vio * vio, char *buf) if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), &addrLen) != 0) { - DBUG_PRINT("exit", ("getpeername, error: %d", errno)); + DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno)); DBUG_RETURN(1); } my_inet_ntoa(vio->remote.sin_addr,buf); |