1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
embedded library trimming


include/my_global.h:
  HAVE_REPLICATION & HAVE_EXTERNAL_CLIENT macro definitions
libmysqld/lib_sql.cc:
  Protocol:: methods implementation for embedded case
sql/field.cc:
  geometry type methods implementations
sql/ha_berkeley.cc:
  set_nfields deletion
sql/ha_innodb.cc:
  macro changed
sql/ha_myisam.cc:
  set_nfields deletion
sql/ha_myisam.h:
  code #ifdef-ed
sql/item.cc:
  bugfix
sql/item_func.cc:
  macro changed
sql/item_strfunc.cc:
  superfluous code deleted
sql/log.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/log_event.cc:
  #ifdef constructions changed
sql/log_event.h:
  #ifdef-s changed
sql/mf_iocache.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/mini_client.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/mysql_priv.h:
  code removation
sql/mysqld.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/opt_range.cc:
  code trimming
sql/protocol.cc:
  net_store_data becomes a member of Protocol
sql/protocol.h:
  changes to make Protocol working in embedded library
sql/repl_failsafe.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/repl_failsafe.h:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/set_var.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/slave.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/slave.h:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/sql_parse.cc:
  code trimming
sql/sql_prepare.cc:
  comment added
sql/sql_repl.cc:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/sql_repl.h:
  HAVE_REPLICATION instead of EMBEDDED_LIBRARY
sql/sql_show.cc:
  mysql_list_processes to work in embedded library
sql/sql_table.cc:
  set_nfields deletion
This commit is contained in:
unknown
2003-01-15 12:11:44 +04:00
parent 1bc932384b
commit 09b79b65f2
31 changed files with 326 additions and 331 deletions

View File

@ -27,6 +27,23 @@
#include <stdarg.h>
#include <assert.h>
#ifndef EMBEDDED_LIBRARY
bool Protocol::net_store_data(const char *from, uint length)
{
ulong packet_length=packet->length();
if (packet_length+5+length > packet->alloced_length() &&
packet->realloc(packet_length+5+length))
return 1;
char *to=(char*) net_store_length((char*) packet->ptr()+packet_length,
(ulonglong) length);
memcpy(to,from,length);
packet->length((uint) (to+length-packet->ptr()));
return 0;
}
#endif
/* Send a error string to client */
void send_error(THD *thd, uint sql_errno, const char *err)
@ -402,23 +419,6 @@ char *net_store_length(char *pkg, uint length)
}
/*
Used internally for storing strings in packet
*/
static bool net_store_data(String *packet, const char *from, uint length)
{
ulong packet_length=packet->length();
if (packet_length+5+length > packet->alloced_length() &&
packet->realloc(packet_length+5+length))
return 1;
char *to=(char*) net_store_length((char*) packet->ptr()+packet_length,
(ulonglong) length);
memcpy(to,from,length);
packet->length((uint) (to+length-packet->ptr()));
return 0;
}
/****************************************************************************
Functions used by the protocol functions (like send_ok) to store strings
and numbers in the header result packet.
@ -574,15 +574,16 @@ err:
DBUG_RETURN(1); /* purecov: inspected */
}
#endif
bool Protocol::write()
{
DBUG_ENTER("Protocol::write");
DBUG_RETURN(SEND_ROW(thd, n_fields, packet->ptr(), packet->length()));
DBUG_RETURN(my_net_write(&thd->net, packet->ptr(), packet->length()));
}
#endif /* EMBEDDED_LIBRARY */
/*
Send \0 end terminated string
@ -640,6 +641,7 @@ bool Protocol::store(I_List<i_string>* str_list)
****************************************************************************/
#ifndef EMBEDDED_LIBRARY
void Protocol_simple::prepare_for_resend()
{
packet->length(0);
@ -647,6 +649,7 @@ void Protocol_simple::prepare_for_resend()
field_pos= 0;
#endif
}
#endif
bool Protocol_simple::store_null()
{
@ -669,7 +672,7 @@ bool Protocol_simple::store(const char *from, uint length)
#endif
if (convert)
return convert->store(packet, from, length);
return net_store_data(packet, from, length);
return net_store_data(from, length);
}
@ -679,7 +682,7 @@ bool Protocol_simple::store_tiny(longlong from)
DBUG_ASSERT(field_types == 0 || field_types[field_pos++] == MYSQL_TYPE_TINY);
#endif
char buff[20];
return net_store_data(packet,(char*) buff,
return net_store_data((char*) buff,
(uint) (int10_to_str((int) from,buff, -10)-buff));
}
@ -690,7 +693,7 @@ bool Protocol_simple::store_short(longlong from)
field_types[field_pos++] == MYSQL_TYPE_SHORT);
#endif
char buff[20];
return net_store_data(packet,(char*) buff,
return net_store_data((char*) buff,
(uint) (int10_to_str((int) from,buff, -10)-buff));
}
@ -700,7 +703,7 @@ bool Protocol_simple::store_long(longlong from)
DBUG_ASSERT(field_types == 0 || field_types[field_pos++] == MYSQL_TYPE_LONG);
#endif
char buff[20];
return net_store_data(packet,(char*) buff,
return net_store_data((char*) buff,
(uint) (int10_to_str((int) from,buff, -10)-buff));
}
@ -712,7 +715,7 @@ bool Protocol_simple::store_longlong(longlong from, bool unsigned_flag)
field_types[field_pos++] == MYSQL_TYPE_LONGLONG);
#endif
char buff[22];
return net_store_data(packet,(char*) buff,
return net_store_data((char*) buff,
(uint) (longlong10_to_str(from,buff,
unsigned_flag ? 10 : -10)-
buff));
@ -726,7 +729,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer)
field_types[field_pos++] == MYSQL_TYPE_FLOAT);
#endif
buffer->set((double) from, decimals, thd->variables.thd_charset);
return net_store_data(packet,(char*) buffer->ptr(), buffer->length());
return net_store_data((char*) buffer->ptr(), buffer->length());
}
bool Protocol_simple::store(double from, uint32 decimals, String *buffer)
@ -736,7 +739,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer)
field_types[field_pos++] == MYSQL_TYPE_DOUBLE);
#endif
buffer->set(from, decimals, thd->variables.thd_charset);
return net_store_data(packet,(char*) buffer->ptr(), buffer->length());
return net_store_data((char*) buffer->ptr(), buffer->length());
}
@ -752,7 +755,7 @@ bool Protocol_simple::store(Field *field)
field->val_str(&tmp,&tmp);
if (convert)
return convert->store(packet, tmp.ptr(), tmp.length());
return net_store_data(packet, tmp.ptr(), tmp.length());
return net_store_data(tmp.ptr(), tmp.length());
}
@ -773,7 +776,7 @@ bool Protocol_simple::store(TIME *tm)
(int) tm->hour,
(int) tm->minute,
(int) tm->second));
return net_store_data(packet, (char*) buff, length);
return net_store_data((char*) buff, length);
}
@ -789,7 +792,7 @@ bool Protocol_simple::store_date(TIME *tm)
(int) tm->year,
(int) tm->month,
(int) tm->day));
return net_store_data(packet, (char*) buff, length);
return net_store_data((char*) buff, length);
}
@ -806,7 +809,7 @@ bool Protocol_simple::store_time(TIME *tm)
(long) tm->day*3600L+(long) tm->hour,
(int) tm->minute,
(int) tm->second));
return net_store_data(packet, (char*) buff, length);
return net_store_data((char*) buff, length);
}
@ -816,8 +819,7 @@ bool Protocol_simple::store_time(TIME *tm)
bool Protocol_prep::prepare_for_send(List<Item> *item_list)
{
field_count=item_list->elements;
set_nfields(item_list->elements);
Protocol::prepare_for_send(item_list);
bit_fields= (field_count+3)/8;
if (packet->alloc(bit_fields))
return 1;
@ -846,7 +848,7 @@ bool Protocol_prep::store(const char *from,uint length)
field_pos++;
if (convert)
return convert->store(packet, from, length);
return net_store_data(packet, from, length);
return net_store_data(from, length);
}