Commit 558d88f9 authored by miguel@light.local's avatar miguel@light.local

Win32 Embedded Server Changes

parent 1faca6fc
...@@ -2,33 +2,95 @@ LIBRARY LIBMYSQL ...@@ -2,33 +2,95 @@ LIBRARY LIBMYSQL
DESCRIPTION 'MySQL 4.0 Client Library' DESCRIPTION 'MySQL 4.0 Client Library'
VERSION 4.0 VERSION 4.0
EXPORTS EXPORTS
mysql_affected_rows
mysql_num_rows mysql_close
mysql_num_fields mysql_connect
mysql_create_db
mysql_data_seek
mysql_debug
mysql_drop_db
mysql_dump_debug_info
mysql_eof mysql_eof
mysql_errno
mysql_error
mysql_escape_string
mysql_fetch_field
mysql_fetch_field_direct mysql_fetch_field_direct
mysql_fetch_fields mysql_fetch_fields
mysql_row_tell mysql_fetch_lengths
mysql_field_tell mysql_fetch_row
mysql_field_count mysql_field_count
mysql_affected_rows mysql_field_seek
mysql_insert_id mysql_field_tell
mysql_errno mysql_free_result
mysql_error mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_info mysql_info
mysql_thread_id
mysql_character_set_name
mysql_init mysql_init
mysql_ssl_set mysql_insert_id
mysql_ssl_clear mysql_kill
mysql_change_user mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_num_fields
mysql_num_rows
mysql_odbc_escape_string
mysql_options
mysql_ping
mysql_query
mysql_real_connect mysql_real_connect
mysql_close mysql_real_query
mysql_refresh
mysql_row_seek
mysql_row_tell
mysql_select_db mysql_select_db
mysql_query mysql_shutdown
mysql_stat
mysql_store_result
mysql_thread_id
mysql_use_result
bmove_upp
delete_dynamic
_dig_vec
init_dynamic_array
insert_dynamic
int2str
is_prefix
list_add
list_delete
max_allowed_packet
my_casecmp
my_init
my_end
my_strdup
my_malloc
my_memdup
my_no_flags_free
my_realloc
my_thread_end
my_thread_init
net_buffer_length
set_dynamic
strcend
strdup_root
strfill
strinstr
strmake
strmov
strxmov
myodbc_remove_escape
mysql_thread_safe
mysql_character_set_name
mysql_change_user
mysql_send_query mysql_send_query
mysql_read_query_result mysql_read_query_result
mysql_real_query mysql_real_escape_string
mysql_ssl_set
mysql_ssl_clear
mysql_real_connect
mysql_master_query mysql_master_query
mysql_master_send_query mysql_master_send_query
mysql_slave_query mysql_slave_query
...@@ -43,34 +105,18 @@ EXPORTS ...@@ -43,34 +105,18 @@ EXPORTS
mysql_rpl_probe mysql_rpl_probe
mysql_set_master mysql_set_master
mysql_add_slave mysql_add_slave
mysql_shutdown
mysql_dump_debug_info
mysql_refresh
mysql_kill
mysql_ping
mysql_stat
mysql_get_server_info
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_list_dbs
mysql_list_tables
mysql_list_fields
mysql_list_processes
mysql_store_result
mysql_use_result
mysql_options
mysql_free_result
mysql_data_seek
mysql_row_seek
mysql_field_seek
mysql_fetch_row
mysql_fetch_lengths
mysql_fetch_field
mysql_escape_string
mysql_real_escape_string
mysql_debug
mysql_odbc_escape_string
myodbc_remove_escape
mysql_thread_safe
...@@ -36,4 +36,9 @@ mysql_load(THD * thd, sql_exchange * ex, TABLE_LIST * table_list, ...@@ -36,4 +36,9 @@ mysql_load(THD * thd, sql_exchange * ex, TABLE_LIST * table_list,
#define mysql_load mysql_load_internal #define mysql_load mysql_load_internal
#if defined (__WIN__)
#include "../sql/sql_load.cpp"
#else
#include "../sql/sql_load.cc" #include "../sql/sql_load.cc"
#endif
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#define main main1 #define main main1
#define mysql_unix_port mysql_inix_port1 #define mysql_unix_port mysql_inix_port1
#define mysql_port mysql_port1 #define mysql_port mysql_port1
#if !defined(__WIN__)
#define net_read_timeout net_read_timeout1 #define net_read_timeout net_read_timeout1
#define net_write_timeout net_write_timeout1 #define net_write_timeout net_write_timeout1
#endif
#define changeable_vars changeable_vars1 #define changeable_vars changeable_vars1
extern "C" extern "C"
...@@ -45,7 +47,11 @@ static bool check_user(THD *thd, enum_server_command command, ...@@ -45,7 +47,11 @@ static bool check_user(THD *thd, enum_server_command command,
void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);} void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
#define free_defaults free_defaults_internal #define free_defaults free_defaults_internal
#if defined (__WIN__)
#include "../sql/mysqld.cpp"
#else
#include "../sql/mysqld.cc" #include "../sql/mysqld.cc"
#endif
#define SCRAMBLE_LENGTH 8 #define SCRAMBLE_LENGTH 8
C_MODE_START C_MODE_START
......
LIBRARY LIBMYSQLD
DESCRIPTION 'MySQL 4.0 Embedded Server Library'
VERSION 4.0
EXPORTS
mysql_server_end
mysql_server_init
mysql_use_result
mysql_thread_safe
mysql_thread_id
mysql_store_result
mysql_stat
mysql_shutdown
mysql_select_db
mysql_row_tell
mysql_row_seek
mysql_real_query
mysql_real_connect
mysql_query
mysql_ping
mysql_options
mysql_num_rows
mysql_num_fields
mysql_list_tables
mysql_list_processes
mysql_list_fields
mysql_list_dbs
mysql_kill
mysql_insert_id
mysql_init
mysql_info
mysql_get_server_info
mysql_get_proto_info
mysql_get_host_info
mysql_get_client_info
mysql_free_result
mysql_field_tell
mysql_field_count
mysql_field_seek
mysql_fetch_row
mysql_fetch_lengths
mysql_fetch_fields
mysql_fetch_field_direct
mysql_fetch_field
mysql_escape_string
mysql_real_escape_string
mysql_error
mysql_errno
mysql_eof
mysql_dump_debug_info
mysql_drop_db
mysql_debug
mysql_data_seek
mysql_create_db
mysql_character_set_name
mysql_change_user
mysql_connect
mysql_close
mysql_affected_rows
mysql_thread_init
mysql_thread_end
mysql_send_query
mysql_read_query_result
mysql_refresh
mysql_odbc_escape_string
myodbc_remove_escape
...@@ -380,10 +380,12 @@ enum db_type default_table_type=DB_TYPE_MYISAM; ...@@ -380,10 +380,12 @@ enum db_type default_table_type=DB_TYPE_MYISAM;
#ifdef __WIN__ #ifdef __WIN__
#undef getpid #undef getpid
#include <process.h> #include <process.h>
#if !defined(EMBEDDED_LIBRARY)
HANDLE hEventShutdown; HANDLE hEventShutdown;
#include "nt_servc.h" #include "nt_servc.h"
static NTService Service; // Service object for WinNT static NTService Service; // Service object for WinNT
#endif #endif
#endif
#ifdef OS2 #ifdef OS2
pthread_cond_t eventShutdown; pthread_cond_t eventShutdown;
...@@ -609,6 +611,7 @@ void kill_mysql(void) ...@@ -609,6 +611,7 @@ void kill_mysql(void)
#endif #endif
#if defined(__WIN__) #if defined(__WIN__)
#if !defined(EMBEDDED_LIBRARY)
{ {
if (!SetEvent(hEventShutdown)) if (!SetEvent(hEventShutdown))
{ {
...@@ -621,6 +624,7 @@ void kill_mysql(void) ...@@ -621,6 +624,7 @@ void kill_mysql(void)
CloseHandle(hEvent); CloseHandle(hEvent);
*/ */
} }
#endif
#elif defined(OS2) #elif defined(OS2)
pthread_cond_signal( &eventShutdown); // post semaphore pthread_cond_signal( &eventShutdown); // post semaphore
#elif defined(HAVE_PTHREAD_KILL) #elif defined(HAVE_PTHREAD_KILL)
...@@ -1558,8 +1562,9 @@ pthread_handler_decl(handle_shutdown,arg) ...@@ -1558,8 +1562,9 @@ pthread_handler_decl(handle_shutdown,arg)
/* this call should create the message queue for this thread */ /* this call should create the message queue for this thread */
PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE); PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE);
#if !defined(EMBEDDED_LIBRARY)
if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0) if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0)
#endif
kill_server(MYSQL_KILL_SIGNAL); kill_server(MYSQL_KILL_SIGNAL);
return 0; return 0;
} }
...@@ -1976,7 +1981,7 @@ The server will not act as a slave."); ...@@ -1976,7 +1981,7 @@ The server will not act as a slave.");
} }
} }
(void) thr_setconcurrency(concurrency); // 10 by default (void) thr_setconcurrency(concurrency); // 10 by default
#ifdef __WIN__ //IRENA #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
{ {
hEventShutdown=CreateEvent(0, FALSE, FALSE, "MySqlShutdown"); hEventShutdown=CreateEvent(0, FALSE, FALSE, "MySqlShutdown");
pthread_t hThread; pthread_t hThread;
...@@ -2084,6 +2089,7 @@ The server will not act as a slave."); ...@@ -2084,6 +2089,7 @@ The server will not act as a slave.");
sql_print_error("After lock_thread_count"); sql_print_error("After lock_thread_count");
#endif #endif
#else #else
#if !defined(EMBEDDED_LIBRARY)
if (Service.IsNT()) if (Service.IsNT())
{ {
if(start_mode) if(start_mode)
...@@ -2103,6 +2109,7 @@ The server will not act as a slave."); ...@@ -2103,6 +2109,7 @@ The server will not act as a slave.");
if(hEventShutdown) CloseHandle(hEventShutdown); if(hEventShutdown) CloseHandle(hEventShutdown);
} }
#endif #endif
#endif
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
my_free((gptr)ssl_acceptor_fd,MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr)ssl_acceptor_fd,MYF(MY_ALLOW_ZERO_PTR));
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
...@@ -2123,7 +2130,7 @@ The server will not act as a slave."); ...@@ -2123,7 +2130,7 @@ The server will not act as a slave.");
} }
#ifdef __WIN__ #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
main and thread entry function for Win32 main and thread entry function for Win32
(all this is needed only to run mysqld as a service on WinNT) (all this is needed only to run mysqld as a service on WinNT)
......
...@@ -62,12 +62,12 @@ ulong net_read_timeout= NET_READ_TIMEOUT; ...@@ -62,12 +62,12 @@ ulong net_read_timeout= NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT; ulong net_write_timeout= NET_WRITE_TIMEOUT;
#endif #endif
#ifdef __WIN__ #if defined(__WIN__) || !defined(MYSQL_SERVER)
/* The following is because alarms doesn't work on windows. */ /* The following is because alarms doesn't work on windows. */
#undef MYSQL_SERVER #define NO_ALARM
#endif #endif
#ifdef MYSQL_SERVER #ifndef NO_ALARM
#include "my_pthread.h" #include "my_pthread.h"
void sql_print_error(const char *format,...); void sql_print_error(const char *format,...);
#define RETRY_COUNT mysqld_net_retry_count #define RETRY_COUNT mysqld_net_retry_count
...@@ -79,7 +79,7 @@ extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received; ...@@ -79,7 +79,7 @@ extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#define statistic_add(A,B,C) #define statistic_add(A,B,C)
#define DONT_USE_THR_ALARM #define DONT_USE_THR_ALARM
#define RETRY_COUNT 1 #define RETRY_COUNT 1
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
#include "thr_alarm.h" #include "thr_alarm.h"
...@@ -322,14 +322,14 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -322,14 +322,14 @@ net_real_write(NET *net,const char *packet,ulong len)
long int length; long int length;
char *pos,*end; char *pos,*end;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if defined(MYSQL_SERVER) #ifndef NO_ALARM
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
uint retry_count=0; uint retry_count=0;
my_bool net_blocking = vio_is_blocking(net->vio); my_bool net_blocking = vio_is_blocking(net->vio);
DBUG_ENTER("net_real_write"); DBUG_ENTER("net_real_write");
#ifdef USE_QUERY_CACHE #ifdef MYSQL_SERVER
if (net->query_cache_query != 0) if (net->query_cache_query != 0)
query_cache_insert(net, packet, len); query_cache_insert(net, packet, len);
#endif #endif
...@@ -371,13 +371,13 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -371,13 +371,13 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif /* HAVE_COMPRESS */ #endif /* HAVE_COMPRESS */
/* DBUG_DUMP("net",packet,len); */ /* DBUG_DUMP("net",packet,len); */
#ifdef MYSQL_SERVER #ifndef NO_ALARM
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
if (net_blocking) if (net_blocking)
thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff); thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff);
#else #else
alarmed=0; alarmed=0;
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
pos=(char*) packet; end=pos+len; pos=(char*) packet; end=pos+len;
while (pos != end) while (pos != end)
...@@ -459,8 +459,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -459,8 +459,7 @@ net_real_write(NET *net,const char *packet,ulong len)
** Read something from server/clinet ** Read something from server/clinet
*****************************************************************************/ *****************************************************************************/
#ifdef MYSQL_SERVER #ifndef NO_ALARM
/* /*
Help function to clear the commuication buffer when we get a too Help function to clear the commuication buffer when we get a too
big packet big packet
...@@ -493,7 +492,7 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed) ...@@ -493,7 +492,7 @@ static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
statistic_add(bytes_received,length,&LOCK_bytes_received); statistic_add(bytes_received,length,&LOCK_bytes_received);
} }
} }
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
/* /*
...@@ -510,7 +509,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -510,7 +509,7 @@ my_real_read(NET *net, ulong *complen)
uint i,retry_count=0; uint i,retry_count=0;
ulong len=packet_error; ulong len=packet_error;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if defined(MYSQL_SERVER) #ifndef NO_ALARM
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
my_bool net_blocking=vio_is_blocking(net->vio); my_bool net_blocking=vio_is_blocking(net->vio);
...@@ -520,10 +519,10 @@ my_real_read(NET *net, ulong *complen) ...@@ -520,10 +519,10 @@ my_real_read(NET *net, ulong *complen)
net->reading_or_writing=1; net->reading_or_writing=1;
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
#ifdef MYSQL_SERVER #ifndef NO_ALARM
if (net_blocking) if (net_blocking)
thr_alarm(&alarmed,net->timeout,&alarm_buff); thr_alarm(&alarmed,net->timeout,&alarm_buff);
#endif /* MYSQL_SERVER */ #endif /* NO_ALARM */
pos = net->buff + net->where_b; /* net->packet -4 */ pos = net->buff + net->where_b; /* net->packet -4 */
for (i=0 ; i < 2 ; i++) for (i=0 ; i < 2 ; i++)
...@@ -646,7 +645,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -646,7 +645,7 @@ my_real_read(NET *net, ulong *complen)
{ {
if (net_realloc(net,helping)) if (net_realloc(net,helping))
{ {
#ifdef MYSQL_SERVER #ifndef NO_ALARM
if (i == 1) if (i == 1)
my_net_skip_rest(net, (uint32) len, &alarmed); my_net_skip_rest(net, (uint32) len, &alarmed);
#endif #endif
......
...@@ -1167,6 +1167,11 @@ void Query_cache::pack(ulong join_limit, uint iteration_limit) ...@@ -1167,6 +1167,11 @@ void Query_cache::pack(ulong join_limit, uint iteration_limit)
void Query_cache::destroy() void Query_cache::destroy()
{ {
if ( !initialized )
{
DBUG_PRINT("qcache", ("Query Cache not initialized"));
return;
}
DBUG_ENTER("Query_cache::destroy"); DBUG_ENTER("Query_cache::destroy");
free_cache(1); free_cache(1);
pthread_mutex_destroy(&structure_guard_mutex); pthread_mutex_destroy(&structure_guard_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment