Commit 45fc8cc2 authored by venu@myvenu.com's avatar venu@myvenu.com

Fix windows build after applyiing the changes from new client.c(sql-common)

NOTE: Still the build fails to compile core server on Windows due to slave_net_timeout linker error from client.obj
      and make sure to have the next changeset, which fixes this.
parent 8f57d0e2
...@@ -104,6 +104,10 @@ SOURCE=..\mysys\charset.c ...@@ -104,6 +104,10 @@ SOURCE=..\mysys\charset.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\libmysql\client.c
# End Source File
# Begin Source File
SOURCE=.\completion_hash.cpp SOURCE=.\completion_hash.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -123,6 +123,10 @@ SOURCE=..\mysys\charset.c ...@@ -123,6 +123,10 @@ SOURCE=..\mysys\charset.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\client.c
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-big5.c" SOURCE="..\strings\ctype-big5.c"
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -178,7 +178,7 @@ LINK32=xilink6.exe ...@@ -178,7 +178,7 @@ LINK32=xilink6.exe
# Name "mysqld - Win32 Max" # Name "mysqld - Win32 Max"
# Begin Source File # Begin Source File
SOURCE=.\convert.cpp SOURCE=.\client.c
!IF "$(CFG)" == "mysqld - Win32 Release" !IF "$(CFG)" == "mysqld - Win32 Release"
...@@ -660,10 +660,6 @@ SOURCE=.\mf_iocache.cpp ...@@ -660,10 +660,6 @@ SOURCE=.\mf_iocache.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\mini_client.cpp
# End Source File
# Begin Source File
SOURCE=..\myisammrg\myrg_rnext_same.c SOURCE=..\myisammrg\myrg_rnext_same.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -85,11 +85,6 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT; ...@@ -85,11 +85,6 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT;
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#endif /* __WIN__ */ #endif /* __WIN__ */
#ifdef HAVE_SMEM
char *shared_memory_base_name=0;
const char *def_shared_memory_base_name=default_shared_memory_base_name;
#endif
const char *sql_protocol_names_lib[] = const char *sql_protocol_names_lib[] =
{ "TCP", "SOCKET", "PIPE", "MEMORY",NullS }; { "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"", TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
...@@ -161,209 +156,7 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, ...@@ -161,209 +156,7 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
const char* user, const char* user,
const char* passwd); const char* passwd);
/*
Create new shared memory connection, return handler of connection
SYNOPSIS
create_shared_memory()
mysql Pointer of mysql structure
net Pointer of net structure
connect_timeout Timeout of connection
*/
#ifdef HAVE_SMEM
HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
{
ulong smem_buffer_length = shared_memory_buffer_length + 4;
/*
event_connect_request is event object for start connection actions
event_connect_answer is event object for confirm, that server put data
handle_connect_file_map is file-mapping object, use for create shared memory
handle_connect_map is pointer on shared memory
handle_map is pointer on shared memory for client
event_server_wrote,
event_server_read,
event_client_wrote,
event_client_read are events for transfer data between server and client
handle_file_map is file-mapping object, use for create shared memory
*/
HANDLE event_connect_request = NULL;
HANDLE event_connect_answer = NULL;
HANDLE handle_connect_file_map = NULL;
char *handle_connect_map = NULL;
char *handle_map = NULL;
HANDLE event_server_wrote = NULL;
HANDLE event_server_read = NULL;
HANDLE event_client_wrote = NULL;
HANDLE event_client_read = NULL;
HANDLE handle_file_map = NULL;
ulong connect_number;
char connect_number_char[22], *p;
char tmp[64];
char *suffix_pos;
DWORD error_allow = 0;
DWORD error_code = 0;
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part
Where:
shared_memory_base_name is unique value for each server
unique_part is uniquel value for each object (events and file-mapping)
*/
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
strmov(suffix_pos, "CONNECT_REQUEST");
if (!(event_connect_request= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
goto err;
}
strmov(suffix_pos, "CONNECT_ANSWER");
if (!(event_connect_answer= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR;
goto err;
}
strmov(suffix_pos, "CONNECT_DATA");
if (!(handle_connect_file_map= OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR;
goto err;
}
if (!(handle_connect_map= MapViewOfFile(handle_connect_file_map,
FILE_MAP_WRITE,0,0,sizeof(DWORD))))
{
error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR;
goto err;
}
/*
Send to server request of connection
*/
if (!SetEvent(event_connect_request))
{
error_allow = CR_SHARED_MEMORY_CONNECT_SET_ERROR;
goto err;
}
/*
Wait of answer from server
*/
if (WaitForSingleObject(event_connect_answer,connect_timeout*1000) !=
WAIT_OBJECT_0)
{
error_allow = CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR;
goto err;
}
/*
Get number of connection
*/
connect_number = uint4korr(handle_connect_map);/*WAX2*/
p= int2str(connect_number, connect_number_char, 10);
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part+number_of_connection
Where:
shared_memory_base_name is uniquel value for each server
unique_part is uniquel value for each object (events and file-mapping)
number_of_connection is number of connection between server and client
*/
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,
"_",NullS);
strmov(suffix_pos, "DATA");
if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_FILE_MAP_ERROR;
goto err2;
}
if ((handle_map = MapViewOfFile(handle_file_map,FILE_MAP_WRITE,0,0,
smem_buffer_length)) == NULL)
{
error_allow = CR_SHARED_MEMORY_MAP_ERROR;
goto err2;
}
strmov(suffix_pos, "SERVER_WROTE");
if ((event_server_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "SERVER_READ");
if ((event_server_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_WROTE");
if ((event_client_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_READ");
if ((event_client_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
/*
Set event that server should send data
*/
SetEvent(event_server_read);
err2:
if (error_allow == 0)
{
net->vio= vio_new_win32shared_memory(net,handle_file_map,handle_map,
event_server_wrote,
event_server_read,event_client_wrote,
event_client_read);
}
else
{
error_code = GetLastError();
if (event_server_read)
CloseHandle(event_server_read);
if (event_server_wrote)
CloseHandle(event_server_wrote);
if (event_client_read)
CloseHandle(event_client_read);
if (event_client_wrote)
CloseHandle(event_client_wrote);
if (handle_map)
UnmapViewOfFile(handle_map);
if (handle_file_map)
CloseHandle(handle_file_map);
}
err:
if (error_allow)
error_code = GetLastError();
if (event_connect_request)
CloseHandle(event_connect_request);
if (event_connect_answer)
CloseHandle(event_connect_answer);
if (handle_connect_map)
UnmapViewOfFile(handle_connect_map);
if (handle_connect_file_map)
CloseHandle(handle_connect_file_map);
if (error_allow)
{
net->last_errno=error_allow;
strmov(net->sqlstate, unknown_sqlstate);
if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR)
sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code);
else
sprintf(net->last_error,ER(net->last_errno),error_code);
return(INVALID_HANDLE_VALUE);
}
return(handle_map);
}
#endif
/* /*
Expand wildcard to a sql string Expand wildcard to a sql string
......
...@@ -288,6 +288,210 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, ...@@ -288,6 +288,210 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
} }
#endif #endif
/*
Create new shared memory connection, return handler of connection
SYNOPSIS
create_shared_memory()
mysql Pointer of mysql structure
net Pointer of net structure
connect_timeout Timeout of connection
*/
#ifdef HAVE_SMEM
HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
{
ulong smem_buffer_length = shared_memory_buffer_length + 4;
/*
event_connect_request is event object for start connection actions
event_connect_answer is event object for confirm, that server put data
handle_connect_file_map is file-mapping object, use for create shared memory
handle_connect_map is pointer on shared memory
handle_map is pointer on shared memory for client
event_server_wrote,
event_server_read,
event_client_wrote,
event_client_read are events for transfer data between server and client
handle_file_map is file-mapping object, use for create shared memory
*/
HANDLE event_connect_request = NULL;
HANDLE event_connect_answer = NULL;
HANDLE handle_connect_file_map = NULL;
char *handle_connect_map = NULL;
char *handle_map = NULL;
HANDLE event_server_wrote = NULL;
HANDLE event_server_read = NULL;
HANDLE event_client_wrote = NULL;
HANDLE event_client_read = NULL;
HANDLE handle_file_map = NULL;
ulong connect_number;
char connect_number_char[22], *p;
char tmp[64];
char *suffix_pos;
DWORD error_allow = 0;
DWORD error_code = 0;
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part
Where:
shared_memory_base_name is unique value for each server
unique_part is uniquel value for each object (events and file-mapping)
*/
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
strmov(suffix_pos, "CONNECT_REQUEST");
if (!(event_connect_request= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
goto err;
}
strmov(suffix_pos, "CONNECT_ANSWER");
if (!(event_connect_answer= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR;
goto err;
}
strmov(suffix_pos, "CONNECT_DATA");
if (!(handle_connect_file_map= OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR;
goto err;
}
if (!(handle_connect_map= MapViewOfFile(handle_connect_file_map,
FILE_MAP_WRITE,0,0,sizeof(DWORD))))
{
error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR;
goto err;
}
/*
Send to server request of connection
*/
if (!SetEvent(event_connect_request))
{
error_allow = CR_SHARED_MEMORY_CONNECT_SET_ERROR;
goto err;
}
/*
Wait of answer from server
*/
if (WaitForSingleObject(event_connect_answer,connect_timeout*1000) !=
WAIT_OBJECT_0)
{
error_allow = CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR;
goto err;
}
/*
Get number of connection
*/
connect_number = uint4korr(handle_connect_map);/*WAX2*/
p= int2str(connect_number, connect_number_char, 10);
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part+number_of_connection
Where:
shared_memory_base_name is uniquel value for each server
unique_part is uniquel value for each object (events and file-mapping)
number_of_connection is number of connection between server and client
*/
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,
"_",NullS);
strmov(suffix_pos, "DATA");
if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_FILE_MAP_ERROR;
goto err2;
}
if ((handle_map = MapViewOfFile(handle_file_map,FILE_MAP_WRITE,0,0,
smem_buffer_length)) == NULL)
{
error_allow = CR_SHARED_MEMORY_MAP_ERROR;
goto err2;
}
strmov(suffix_pos, "SERVER_WROTE");
if ((event_server_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "SERVER_READ");
if ((event_server_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_WROTE");
if ((event_client_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_READ");
if ((event_client_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
/*
Set event that server should send data
*/
SetEvent(event_server_read);
err2:
if (error_allow == 0)
{
net->vio= vio_new_win32shared_memory(net,handle_file_map,handle_map,
event_server_wrote,
event_server_read,event_client_wrote,
event_client_read);
}
else
{
error_code = GetLastError();
if (event_server_read)
CloseHandle(event_server_read);
if (event_server_wrote)
CloseHandle(event_server_wrote);
if (event_client_read)
CloseHandle(event_client_read);
if (event_client_wrote)
CloseHandle(event_client_wrote);
if (handle_map)
UnmapViewOfFile(handle_map);
if (handle_file_map)
CloseHandle(handle_file_map);
}
err:
if (error_allow)
error_code = GetLastError();
if (event_connect_request)
CloseHandle(event_connect_request);
if (event_connect_answer)
CloseHandle(event_connect_answer);
if (handle_connect_map)
UnmapViewOfFile(handle_connect_map);
if (handle_connect_file_map)
CloseHandle(handle_connect_file_map);
if (error_allow)
{
net->last_errno=error_allow;
strmov(net->sqlstate, unknown_sqlstate);
if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR)
sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code);
else
sprintf(net->last_error,ER(net->last_errno),error_code);
return(INVALID_HANDLE_VALUE);
}
return(handle_map);
}
#endif
/***************************************************************************** /*****************************************************************************
Read a packet from server. Give error message if socket was down Read a packet from server. Give error message if socket was down
or packet is an error message or packet is an error message
...@@ -865,7 +1069,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, ...@@ -865,7 +1069,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
#ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL #ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL
else else
unpack_fields_40(data->data, field, alloc, lengths, default_value ? 6 : 5, unpack_fields_40(data->data, field, alloc, lengths, default_value ? 6 : 5,
default_value, server_capabilities & CLIENT_LONG_FLAG); default_value, (my_bool)(server_capabilities & CLIENT_LONG_FLAG));
#endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */ #endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */
#endif /*MYSQL_SERVER*/ #endif /*MYSQL_SERVER*/
free_rows(data); /* Free old data */ free_rows(data); /* Free old data */
......
...@@ -34,7 +34,7 @@ String *Item_func_geometry_from_text::val_str(String *str) ...@@ -34,7 +34,7 @@ String *Item_func_geometry_from_text::val_str(String *str)
uint32 srid; uint32 srid;
if ((arg_count == 2) && !args[1]->null_value) if ((arg_count == 2) && !args[1]->null_value)
srid= args[1]->val_int(); srid= (uint32)args[1]->val_int();
else else
srid= 0; srid= 0;
...@@ -62,7 +62,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str) ...@@ -62,7 +62,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
uint32 srid; uint32 srid;
if ((arg_count == 2) && !args[1]->null_value) if ((arg_count == 2) && !args[1]->null_value)
srid= args[1]->val_int(); srid= (uint32)args[1]->val_int();
else else
srid= 0; srid= 0;
......
...@@ -224,7 +224,7 @@ int search_keyword(THD *thd, TABLE *keywords, struct st_find_field *find_fields, ...@@ -224,7 +224,7 @@ int search_keyword(THD *thd, TABLE *keywords, struct st_find_field *find_fields,
if (!select->cond->val_int()) // Dosn't match like if (!select->cond->val_int()) // Dosn't match like
continue; continue;
*key_id= find_fields[help_keyword_help_keyword_id].field->val_int(); *key_id= (int)find_fields[help_keyword_help_keyword_id].field->val_int();
count++; count++;
} }
...@@ -556,13 +556,12 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol, ...@@ -556,13 +556,12 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol,
String **pos= pointers; String **pos= pointers;
List_iterator<String> it(*names); List_iterator<String> it(*names);
String *cur_name;
while ((*pos++= it++)); while ((*pos++= it++));
qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp); qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp);
String **end= pointers + names->elements; String **end= pointers + names->elements;
for (String **pos= pointers; pos!=end; pos++) for (pos= pointers; pos!=end; pos++)
{ {
protocol->prepare_for_resend(); protocol->prepare_for_resend();
if (source_name) if (source_name)
...@@ -688,8 +687,8 @@ int mysqld_help(THD *thd, const char *mask) ...@@ -688,8 +687,8 @@ int mysqld_help(THD *thd, const char *mask)
res= -1; res= -1;
goto end; goto end;
} }
size_t i;
for (size_t i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++) for (i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++)
tables[i].table->file->init_table_handle_for_HANDLER(); tables[i].table->file->init_table_handle_for_HANDLER();
if (!(select_topics_by_name= if (!(select_topics_by_name=
...@@ -739,9 +738,9 @@ int mysqld_help(THD *thd, const char *mask) ...@@ -739,9 +738,9 @@ int mysqld_help(THD *thd, const char *mask)
{ {
Field *topic_cat_id= used_fields[help_topic_help_category_id].field; Field *topic_cat_id= used_fields[help_topic_help_category_id].field;
Item *cond_topic_by_cat= new Item_func_equal(new Item_field(topic_cat_id), Item *cond_topic_by_cat= new Item_func_equal(new Item_field(topic_cat_id),
new Item_int(category_id)); new Item_int((int32)category_id));
Item *cond_cat_by_cat= new Item_func_equal(new Item_field(cat_cat_id), Item *cond_cat_by_cat= new Item_func_equal(new Item_field(cat_cat_id),
new Item_int(category_id)); new Item_int((int32)category_id));
if (!(select_topics_by_cat= prepare_simple_select(thd,cond_topic_by_cat, if (!(select_topics_by_cat= prepare_simple_select(thd,cond_topic_by_cat,
tables,tables[0].table, tables,tables[0].table,
&error)) || &error)) ||
......
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