diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/field.h | 4 | ||||
-rw-r--r-- | sql/gen_lex_hash.cc | 2 | ||||
-rw-r--r-- | sql/hostname.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 6 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 6 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/md5.c | 36 | ||||
-rw-r--r-- | sql/mini_client.cc | 42 | ||||
-rw-r--r-- | sql/mysql_priv.h | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 108 | ||||
-rw-r--r-- | sql/net_serv.cc | 22 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_db.cc | 4 | ||||
-rw-r--r-- | sql/sql_insert.cc | 4 | ||||
-rw-r--r-- | sql/sql_load.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 16 | ||||
-rw-r--r-- | sql/sql_table.cc | 20 | ||||
-rw-r--r-- | sql/sql_udf.cc | 2 | ||||
-rw-r--r-- | sql/violite.c | 32 |
21 files changed, 225 insertions, 97 deletions
diff --git a/sql/field.cc b/sql/field.cc index 894ef2ab013..01178efbdb1 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2295,7 +2295,7 @@ void Field_timestamp::store(longlong nr) } else #endif - longstore(ptr,timestamp); + longstore(ptr,(ulong)timestamp); } diff --git a/sql/field.h b/sql/field.h index ee18d2fa7ae..fc0bfdc75d5 100644 --- a/sql/field.h +++ b/sql/field.h @@ -38,8 +38,8 @@ public: static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */ enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL, - CHECK,EMPTY,UNKNOWN,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,BIT_FIELD, - TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD}; + CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD, + BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD}; char *ptr; // Position to field in record uchar *null_ptr; // Byte where null_bit is uint8 null_bit; // And position to it diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 6bb43ec2970..5eee5c6163a 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=8214901L; best_t1=4099790L; best_t2=2406115L; best_type=4; /* mode=4799 add=2 type: 0 */ + start_value=487844L; best_t1=4969454L; best_t2=2266538L; best_type=2; /* mode=4567 add=5 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); diff --git a/sql/hostname.cc b/sql/hostname.cc index fed9e60b574..bc812341337 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -26,7 +26,7 @@ #ifdef __cplusplus extern "C" { // Because of SCO 3.2V4.2 #endif -#ifndef __WIN__ +#if !defined( __WIN__) && !defined(OS2) #include <sys/resource.h> #ifdef HAVE_SYS_UN_H #include <sys/un.h> diff --git a/sql/item_func.cc b/sql/item_func.cc index ef3372629f6..989d7709513 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1489,8 +1489,14 @@ longlong Item_func_get_lock::val_int() thd->mysys_var->current_cond= &ull->cond; pthread_mutex_unlock(&thd->mysys_var->mutex); +#ifdef HAVE_TIMESPEC_TS_SEC + abstime.ts_sec=time((time_t*) 0)+(time_t) timeout; + abstime.ts_nsec=0; +#else abstime.tv_sec=time((time_t*) 0)+(time_t) timeout; abstime.tv_nsec=0; +#endif + while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) != ETIME && error != ETIMEDOUT && ull->locked) { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 80f72c30e57..bd7fde79629 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1009,8 +1009,8 @@ String *Item_func_encrypt::val_str(String *str) if (arg_count == 1) { // generate random salt time_t timestamp=current_thd->query_start(); - salt[0] = bin_to_ascii(timestamp & 0x3f); - salt[1] = bin_to_ascii((timestamp >> 5) & 0x3f); + salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f); + salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f); salt[2] = 0; salt_ptr=salt; } @@ -1103,7 +1103,7 @@ void Item_func_soundex::fix_length_and_dec() */ extern "C" { -extern char *soundex_map; // In mysys/static.c +extern const char *soundex_map; // In mysys/static.c } static char get_scode(char *ptr) diff --git a/sql/log_event.cc b/sql/log_event.cc index 1263d361b7f..41efa0f5658 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -55,7 +55,7 @@ int Log_event::write_header(IO_CACHE* file) // make sure to change this when the header gets bigger char buf[LOG_EVENT_HEADER_LEN]; char* pos = buf; - int4store(pos, when); // timestamp + int4store(pos, (ulong) when); // timestamp pos += 4; *pos++ = get_type_code(); // event type code int4store(pos, server_id); diff --git a/sql/md5.c b/sql/md5.c index 0775ba3bd1a..4c2e80107b8 100644 --- a/sql/md5.c +++ b/sql/md5.c @@ -123,10 +123,10 @@ void MD5Init (MD5_CTX *context) /* context */ operation, processing another message block, and updating the context. */ -void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +void MD5Update ( +MD5_CTX *context, /* context */ +unsigned char *input, /* input block */ +unsigned int inputLen) /* length of input block */ { unsigned int i, idx, partLen; @@ -164,9 +164,9 @@ unsigned int inputLen; /* length of input block */ /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +void MD5Final ( +unsigned char digest[16], /* message digest */ +MD5_CTX *context) /* context */ { unsigned char bits[8]; unsigned int idx, padLen; @@ -193,9 +193,9 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; +static void MD5Transform ( +UINT4 state[4], +unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; @@ -287,10 +287,10 @@ unsigned char block[64]; /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; +static void Encode ( +unsigned char *output, +UINT4 *input, +unsigned int len) { unsigned int i, j; @@ -306,10 +306,10 @@ unsigned int len; /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; +static void Decode ( +UINT4 *output, +unsigned char *input, +unsigned int len) { unsigned int i, j; diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 2886b6e02d2..88a02e227a3 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -82,6 +82,9 @@ static void mc_free_old_query(MYSQL *mysql); #if defined(MSDOS) || defined(__WIN__) #define ERRNO WSAGetLastError() #define perror(A) +#elif defined(OS2) +#define ERRNO sock_errno() +#define SOCKET_ERROR -1 #else #include <sys/errno.h> #define ERRNO errno @@ -235,7 +238,7 @@ static void mc_free_old_query(MYSQL *mysql) static int mc_sock_connect(my_socket s, const struct sockaddr *name, uint namelen, uint to) { -#if defined(__WIN__) +#if defined(__WIN__) || defined(OS2) return connect(s, (struct sockaddr*) name, namelen); #else int flags, res, s_err; @@ -330,18 +333,18 @@ mc_net_safe_read(MYSQL *mysql) { DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); - if(errno != EINTR) + if (socket_errno != EINTR) + { + mc_end_server(mysql); + if(net->last_errno != ER_NET_PACKET_TOO_LARGE) { - mc_end_server(mysql); - if(net->last_errno != ER_NET_PACKET_TOO_LARGE) - { - net->last_errno=CR_SERVER_LOST; - strmov(net->last_error,ER(net->last_errno)); - } - else - strmov(net->last_error, "Packet too large - increase \ + net->last_errno=CR_SERVER_LOST; + strmov(net->last_error,ER(net->last_errno)); + } + else + strmov(net->last_error, "Packet too large - increase \ max_allowed_packet on this server"); - } + } return(packet_error); } if (net->read_pos[0] == 255) @@ -451,7 +454,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command, if (net_write_command(net,(uchar) command,arg, length ? length :(uint) 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)); mc_end_server(mysql); if (mc_mysql_reconnect(mysql) || net_write_command(net,(uchar) command,arg, @@ -535,9 +538,9 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, if (mc_sock_connect(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; } } @@ -585,7 +588,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, if ((sock = 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); @@ -622,7 +625,7 @@ mc_mysql_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); @@ -630,11 +633,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, #endif sock_addr.sin_port = (ushort) htons((ushort) port); if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), - mysql->options.connect_timeout) <0) + 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); if (thr_alarm_in_use(&alarmed)) thr_end_alarm(&alarmed); goto error; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 19af3af8c68..06d0b1528f4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -28,7 +28,9 @@ #include <my_bitmap.h> #include <violite.h> +#ifdef __EMX__ #undef write // remove pthread.h macro definition for EMX +#endif typedef ulong table_map; /* Used for table bits in join */ typedef ulong key_map; /* Used for finding keys */ @@ -110,7 +112,7 @@ void kill_one_thread(THD *thd, ulong id); #define FLUSH_TIME 0 /* Don't flush tables */ #define MAX_CONNECT_ERRORS 10 // errors before disabling host -#ifdef __WIN__ +#if defined(__WIN__) || defined(OS2) #define IF_WIN(A,B) (A) #undef FLUSH_TIME #define FLUSH_TIME 1800 /* Flush every half hour */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 57e65025c8f..35aeaecc6e1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -57,7 +57,9 @@ extern "C" { // Because of SCO 3.2V4.2 #include <grp.h> #endif -#ifndef __WIN__ +#if defined(OS2) +# include <sys/un.h> +#elif !defined( __WIN__) #include <sys/resource.h> #ifdef HAVE_SYS_UN_H # include <sys/un.h> @@ -358,6 +360,10 @@ HANDLE hEventShutdown; static NTService Service; // Service object for WinNT #endif +#ifdef OS2 +pthread_cond_t eventShutdown; +#endif + static void start_signal_handler(void); static void *signal_hand(void *arg); static void set_options(void); @@ -405,7 +411,7 @@ static void close_connections(void) (void) pthread_mutex_unlock(&LOCK_manager); /* kill connection thread */ -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) DBUG_PRINT("quit",("waiting for select thread: %lx",select_thread)); (void) pthread_mutex_lock(&LOCK_thread_count); @@ -576,6 +582,8 @@ void kill_mysql(void) // SetEvent(hEventShutdown); // CloseHandle(hEvent); } +#elif defined(OS2) + pthread_cond_signal( &eventShutdown); // post semaphore #elif defined(HAVE_PTHREAD_KILL) if (pthread_kill(signal_thread,MYSQL_KILL_SIGNAL))// End everything nicely { @@ -592,7 +600,10 @@ void kill_mysql(void) /* Force server down. kill all connections and threads and exit */ -#ifndef __WIN__ +#if defined(OS2) +extern "C" void kill_server(int sig_ptr) +#define RETURN_FROM_KILL_SERVER return +#elif !defined(__WIN__) static void *kill_server(void *sig_ptr) #define RETURN_FROM_KILL_SERVER return 0 #else @@ -615,7 +626,7 @@ static void __cdecl kill_server(int sig_ptr) else sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */ -#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) +#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2) my_thread_init(); // If this is a new thread #endif close_connections(); @@ -623,7 +634,9 @@ static void __cdecl kill_server(int sig_ptr) unireg_abort(1); /* purecov: inspected */ else unireg_end(0); +#ifndef OS2 pthread_exit(0); /* purecov: deadcode */ +#endif RETURN_FROM_KILL_SERVER; } @@ -645,7 +658,7 @@ static sig_handler print_signal_warning(int sig) #ifdef DONT_REMEMBER_SIGNAL sigset(sig,print_signal_warning); /* int. thread system calls */ #endif -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) if (sig == SIGALRM) alarm(2); /* reschedule alarm */ #endif @@ -655,7 +668,9 @@ static sig_handler print_signal_warning(int sig) void unireg_end(int signal_number __attribute__((unused))) { clean_up(); +#ifndef OS2 pthread_exit(0); // Exit is in main thread +#endif } @@ -746,7 +761,7 @@ static void set_ports() static void set_user(const char *user) { -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) struct passwd *ent; // don't bother if we aren't superuser @@ -794,7 +809,7 @@ static void set_user(const char *user) static void set_root(const char *path) { -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) if (chroot(path) == -1) { sql_perror("chroot"); @@ -853,7 +868,7 @@ static void server_init(void) } if (listen(ip_sock,(int) back_log) < 0) sql_print_error("Warning: listen() on TCP/IP failed with error %d", - errno); + socket_errno); } if (mysqld_chroot) @@ -940,7 +955,7 @@ static void server_init(void) #endif if (listen(unix_sock,(int) back_log) < 0) sql_print_error("Warning: listen() on Unix socket failed with error %d", - errno); + socket_errno); } #endif DBUG_PRINT("info",("server started")); @@ -1088,13 +1103,17 @@ static sig_handler abort_thread(int sig __attribute__((unused))) ** the signal thread is ready before continuing ******************************************************************************/ -#ifdef __WIN__ +#if defined(__WIN__) || defined(OS2) static void init_signals(void) { int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT } ; for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++) signal( signals[i], kill_server) ; +#if defined(__WIN__) signal(SIGBREAK,SIG_IGN); //ignore SIGBREAK for NT +#else + signal(SIGBREAK, kill_server); +#endif } static void start_signal_handler(void) @@ -1473,6 +1492,29 @@ int __stdcall handle_kill(ulong ctrl_type) } #endif +#ifdef OS2 +pthread_handler_decl(handle_shutdown,arg) +{ + my_thread_init(); + + // wait semaphore + pthread_cond_wait( &eventShutdown, NULL); + + // close semaphore and kill server + pthread_cond_destroy( &eventShutdown); + + // exit main loop on main thread, so kill will be done from + // main thread (this is thread 2) + abort_loop = 1; + + // unblock select() + so_cancel( ip_sock); + so_cancel( unix_sock); + + return 0; +} +#endif + const char *load_default_groups[]= { "mysqld","server",0 }; #ifdef HAVE_LIBWRAP @@ -1558,7 +1600,7 @@ int main(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); defaults_argv=argv; mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */ -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) if (!mysql_tmpdir) mysql_tmpdir=getenv("TEMP"); if (!mysql_tmpdir) @@ -1646,7 +1688,7 @@ int main(int argc, char **argv) my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR); pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); -#ifdef SET_RLIMIT_NOFILE +#if defined( SET_RLIMIT_NOFILE) || defined( OS2) /* connections and databases neads lots of files */ { uint wanted_files=10+(uint) max(max_connections*5, @@ -1854,6 +1896,14 @@ The server will not act as a slave."); Service.SetShutdownEvent(hEventShutdown); } #endif +#ifdef OS2 + { + pthread_cond_init( &eventShutdown, NULL); + pthread_t hThread; + if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) + sql_print_error("Warning: Can't create thread to handle shutdown requests"); + } +#endif if ( #ifdef HAVE_BERKELEY_DB @@ -2192,8 +2242,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) } #ifdef HAVE_SYS_UN_H FD_SET(unix_sock,&clientFDs); +#ifdef HAVE_FCNTL socket_flags=fcntl(unix_sock, F_GETFL, 0); #endif +#endif DBUG_PRINT("general",("Waiting for connections.")); while (!abort_loop) @@ -2205,10 +2257,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) #else if (select((int) max_used_connection,&readFDs,0,0,0) < 0) { - if (errno != EINTR) + if (socket_errno != EINTR) { if (!select_errors++ && !abort_loop) /* purecov: inspected */ - sql_print_error("mysqld: Got error %d from select",errno); /* purecov: inspected */ + sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */ } continue; } @@ -2344,6 +2396,11 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) create_new_thread(thd); } +#ifdef OS2 + // kill server must be invoked from thread 1! + kill_server(MYSQL_KILL_SIGNAL); +#endif + #ifdef __NT__ pthread_mutex_lock(&LOCK_thread_count); handler_count--; @@ -4385,6 +4442,29 @@ static uint set_maximum_open_files(uint max_file_limit) } #endif +#ifdef OS2 +static uint set_maximum_open_files(uint max_file_limit) +{ + LONG cbReqCount; + ULONG cbCurMaxFH, cbCurMaxFH0; + APIRET ulrc; + + // get current limit + cbReqCount = 0; + DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); + + // set new limit + cbReqCount = max_file_limit - cbCurMaxFH0; + ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); + if (ulrc) { + sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", + cbCurMaxFH0); + cbCurMaxFH = cbCurMaxFH0; + } + + return cbCurMaxFH; +} +#endif /* Return a bitfield from a string of substrings separated by ',' diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 4c4642034e1..ba0944a2516 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -50,7 +50,7 @@ ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */ #if !defined(__WIN__) && !defined(MSDOS) #include <sys/socket.h> #else -#undef MYSQL_SERVER // Win32 can't handle interrupts +#undef MYSQL_SERVER /* Win32 can't handle interrupts */ #endif #if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) #include <netinet/in_systm.h> @@ -68,9 +68,15 @@ 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_init(A) (*(A))=0 #define thr_alarm_in_use(A) (*(A)) #define thr_end_alarm(A) #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) @@ -124,7 +130,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 @@ -271,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len) int length; char *pos,*end; thr_alarm_t alarmed; -#if !defined(__WIN__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) ALARM alarm_buff; #endif uint retry_count=0; @@ -329,7 +335,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)) @@ -418,7 +424,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) { if (!thr_alarm(alarmed,net->timeout,&alarm_buff) || (!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0)) - return; // Can't setup, abort + return; /* Can't setup, abort */ } while (remain > 0) { @@ -448,7 +454,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); @@ -475,7 +481,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/sql/slave.cc b/sql/slave.cc index 7cb9bdfd3fc..f6e8822ea14 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -703,7 +703,7 @@ static int init_slave_thread(THD* thd) thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a38829f3605..d885d308770 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1401,7 +1401,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) { int error; -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) /* Win32 can't drop a file that is open */ if (lock_type == TL_WRITE_ALLOW_READ #ifdef HAVE_GEMINI_DB @@ -1411,7 +1411,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) { lock_type= TL_WRITE; } -#endif /* __WIN__ */ +#endif /* __WIN__ || OS2 */ table_list->table=table; table->grant= table_list->grant; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7cd892f6079..d0300b57bdb 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -338,7 +338,9 @@ bool mysql_change_db(THD *thd,const char *name) } (void) sprintf(path,"%s/%s",mysql_data_home,dbname); - unpack_dirname(path,path); // Convert if not unix + length=unpack_dirname(path,path); // Convert if not unix + if (length && path[length-1] == FN_LIBCHAR) + path[length-1]=0; // remove ending '\' if (access(path,F_OK)) { net_printf(&thd->net,ER_BAD_DB_ERROR,dbname); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 50e4a6dedd4..c14fbda3bc5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -876,7 +876,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_lock(&di->mutex); -#ifndef __WIN__ /* Win32 calls this in pthread_create */ +#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */ if (my_thread_init()) { strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES)); @@ -895,7 +895,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) } thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ce8e34b9265..274b1814674 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -156,7 +156,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, else { unpack_filename(name,ex->file_name); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(MY_WME))) DBUG_RETURN(-1); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 796b571722f..2e5333925e7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -62,9 +62,13 @@ extern VioSSLAcceptorFd* ssl_acceptor_fd; #ifdef __WIN__ static void test_signal(int sig_ptr) { -#ifndef DBUG_OFF +#if !defined( DBUG_OFF) MessageBox(NULL,"Test signal","DBUG",MB_OK); #endif +#if defined(OS2) + fprintf( stderr, "Test signal %d\n", sig_ptr); + fflush( stderr); +#endif } static void init_signals(void) { @@ -477,7 +481,7 @@ pthread_handler_decl(handle_one_connection,arg) pthread_detach_this_thread(); -#ifndef __WIN__ /* Win32 calls this in pthread_create */ +#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */ if (my_thread_init()) // needed to be called first before we call // DBUG_ macros { @@ -499,9 +503,9 @@ pthread_handler_decl(handle_one_connection,arg) thd->thread_id)); // now that we've called my_thread_init(), it is safe to call DBUG_* -#ifdef __WIN__ +#if defined(__WIN__) init_signals(); // IRENA; testing ? -#else +#elif !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); @@ -602,7 +606,7 @@ pthread_handler_decl(handle_bootstrap,arg) thd->thread_stack= (char*) &thd; thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); @@ -940,7 +944,9 @@ bool do_command(THD *thd) #ifdef __WIN__ sleep(1); // must wait after eof() #endif +#ifndef OS2 send_eof(net); // This is for 'quit request' +#endif close_connection(net); close_thread_tables(thd); // Free before kill free_root(&thd->mem_root,MYF(0)); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1728427370f..5c3d8def542 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1073,19 +1073,31 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { +#ifdef OS2 + thr_lock_type lock_type = TL_WRITE; +#else + thr_lock_type lock_type = TL_READ_NO_INSERT; +#endif + DBUG_ENTER("mysql_analyze_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "analyze",TL_READ_NO_INSERT, 1,0,0, + "analyze", lock_type, 1,0,0, &handler::analyze)); } int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) { +#ifdef OS2 + thr_lock_type lock_type = TL_WRITE; +#else + thr_lock_type lock_type = TL_READ_NO_INSERT; +#endif + DBUG_ENTER("mysql_check_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "check", - TL_READ_NO_INSERT, 0, 0, HA_OPEN_FOR_REPAIR, + "check", lock_type, + 0, 0, HA_OPEN_FOR_REPAIR, &handler::check)); } @@ -1543,7 +1555,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } } -#if defined( __WIN__) || defined( __EMX__) +#if defined( __WIN__) || defined( __EMX__) || defined( OS2) // Win32 can't rename an open table, so we must close the org table! table_name=thd->strdup(table_name); // must be saved if (close_cached_table(thd,table)) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 2ba937be50a..8184ae3b15e 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -53,7 +53,7 @@ extern "C" FreeLibrary((HMODULE)lib); } -#else +#elif !defined(OS2) #include <dlfcn.h> #endif diff --git a/sql/violite.c b/sql/violite.c index 902110ff072..aff4224e5a3 100644 --- a/sql/violite.c +++ b/sql/violite.c @@ -39,7 +39,7 @@ #include <sys/ioctl.h> #endif -#if defined(__EMX__) +#if defined(__EMX__) || defined(OS2) #define ioctlsocket ioctl #endif /* defined(__EMX__) */ @@ -105,7 +105,7 @@ 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 */ @@ -116,7 +116,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) { /* set to blocking mode by default */ ulong arg=0, r; - r = ioctlsocket(sd,FIONBIO,(void*) &arg, sizeof(arg)); + r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg)); } #endif } @@ -154,7 +154,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() */ } @@ -163,12 +163,17 @@ 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__ +#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); @@ -179,7 +184,7 @@ int vio_read(Vio * vio, gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("vio_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)); @@ -192,12 +197,17 @@ 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__ +#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); @@ -207,7 +217,7 @@ int vio_write(Vio * vio, const gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("vio_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)); @@ -221,7 +231,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) @@ -346,7 +356,7 @@ int vio_close(Vio * vio) } if (r) { - DBUG_PRINT("vio_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; @@ -385,7 +395,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); |