summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <hf@deer.mysql.r18.ru>2002-12-16 18:58:55 +0400
committerunknown <hf@deer.mysql.r18.ru>2002-12-16 18:58:55 +0400
commit77892ac27ae289541d3561eb12dccefa0cdf7931 (patch)
tree84a5d074a9241cebc5ac2f73a883ad6765c39100 /sql
parent8745c29b08a2a82edc5a86b2d25dd30daaa2de5a (diff)
parenta42aa8db7f1b7f4399f6eb5c5be97a2f6918f9bc (diff)
downloadmariadb-git-77892ac27ae289541d3561eb12dccefa0cdf7931.tar.gz
Merging
BitKeeper/etc/logging_ok: auto-union sql/field.cc: Auto merged sql/field.h: Auto merged sql/item_func.cc: Auto merged sql/mysql_priv.h: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/convert.cc9
-rw-r--r--sql/field.cc19
-rw-r--r--sql/field.h2
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/ha_myisam.cc14
-rw-r--r--sql/item.cc63
-rw-r--r--sql/item.h20
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/item_strfunc.cc6
-rw-r--r--sql/log.cc14
-rw-r--r--sql/log_event.cc62
-rw-r--r--sql/log_event.h39
-rw-r--r--sql/mf_iocache.cc5
-rw-r--r--sql/mini_client.cc3
-rw-r--r--sql/mysql_priv.h8
-rw-r--r--sql/mysqld.cc523
-rw-r--r--sql/net_serv.cc4
-rw-r--r--sql/protocol.cc53
-rw-r--r--sql/repl_failsafe.cc5
-rw-r--r--sql/repl_failsafe.h2
-rw-r--r--sql/set_var.cc23
-rw-r--r--sql/set_var.h3
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/slave.h6
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_base.cc1
-rw-r--r--sql/sql_cache.cc4
-rw-r--r--sql/sql_class.cc9
-rw-r--r--sql/sql_class.h17
-rw-r--r--sql/sql_load.cc7
-rw-r--r--sql/sql_parse.cc67
-rw-r--r--sql/sql_prepare.cc8
-rw-r--r--sql/sql_repl.cc6
-rw-r--r--sql/sql_repl.h4
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_show.cc23
-rw-r--r--sql/sql_table.cc16
37 files changed, 788 insertions, 274 deletions
diff --git a/sql/convert.cc b/sql/convert.cc
index 155cb57f9fe..444a454d2af 100644
--- a/sql/convert.cc
+++ b/sql/convert.cc
@@ -463,3 +463,12 @@ bool CONVERT::store(String *packet,const char *from,uint length)
packet->length((uint) (to-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
+
diff --git a/sql/field.cc b/sql/field.cc
index e3db572eb57..e6a4c30d7f5 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4508,7 +4508,7 @@ void Field_blob::set_key_image(char *buff,uint length)
void Field_geom::get_key_image(char *buff,uint length, imagetype type)
{
- length-=HA_KEY_BLOB_LENGTH;
+/* length-=HA_KEY_BLOB_LENGTH;
ulong blob_length=get_length(ptr);
char *blob;
get_ptr(&blob);
@@ -4523,12 +4523,19 @@ void Field_geom::get_key_image(char *buff,uint length, imagetype type)
float8store(buff+16, mbr.ymin);
float8store(buff+24, mbr.ymax);
return;
+*/
+ Field_blob::get_key_image(buff, length, type);
}
void Field_geom::set_key_image(char *buff,uint length)
{
+ Field_blob::set_key_image(buff, length);
}
+void Field_geom::sql_type(String &res) const
+{
+ res.set("geometry", 8U, default_charset_info);
+}
int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length)
{
@@ -5187,6 +5194,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length)
case FIELD_TYPE_BLOB: return 2+portable_sizeof_char_ptr;
case FIELD_TYPE_MEDIUM_BLOB: return 3+portable_sizeof_char_ptr;
case FIELD_TYPE_LONG_BLOB: return 4+portable_sizeof_char_ptr;
+ case FIELD_TYPE_GEOMETRY: return 2+portable_sizeof_char_ptr;
case FIELD_TYPE_SET:
case FIELD_TYPE_ENUM: abort(); return 0; // This shouldn't happen
default: return 0;
@@ -5233,15 +5241,14 @@ Field *make_field(char *ptr, uint32 field_length,
f_packtype(pack_flag),
field_length);
- if (f_is_blob(pack_flag))
- return new Field_blob(ptr,null_pos,null_bit,
- unireg_check, field_name, table,
- pack_length, field_charset);
if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length);
-
+ if (f_is_blob(pack_flag))
+ return new Field_blob(ptr,null_pos,null_bit,
+ unireg_check, field_name, table,
+ pack_length, field_charset);
if (interval)
{
if (f_is_enum(pack_flag))
diff --git a/sql/field.h b/sql/field.h
index 4c0af6e807b..9258e15ed04 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -944,6 +944,8 @@ public:
:Field_blob(len_arg, maybe_null_arg, field_name_arg,
table_arg, my_charset_bin) {}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY; }
+ enum_field_types type() const { return FIELD_TYPE_GEOMETRY;}
+ void sql_type(String &str) const;
void get_key_image(char *buff,uint length, imagetype type);
void set_key_image(char *buff,uint length);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 8f933085066..f4d21bf6216 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -871,6 +871,7 @@ innobase_commit_low(
/*================*/
trx_t* trx) /* in: transaction handle */
{
+#ifndef EMBEDDED_LIBRARY
if (current_thd->slave_thread) {
/* Update the replication position info inside InnoDB */
#ifdef NEED_TO_BE_FIXED
@@ -884,6 +885,7 @@ innobase_commit_low(
active_mi->rli.event_len +
active_mi->rli.pending));
}
+#endif /* EMBEDDED_LIBRARY */
trx_commit_for_mysql(trx);
}
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 67fddf34d5c..0680f13a7df 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -60,11 +60,14 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
DBUG_PRINT(msg_type,("message: %s",msgbuf));
+#ifndef EMBEDDED_LIBRARY
if (thd->net.vio == 0)
{
sql_print_error(msgbuf);
return;
}
+#endif
+
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR |
T_AUTO_REPAIR))
{
@@ -138,6 +141,7 @@ const char *ha_myisam::index_type(uint key_number)
int ha_myisam::net_read_dump(NET* net)
{
+#ifndef EMBEDDED_LIBRARY
int data_fd = file->dfile;
int error = 0;
@@ -160,14 +164,17 @@ int ha_myisam::net_read_dump(NET* net)
goto err;
}
}
-
err:
return error;
+#else
+ return (int)net;
+#endif
}
int ha_myisam::dump(THD* thd, int fd)
{
+#ifndef EMBEDDED_LIBRARY
MYISAM_SHARE* share = file->s;
NET* net = &thd->net;
uint blocksize = share->blocksize;
@@ -216,6 +223,9 @@ int ha_myisam::dump(THD* thd, int fd)
err:
my_free((gptr) buf, MYF(0));
return error;
+#else
+ return (int)thd - fd;
+#endif
}
/* Name is here without an extension */
@@ -1100,7 +1110,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
keydef[i].flag|=HA_AUTO_KEY;
found_auto_increment=1;
}
- if (field->type() == FIELD_TYPE_BLOB)
+ if ((field->type() == FIELD_TYPE_BLOB) || (field->type() == FIELD_TYPE_GEOMETRY))
{
keydef[i].seg[j].flag|=HA_BLOB_PART;
/* save number of bytes used to pack length */
diff --git a/sql/item.cc b/sql/item.cc
index d05578c800a..10d26060278 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -569,7 +569,9 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
cause error ER_NON_UNIQ_ERROR in find_field_in_tables.
*/
SELECT_LEX *last= 0;
-
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0;
+#endif
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
@@ -1006,6 +1008,65 @@ 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=alloc_root(alloc, value->length() + 1)))
+ {
+ *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
diff --git a/sql/item.h b/sql/item.h
index 1ea76731fd3..47c7541d3e3 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -19,6 +19,7 @@
#pragma interface /* gcc class implementation */
#endif
+class CONVERT;
class Protocol;
struct st_table_list;
void item_init(void); /* Init item functions */
@@ -63,6 +64,10 @@ 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;
@@ -199,6 +204,10 @@ 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);
@@ -231,6 +240,11 @@ public:
String *val_str(String *str);
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)
@@ -239,7 +253,6 @@ public:
max_length=0;
return res;
}
- bool send(Protocol *protocol, String *str);
bool basic_const_item() const { return 1; }
Item *new_item() { return new Item_null(name); }
bool is_null() { return 1; }
@@ -532,6 +545,11 @@ 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)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index c0b6a872831..bcc04aac6a9 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1656,6 +1656,7 @@ longlong Item_master_pos_wait::val_int()
return 0;
}
ulong pos = (ulong)args[1]->val_int();
+#ifndef EMBEDDED_LIBRARY
LOCK_ACTIVE_MI;
if ((event_count = active_mi->rli.wait_for_pos(thd, log_name, pos)) == -1)
{
@@ -1663,6 +1664,7 @@ longlong Item_master_pos_wait::val_int()
event_count=0;
}
UNLOCK_ACTIVE_MI;
+#endif
return event_count;
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 473c4538ab1..7dcab11912e 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1394,6 +1394,11 @@ String *Item_func_user::val_str(String *str)
const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
+#ifdef EMBEDDED_LIBRARY
+ if (str->copy("localuser@localhost", (uint)strlen("localuser@localhost"), cs))
+ return &empty_string;
+#else
+
if (str->alloc(res_length))
{
null_value=1;
@@ -1401,6 +1406,7 @@ String *Item_func_user::val_str(String *str)
}
res_length=cs->snprintf(cs, (char*)str->ptr(), res_length, "%s@%s",thd->user,host);
str->length(res_length);
+#endif
str->set_charset(cs);
return str;
}
diff --git a/sql/log.cc b/sql/log.cc
index dc7b5789efb..527d1605a2d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -23,6 +23,8 @@
#endif
#include "mysql_priv.h"
+#include <mysql.h>
+
#include "sql_acl.h"
#include "sql_repl.h"
@@ -31,6 +33,7 @@
#include <m_ctype.h> // For test_if_number
#include <assert.h>
+
MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
extern I_List<i_string> binlog_do_db, binlog_ignore_db;
@@ -610,6 +613,8 @@ err:
LOG_INFO_IO Got IO error while reading file
*/
+#ifndef EMBEDDED_LIBRARY
+
int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
{
int error;
@@ -739,6 +744,8 @@ err:
DBUG_RETURN(error);
}
+#endif /* EMBEDDED_LIBRARY */
+
/*
Create a new log file name
@@ -1048,6 +1055,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
#else
IO_CACHE *file = &log_file;
#endif
+#ifndef EMBEDDED_LIBRARY
if ((thd && !(thd->options & OPTION_BIN_LOG) &&
(thd->master_access & SUPER_ACL)) ||
(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
@@ -1056,6 +1064,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
DBUG_PRINT("error",("!db_ok"));
DBUG_RETURN(0);
}
+#endif /* EMBEDDED_LIBRARY */
error=1;
/*
@@ -1419,6 +1428,7 @@ void MYSQL_LOG::close(bool exiting)
DBUG_PRINT("enter",("exiting: %d", (int) exiting));
if (is_open())
{
+#ifndef EMBEDDED_LIBRARY
if (log_type == LOG_BIN && !no_auto_events && exiting)
{
Stop_log_event s;
@@ -1426,6 +1436,7 @@ void MYSQL_LOG::close(bool exiting)
s.write(&log_file);
signal_update();
}
+#endif /* EMBEDDED_LIBRARY */
end_io_cache(&log_file);
if (my_close(log_file.file,MYF(0)) < 0 && ! write_error)
{
@@ -1549,3 +1560,6 @@ void sql_perror(const char *message)
perror(message);
#endif
}
+
+
+
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 1f4371d5919..913af1bdd7c 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -80,12 +80,14 @@ static void pretty_print_str(FILE* file, char* str, int len)
ignored_error_code()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
inline int ignored_error_code(int err_code)
{
return use_slave_mask && bitmap_is_set(&slave_error_mask, err_code);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -122,6 +124,7 @@ static void pretty_print_str(String* packet, char* str, int len)
slave_load_file_stem()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
static inline char* slave_load_file_stem(char*buf, uint file_id,
int event_server_id)
@@ -135,6 +138,7 @@ static inline char* slave_load_file_stem(char*buf, uint file_id,
return int10_to_str(file_id, buf, 10);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -148,6 +152,7 @@ static inline char* slave_load_file_stem(char*buf, uint file_id,
Easily fixable by adding server_id as a prefix to the log files.
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
static void cleanup_load_tmpdir()
{
@@ -167,6 +172,7 @@ static void cleanup_load_tmpdir()
my_dirend(dirp);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -284,6 +290,7 @@ Log_event::Log_event(const char* buf, bool old_format)
#ifndef MYSQL_CLIENT
+#ifndef EMBEDDED_LIBRARY
/*****************************************************************************
@@ -310,6 +317,7 @@ void Log_event::pack_info(Protocol *protocol)
{
protocol->store("",0);
}
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -336,6 +344,7 @@ void Log_event::init_show_field_list(List<Item>* field_list)
Only called by SHOW BINLOG EVENTS
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
{
const char *p= strrchr(log_name, FN_LIBCHAR);
@@ -353,6 +362,7 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
pack_info(protocol);
return protocol->write();
}
+#endif /* EMBEDDED_LIBRARY */
#endif // !MYSQL_CLIENT
/*****************************************************************************
@@ -560,9 +570,11 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len,
case ROTATE_EVENT:
ev = new Rotate_log_event(buf, event_len, old_format);
break;
+#ifndef EMBEDDED_LIBRARY
case SLAVE_EVENT:
ev = new Slave_log_event(buf, event_len);
break;
+#endif /* EMBEDDED_LIBRARY */
case CREATE_FILE_EVENT:
ev = new Create_file_log_event(buf, event_len, old_format);
break;
@@ -578,9 +590,11 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len,
case START_EVENT:
ev = new Start_log_event(buf, old_format);
break;
+#ifndef EMBEDDED_LIBRARY
case STOP_EVENT:
ev = new Stop_log_event(buf, old_format);
break;
+#endif /* EMBEDDED_LIBRARY */
case INTVAR_EVENT:
ev = new Intvar_log_event(buf, old_format);
break;
@@ -667,6 +681,7 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
*****************************************************************************
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
/*****************************************************************************
@@ -690,6 +705,7 @@ void Query_log_event::pack_info(Protocol *protocol)
protocol->store((char*) tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -822,6 +838,7 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
Query_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Query_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -911,6 +928,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
return Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -926,6 +944,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
Start_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Start_log_event::pack_info(Protocol *protocol)
{
@@ -941,6 +960,7 @@ void Start_log_event::pack_info(Protocol *protocol)
protocol->store(tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1009,6 +1029,7 @@ int Start_log_event::write_data(IO_CACHE* file)
In this case we should stop the slave.
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Start_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -1022,6 +1043,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
return Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1037,6 +1059,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
Load_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Load_log_event::pack_info(Protocol *protocol)
{
@@ -1114,6 +1137,7 @@ void Load_log_event::pack_info(Protocol *protocol)
protocol->store(tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1417,6 +1441,7 @@ void Load_log_event::set_fields(List<Item> &field_list)
Load_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
{
@@ -1528,6 +1553,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
return Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1543,6 +1569,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
Rotate_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Rotate_log_event::pack_info(Protocol *protocol)
{
@@ -1557,6 +1584,7 @@ void Rotate_log_event::pack_info(Protocol *protocol)
protocol->store(tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1649,6 +1677,7 @@ int Rotate_log_event::write_data(IO_CACHE* file)
0 ok
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -1666,6 +1695,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
DBUG_RETURN(0);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1681,6 +1711,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
Intvar_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Intvar_log_event::pack_info(Protocol *protocol)
{
@@ -1693,6 +1724,7 @@ void Intvar_log_event::pack_info(Protocol *protocol)
protocol->store(tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1771,6 +1803,7 @@ void Intvar_log_event::print(FILE* file, bool short_form, char* last_db)
Intvar_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -1787,6 +1820,7 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
return 0;
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1802,6 +1836,7 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
Rand_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Rand_log_event::pack_info(Protocol *protocol)
{
@@ -1813,6 +1848,7 @@ void Rand_log_event::pack_info(Protocol *protocol)
protocol->store(buf1, (uint) (pos-buf1));
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1865,6 +1901,7 @@ void Rand_log_event::print(FILE* file, bool short_form, char* last_db)
Rand_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Rand_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -1874,6 +1911,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
return 0;
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -1889,6 +1927,8 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
Slave_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
+
#ifndef MYSQL_CLIENT
void Slave_log_event::pack_info(Protocol *protocol)
{
@@ -2112,6 +2152,7 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
return 0;
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -2237,6 +2278,7 @@ void Create_file_log_event::print(FILE* file, bool short_form,
Create_file_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Create_file_log_event::pack_info(Protocol *protocol)
{
@@ -2256,12 +2298,14 @@ void Create_file_log_event::pack_info(Protocol *protocol)
protocol->store((char*) tmp.ptr(), tmp.length());
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
Create_file_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -2320,6 +2364,7 @@ err:
return error ? 1 : Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -2396,6 +2441,7 @@ void Append_block_log_event::print(FILE* file, bool short_form,
Append_block_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Append_block_log_event::pack_info(Protocol *protocol)
{
@@ -2407,12 +2453,14 @@ void Append_block_log_event::pack_info(Protocol *protocol)
protocol->store(buf, (int32) length);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
Append_block_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -2442,6 +2490,7 @@ err:
return error ? error : Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -2511,6 +2560,7 @@ void Delete_file_log_event::print(FILE* file, bool short_form,
Delete_file_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Delete_file_log_event::pack_info(Protocol *protocol)
{
@@ -2520,12 +2570,14 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
protocol->store(buf, (int32) length);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
Delete_file_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -2540,6 +2592,7 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
return Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -2610,6 +2663,7 @@ void Execute_load_log_event::print(FILE* file, bool short_form,
Execute_load_log_event::pack_info()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
void Execute_load_log_event::pack_info(Protocol *protocol)
{
@@ -2619,12 +2673,14 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
protocol->store(buf, (int32) length);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
Execute_load_log_event::exec_event()
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
#ifndef MYSQL_CLIENT
int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
{
@@ -2685,6 +2741,7 @@ err:
return error ? error : Log_event::exec_event(rli);
}
#endif // !MYSQL_CLIENT
+#endif /* EMBEDDED_LIBRARY */
/*****************************************************************************
@@ -2776,8 +2833,3 @@ char* sql_ex_info::init(char* buf,char* buf_end,bool use_new_format)
}
-
-
-
-
-
diff --git a/sql/log_event.h b/sql/log_event.h
index c4f93c7a9b6..e0ebe4150bb 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -267,10 +267,12 @@ public:
static int read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock);
void set_log_pos(MYSQL_LOG* log);
- virtual void pack_info(Protocol *protocol);
- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
static void init_show_field_list(List<Item>* field_list);
+#ifndef EMBEDDED_LIBRARY
+ int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
+ virtual void pack_info(Protocol *protocol);
virtual int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
virtual const char* get_db()
{
return thd ? thd->db : 0;
@@ -355,8 +357,10 @@ public:
Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
bool using_trans);
const char* get_db() { return db; }
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -383,6 +387,7 @@ public:
}
};
+#ifndef EMBEDDED_LIBRARY
/*****************************************************************************
@@ -404,8 +409,10 @@ public:
#ifndef MYSQL_CLIENT
Slave_log_event(THD* thd_arg, struct st_relay_log_info* rli);
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -418,6 +425,8 @@ public:
int write_data(IO_CACHE* file );
};
+#endif /* EMBEDDED_LIBRARY */
+
/*****************************************************************************
@@ -454,13 +463,15 @@ public:
List<Item>& fields_arg, enum enum_duplicates handle_dup,
bool using_trans);
void set_fields(List<Item> &fields_arg);
- void pack_info(Protocol* protocol);
const char* get_db() { return db; }
+#ifndef EMBEDDED_LIBRARY
+ void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli)
{
return exec_event(thd->slave_net,rli);
}
int exec_event(NET* net, struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -507,8 +518,10 @@ public:
created = (uint32) when;
memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
}
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -542,8 +555,10 @@ public:
Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
:Log_event(),val(val_arg),type(type_arg)
{}
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -574,8 +589,10 @@ class Rand_log_event: public Log_event
Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
:Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
{}
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -594,13 +611,17 @@ class Rand_log_event: public Log_event
Stop Log Event class
****************************************************************************/
+#ifndef EMBEDDED_LIBRARY
+
class Stop_log_event: public Log_event
{
public:
#ifndef MYSQL_CLIENT
Stop_log_event() :Log_event()
{}
+#ifndef EMBEDDED_LIBRARY
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -613,6 +634,8 @@ public:
bool is_valid() { return 1; }
};
+#endif /* EMBEDDED_LIBRARY */
+
/*****************************************************************************
@@ -636,8 +659,10 @@ public:
pos(pos_arg),ident_len(ident_len_arg ? ident_len_arg :
(uint) strlen(new_log_ident_arg)), alloced(0)
{}
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -683,8 +708,10 @@ public:
enum enum_duplicates handle_dup,
char* block_arg, uint block_len_arg,
bool using_trans);
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -733,8 +760,10 @@ public:
#ifndef MYSQL_CLIENT
Append_block_log_event(THD* thd, char* block_arg,
uint block_len_arg, bool using_trans);
+#ifndef EMBEDDED_LIBRARY
int exec_event(struct st_relay_log_info* rli);
void pack_info(Protocol* protocol);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -759,8 +788,10 @@ public:
#ifndef MYSQL_CLIENT
Delete_file_log_event(THD* thd, bool using_trans);
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
@@ -785,8 +816,10 @@ public:
#ifndef MYSQL_CLIENT
Execute_load_log_event(THD* thd, bool using_trans);
+#ifndef EMBEDDED_LIBRARY
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
+#endif /* EMBEDDED_LIBRARY */
#else
void print(FILE* file, bool short_form = 0, char* last_db = 0);
#endif
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index 1bc65eebd23..436b79b23c3 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -30,6 +30,8 @@
flush_io_cache().
*/
+#ifndef EMBEDDED_LIBRARY
+
#define MAP_TO_USE_RAID
#include "mysql_priv.h"
#ifdef HAVE_AIOWAIT
@@ -81,3 +83,6 @@ int _my_b_net_read(register IO_CACHE *info, byte *Buffer,
}
} /* extern "C" */
+#endif /* EMBEDDED_LIBRARY */
+
+
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 83f68a28228..b84f01da16c 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -22,6 +22,7 @@
in case we decide to make them external at some point
*/
+#ifndef EMBEDDED_LIBRARY
#include <my_global.h>
/* my_pthread must be included early to be able to fix things */
#if defined(THREAD)
@@ -1471,3 +1472,5 @@ MYSQL_RES *mc_mysql_store_result(MYSQL *mysql)
mysql->fields=0; /* fields is now in result */
DBUG_RETURN(result); /* Data fetched */
}
+
+#endif /*EMBEDDED_LIBRARY*/
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index cf0cefd76da..a489237a6e8 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -879,6 +879,14 @@ inline void mark_as_null_row(TABLE *table)
bfill(table->null_flags,table->null_bytes,255);
}
+#ifdef EMBEDDED_LIBRARY
+ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len);
+#define SEND_ROW(thd, n_fields, data, data_len)\
+ embedded_send_row(thd, n_fields, data, data_len)
+#else
+#define SEND_ROW(thd, n_fields, data, data_len)\
+ my_net_write(&thd->net, data, data_len)
+#endif
compare_func_creator comp_eq_creator(bool invert);
compare_func_creator comp_ge_creator(bool invert);
compare_func_creator comp_gt_creator(bool invert);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 943af7b44be..8869a642ed3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -485,6 +485,8 @@ static uint set_maximum_open_files(uint max_file_limit);
#endif
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
+
+#ifndef EMBEDDED_LIBRARY
/****************************************************************************
** Code to end mysqld
****************************************************************************/
@@ -660,6 +662,7 @@ static void close_connections(void)
DBUG_PRINT("quit",("close_connections thread"));
DBUG_VOID_RETURN;
}
+#endif /*EMBEDDED_LIBRARY*/
static void close_server_sock()
{
@@ -751,6 +754,7 @@ void kill_mysql(void)
DBUG_VOID_RETURN;
}
+#ifndef EMBEDDED_LIBRARY
/* Force server down. kill all connections and threads and exit */
@@ -791,13 +795,16 @@ static void __cdecl kill_server(int sig_ptr)
RETURN_FROM_KILL_SERVER;
}
+#endif /* EMBEDDED_LIBRARY */
#ifdef USE_ONE_SIGNAL_HAND
extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
SHUTDOWN_THD;
my_thread_init(); // Initialize new thread
+#ifndef EMBEDDED_LIBRARY
kill_server(0);
+#endif /* EMBEDDED_LIBRARY */
my_thread_end(); // Normally never reached
return 0;
}
@@ -868,8 +875,10 @@ void clean_up(bool print_message)
DBUG_PRINT("exit",("clean_up"));
if (cleanup_done++)
return; /* purecov: inspected */
+#ifndef EMBEDDED_LIBRARY
if (use_slave_mask)
bitmap_free(&slave_error_mask);
+#endif
acl_free(1);
grant_free();
query_cache_destroy();
@@ -891,12 +900,16 @@ void clean_up(bool print_message)
free_defaults(defaults_argv);
my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR));
free_tmpdir(&mysql_tmpdir_list);
+#ifndef EMBEDDED_LIBRARY
my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
+#endif
x_free(opt_bin_logname);
x_free(opt_relay_logname);
bitmap_free(&temp_pool);
free_max_user_conn();
+#ifndef EMBEDDED_LIBRARY
end_slave_list();
+#endif
#ifdef USE_REGEX
regex_end();
#endif
@@ -1178,7 +1191,7 @@ void yyerror(const char *s)
thd->lex.yylineno);
}
-
+#ifndef EMBEDDED_LIBRARY
void close_connection(NET *net,uint errcode,bool lock)
{
st_vio* vio;
@@ -1198,6 +1211,7 @@ void close_connection(NET *net,uint errcode,bool lock)
(void) pthread_mutex_unlock(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
+#endif
/* Called when a thread is aborted */
/* ARGSUSED */
@@ -1713,7 +1727,7 @@ extern "C" int my_message_sql(uint error, const char *str,
void clear_error_message(THD *thd)
{
- thd->net.last_error[0]= 0;
+ thd->clear_error();
}
@@ -1825,27 +1839,12 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
no_auto_events);
}
-
-
-#ifdef __WIN__
-int win_main(int argc, char **argv)
-#else
-int main(int argc, char **argv)
-#endif
+static int init_common_variables(const char *conf_file_name, int argc, char **argv,
+ const char **groups)
{
- 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
+ umask(((~my_umask) & 0666));
tzset(); // Set tzname
start_time=time((time_t*) 0);
@@ -1877,21 +1876,15 @@ int main(int argc, char **argv)
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;
+ load_defaults(conf_file_name, groups, &argc, &argv);
+ defaults_argv=argv;
set_options();
get_options(argc,argv);
if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
@@ -1899,8 +1892,46 @@ int main(int argc, char **argv)
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
server_version, SYSTEM_TYPE,MACHINE_TYPE));
- /* These must be set early */
+#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
+ if (set_default_charset_by_name(sys_charset.value, MYF(MY_WME)))
+ return 1;
+ charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
+
+ if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
+ return 2;
+
+ return 0;
+}
+static int init_thread_environement()
+{
(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);
@@ -1917,7 +1948,9 @@ int main(int argc, char **argv)
(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);
+#ifndef EMBEDDED_LIBRARY
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
+#endif
(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);
@@ -1926,13 +1959,30 @@ int main(int argc, char **argv)
(void) pthread_cond_init(&COND_thread_cache,NULL);
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
(void) pthread_cond_init(&COND_manager,NULL);
+#ifndef EMBEDDED_LIBRARY
(void) pthread_cond_init(&COND_rpl_status, NULL);
- init_signals();
+#endif
+ /* 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);
+ pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
- 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));
+ if (pthread_key_create(&THR_THD,NULL) ||
+ pthread_key_create(&THR_MALLOC,NULL))
+ {
+ sql_print_error("Can't create thread-keys");
+ return 1;
+ }
+ (void) thr_setconcurrency(concurrency); // 10 by default
+
+ return 0;
+}
+
+static void init_ssl()
+{
#ifdef HAVE_OPENSSL
if (opt_use_ssl)
{
@@ -1944,70 +1994,13 @@ int main(int argc, char **argv)
if (!ssl_acceptor_fd)
opt_use_ssl = 0;
}
+ if (des_key_file)
+ load_des_key_file(des_key_file);
#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();
+static int init_server_components()
+{
table_cache_init();
hostname_cache_init();
query_cache_result_size_limit(query_cache_limit);
@@ -2015,12 +2008,9 @@ int main(int argc, char **argv)
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions();
init_thr_lock();
+#ifndef EMBEDDED_LIBRARY
init_slave_list();
-#ifdef HAVE_OPENSSL
- if (des_key_file)
- load_des_key_file(des_key_file);
-#endif /* HAVE_OPENSSL */
-
+#endif
/* Setup log files */
if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
@@ -2031,26 +2021,17 @@ int main(int argc, char **argv)
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);
+ return 1;
}
ha_key_cache();
+
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if (locked_in_memory && !geteuid())
{
@@ -2069,71 +2050,9 @@ int main(int argc, char **argv)
(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",
@@ -2141,25 +2060,29 @@ The server will not act as a slave.");
using_update_log=1;
}
+ return 0;
+}
- if (opt_bootstrap)
- {
- int error=bootstrap(stdin);
- end_thr_alarm(); // Don't allow alarms
- unireg_abort(error ? 1 : 0);
- }
- if (opt_init_file)
+static void create_maintenance_thread()
+{
+ if (
+#ifdef HAVE_BERKELEY_DB
+ !berkeley_skip ||
+#endif
+ (flush_time && flush_time != ~(ulong) 0L))
{
- if (read_init_file(opt_init_file))
- {
- end_thr_alarm(); // Don't allow alarms
- unireg_abort(1);
- }
+ pthread_t hThread;
+ if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
+ sql_print_error("Warning: Can't create thread to manage maintenance");
}
- (void) thr_setconcurrency(concurrency); // 10 by default
-#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
+}
+
+static void create_shutdown_thread()
+{
+
+#ifdef __WIN__
{
- hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
+ hEventShutdown=CreateEvent(0, FALSE, FALSE, 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");
@@ -2176,38 +2099,24 @@ The server will not act as a slave.");
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__
+void create_named_pipe_thread()
+{
if (hPipe == INVALID_HANDLE_VALUE &&
- (!have_tcpip || opt_disable_networking) &&
- !opt_enable_shared_memory)
+ (!have_tcpip || opt_disable_networking))
{
- sql_print_error("TCP/IP,--shared-memory or --named-pipe should be configured on NT OS");
- unireg_abort(1);
+ sql_print_error("TCP/IP or --enable-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++;
@@ -2218,36 +2127,169 @@ The server will not act as a slave.");
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");
+ sql_print_error("Warning: Can't create thread to handle named pipes");
handler_count--;
}
}
while (handler_count > 0)
- {
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
- }
}
pthread_mutex_unlock(&LOCK_thread_count);
}
+}
+#endif
+
+#ifndef EMBEDDED_LIBRARY
+#ifdef __WIN__
+int win_main(int argc, char **argv)
+#else
+int main(int argc, char **argv)
+#endif
+{
+ int init_error;
+
+ DEBUGGER_OFF;
+
+#ifdef _CUSTOMSTARTUPCONFIG_
+ if (_cust_check_startup())
+ {
+ / * _cust_check_startup will report startup failure error * /
+ exit( 1 );
+ }
+#endif
+
+ MY_INIT(argv[0]); // init my_sys library & pthreads
+
+ if ((init_error=init_common_variables(MYSQL_CONFIG_NAME,
+ argc, argv, load_default_groups)))
+ if (init_error == 2)
+ unireg_abort(1);
+ else
+ exit(1);
+
+ init_signals();
+ if (init_thread_environement())
+ exit(1);
+ select_thread=pthread_self();
+ select_thread_in_use=1;
+ if (!(opt_specialflag & SPECIAL_NO_PRIOR))
+ my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
+
+ if (!(opt_specialflag & SPECIAL_NO_PRIOR))
+ my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
+
+ init_ssl();
+
+#ifdef HAVE_LIBWRAP
+ libwrapName= my_progname+dirname_length(my_progname);
+ openlog(libwrapName, LOG_PID, LOG_AUTH);
+#endif
+
+ /*
+ We have enough space for fiddling with the argv, continue
+ */
+ 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();
+
+ 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 (init_server_components())
+ exit(1);
+
+#ifdef __WIN__
+#define MYSQL_ERR_FILE "mysql.err"
+ if (!opt_console)
+ {
+ freopen(MYSQL_ERR_FILE,"a+",stdout);
+ freopen(MYSQL_ERR_FILE,"a+",stderr);
+ }
+#endif
+
+#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;
+ 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
+ exit(1);
+ }
+ if (!opt_noacl)
+ (void) grant_init((THD *)0);
+
+#ifdef HAVE_DLOPEN
+ if (!opt_noacl)
+ udf_init();
+#endif
+ /* init_slave() must be called after the thread keys are created */
+ init_slave();
+
+ 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);
+ }
+ }
+
+ create_shutdown_thread();
+ create_maintenance_thread();
+
+ printf(ER(ER_READY),my_progname,server_version,"");
+ fflush(stdout);
+
+#ifdef __NT__
+ create_named_pipe_thread();
#else
handle_connections_sockets(0);
#ifdef EXTRA_DEBUG2
@@ -2294,6 +2336,7 @@ The server will not act as a slave.");
return(0); /* purecov: deadcode */
}
+#endif /* EMBEDDED_LIBRARY */
/****************************************************************************
Main and thread entry function for Win32
@@ -2432,7 +2475,7 @@ int main(int argc, char **argv)
Execute all commands from a file. Used by the mysql_install_db script to
create MySQL privilege tables without having to start a full MySQL server.
*/
-
+#ifndef EMBEDDED_LIBRARY
static int bootstrap(FILE *file)
{
THD *thd= new THD;
@@ -2469,6 +2512,8 @@ static int bootstrap(FILE *file)
DBUG_RETURN(error);
}
+#endif
+
static bool read_init_file(char *file_name)
{
FILE *file;
@@ -2476,11 +2521,14 @@ static bool read_init_file(char *file_name)
DBUG_PRINT("enter",("name: %s",file_name));
if (!(file=my_fopen(file_name,O_RDONLY,MYF(MY_WME))))
return(1);
+#ifndef EMBEDDED_LIBRARY
bootstrap(file); /* Ignore errors from this */
+#endif
(void) my_fclose(file,MYF(MY_WME));
return 0;
}
+#ifndef EMBEDDED_LIBRARY
static void create_new_thread(THD *thd)
{
@@ -2562,6 +2610,7 @@ static void create_new_thread(THD *thd)
DBUG_PRINT("info",("Thread created"));
DBUG_VOID_RETURN;
}
+#endif
#ifdef SIGNALS_DONT_BREAK_READ
inline void kill_broken_server()
@@ -2579,6 +2628,7 @@ inline void kill_broken_server()
#define MAYBE_BROKEN_SYSCALL
#endif
+#ifndef EMBEDDED_LIBRARY
/* Handle new connections and spawn new process to handle them */
extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
@@ -3083,6 +3133,7 @@ error:
}
#endif /* HAVE_SMEM */
+#endif /* EMBEDDED_LIBRARY */
/******************************************************************************
** handle start options
@@ -3447,6 +3498,7 @@ struct my_option my_long_options[] =
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"memlock", OPT_MEMLOCK, "Lock mysqld in memory", (gptr*) &locked_in_memory,
(gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifndef EMBEDDED_LIBRARY
{"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
"Option used by mysql-test for debugging and testing of replication",
(gptr*) &disconnect_slave_event_count,
@@ -3465,6 +3517,7 @@ struct my_option my_long_options[] =
(gptr*) &opt_sporadic_binlog_dump_fail,
(gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
+#endif /* EMBEDDED_LIBRARY */
{"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT,
"Simulate memory shortage when compiled with the --with-debug=full option",
0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -3607,12 +3660,14 @@ struct my_option my_long_options[] =
{"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, "Undocumented",
(gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifndef EMBEDDED_LIBRARY
{"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, "Undocumented",
(gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS,
"Tells the slave thread to continue replication when a query returns an error from the provided list",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
{"socket", OPT_SOCKET, "Socket file to use for connection",
(gptr*) &mysql_unix_port, (gptr*) &mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -3940,6 +3995,7 @@ struct my_option my_long_options[] =
(gptr*) &global_system_variables.read_buff_size,
(gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
+#ifndef EMBEDDED_LIBRARY
{"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
"Max space to use for all relay logs",
(gptr*) &relay_log_space_limit,
@@ -3954,6 +4010,7 @@ struct my_option my_long_options[] =
"Number of seconds to wait for more data from a master/slave connection before aborting the read.",
(gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,
GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
+#endif
{"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
"If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
(gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
@@ -4297,9 +4354,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'o':
protocol_version=PROTOCOL_VERSION-1;
break;
+#ifndef EMBEDDED_LIBRARY
case OPT_SLAVE_SKIP_ERRORS:
init_slave_skip_errors(argument);
break;
+#endif
case OPT_SAFEMALLOC_MEM_LIMIT:
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
safemalloc_mem_limit = atoi(argument);
@@ -4339,6 +4398,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_BIN_LOG:
opt_bin_log=1;
break;
+#ifndef EMBEDDED_LIBRARY
case (int) OPT_INIT_RPL_ROLE:
{
int role;
@@ -4459,13 +4519,14 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
table_rules_on = 1;
break;
}
- case (int) OPT_SLOW_QUERY_LOG:
- opt_slow_log=1;
- break;
case (int)OPT_RECKLESS_SLAVE:
opt_reckless_slave = 1;
init_slave_skip_errors("all");
break;
+#endif /* EMBEDDED_LIBRARY */
+ case (int) OPT_SLOW_QUERY_LOG:
+ opt_slow_log=1;
+ break;
case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC;
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
@@ -4839,11 +4900,13 @@ static void fix_paths(void)
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
exit(1);
+#ifndef EMBEDDED_LIBRARY
if (!slave_load_tmpdir)
{
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
exit(1);
}
+#endif
}
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index d165125eb90..f9adee5812a 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -23,6 +23,7 @@
3 byte length & 1 byte package-number.
*/
+#ifndef EMBEDDED_LIBRARY
#ifdef __WIN__
#include <winsock.h>
#endif
@@ -852,3 +853,6 @@ my_net_read(NET *net)
#endif /* HAVE_COMPRESS */
return len;
}
+
+#endif /* EMBEDDED_LIBRARY */
+
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 88bfe6831c4..ec7ced0e626 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -39,7 +39,9 @@ void send_error(THD *thd, uint sql_errno, const char *err)
err ? err : net->last_error[0] ?
net->last_error : "NULL"));
+#ifndef EMBEDDED_LIBRARY
query_cache_abort(net);
+#endif
thd->query_error= 1; // needed to catch query errors during replication
if (!err)
{
@@ -56,6 +58,12 @@ void send_error(THD *thd, uint sql_errno, const char *err)
}
}
}
+
+#ifdef EMBEDDED_LIBRARY
+ net->last_errno= sql_errno;
+ strmake(net->last_error, err, sizeof(net->last_error)-1);
+#else
+
if (net->vio == 0)
{
if (thd->bootstrap)
@@ -78,6 +86,7 @@ void send_error(THD *thd, uint sql_errno, const char *err)
set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
}
VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
+#endif /* EMBEDDED_LIBRARY*/
thd->fatal_error=0; // Error message is given
thd->net.report_error= 0;
DBUG_VOID_RETURN;
@@ -88,6 +97,7 @@ void send_error(THD *thd, uint sql_errno, const char *err)
This is used by mysqld.cc, which doesn't have a THD
*/
+#ifndef EMBEDDED_LIBRARY
void net_send_error(NET *net, uint sql_errno, const char *err)
{
char buff[2];
@@ -100,7 +110,7 @@ void net_send_error(NET *net, uint sql_errno, const char *err)
net_write_command(net,(uchar) 255, buff, 2, err, length);
DBUG_VOID_RETURN;
}
-
+#endif
/*
Send a warning to the end user
@@ -137,14 +147,22 @@ net_printf(THD *thd, uint errcode, ...)
{
va_list args;
uint length,offset;
- const char *format,*text_pos;
+ const char *format;
+#ifndef EMBEDDED_LIBRARY
+ const char *text_pos;
+#else
+ char text_pos[500];
+#endif
int head_length= NET_HEADER_SIZE;
NET *net= &thd->net;
+
DBUG_ENTER("net_printf");
DBUG_PRINT("enter",("message: %u",errcode));
thd->query_error= 1; // needed to catch query errors during replication
+#ifndef EMBEDDED_LIBRARY
query_cache_abort(net); // Safety
+#endif
va_start(args,errcode);
/*
The following is needed to make net_printf() work with 0 argument for
@@ -160,13 +178,16 @@ net_printf(THD *thd, uint errcode, ...)
errcode= ER_UNKNOWN_ERROR;
}
offset= net->return_errno ? 2 : 0;
+#ifndef EMBEDDED_LIBRARY
text_pos=(char*) net->buff+head_length+offset+1;
+#endif
(void) vsprintf(my_const_cast(char*) (text_pos),format,args);
length=(uint) strlen((char*) text_pos);
if (length >= sizeof(net->last_error))
length=sizeof(net->last_error)-1; /* purecov: inspected */
va_end(args);
+#ifndef EMBEDDED_LIBRARY
if (net->vio == 0)
{
if (thd->bootstrap)
@@ -184,10 +205,36 @@ net_printf(THD *thd, uint errcode, ...)
if (offset)
int2store(text_pos-2, errcode);
VOID(net_real_write(net,(char*) net->buff,length+head_length+1+offset));
+#else
+ net->last_errno= errcode;
+ strmake(net->last_error, text_pos, length);
+#endif
thd->fatal_error=0; // Error message is given
DBUG_VOID_RETURN;
}
+/*
+ Function called by my_net_init() to set some check variables
+*/
+
+#ifndef EMBEDDED_LIBRARY
+extern "C" {
+void my_net_local_init(NET *net)
+{
+ net->max_packet= (uint) global_system_variables.net_buffer_length;
+ net->read_timeout= (uint) global_system_variables.net_read_timeout;
+ net->write_timeout=(uint) global_system_variables.net_write_timeout;
+ net->retry_count= (uint) global_system_variables.net_retry_count;
+ net->max_packet_size= max(global_system_variables.net_buffer_length,
+ global_system_variables.max_allowed_packet);
+}
+}
+
+#else /* EMBEDDED_LIBRARY */
+void my_net_local_init(NET *net __attribute__(unused))
+{
+}
+#endif /* EMBEDDED_LIBRARY */
/*
Return ok to the client.
@@ -214,6 +261,7 @@ net_printf(THD *thd, uint errcode, ...)
If net->no_send_ok return without sending packet
*/
+#ifndef EMBEDDED_LIBRARY
void
send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
@@ -299,6 +347,7 @@ send_eof(THD *thd, bool no_flush)
}
DBUG_VOID_RETURN;
}
+#endif /* EMBEDDED_LIBRARY */
/****************************************************************************
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 16b2eedd3b2..4942dd9cfd8 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -16,6 +16,8 @@
// Sasha Pachev <sasha@mysql.com> is currently in charge of this file
+#ifndef EMBEDDED_LIBRARY
+
#include "mysql_priv.h"
#include "repl_failsafe.h"
#include "sql_repl.h"
@@ -893,3 +895,6 @@ err:
return error;
}
+
+#endif /* EMBEDDED_LIBRARY */
+
diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h
index ef1dc1f8778..e517f0a5a8a 100644
--- a/sql/repl_failsafe.h
+++ b/sql/repl_failsafe.h
@@ -1,3 +1,4 @@
+#ifndef EMBEDDED_LIBRARY
#ifndef REPL_FAILSAFE_H
#define REPL_FAILSAFE_H
@@ -35,3 +36,4 @@ int register_slave(THD* thd, uchar* packet, uint packet_length);
void unregister_slave(THD* thd, bool only_mine, bool need_mutex);
#endif
+#endif /* EMBEDDED_LIBRARY */
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 3404df1c56a..dd30d2e377d 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -45,6 +45,7 @@
#endif
#include "mysql_priv.h"
+#include <mysql.h>
#include "slave.h"
#include "sql_acl.h"
#include <my_getopt.h>
@@ -205,8 +206,10 @@ sys_var_thd_enum sys_query_cache_type("query_cache_type",
sys_var_long_ptr sys_server_id("server_id",&server_id);
sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
&opt_slave_compressed_protocol);
+#ifndef EMBEDDED_LIBRARY
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
&slave_net_timeout);
+#endif
sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
&slow_launch_time);
sys_var_thd_ulong sys_sort_buffer("sort_buffer_size",
@@ -296,7 +299,9 @@ static sys_var_readonly sys_warning_count("warning_count",
get_warning_count);
/* alias for last_insert_id() to be compatible with Sybase */
+#ifndef EMBEDDED_LIBRARY
static sys_var_slave_skip_counter sys_slave_skip_counter("sql_slave_skip_counter");
+#endif
static sys_var_rand_seed1 sys_rand_seed1("rand_seed1");
static sys_var_rand_seed2 sys_rand_seed2("rand_seed2");
@@ -378,9 +383,11 @@ sys_var *sys_variables[]=
&sys_safe_updates,
&sys_select_limit,
&sys_server_id,
+#ifndef EMBEDDED_LIBRARY
&sys_slave_compressed_protocol,
&sys_slave_net_timeout,
&sys_slave_skip_counter,
+#endif
&sys_slow_launch_time,
&sys_sort_buffer,
&sys_sql_big_tables,
@@ -473,7 +480,9 @@ struct show_var_st init_vars[]= {
{"log", (char*) &opt_log, SHOW_BOOL},
{"log_update", (char*) &opt_update_log, SHOW_BOOL},
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
+#ifndef EMBEDDED_LIBRARY
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
+#endif
{"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL},
{sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
{sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
@@ -525,7 +534,9 @@ struct show_var_st init_vars[]= {
{"shared_memory_base_name", (char*) &shared_memory_base_name, SHOW_CHAR_PTR},
#endif
{sys_server_id.name, (char*) &sys_server_id, SHOW_SYS},
+#ifndef EMBEDDED_LIBRARY
{sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS},
+#endif
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
@@ -625,6 +636,7 @@ static void fix_tx_isolation(THD *thd, enum_var_type type)
If we are changing the thread variable, we have to copy it to NET too
*/
+#ifndef EMBEDDED_LIBRARY
static void fix_net_read_timeout(THD *thd, enum_var_type type)
{
if (type != OPT_GLOBAL)
@@ -643,6 +655,14 @@ static void fix_net_retry_count(THD *thd, enum_var_type type)
if (type != OPT_GLOBAL)
thd->net.retry_count=thd->variables.net_retry_count;
}
+#else /* EMBEDDED_LIBRARY */
+static void fix_net_read_timeout(THD *thd __attribute__(unused), enum_var_type type __attribute__(unused))
+{}
+static void fix_net_write_timeout(THD *thd __attribute__(unused), enum_var_type type __attribute__(unused))
+{}
+static void fix_net_retry_count(THD *thd __attribute__(unused), enum_var_type type __attribute__(unused))
+{}
+#endif /* EMBEDDED_LIBRARY */
static void fix_query_cache_size(THD *thd, enum_var_type type)
@@ -1059,6 +1079,7 @@ byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type)
}
+#ifndef EMBEDDED_LIBRARY
bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
{
int result= 0;
@@ -1094,7 +1115,7 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
UNLOCK_ACTIVE_MI;
return 0;
}
-
+#endif /* EMBEDDED_LIBRARY */
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
{
diff --git a/sql/set_var.h b/sql/set_var.h
index 39a5995e30f..d18c8c44596 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -339,6 +339,7 @@ public:
};
+#ifndef EMBEDDED_LIBRARY
class sys_var_slave_skip_counter :public sys_var
{
public:
@@ -351,7 +352,7 @@ public:
type() or value_ptr()
*/
};
-
+#endif
class sys_var_rand_seed1 :public sys_var
{
diff --git a/sql/slave.cc b/sql/slave.cc
index 7d3ec8d3dce..24ec1fc2536 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
+#ifndef EMBEDDED_LIBRARY
#include "mysql_priv.h"
#include <mysql.h>
#include <myisam.h>
@@ -3181,3 +3181,5 @@ err:
template class I_List_iterator<i_string>;
template class I_List_iterator<i_string_pair>;
#endif
+
+#endif /* EMBEDDED_LIBRARY */
diff --git a/sql/slave.h b/sql/slave.h
index 2c750e415bc..84685b7e429 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -1,3 +1,5 @@
+#ifndef EMBEDDED_LIBRARY
+
#ifndef SLAVE_H
#define SLAVE_H
@@ -461,3 +463,7 @@ extern I_List<i_string_pair> replicate_rewrite_db;
extern I_List<THD> threads;
#endif
+#else
+#define SLAVE_IO 1
+#define SLAVE_SQL 2
+#endif /* EMBEDDED_LIBRARY */
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 310ac16e927..e2ddd2cba81 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2706,8 +2706,12 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table)
GRANT_TABLE *grant_table;
rw_rdlock(&LOCK_grant);
+#ifdef EMBEDDED_LIBRARY
+ grant_table= NULL;
+#else
grant_table = table_hash_search(thd->host,thd->ip,db,user,
table->real_name,0);
+#endif
table->grant.grant_table=grant_table; // Remember for column test
table->grant.version=grant_version;
if (grant_table)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 87cc0d616a9..f7a0c6960d4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -195,7 +195,6 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
DBUG_RETURN(open_list);
}
-
/*****************************************************************************
* Functions to free open table cache
****************************************************************************/
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index aa0f5824b4e..f0c16369ef9 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -761,7 +761,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
if ((local_tables = is_cacheable(thd, thd->query_length,
thd->query, &thd->lex, tables_used)))
{
- NET *net = &thd->net;
+ NET *net= &thd->net;
byte flags = (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0);
STRUCT_LOCK(&structure_guard_mutex);
@@ -1022,11 +1022,13 @@ 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
if (net_real_write(&thd->net, result->data(),
result_block->used -
result_block->headers_len() -
ALIGN_SIZE(sizeof(Query_cache_result))))
break; // Client aborted
+#endif
result_block = result_block->next;
} while (result_block != first_result_block);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 345a2e6f34d..a4cd34e7856 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -109,8 +109,10 @@ THD::THD():user_time(0), fatal_error(0),
mysys_var=0;
#ifndef DBUG_OFF
dbug_sentry=THD_SENTRY_MAGIC;
-#endif
+#endif
+#ifndef EMBEDDED_LIBRARY
net.vio=0;
+#endif
net.last_error[0]=0; // If error on boot
ull=0;
system_thread=cleanup_done=0;
@@ -268,11 +270,13 @@ THD::~THD()
pthread_mutex_unlock(&LOCK_delete);
/* Close connection */
+#ifndef EMBEDDED_LIBRARY
if (net.vio)
{
vio_delete(net.vio);
net_end(&net);
}
+#endif
if (!cleanup_done)
cleanup();
#ifdef USING_TRANSACTIONS
@@ -513,6 +517,8 @@ bool select_send::send_fields(List<Item> &list,uint flag)
}
+#ifndef EMBEDDED_LIBRARY
+
/* Send data to client. Returns 0 if ok */
bool select_send::send_data(List<Item> &items)
@@ -545,6 +551,7 @@ bool select_send::send_data(List<Item> &items)
DBUG_RETURN(protocol->write());
DBUG_RETURN(1);
}
+#endif /* EMBEDDED_LIBRARY */
bool select_send::send_eof()
{
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 50ab7919998..1d5a00682b8 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -178,6 +178,9 @@ public:
convert_array(from_map, (uchar*) a,length);
}
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; }
};
@@ -338,6 +341,10 @@ class select_result;
#define THD_SENTRY_MAGIC 0xfeedd1ff
#define THD_SENTRY_GONE 0xdeadbeef
+#ifdef EMBEDDED_LIBRARY
+typedef struct st_mysql;
+#endif
+
#define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
struct system_variables
@@ -381,9 +388,11 @@ struct system_variables
For each client connection we create a separate thread with THD serving as
a thread/connection descriptor
*/
-
class THD :public ilink {
public:
+#ifdef EMBEDDED_LIBRARY
+ struct st_mysql *mysql;
+#endif
NET net; // client connection descriptor
LEX lex; // parse tree descriptor
MEM_ROOT mem_root; // 1 command-life memory pool
@@ -541,6 +550,7 @@ public:
THD();
~THD();
+
void init(void);
void change_user(void);
void cleanup(void);
@@ -636,12 +646,17 @@ public:
void add_changed_table(const char *key, long key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
int send_explain_fields(select_result *result);
+#ifndef EMBEDDED_LIBRARY
inline void clear_error()
{
net.last_error[0]= 0;
net.last_errno= 0;
net.report_error= 0;
}
+#else
+ void clear_error();
+#endif
+
void add_possible_loop(Item *);
};
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 00450a3b86c..3e281e6e916 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -77,6 +77,8 @@ static int read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
String &enclosed);
+#ifndef EMBEDDED_LIBRARY
+
int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
List<Item> &fields, enum enum_duplicates handle_duplicates,
bool read_file_from_client,thr_lock_type lock_type)
@@ -156,12 +158,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if (read_file_from_client && handle_duplicates == DUP_ERROR)
handle_duplicates=DUP_IGNORE;
+#ifndef EMBEDDED_LIBRARY
if (read_file_from_client)
{
(void)net_request_file(&thd->net,ex->file_name);
file = -1;
}
else
+#endif
{
read_file_from_client=0;
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
@@ -329,6 +333,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_RETURN(error);
}
+#endif /* EMBEDDED_LIBRARY */
/****************************************************************************
** Read of rows of fixed size + optional garage + optonal newline
@@ -563,9 +568,11 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, String &field_term,
cache.read_function = _my_b_net_read;
need_end_io_cache = 1;
+#ifndef EMBEDDED_LIBRARY
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
cache.pre_read = cache.pre_close =
(IO_CACHE_CALLBACK) log_loaded_block;
+#endif
}
}
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index f3636f0b1bb..b3e44fe10b3 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -476,6 +476,7 @@ static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0)
Returns 0 on ok, -1 < if error is given > 0 on error.
*/
+#ifndef EMBEDDED_LIBRARY
static int
check_connections(THD *thd)
{
@@ -622,7 +623,7 @@ check_connections(THD *thd)
thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout;
if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
opt_using_transactions)
- thd->net.return_status= &thd->server_status;
+ net->return_status= &thd->server_status;
net->read_timeout=(uint) thd->variables.net_read_timeout;
char prepared_scramble[SCRAMBLE41_LENGTH+4]; /* Buffer for scramble and hash */
@@ -685,7 +686,6 @@ check_connections(THD *thd)
return 0;
}
-
pthread_handler_decl(handle_one_connection,arg)
{
THD *thd=(THD*) arg;
@@ -876,6 +876,8 @@ end:
DBUG_RETURN(0); // Never reached
}
+#endif /* EMBEDDED_LIBRARY */
+
/* This works because items are allocated with sql_alloc() */
void free_items(Item *item)
@@ -920,7 +922,9 @@ 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));
@@ -930,8 +934,9 @@ err:
}
- /* Execute one command from socket (query or simple command) */
+#ifndef EMBEDDED_LIBRARY
+ /* Execute one command from socket (query or simple command) */
bool do_command(THD *thd)
{
char *packet;
@@ -969,6 +974,7 @@ bool do_command(THD *thd)
DBUG_RETURN(dispatch_command(command,thd, packet+1, (uint) packet_length));
}
+#endif /* EMBEDDED_LIBRARY */
bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length)
@@ -998,12 +1004,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (!mysql_change_db(thd,packet))
mysql_log.write(thd,command,"%s",thd->db);
break;
+#ifndef EMBEDDED_LIBRARY
case COM_REGISTER_SLAVE:
{
if (!register_slave(thd, (uchar*)packet, packet_length))
send_ok(thd);
break;
}
+#endif
case COM_TABLE_DUMP:
{
statistic_increment(com_other, &LOCK_status);
@@ -1021,6 +1029,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
+#ifndef EMBEDDED_LIBRARY
case COM_CHANGE_USER:
{
thd->change_user();
@@ -1137,7 +1146,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->priv_user=save_priv_user;
break;
}
-
+#endif /* EMBEDDED_LIBRARY */
case COM_EXECUTE:
{
mysql_stmt_execute(thd, packet);
@@ -1250,6 +1259,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_rm_db(thd,db,0,0);
break;
}
+#ifndef EMBEDDED_LIBRARY
case COM_BINLOG_DUMP:
{
statistic_increment(com_other,&LOCK_status);
@@ -1274,6 +1284,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
net->error = 0;
break;
}
+#endif
case COM_REFRESH:
{
statistic_increment(com_stat[SQLCOM_FLUSH],&LOCK_status);
@@ -1287,6 +1298,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
send_eof(thd);
break;
}
+#ifndef EMBEDDED_LIBRARY
case COM_SHUTDOWN:
statistic_increment(com_other,&LOCK_status);
if (check_global_access(thd,SHUTDOWN_ACL))
@@ -1307,7 +1319,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
kill_mysql();
error=TRUE;
break;
-
+#endif
+#ifndef EMBEDDED_LIBRARY
case COM_STATISTICS:
{
mysql_log.write(thd,command,NullS);
@@ -1329,6 +1342,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
VOID(net_flush(net));
break;
}
+#endif
case COM_PING:
statistic_increment(com_other,&LOCK_status);
send_ok(thd); // Tell client we are alive
@@ -1478,6 +1492,7 @@ mysql_execute_command(THD *thd)
*/
thd->old_total_warn_count= thd->total_warn_count;
+#ifndef EMBEDDED_LIBRARY
if (thd->slave_thread)
{
/*
@@ -1499,7 +1514,7 @@ mysql_execute_command(THD *thd)
}
#endif
}
-
+#endif /* EMBEDDED_LIBRARY */
/*
TODO: make derived tables processing 'inside' SELECT processing.
TODO: solve problem with depended derived tables in subselects
@@ -1523,9 +1538,13 @@ mysql_execute_command(THD *thd)
}
}
if ((&lex->select_lex != lex->all_selects_list &&
- lex->unit.create_total_list(thd, lex, &tables)) ||
+ lex->unit.create_total_list(thd, lex, &tables))
+#ifndef EMBEDDED_LIBRARY
+ ||
(table_rules_on && tables && thd->slave_thread &&
- !tables_ok(thd,tables)))
+ !tables_ok(thd,tables))
+#endif
+ )
DBUG_VOID_RETURN;
statistic_increment(com_stat[lex->sql_command],&LOCK_status);
@@ -1608,6 +1627,7 @@ mysql_execute_command(THD *thd)
res= mysqld_help(thd,lex->help_arg);
break;
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_PURGE:
{
if (check_global_access(thd, SUPER_ACL))
@@ -1615,6 +1635,8 @@ mysql_execute_command(THD *thd)
res = purge_master_logs(thd, lex->to_log);
break;
}
+#endif
+
case SQLCOM_SHOW_WARNS:
{
res= mysqld_show_warnings(thd, (ulong)
@@ -1640,6 +1662,8 @@ mysql_execute_command(THD *thd)
#endif
break;
}
+
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_SHOW_SLAVE_HOSTS:
{
if (check_global_access(thd, REPL_SLAVE_ACL))
@@ -1654,6 +1678,8 @@ mysql_execute_command(THD *thd)
res = show_binlog_events(thd);
break;
}
+#endif
+
case SQLCOM_BACKUP_TABLE:
{
if (check_db_used(thd,tables) ||
@@ -1673,6 +1699,8 @@ mysql_execute_command(THD *thd)
res = mysql_restore_table(thd, tables);
break;
}
+
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_CHANGE_MASTER:
{
if (check_global_access(thd, SUPER_ACL))
@@ -1707,6 +1735,7 @@ mysql_execute_command(THD *thd)
else
res = load_master_data(thd);
break;
+#endif /* EMBEDDED_LIBRARY */
#ifdef HAVE_INNOBASE_DB
case SQLCOM_SHOW_INNODB_STATUS:
@@ -1718,6 +1747,7 @@ mysql_execute_command(THD *thd)
}
#endif
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_LOAD_MASTER_TABLE:
{
if (!tables->db)
@@ -1749,6 +1779,8 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI;
break;
}
+#endif /* EMBEDDED_LIBRARY */
+
case SQLCOM_CREATE_TABLE:
{
ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
@@ -1850,6 +1882,7 @@ mysql_execute_command(THD *thd)
res = mysql_create_index(thd, tables, lex->key_list);
break;
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_SLAVE_START:
{
LOCK_ACTIVE_MI;
@@ -1864,6 +1897,8 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI;
break;
}
+#endif
+
case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
@@ -1954,6 +1989,7 @@ mysql_execute_command(THD *thd)
res= -1;
break;
}
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_SHOW_BINLOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
@@ -1966,6 +2002,7 @@ mysql_execute_command(THD *thd)
break;
}
#endif
+#endif /* EMBEDDED_LIBRARY */
case SQLCOM_SHOW_CREATE:
#ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
@@ -2421,6 +2458,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_CHANGE_DB:
mysql_change_db(thd,select_lex->db);
break;
+#ifndef EMBEDDED_LIBRARY
case SQLCOM_LOAD:
{
uint privilege= (lex->duplicates == DUP_REPLACE ?
@@ -2447,6 +2485,7 @@ mysql_execute_command(THD *thd)
lex->duplicates, (bool) lex->local_file, lex->lock_option);
break;
}
+#endif /* EMBEDDED_LIBRARY */
case SQLCOM_SET_OPTION:
if (!(res=sql_set_variables(thd, &lex->var_list)))
send_ok(thd);
@@ -3126,7 +3165,9 @@ mysql_parse(THD *thd, char *inBuf, uint length)
else
{
mysql_execute_command(thd);
+#ifndef EMBEDDED_LIBRARY
query_cache_end_of_result(&thd->net);
+#endif
}
}
}
@@ -3134,7 +3175,9 @@ mysql_parse(THD *thd, char *inBuf, uint length)
{
DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
thd->fatal_error));
+#ifndef EMBEDDED_LIBRARY
query_cache_abort(&thd->net);
+#endif
}
thd->proc_info="freeing items";
free_items(thd->free_list); /* Free strings used by items */
@@ -3251,7 +3294,6 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
allowed_type_modifier= AUTO_INCREMENT_FLAG;
break;
case FIELD_TYPE_NULL:
- case FIELD_TYPE_GEOMETRY:
break;
case FIELD_TYPE_DECIMAL:
if (!length)
@@ -3275,6 +3317,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
+ case FIELD_TYPE_GEOMETRY:
if (new_field->length)
{
/* The user has given a length to the blob column */
@@ -3424,7 +3467,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
if (new_field->length >= MAX_FIELD_WIDTH ||
(!new_field->length && !(new_field->flags & BLOB_FLAG) &&
- type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING))
+ type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING && type != FIELD_TYPE_GEOMETRY))
{
net_printf(thd,ER_TOO_BIG_FIELDLENGTH,field_name,
MAX_FIELD_WIDTH-1); /* purecov: inspected */
@@ -3714,9 +3757,11 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
refresh_status();
if (options & REFRESH_THREADS)
flush_thread_cache();
+#ifndef EMBEDDED_LIBRARY
if (options & REFRESH_MASTER)
if (reset_master(thd))
result=1;
+#endif
#ifdef OPENSSL
if (options & REFRESH_DES_KEY_FILE)
{
@@ -3724,6 +3769,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
result=load_des_key_file(des_key_file);
}
#endif
+#ifndef EMBEDDED_LIBRARY
if (options & REFRESH_SLAVE)
{
LOCK_ACTIVE_MI;
@@ -3731,6 +3777,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
result=1;
UNLOCK_ACTIVE_MI;
}
+#endif
if (options & REFRESH_USER_RESOURCES)
reset_mqh(thd,(LEX_USER *) NULL);
return result;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 704acc9c1c2..0c21ffe3f95 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -140,7 +140,11 @@ static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
int4store(buff, stmt->stmt_id);
int2store(buff+4, columns);
int2store(buff+6, stmt->param_count);
+#ifndef EMBEDDED_LIBRARY
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
+#else
+ return true;
+#endif
}
/*
@@ -299,7 +303,11 @@ static bool setup_params_data(PREP_STMT *stmt)
Item_param *param;
DBUG_ENTER("setup_params_data");
+#ifndef EMBEDDED_LIBRARY
uchar *pos=(uchar*) thd->net.read_pos+1+MYSQL_STMT_HEADER; //skip header
+#else
+ uchar *pos= 0; //just to compile TODO code for embedded case
+#endif
uchar *read_pos= pos+(stmt->param_count+7) / 8; //skip null bits
if (*read_pos++) //types supplied / first execute
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 375a7478377..3bffeaccb15 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -16,6 +16,8 @@
// Sasha Pachev <sasha@mysql.com> is currently in charge of this file
+#ifndef EMBEDDED_LIBRARY
+
#include "mysql_priv.h"
#include "sql_repl.h"
#include "sql_acl.h"
@@ -1153,3 +1155,7 @@ int log_loaded_block(IO_CACHE* file)
}
return 0;
}
+
+#endif
+
+
diff --git a/sql/sql_repl.h b/sql/sql_repl.h
index 15435382b08..5ba7d0ce74e 100644
--- a/sql/sql_repl.h
+++ b/sql/sql_repl.h
@@ -1,3 +1,4 @@
+#ifndef EMBEDDED_LIBRARY
#include "slave.h"
typedef struct st_slave_info
@@ -53,3 +54,6 @@ typedef struct st_load_file_info
} LOAD_FILE_INFO;
int log_loaded_block(IO_CACHE* file);
+
+#endif /* EMBEDDED_LIBRARY */
+
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 602a4b494b6..c7ab438ba97 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3640,7 +3640,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
(thd->options & OPTION_AUTO_IS_NULL) &&
thd->insert_id())
{
+#ifndef EMBEDDED_LIBRARY
query_cache_abort(&thd->net);
+#endif
COND *new_cond;
if ((new_cond= new Item_func_eq(args[0],
new Item_int("last_insert_id()",
@@ -5563,6 +5565,9 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{
Item *item= *group->item;
item->save_org_in_field(group->field);
+#ifdef EMBEDDED_LIBRARY
+ join->thd->net.last_errno= 0;
+#endif
/* Store in the used key if the field was 0 */
if (item->maybe_null)
group->buff[-1]=item->null_value ? 1 : 0;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f60cba54e84..1ecb5e817d7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -52,8 +52,6 @@ extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
** Send list of databases
** A database is a directory in the mysql_data_home directory
****************************************************************************/
-
-
int
mysqld_show_dbs(THD *thd,const char *wild)
{
@@ -650,7 +648,6 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
/***************************************************************************
** List all columns in a table_list->real_name
***************************************************************************/
-
int
mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
bool verbose)
@@ -687,13 +684,14 @@ 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))
DBUG_RETURN(1);
restore_record(table,2); // Get empty record
@@ -753,8 +751,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
if (verbose)
{
/* Add grant options & comments */
- col_access= get_column_grant(thd,table_list,field) & COL_ACLS;
end=tmp;
+ col_access= get_column_grant(thd,table_list,field) & COL_ACLS;
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
{
if (col_access & 1)
@@ -962,7 +960,9 @@ 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;
}
@@ -979,6 +979,7 @@ 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)
@@ -993,6 +994,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
MYF(MY_WME)))
DBUG_RETURN(-1);
}
+#endif
DBUG_RETURN(0);
}
@@ -1238,7 +1240,7 @@ public:
template class I_List<thread_info>;
#endif
-
+#ifndef EMBEDDED_LIBRARY
void mysqld_list_processes(THD *thd,const char *user, bool verbose)
{
Item *field;
@@ -1351,7 +1353,12 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
send_eof(thd);
DBUG_VOID_RETURN;
}
-
+#else /* EMBEDDED_LIBRARY */
+void mysqld_list_processes(THD *thd __attribute__(unused),
+ const char *user __attribute__(unused),
+ bool verbose __attribute__(unused))
+{}
+#endif
/*****************************************************************************
Status functions
@@ -1468,6 +1475,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
+#ifndef EMBEDDED_LIBRARY
case SHOW_RPL_STATUS:
end= int10_to_str((long) rpl_status_type[(int)rpl_status], buff, 10);
break;
@@ -1479,6 +1487,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
UNLOCK_ACTIVE_MI;
break;
}
+#endif /* EMBEDDED_LIBRARY */
case SHOW_OPENTABLES:
end= int10_to_str((long) cached_tables(), buff, 10);
break;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1ab84531e40..49e84db62c9 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -418,6 +418,16 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field->unireg_check=Field::BLOB_FIELD;
blob_columns++;
break;
+ case FIELD_TYPE_GEOMETRY:
+ sql_field->pack_flag=FIELDFLAG_GEOM |
+ pack_length_to_packflag(sql_field->pack_length -
+ portable_sizeof_char_ptr);
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ sql_field->length=8; // Unireg field length
+ sql_field->unireg_check=Field::BLOB_FIELD;
+ blob_columns++;
+ break;
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
sql_field->pack_flag=0;
@@ -1198,6 +1208,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->open_options|= extra_open_options;
table->table = open_ltable(thd, table, lock_type);
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0; // these errors shouldn't get client
+#endif
thd->open_options&= ~extra_open_options;
protocol->prepare_for_resend();
@@ -1264,6 +1277,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
int result_code = (table->table->file->*operator_func)(thd, check_opt);
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0; // these errors shouldn't get client
+#endif
protocol->prepare_for_resend();
protocol->store(table_name);
protocol->store(operator_name);