mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
SCRUM
embedded-related changes include/mysql_com.h: net_flush emptification libmysqld/lib_sql.cc: Some Protocol:: methods implemented sql/convert.cc: changes to use convert in embedded library sql/field.cc: set_key_image changed sql/item.cc: obsolete functions removed sql/item.h: embedded-related changes in Protocol class sql/log.cc: there's no ports in embedded library sql/mysqld.cc: some debug stuff sql/protocol.cc: embedded-related changes sql/protocol.h: embedded-related changes sql/sql_cache.cc: comment added sql/sql_class.cc: no need to do special embedded select_send::send_row sql/sql_class.h: embedded-related changes sql/sql_parse.cc: comments added debugging stuff deleted sql/sql_show.cc: non-protocol sending removed
This commit is contained in:
parent
150a238f03
commit
f9dff9748e
15 changed files with 89 additions and 851 deletions
|
@ -227,7 +227,12 @@ void my_net_local_init(NET *net);
|
|||
void net_end(NET *net);
|
||||
void net_clear(NET *net);
|
||||
my_bool net_realloc(NET *net, unsigned long length);
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
my_bool net_flush(NET *net);
|
||||
#else
|
||||
#define net_flush(A) (0)
|
||||
#endif
|
||||
|
||||
my_bool my_net_write(NET *net,const char *packet,unsigned long len);
|
||||
my_bool net_write_command(NET *net,unsigned char command,
|
||||
const char *header, unsigned long head_len,
|
||||
|
|
|
@ -345,81 +345,6 @@ void *create_embedded_thd(int client_flag, char *db)
|
|||
|
||||
C_MODE_END
|
||||
|
||||
bool send_fields(THD *thd, List<Item> &list, uint flag)
|
||||
{
|
||||
List_iterator_fast<Item> it(list);
|
||||
Item *item;
|
||||
MEM_ROOT *alloc;
|
||||
MYSQL_FIELD *field, *client_field;
|
||||
unsigned int field_count= list.elements;
|
||||
MYSQL *mysql= thd->mysql;
|
||||
|
||||
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
|
||||
sizeof(ulong) * (field_count + 1),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
goto err;
|
||||
mysql->result->lengths= (ulong *)(mysql->result + 1);
|
||||
|
||||
mysql->field_count=field_count;
|
||||
alloc= &mysql->field_alloc;
|
||||
field= (MYSQL_FIELD *)alloc_root(alloc, sizeof(MYSQL_FIELD)*list.elements);
|
||||
if (!field)
|
||||
goto err;
|
||||
|
||||
client_field= field;
|
||||
while ((item= it++))
|
||||
{
|
||||
Send_field server_field;
|
||||
item->make_field(&server_field);
|
||||
|
||||
client_field->table= strdup_root(alloc, server_field.table_name);
|
||||
client_field->name= strdup_root(alloc,server_field.col_name);
|
||||
client_field->length= server_field.length;
|
||||
client_field->type= server_field.type;
|
||||
client_field->flags= server_field.flags;
|
||||
client_field->decimals= server_field.decimals;
|
||||
|
||||
if (INTERNAL_NUM_FIELD(client_field))
|
||||
client_field->flags|= NUM_FLAG;
|
||||
|
||||
if (flag & 2)
|
||||
{
|
||||
char buff[80];
|
||||
String tmp(buff, sizeof(buff), default_charset_info), *res;
|
||||
|
||||
if (!(res=item->val_str(&tmp)))
|
||||
client_field->def= strdup_root(alloc, "");
|
||||
else
|
||||
client_field->def= strdup_root(alloc, tmp.ptr());
|
||||
}
|
||||
else
|
||||
client_field->def=0;
|
||||
client_field->max_length= 0;
|
||||
++client_field;
|
||||
}
|
||||
mysql->result->fields = field;
|
||||
|
||||
if (!(mysql->result->data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
goto err;
|
||||
|
||||
init_alloc_root(&mysql->result->data->alloc,8192,0); /* Assume rowlength < 8192 */
|
||||
mysql->result->data->alloc.min_malloc=sizeof(MYSQL_ROWS);
|
||||
mysql->result->data->rows=0;
|
||||
mysql->result->data->fields=field_count;
|
||||
mysql->result->field_count=field_count;
|
||||
mysql->result->data->prev_ptr= &mysql->result->data->data;
|
||||
|
||||
mysql->result->field_alloc= mysql->field_alloc;
|
||||
mysql->result->current_field=0;
|
||||
mysql->result->current_row=0;
|
||||
|
||||
return 0;
|
||||
err:
|
||||
send_error(thd, ER_OUT_OF_RESOURCES); /* purecov: inspected */
|
||||
return 1; /* purecov: inspected */
|
||||
}
|
||||
|
||||
bool Protocol::send_fields(List<Item> *list, uint flag)
|
||||
{
|
||||
List_iterator_fast<Item> it(*list);
|
||||
|
@ -429,6 +354,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
|
|||
|
||||
DBUG_ENTER("send_fields");
|
||||
|
||||
field_count= list->elements;
|
||||
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
|
||||
sizeof(ulong) * (field_count + 1),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
|
@ -495,92 +421,17 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
|
|||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
}
|
||||
|
||||
bool Protocol::send_records_num(List<Item> *list, ulonglong records)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Protocol::write()
|
||||
{
|
||||
*next_field= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Get the length of next field. Change parameter to point at fieldstart */
|
||||
static ulong
|
||||
net_field_length(uchar **packet)
|
||||
{
|
||||
reg1 uchar *pos= *packet;
|
||||
if (*pos < 251)
|
||||
{
|
||||
(*packet)++;
|
||||
return (ulong) *pos;
|
||||
}
|
||||
if (*pos == 251)
|
||||
{
|
||||
(*packet)++;
|
||||
return NULL_LENGTH;
|
||||
}
|
||||
if (*pos == 252)
|
||||
{
|
||||
(*packet)+=3;
|
||||
return (ulong) uint2korr(pos+1);
|
||||
}
|
||||
if (*pos == 253)
|
||||
{
|
||||
(*packet)+=4;
|
||||
return (ulong) uint3korr(pos+1);
|
||||
}
|
||||
(*packet)+=9; /* Must be 254 when here */
|
||||
return (ulong) uint4korr(pos+1);
|
||||
}
|
||||
|
||||
|
||||
bool select_send::send_data(List<Item> &items)
|
||||
{
|
||||
List_iterator_fast<Item> li(items);
|
||||
Item *item;
|
||||
MYSQL_ROWS *cur;
|
||||
int n_fields= items.elements;
|
||||
ulong len;
|
||||
CONVERT *convert= thd->variables.convert_set;
|
||||
CHARSET_INFO *charset_info= thd->packet.charset();
|
||||
MYSQL_DATA *result= thd->mysql->result->data;
|
||||
MEM_ROOT *alloc= &result->alloc;
|
||||
MYSQL_ROW cur_field;
|
||||
MYSQL_FIELD *mysql_fields= thd->mysql->result->fields;
|
||||
|
||||
DBUG_ENTER("send_data");
|
||||
|
||||
if (unit->offset_limit_cnt)
|
||||
{ // using limit offset,count
|
||||
unit->offset_limit_cnt--;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
result->rows++;
|
||||
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS)+(n_fields + 1) * sizeof(char *))))
|
||||
{
|
||||
my_error(ER_OUT_OF_RESOURCES,MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
cur->data= (MYSQL_ROW)(((char *)cur) + sizeof(MYSQL_ROWS));
|
||||
|
||||
*result->prev_ptr= cur;
|
||||
result->prev_ptr= &cur->next;
|
||||
cur_field=cur->data;
|
||||
for (item=li++; item; item=li++, cur_field++, mysql_fields++)
|
||||
{
|
||||
if (item->embedded_send(convert, charset_info, alloc, cur_field, &len))
|
||||
{
|
||||
my_error(ER_OUT_OF_RESOURCES,MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (mysql_fields->max_length < len)
|
||||
mysql_fields->max_length=len;
|
||||
}
|
||||
|
||||
*cur_field= 0;
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
void
|
||||
send_ok(THD *thd,ha_rows affected_rows,ulonglong id,const char *message)
|
||||
{
|
||||
|
@ -598,86 +449,8 @@ send_ok(THD *thd,ha_rows affected_rows,ulonglong id,const char *message)
|
|||
void
|
||||
send_eof(THD *thd, bool no_flush)
|
||||
{
|
||||
/* static char eof_buff[1]= { (char) 254 };
|
||||
NET *net= &thd->net;
|
||||
DBUG_ENTER("send_eof");
|
||||
if (net->vio != 0)
|
||||
{
|
||||
if (!no_flush && (thd->client_capabilities & CLIENT_PROTOCOL_41))
|
||||
{
|
||||
char buff[5];
|
||||
uint tmp= min(thd->total_warn_count, 65535);
|
||||
buff[0]=254;
|
||||
int2store(buff+1, tmp);
|
||||
int2store(buff+3, 0); // No flags yet
|
||||
VOID(my_net_write(net,buff,5));
|
||||
VOID(net_flush(net));
|
||||
}
|
||||
else
|
||||
{
|
||||
VOID(my_net_write(net,eof_buff,1));
|
||||
if (!no_flush)
|
||||
VOID(net_flush(net));
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
*/
|
||||
}
|
||||
|
||||
#ifdef DUMMY
|
||||
int embedded_send_row(THD *thd, int n_fields, const char *data, int data_len)
|
||||
{
|
||||
MYSQL *mysql= thd->mysql;
|
||||
MYSQL_DATA *result= mysql->result->data;
|
||||
MYSQL_ROWS **prev_ptr= &mysql->result->data->data;
|
||||
MYSQL_ROWS *cur;
|
||||
MEM_ROOT *alloc= &mysql->result->data->alloc;
|
||||
char *to;
|
||||
uchar *cp;
|
||||
MYSQL_FIELD *mysql_fields= mysql->result->fields;
|
||||
MYSQL_ROW cur_field, end_field;
|
||||
ulong len;
|
||||
|
||||
DBUG_ENTER("embedded_send_row");
|
||||
|
||||
result->rows++;
|
||||
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (n_fields + 1) * sizeof(MYSQL_ROW) + data_len)))
|
||||
{
|
||||
my_error(ER_OUT_OF_RESOURCES,MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
cur->data= (MYSQL_ROW)(cur + 1);
|
||||
|
||||
*result->prev_ptr= cur;
|
||||
result->prev_ptr= &cur->next;
|
||||
to= (char*) (cur->data+n_fields+1);
|
||||
cp= (uchar *)data;
|
||||
end_field= cur->data + n_fields;
|
||||
|
||||
for (cur_field=cur->data; cur_field<end_field; cur_field++, mysql_fields++)
|
||||
{
|
||||
if ((len= (ulong) net_field_length(&cp)) == NULL_LENGTH)
|
||||
{
|
||||
*cur_field = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*cur_field= to;
|
||||
memcpy(to,(char*) cp,len);
|
||||
to[len]=0;
|
||||
to+=len+1;
|
||||
cp+=len;
|
||||
if (mysql_fields->max_length < len)
|
||||
mysql_fields->max_length=len;
|
||||
}
|
||||
}
|
||||
|
||||
*cur_field= to;
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint STDCALL mysql_warning_count(MYSQL *mysql)
|
||||
{
|
||||
return ((THD *)mysql->thd)->total_warn_count;
|
||||
|
@ -688,11 +461,10 @@ void Protocol_simple::prepare_for_resend()
|
|||
MYSQL_ROWS *cur;
|
||||
ulong len;
|
||||
MYSQL_DATA *result= thd->mysql->result->data;
|
||||
MEM_ROOT *alloc= &result->alloc;
|
||||
MYSQL_FIELD *mysql_fields= thd->mysql->result->fields;
|
||||
|
||||
DBUG_ENTER("send_data");
|
||||
|
||||
alloc= &result->alloc;
|
||||
result->rows++;
|
||||
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS)+(field_count + 1) * sizeof(char *))))
|
||||
{
|
||||
|
@ -704,26 +476,44 @@ void Protocol_simple::prepare_for_resend()
|
|||
*result->prev_ptr= cur;
|
||||
result->prev_ptr= &cur->next;
|
||||
next_field=cur->data;
|
||||
next_mysql_field= thd->mysql->result->fields;
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool Protocol::net_store_data(const char *from, uint length)
|
||||
bool Protocol_simple::store_null()
|
||||
{
|
||||
MYSQL_FIELD *mysql_fields= thd->mysql->result->fields;
|
||||
if (!length)
|
||||
{
|
||||
*next_field= NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(*next_field=alloc_root(alloc, length + 1)))
|
||||
return true;
|
||||
memcpy(*next_field, from, length);
|
||||
(*next_field)[length]= 0;
|
||||
}
|
||||
++next_field;
|
||||
if (mysql_fields->max_length < length)
|
||||
mysql_fields->max_length=length;
|
||||
*(next_field++)= NULL;
|
||||
++next_mysql_field;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Protocol::net_store_data(const char *from, uint length)
|
||||
{
|
||||
if (!(*next_field=alloc_root(alloc, length + 1)))
|
||||
return true;
|
||||
memcpy(*next_field, from, length);
|
||||
(*next_field)[length]= 0;
|
||||
if (next_mysql_field->max_length < length)
|
||||
next_mysql_field->max_length=length;
|
||||
++next_field;
|
||||
++next_mysql_field;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The same as Protocol::net_store_data but does the converstion
|
||||
*/
|
||||
bool Protocol::convert_str(const char *from, uint length)
|
||||
{
|
||||
if (!(*next_field=alloc_root(alloc, length + 1)))
|
||||
return true;
|
||||
convert->store_dest(*next_field, from, length);
|
||||
(*next_field)[length]= 0;
|
||||
if (next_mysql_field->max_length < length)
|
||||
next_mysql_field->max_length=length;
|
||||
++next_field;
|
||||
++next_mysql_field;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -457,18 +457,6 @@ bool CONVERT::store(String *packet,const char *from,uint length)
|
|||
return 1;
|
||||
char *to=(char*) net_store_length((char*) packet->ptr()+packet_length,
|
||||
(ulonglong)length);
|
||||
|
||||
for (const char *end=from+length ; from != end ; from++)
|
||||
*to++= to_map[(uchar) *from];
|
||||
packet->length((uint) (to-packet->ptr()));
|
||||
packet->length((uint) (store_dest(to, from, length)-packet->ptr()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
void CONVERT::convert_back(char *dest, const char *source, uint length) const
|
||||
{
|
||||
for (char *end= dest+length; dest < end; dest++, source++)
|
||||
*dest= to_map[*source];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4589,7 +4589,7 @@ void Field_geom::get_key_image(char *buff,uint length,CHARSET_INFO *cs, imagetyp
|
|||
|
||||
void Field_geom::set_key_image(char *buff,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
Field_blob::set_key_image(buff, length);
|
||||
Field_blob::set_key_image(buff, length, cs);
|
||||
}
|
||||
|
||||
void Field_geom::sql_type(String &res) const
|
||||
|
|
58
sql/item.cc
58
sql/item.cc
|
@ -1006,64 +1006,6 @@ bool Item_field::send(Protocol *protocol, String *buffer)
|
|||
return protocol->store(result_field);
|
||||
}
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length)
|
||||
{
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String s(buff, sizeof(buff), charset), *value;
|
||||
if (!(value=val_str(&s)))
|
||||
{
|
||||
*result= NULL;
|
||||
*length= 0;
|
||||
return false;
|
||||
}
|
||||
if (!(*result=alloc_root(alloc, value->length() + 1)))
|
||||
return true;
|
||||
*length= value->length();
|
||||
if (convert)
|
||||
convert->convert_back(*result, value->ptr(), *length);
|
||||
else
|
||||
memcpy(*result, value->ptr(), *length);
|
||||
(*result)[*length]= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length)
|
||||
{
|
||||
*result= NULL;
|
||||
*length= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length)
|
||||
{
|
||||
if (result_field->is_null())
|
||||
{
|
||||
*result= NULL;
|
||||
*length= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String tmp(buff,sizeof(buff),default_charset_info);
|
||||
result_field->val_str(&tmp,&tmp);
|
||||
|
||||
if (!(*result=alloc_root(alloc, tmp.length() + 1)))
|
||||
return true;
|
||||
*length= tmp.length();
|
||||
if (convert)
|
||||
convert->convert_back(*result, tmp.ptr(), *length);
|
||||
else
|
||||
memcpy(*result, tmp.ptr(), *length);
|
||||
(*result)[*length]= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
This is used for HAVING clause
|
||||
Find field in select list having the same name
|
||||
|
|
18
sql/item.h
18
sql/item.h
|
@ -19,7 +19,6 @@
|
|||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
class CONVERT;
|
||||
class Protocol;
|
||||
struct st_table_list;
|
||||
void item_init(void); /* Init item functions */
|
||||
|
@ -64,10 +63,6 @@ public:
|
|||
virtual int save_safe_in_field(Field *field)
|
||||
{ return save_in_field(field, 1); }
|
||||
virtual bool send(Protocol *protocol, String *str);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
virtual bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length);
|
||||
#endif
|
||||
virtual bool eq(const Item *, bool binary_cmp) const;
|
||||
virtual Item_result result_type () const { return REAL_RESULT; }
|
||||
virtual enum_field_types field_type() const;
|
||||
|
@ -155,10 +150,6 @@ public:
|
|||
longlong val_int_result();
|
||||
String *str_result(String* tmp);
|
||||
bool send(Protocol *protocol, String *str_arg);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length);
|
||||
#endif
|
||||
bool fix_fields(THD *, struct st_table_list *, Item **);
|
||||
void make_field(Send_field *tmp_field);
|
||||
int save_in_field(Field *field,bool no_conversions);
|
||||
|
@ -192,10 +183,6 @@ public:
|
|||
int save_in_field(Field *field, bool no_conversions);
|
||||
int save_safe_in_field(Field *field);
|
||||
bool send(Protocol *protocol, String *str);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length);
|
||||
#endif
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
|
||||
bool fix_fields(THD *thd, struct st_table_list *list, Item **item)
|
||||
|
@ -499,11 +486,6 @@ public:
|
|||
return (null_value=(*ref)->get_date(ltime,fuzzydate));
|
||||
}
|
||||
bool send(Protocol *prot, String *tmp){ return (*ref)->send(prot, tmp); }
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
bool embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
|
||||
char **result, ulong *length)
|
||||
{ return (*ref)->embedded_send(convert, charset, alloc, result, length); }
|
||||
#endif
|
||||
void make_field(Send_field *field) { (*ref)->make_field(field); }
|
||||
bool fix_fields(THD *, struct st_table_list *, Item **);
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#endif
|
||||
|
||||
#include "mysql_priv.h"
|
||||
#include <mysql.h>
|
||||
#include "sql_acl.h"
|
||||
#include "sql_repl.h"
|
||||
|
||||
|
@ -203,7 +202,9 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
|
|||
case LOG_NORMAL:
|
||||
{
|
||||
char *end;
|
||||
#ifdef __NT__
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
sprintf(buff, "%s, Version: %s, embedded library\n", my_progname, server_version);
|
||||
#elif __NT__
|
||||
sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port);
|
||||
#else
|
||||
sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port);
|
||||
|
|
478
sql/mysqld.cc
478
sql/mysqld.cc
|
@ -956,8 +956,8 @@ static void set_ports()
|
|||
{ // Get port if not from commandline
|
||||
struct servent *serv_ptr;
|
||||
mysql_port = MYSQL_PORT;
|
||||
if ((serv_ptr = getservbyname("mysql", "tcp")))
|
||||
mysql_port = ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
|
||||
// if ((serv_ptr = getservbyname("mysql", "tcp")))
|
||||
// mysql_port = ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
|
||||
if ((env = getenv("MYSQL_TCP_PORT")))
|
||||
mysql_port = (uint) atoi(env); /* purecov: inspected */
|
||||
}
|
||||
|
@ -1865,6 +1865,7 @@ static int init_common_variables(const char *conf_file_name, int argc, char **ar
|
|||
umask(((~my_umask) & 0666));
|
||||
tzset(); // Set tzname
|
||||
|
||||
max_system_variables.pseudo_thread_id= (ulong)~0;
|
||||
start_time=time((time_t*) 0);
|
||||
#ifdef OS2
|
||||
{
|
||||
|
@ -2287,7 +2288,6 @@ The server will not act as a slave.");
|
|||
|
||||
if (opt_bootstrap)
|
||||
{
|
||||
printf("###stdin as bootstrap\n");
|
||||
int error=bootstrap(stdin);
|
||||
end_thr_alarm(); // Don't allow alarms
|
||||
unireg_abort(error ? 1 : 0);
|
||||
|
@ -2358,478 +2358,6 @@ The server will not act as a slave.");
|
|||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
#ifdef REMOTE
|
||||
|
||||
#ifdef __WIN__
|
||||
int win_main(int argc, char **argv)
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
DEBUGGER_OFF;
|
||||
|
||||
my_umask=0660; // Default umask for new files
|
||||
my_umask_dir=0700; // Default umask for new directories
|
||||
MAIN_THD;
|
||||
/*
|
||||
Initialize signal_th and shutdown_th to main_th for default value
|
||||
as we need to initialize them to something safe. They are used
|
||||
when compiled with safemalloc.
|
||||
*/
|
||||
SIGNAL_THD;
|
||||
SHUTDOWN_THD;
|
||||
MY_INIT(argv[0]); // init my_sys library & pthreads
|
||||
tzset(); // Set tzname
|
||||
|
||||
start_time=time((time_t*) 0);
|
||||
#ifdef OS2
|
||||
{
|
||||
// fix timezone for daylight saving
|
||||
struct tm *ts = localtime(&start_time);
|
||||
if (ts->tm_isdst > 0)
|
||||
_timezone -= 3600;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TZNAME
|
||||
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
|
||||
{
|
||||
struct tm tm_tmp;
|
||||
localtime_r(&start_time,&tm_tmp);
|
||||
strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct tm *start_tm;
|
||||
start_tm=localtime(&start_time);
|
||||
strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
|
||||
strmov(glob_hostname,"mysql");
|
||||
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
|
||||
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
|
||||
#ifndef DBUG_OFF
|
||||
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
|
||||
#else
|
||||
strmov(strend(server_version),MYSQL_SERVER_SUFFIX);
|
||||
#endif
|
||||
#ifdef _CUSTOMSTARTUPCONFIG_
|
||||
if (_cust_check_startup())
|
||||
{
|
||||
/* _cust_check_startup will report startup failure error */
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
load_defaults(MYSQL_CONFIG_NAME,load_default_groups,&argc,&argv);
|
||||
defaults_argv=argv;
|
||||
|
||||
set_options();
|
||||
get_options(argc,argv);
|
||||
max_system_variables.pseudo_thread_id= (ulong)~0;
|
||||
if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
|
||||
strcat(server_version,"-log");
|
||||
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
|
||||
server_version, SYSTEM_TYPE,MACHINE_TYPE));
|
||||
|
||||
/* These must be set early */
|
||||
|
||||
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_open,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
|
||||
(void) my_rwlock_init(&LOCK_grant, NULL);
|
||||
(void) pthread_cond_init(&COND_thread_count,NULL);
|
||||
(void) pthread_cond_init(&COND_refresh,NULL);
|
||||
(void) pthread_cond_init(&COND_thread_cache,NULL);
|
||||
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
|
||||
(void) pthread_cond_init(&COND_manager,NULL);
|
||||
(void) pthread_cond_init(&COND_rpl_status, NULL);
|
||||
init_signals();
|
||||
|
||||
if (set_default_charset_by_name(sys_charset.value, MYF(MY_WME)))
|
||||
exit(1);
|
||||
charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
{
|
||||
/* having ssl_acceptor_fd != 0 signals the use of SSL */
|
||||
ssl_acceptor_fd= new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert,
|
||||
opt_ssl_ca, opt_ssl_capath,
|
||||
opt_ssl_cipher);
|
||||
DBUG_PRINT("info",("ssl_acceptor_fd: %lx", (long) ssl_acceptor_fd));
|
||||
if (!ssl_acceptor_fd)
|
||||
opt_use_ssl = 0;
|
||||
}
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
#ifdef HAVE_LIBWRAP
|
||||
libwrapName= my_progname+dirname_length(my_progname);
|
||||
openlog(libwrapName, LOG_PID, LOG_AUTH);
|
||||
#endif
|
||||
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
|
||||
/* Parameter for threads created for connections */
|
||||
(void) pthread_attr_init(&connection_attrib);
|
||||
(void) pthread_attr_setdetachstate(&connection_attrib,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack);
|
||||
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
|
||||
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
|
||||
|
||||
#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
|
||||
/* connections and databases needs lots of files */
|
||||
{
|
||||
uint wanted_files=10+(uint) max(max_connections*5,
|
||||
max_connections+table_cache_size*2);
|
||||
set_if_bigger(wanted_files, open_files_limit);
|
||||
// Note that some system returns 0 if we succeed here:
|
||||
uint files=set_maximum_open_files(wanted_files);
|
||||
if (files && files < wanted_files && ! open_files_limit)
|
||||
{
|
||||
max_connections= (ulong) min((files-10),max_connections);
|
||||
table_cache_size= (ulong) max((files-10-max_connections)/2,64);
|
||||
DBUG_PRINT("warning",
|
||||
("Changed limits: max_connections: %ld table_cache: %ld",
|
||||
max_connections,table_cache_size));
|
||||
sql_print_error("Warning: Changed limits: max_connections: %ld table_cache: %ld",max_connections,table_cache_size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
unireg_init(opt_specialflag); /* Set up extern variabels */
|
||||
init_errmessage(); /* Read error messages from file */
|
||||
lex_init();
|
||||
item_init();
|
||||
set_var_init();
|
||||
mysys_uses_curses=0;
|
||||
#ifdef USE_REGEX
|
||||
regex_init();
|
||||
#endif
|
||||
select_thread=pthread_self();
|
||||
select_thread_in_use=1;
|
||||
if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
|
||||
unireg_abort(1);
|
||||
|
||||
/*
|
||||
We have enough space for fiddling with the argv, continue
|
||||
*/
|
||||
umask(((~my_umask) & 0666));
|
||||
if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
|
||||
{
|
||||
unireg_abort(1); /* purecov: inspected */
|
||||
}
|
||||
mysql_data_home= mysql_data_home_buff;
|
||||
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
|
||||
mysql_data_home[1]=0;
|
||||
server_init();
|
||||
table_cache_init();
|
||||
hostname_cache_init();
|
||||
query_cache_result_size_limit(query_cache_limit);
|
||||
query_cache_resize(query_cache_size);
|
||||
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
|
||||
reset_floating_point_exceptions();
|
||||
init_thr_lock();
|
||||
init_slave_list();
|
||||
#ifdef HAVE_OPENSSL
|
||||
if (des_key_file)
|
||||
load_des_key_file(des_key_file);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
/* Setup log files */
|
||||
if (opt_log)
|
||||
open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
|
||||
LOG_NORMAL);
|
||||
if (opt_update_log)
|
||||
{
|
||||
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
|
||||
NullS, LOG_NEW);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
if (opt_slow_log)
|
||||
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
|
||||
NullS, LOG_NORMAL);
|
||||
#ifdef __WIN__
|
||||
#define MYSQL_ERR_FILE "mysql.err"
|
||||
if (!opt_console)
|
||||
{
|
||||
freopen(MYSQL_ERR_FILE,"a+",stdout);
|
||||
freopen(MYSQL_ERR_FILE,"a+",stderr);
|
||||
}
|
||||
#endif
|
||||
if (ha_init())
|
||||
{
|
||||
sql_print_error("Can't init databases");
|
||||
if (unix_sock != INVALID_SOCKET)
|
||||
unlink(mysql_unix_port);
|
||||
exit(1);
|
||||
}
|
||||
ha_key_cache();
|
||||
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
|
||||
if (locked_in_memory && !geteuid())
|
||||
{
|
||||
if (mlockall(MCL_CURRENT))
|
||||
{
|
||||
sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno);
|
||||
}
|
||||
else
|
||||
locked_in_memory=1;
|
||||
}
|
||||
#else
|
||||
locked_in_memory=0;
|
||||
#endif
|
||||
|
||||
if (opt_myisam_log)
|
||||
(void) mi_log( 1 );
|
||||
ft_init_stopwords(ft_precompiled_stopwords);
|
||||
|
||||
#ifdef __WIN__
|
||||
if (!opt_console)
|
||||
FreeConsole(); // Remove window
|
||||
#endif
|
||||
|
||||
/*
|
||||
init signals & alarm
|
||||
After this we can't quit by a simple unireg_abort
|
||||
*/
|
||||
error_handler_hook = my_message_sql;
|
||||
if (pthread_key_create(&THR_THD,NULL) ||
|
||||
pthread_key_create(&THR_MALLOC,NULL))
|
||||
{
|
||||
sql_print_error("Can't create thread-keys");
|
||||
if (unix_sock != INVALID_SOCKET)
|
||||
unlink(mysql_unix_port);
|
||||
exit(1);
|
||||
}
|
||||
start_signal_handler(); // Creates pidfile
|
||||
if (acl_init((THD*) 0, opt_noacl))
|
||||
{
|
||||
abort_loop=1;
|
||||
select_thread_in_use=0;
|
||||
(void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL);
|
||||
#ifndef __WIN__
|
||||
if (!opt_bootstrap)
|
||||
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
|
||||
#endif
|
||||
if (unix_sock != INVALID_SOCKET)
|
||||
unlink(mysql_unix_port);
|
||||
exit(1);
|
||||
}
|
||||
if (!opt_noacl)
|
||||
(void) grant_init((THD*) 0);
|
||||
init_max_user_conn();
|
||||
init_update_queries();
|
||||
DBUG_ASSERT(current_thd == 0);
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
if (!opt_noacl)
|
||||
udf_init();
|
||||
#endif
|
||||
/* init_slave() must be called after the thread keys are created */
|
||||
init_slave();
|
||||
|
||||
DBUG_ASSERT(current_thd == 0);
|
||||
if (opt_bin_log && !server_id)
|
||||
{
|
||||
server_id= !master_host ? 1 : 2;
|
||||
switch (server_id) {
|
||||
#ifdef EXTRA_DEBUG
|
||||
case 1:
|
||||
sql_print_error("\
|
||||
Warning: You have enabled the binary log, but you haven't set server-id:\n\
|
||||
Updates will be logged to the binary log, but connections to slaves will\n\
|
||||
not be accepted.");
|
||||
break;
|
||||
#endif
|
||||
case 2:
|
||||
sql_print_error("\
|
||||
Warning: You should set server-id to a non-0 value if master_host is set.\n\
|
||||
The server will not act as a slave.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (opt_bin_log)
|
||||
{
|
||||
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
|
||||
opt_binlog_index_name,LOG_BIN);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
|
||||
if (opt_bootstrap)
|
||||
{
|
||||
int error=bootstrap(stdin);
|
||||
end_thr_alarm(); // Don't allow alarms
|
||||
unireg_abort(error ? 1 : 0);
|
||||
}
|
||||
if (opt_init_file)
|
||||
{
|
||||
if (read_init_file(opt_init_file))
|
||||
{
|
||||
end_thr_alarm(); // Don't allow alarms
|
||||
unireg_abort(1);
|
||||
}
|
||||
}
|
||||
(void) thr_setconcurrency(concurrency); // 10 by default
|
||||
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
|
||||
{
|
||||
hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_error("Warning: Can't create thread to handle shutdown requests");
|
||||
|
||||
// On "Stop Service" we have to do regular shutdown
|
||||
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
|
||||
!berkeley_skip ||
|
||||
#endif
|
||||
(flush_time && flush_time != ~(ulong) 0L))
|
||||
{
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
|
||||
sql_print_error("Warning: Can't create thread to manage maintenance");
|
||||
}
|
||||
|
||||
printf(ER(ER_READY),my_progname,server_version,"");
|
||||
fflush(stdout);
|
||||
#if defined(__NT__) || defined(HAVE_SMEM)
|
||||
#ifdef __NT__
|
||||
if (hPipe == INVALID_HANDLE_VALUE &&
|
||||
(!have_tcpip || opt_disable_networking) &&
|
||||
!opt_enable_shared_memory)
|
||||
{
|
||||
sql_print_error("TCP/IP,--shared-memory or --named-pipe should be configured on NT OS");
|
||||
unireg_abort(1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
(void) pthread_cond_init(&COND_handler_count,NULL);
|
||||
{
|
||||
pthread_t hThread;
|
||||
handler_count=0;
|
||||
#ifdef __NT__
|
||||
if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_namedpipes, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle named pipes");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SMEM
|
||||
if (opt_enable_shared_memory)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_shared_memory, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle shared memory");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (have_tcpip && !opt_disable_networking)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_sockets, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle tcp/ip");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
while (handler_count > 0)
|
||||
{
|
||||
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
}
|
||||
#else
|
||||
handle_connections_sockets(0);
|
||||
#ifdef EXTRA_DEBUG2
|
||||
sql_print_error("Exiting main thread");
|
||||
#endif
|
||||
#endif /* __NT__ */
|
||||
|
||||
/* (void) pthread_attr_destroy(&connection_attrib); */
|
||||
|
||||
DBUG_PRINT("quit",("Exiting main thread"));
|
||||
|
||||
#ifndef __WIN__
|
||||
#ifdef EXTRA_DEBUG2
|
||||
sql_print_error("Before Lock_thread_count");
|
||||
#endif
|
||||
(void) pthread_mutex_lock(&LOCK_thread_count);
|
||||
DBUG_PRINT("quit", ("Got thread_count mutex"));
|
||||
select_thread_in_use=0; // For close_connections
|
||||
(void) pthread_mutex_unlock(&LOCK_thread_count);
|
||||
(void) pthread_cond_broadcast(&COND_thread_count);
|
||||
#ifdef EXTRA_DEBUG2
|
||||
sql_print_error("After lock_thread_count");
|
||||
#endif
|
||||
#endif /* __WIN__ */
|
||||
|
||||
/* Wait until cleanup is done */
|
||||
(void) pthread_mutex_lock(&LOCK_thread_count);
|
||||
while (!ready_to_exit)
|
||||
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
|
||||
(void) pthread_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
|
||||
if (Service.IsNT() && start_mode)
|
||||
Service.Stop();
|
||||
else
|
||||
{
|
||||
Service.SetShutdownEvent(0);
|
||||
if (hEventShutdown)
|
||||
CloseHandle(hEventShutdown);
|
||||
}
|
||||
#endif
|
||||
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||
exit(0);
|
||||
return(0); /* purecov: deadcode */
|
||||
}
|
||||
#endif /* REMOTE */
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
Main and thread entry function for Win32
|
||||
(all this is needed only to run mysqld as a service on WinNT)
|
||||
|
|
|
@ -41,6 +41,10 @@ bool Protocol::net_store_data(const char *from, uint length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline bool Protocol::convert_str(const char *from, uint length)
|
||||
{
|
||||
convert->store(packet, from, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -56,7 +60,7 @@ void send_error(THD *thd, uint sql_errno, const char *err)
|
|||
err ? err : net->last_error[0] ?
|
||||
net->last_error : "NULL"));
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/
|
||||
query_cache_abort(net);
|
||||
#endif
|
||||
thd->query_error= 1; // needed to catch query errors during replication
|
||||
|
@ -577,6 +581,15 @@ err:
|
|||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
}
|
||||
|
||||
bool Protocol::send_records_num(List<Item> *list, ulonglong records)
|
||||
{
|
||||
char *pos;
|
||||
char buff[20];
|
||||
pos=net_store_length(buff, (uint) list->elements);
|
||||
pos=net_store_length(pos, records);
|
||||
return my_net_write(&thd->net, buff,(uint) (pos-buff));
|
||||
}
|
||||
|
||||
bool Protocol::write()
|
||||
{
|
||||
DBUG_ENTER("Protocol::write");
|
||||
|
@ -652,7 +665,6 @@ void Protocol_simple::prepare_for_resend()
|
|||
field_pos= 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Protocol_simple::store_null()
|
||||
{
|
||||
|
@ -663,6 +675,7 @@ bool Protocol_simple::store_null()
|
|||
buff[0]= (char)251;
|
||||
return packet->append(buff, sizeof(buff), PACKET_BUFFET_EXTRA_ALLOC);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Protocol_simple::store(const char *from, uint length)
|
||||
{
|
||||
|
@ -674,7 +687,7 @@ bool Protocol_simple::store(const char *from, uint length)
|
|||
field_pos++;
|
||||
#endif
|
||||
if (convert)
|
||||
return convert->store(packet, from, length);
|
||||
return convert_str(from, length);
|
||||
return net_store_data(from, length);
|
||||
}
|
||||
|
||||
|
@ -757,7 +770,7 @@ bool Protocol_simple::store(Field *field)
|
|||
String tmp(buff,sizeof(buff),default_charset_info);
|
||||
field->val_str(&tmp,&tmp);
|
||||
if (convert)
|
||||
return convert->store(packet, tmp.ptr(), tmp.length());
|
||||
return convert_str(tmp.ptr(), tmp.length());
|
||||
return net_store_data(tmp.ptr(), tmp.length());
|
||||
}
|
||||
|
||||
|
@ -863,7 +876,7 @@ bool Protocol_prep::store(const char *from,uint length)
|
|||
#endif
|
||||
field_pos++;
|
||||
if (convert)
|
||||
return convert->store(packet, from, length);
|
||||
return convert_str(from, length);
|
||||
return net_store_data(from, length);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
class CONVERT;
|
||||
class i_string;
|
||||
class THD;
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
typedef struct st_mysql_field MYSQL_FIELD;
|
||||
#endif
|
||||
class Protocol
|
||||
{
|
||||
protected:
|
||||
|
@ -35,11 +37,12 @@ protected:
|
|||
#endif
|
||||
uint field_count;
|
||||
bool net_store_data(const char *from, uint length);
|
||||
bool convert_str(const char *from, uint length);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
char **next_field;
|
||||
MYSQL_FIELD *next_mysql_field;
|
||||
MEM_ROOT *alloc;
|
||||
#endif
|
||||
|
||||
public:
|
||||
CONVERT *convert;
|
||||
|
||||
|
@ -47,6 +50,7 @@ public:
|
|||
Protocol(THD *thd) { init(thd); }
|
||||
void init(THD* thd);
|
||||
bool send_fields(List<Item> *list, uint flag);
|
||||
bool send_records_num(List<Item> *list, ulonglong records);
|
||||
bool store(I_List<i_string> *str_list);
|
||||
bool store(const char *from);
|
||||
String *storage_packet() { return packet; }
|
||||
|
|
|
@ -1022,7 +1022,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
|||
ALIGN_SIZE(sizeof(Query_cache_result))));
|
||||
|
||||
Query_cache_result *result = result_block->result();
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/
|
||||
if (net_real_write(&thd->net, result->data(),
|
||||
result_block->used -
|
||||
result_block->headers_len() -
|
||||
|
|
|
@ -516,9 +516,6 @@ bool select_send::send_fields(List<Item> &list,uint flag)
|
|||
return thd->protocol->send_fields(&list,flag);
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
/* Send data to client. Returns 0 if ok */
|
||||
|
||||
bool select_send::send_data(List<Item> &items)
|
||||
|
@ -551,7 +548,6 @@ bool select_send::send_data(List<Item> &items)
|
|||
DBUG_RETURN(protocol->write());
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
bool select_send::send_eof()
|
||||
{
|
||||
|
|
|
@ -177,10 +177,13 @@ public:
|
|||
{
|
||||
convert_array(from_map, (uchar*) a,length);
|
||||
}
|
||||
char *store_dest(char *to, const char *from, uint length)
|
||||
{
|
||||
for (const char *end=from+length ; from != end ; from++)
|
||||
*to++= to_map[(uchar) *from];
|
||||
return to;
|
||||
}
|
||||
bool store(String *, const char *,uint);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
void convert_back(char *dest, const char *source, uint length) const;
|
||||
#endif
|
||||
inline uint number() { return numb; }
|
||||
};
|
||||
|
||||
|
|
|
@ -857,7 +857,6 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
|
|||
TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC);
|
||||
while (fgets(buff, thd->net.max_packet, file))
|
||||
{
|
||||
printf("%s", buff);
|
||||
uint length=(uint) strlen(buff);
|
||||
while (length && (my_isspace(system_charset_info, buff[length-1]) ||
|
||||
buff[length-1] == ';'))
|
||||
|
@ -940,9 +939,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
|
|||
my_error(ER_GET_ERRNO, MYF(0));
|
||||
goto err;
|
||||
}
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
net_flush(&thd->net);
|
||||
#endif
|
||||
if ((error = table->file->dump(thd,fd)))
|
||||
my_error(ER_GET_ERRNO, MYF(0));
|
||||
|
||||
|
@ -3239,7 +3236,7 @@ mysql_parse(THD *thd, char *inBuf, uint length)
|
|||
else
|
||||
{
|
||||
mysql_execute_command(thd);
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/
|
||||
query_cache_end_of_result(&thd->net);
|
||||
#endif
|
||||
}
|
||||
|
@ -3249,7 +3246,7 @@ mysql_parse(THD *thd, char *inBuf, uint length)
|
|||
{
|
||||
DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
|
||||
thd->fatal_error));
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/
|
||||
query_cache_abort(&thd->net);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -687,15 +687,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
|
|||
field_list.push_back(new Item_empty_string("Comment",255));
|
||||
}
|
||||
// Send first number of fields and records
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
{
|
||||
char *pos;
|
||||
pos=net_store_length(tmp, (uint) field_list.elements);
|
||||
pos=net_store_length(pos,(ulonglong) file->records);
|
||||
(void) my_net_write(&thd->net,tmp,(uint) (pos-tmp));
|
||||
}
|
||||
#endif
|
||||
if (protocol->send_fields(&field_list,0))
|
||||
if (protocol->send_records_num(&field_list, (ulonglong)file->records) ||
|
||||
protocol->send_fields(&field_list,0))
|
||||
DBUG_RETURN(1);
|
||||
restore_record(table,2); // Get empty record
|
||||
|
||||
|
@ -963,9 +956,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
|
|||
restore_record(table,2); // Get empty record
|
||||
if (thd->protocol->send_fields(&field_list,2))
|
||||
DBUG_VOID_RETURN;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
VOID(net_flush(&thd->net));
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -982,7 +973,6 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
|
|||
if (store_create_info(thd, table, packet))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (protocol->convert)
|
||||
protocol->convert->convert((char*) packet->ptr(), packet->length());
|
||||
if (fd < 0)
|
||||
|
@ -997,7 +987,6 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
|
|||
MYF(MY_WME)))
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
#endif
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue