diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 10 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 1 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 4 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 16 | ||||
-rw-r--r-- | sql/ha_myisam.h | 2 | ||||
-rw-r--r-- | sql/item.cc | 3 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 6 | ||||
-rw-r--r-- | sql/log.cc | 13 | ||||
-rw-r--r-- | sql/log_event.cc | 193 | ||||
-rw-r--r-- | sql/log_event.h | 56 | ||||
-rw-r--r-- | sql/mf_iocache.cc | 5 | ||||
-rw-r--r-- | sql/mini_client.cc | 5 | ||||
-rw-r--r-- | sql/mysql_priv.h | 8 | ||||
-rw-r--r-- | sql/mysqld.cc | 30 | ||||
-rw-r--r-- | sql/opt_range.cc | 34 | ||||
-rw-r--r-- | sql/protocol.cc | 70 | ||||
-rw-r--r-- | sql/protocol.h | 20 | ||||
-rw-r--r-- | sql/repl_failsafe.cc | 6 | ||||
-rw-r--r-- | sql/repl_failsafe.h | 4 | ||||
-rw-r--r-- | sql/set_var.cc | 29 | ||||
-rw-r--r-- | sql/slave.cc | 7 | ||||
-rw-r--r-- | sql/slave.h | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 6 | ||||
-rw-r--r-- | sql/sql_repl.h | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 20 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 |
29 files changed, 251 insertions, 314 deletions
diff --git a/sql/field.cc b/sql/field.cc index 658dc711f6e..c3feb0b8826 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4586,7 +4586,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); @@ -4601,8 +4601,6 @@ 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) @@ -4612,7 +4610,7 @@ void Field_geom::set_key_image(char *buff,uint length) void Field_geom::sql_type(String &res) const { - res.set("geometry", 8U, default_charset_info); + res.set("geometry", 8, default_charset_info); } int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) @@ -5255,10 +5253,10 @@ uint32 calc_pack_length(enum_field_types type,uint32 length) case FIELD_TYPE_LONGLONG: return 8; /* Don't crash if no longlong */ case FIELD_TYPE_NULL : return 0; case FIELD_TYPE_TINY_BLOB: return 1+portable_sizeof_char_ptr; - case FIELD_TYPE_BLOB: return 2+portable_sizeof_char_ptr; + case FIELD_TYPE_BLOB: + case FIELD_TYPE_GEOMETRY: 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; diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 07f367d7470..c5d588d1f19 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -255,7 +255,6 @@ int berkeley_show_logs(Protocol *protocol) /* Error is 0 here */ if (all_logs) { - protocol->set_nfields(3); for (a = all_logs, f = free_logs; *a; ++a) { protocol->prepare_for_resend(); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f4d21bf6216..a50ee6cf93d 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -871,7 +871,7 @@ innobase_commit_low( /*================*/ trx_t* trx) /* in: transaction handle */ { -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION if (current_thd->slave_thread) { /* Update the replication position info inside InnoDB */ #ifdef NEED_TO_BE_FIXED @@ -885,7 +885,7 @@ innobase_commit_low( active_mi->rli.event_len + active_mi->rli.pending)); } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ trx_commit_for_mysql(trx); } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index a3bc925a015..28c3372dde6 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -76,7 +76,6 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, } length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - name); - protocol->set_nfields(4); protocol->prepare_for_resend(); protocol->store(name, length); protocol->store(param->op_name); @@ -140,9 +139,9 @@ const char *ha_myisam::index_type(uint key_number) "BTREE"); } +#ifdef HAVE_REPLICATION int ha_myisam::net_read_dump(NET* net) { -#ifndef EMBEDDED_LIBRARY int data_fd = file->dfile; int error = 0; @@ -167,15 +166,11 @@ int ha_myisam::net_read_dump(NET* net) } 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; @@ -224,10 +219,8 @@ int ha_myisam::dump(THD* thd, int fd) err: my_free((gptr) buf, MYF(0)); return error; -#else - return (int)thd - fd; -#endif } +#endif /* HAVE_REPLICATION */ /* Name is here without an extension */ @@ -1056,8 +1049,9 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, for (i=0; i < table_arg->keys ; i++, pos++) { keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL)); - keydef[i].key_alg=pos->algorithm == HA_KEY_ALG_UNDEF ? - HA_KEY_ALG_BTREE : pos->algorithm; + keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? + (pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) : + pos->algorithm; keydef[i].seg=keyseg; keydef[i].keysegs=pos->key_parts; for (j=0 ; j < pos->key_parts ; j++) diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index 215608f8f0a..5dc294b3b9f 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -127,6 +127,8 @@ class ha_myisam: public handler int optimize(THD* thd, HA_CHECK_OPT* check_opt); int restore(THD* thd, HA_CHECK_OPT* check_opt); int backup(THD* thd, HA_CHECK_OPT* check_opt); +#ifdef HAVE_REPLICATION int dump(THD* thd, int fd); int net_read_dump(NET* net); +#endif }; diff --git a/sql/item.cc b/sql/item.cc index a46b5f3af23..12195ae359a 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1014,8 +1014,7 @@ bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT { char buff[MAX_FIELD_WIDTH]; String s(buff, sizeof(buff), charset), *value; - if (!(value=val_str(&s)) || - !(*result=alloc_root(alloc, value->length() + 1))) + if (!(value=val_str(&s))) { *result= NULL; *length= 0; diff --git a/sql/item_func.cc b/sql/item_func.cc index bcc04aac6a9..79bb0cbb0ae 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1656,7 +1656,7 @@ longlong Item_master_pos_wait::val_int() return 0; } ulong pos = (ulong)args[1]->val_int(); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION LOCK_ACTIVE_MI; if ((event_count = active_mi->rli.wait_for_pos(thd, log_name, pos)) == -1) { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c83b0bcb651..0b9658a5c2a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1394,11 +1394,6 @@ 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; @@ -1406,7 +1401,6 @@ 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 e09a13c1328..9d56a16b0da 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -24,7 +24,6 @@ #include "mysql_priv.h" #include <mysql.h> - #include "sql_acl.h" #include "sql_repl.h" @@ -614,7 +613,7 @@ err: LOG_INFO_IO Got IO error while reading file */ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli) { @@ -745,7 +744,7 @@ err: DBUG_RETURN(error); } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ /* @@ -1056,7 +1055,7 @@ bool MYSQL_LOG::write(Log_event* event_info) #else IO_CACHE *file = &log_file; #endif -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION if ((thd && !(thd->options & OPTION_BIN_LOG) && (thd->master_access & SUPER_ACL)) || (local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db))) @@ -1065,7 +1064,7 @@ bool MYSQL_LOG::write(Log_event* event_info) DBUG_PRINT("error",("!db_ok")); DBUG_RETURN(0); } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ error=1; /* @@ -1429,7 +1428,7 @@ void MYSQL_LOG::close(bool exiting) DBUG_PRINT("enter",("exiting: %d", (int) exiting)); if (is_open()) { -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION if (log_type == LOG_BIN && !no_auto_events && exiting) { Stop_log_event s; @@ -1437,7 +1436,7 @@ void MYSQL_LOG::close(bool exiting) s.write(&log_file); signal_update(); } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ end_io_cache(&log_file); if (my_close(log_file.file,MYF(0)) < 0 && ! write_error) { diff --git a/sql/log_event.cc b/sql/log_event.cc index 76eb10e85fc..22416fa77a7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -82,14 +82,12 @@ static void pretty_print_str(FILE* file, char* str, int len) ignored_error_code() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(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 */ +#endif /***************************************************************************** @@ -126,8 +124,7 @@ static void pretty_print_str(String* packet, char* str, int len) slave_load_file_stem() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) static inline char* slave_load_file_stem(char*buf, uint file_id, int event_server_id) { @@ -139,8 +136,7 @@ static inline char* slave_load_file_stem(char*buf, uint file_id, *buf++ = '-'; return int10_to_str(file_id, buf, 10); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -154,8 +150,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 +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) static void cleanup_load_tmpdir() { MY_DIR *dirp; @@ -173,8 +168,7 @@ static void cleanup_load_tmpdir() my_dirend(dirp); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -292,7 +286,7 @@ Log_event::Log_event(const char* buf, bool old_format) #ifndef MYSQL_CLIENT -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION /***************************************************************************** @@ -319,25 +313,7 @@ void Log_event::pack_info(Protocol *protocol) { protocol->store("",0); } -#endif /* EMBEDDED_LIBRARY */ -/***************************************************************************** - - Log_event::init_show_field_list() - - ****************************************************************************/ -void Log_event::init_show_field_list(List<Item>* field_list) -{ - field_list->push_back(new Item_empty_string("Log_name", 20)); - field_list->push_back(new Item_return_int("Pos", 11, - MYSQL_TYPE_LONGLONG)); - field_list->push_back(new Item_empty_string("Event_type", 20)); - field_list->push_back(new Item_return_int("Server_id", 10, - MYSQL_TYPE_LONG)); - field_list->push_back(new Item_return_int("Orig_log_pos", 11, - MYSQL_TYPE_LONGLONG)); - field_list->push_back(new Item_empty_string("Info", 20)); -} /***************************************************************************** @@ -346,7 +322,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); @@ -364,7 +340,26 @@ 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 /* HAVE_REPLICATION */ + +/***************************************************************************** + + Log_event::init_show_field_list() + + ****************************************************************************/ +void Log_event::init_show_field_list(List<Item>* field_list) +{ + field_list->push_back(new Item_empty_string("Log_name", 20)); + field_list->push_back(new Item_return_int("Pos", 11, + MYSQL_TYPE_LONGLONG)); + field_list->push_back(new Item_empty_string("Event_type", 20)); + field_list->push_back(new Item_return_int("Server_id", 10, + MYSQL_TYPE_LONG)); + field_list->push_back(new Item_return_int("Orig_log_pos", 11, + MYSQL_TYPE_LONGLONG)); + field_list->push_back(new Item_empty_string("Info", 20)); +} + #endif // !MYSQL_CLIENT /***************************************************************************** @@ -572,11 +567,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 +#ifdef HAVE_REPLICATION case SLAVE_EVENT: ev = new Slave_log_event(buf, event_len); break; -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ case CREATE_FILE_EVENT: ev = new Create_file_log_event(buf, event_len, old_format); break; @@ -592,11 +587,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 +#ifdef HAVE_REPLICATION case STOP_EVENT: ev = new Stop_log_event(buf, old_format); break; -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ case INTVAR_EVENT: ev = new Intvar_log_event(buf, old_format); break; @@ -683,8 +678,7 @@ void Log_event::set_log_pos(MYSQL_LOG* log) ***************************************************************************** ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) /***************************************************************************** Query_log_event::pack_info() @@ -706,8 +700,7 @@ void Query_log_event::pack_info(Protocol *protocol) tmp.append(query, q_len); protocol->store((char*) tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -840,8 +833,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 +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Query_log_event::exec_event(struct st_relay_log_info* rli) { int expected_error,actual_error = 0; @@ -929,8 +921,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) free_root(&thd->mem_root,0); return Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -946,8 +937,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) Start_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Start_log_event::pack_info(Protocol *protocol) { char buf1[256]; @@ -961,8 +951,7 @@ void Start_log_event::pack_info(Protocol *protocol) tmp.append(llstr(binlog_version, buf)); protocol->store(tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1031,8 +1020,7 @@ int Start_log_event::write_data(IO_CACHE* file) In this case we should stop the slave. ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Start_log_event::exec_event(struct st_relay_log_info* rli) { /* All temporary tables was deleted on the master */ @@ -1044,8 +1032,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) cleanup_load_tmpdir(); return Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1061,8 +1048,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) Load_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Load_log_event::pack_info(Protocol *protocol) { char buf[256]; @@ -1138,8 +1124,7 @@ void Load_log_event::pack_info(Protocol *protocol) protocol->store(tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1443,8 +1428,7 @@ void Load_log_event::set_fields(List<Item> &field_list) Load_log_event::exec_event() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli) { init_sql_alloc(&thd->mem_root, 8192,0); @@ -1550,8 +1534,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 */ +#endif /***************************************************************************** @@ -1567,8 +1550,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 +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Rotate_log_event::pack_info(Protocol *protocol) { char buf1[256], buf[22]; @@ -1581,8 +1563,7 @@ void Rotate_log_event::pack_info(Protocol *protocol) tmp.append("; forced by master"); protocol->store(tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1675,8 +1656,7 @@ int Rotate_log_event::write_data(IO_CACHE* file) 0 ok ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Rotate_log_event::exec_event(struct st_relay_log_info* rli) { char* log_name = rli->master_log_name; @@ -1692,8 +1672,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) flush_relay_log_info(rli); DBUG_RETURN(0); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1709,8 +1688,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) Intvar_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Intvar_log_event::pack_info(Protocol *protocol) { char buf1[256], buf[22]; @@ -1721,8 +1699,7 @@ void Intvar_log_event::pack_info(Protocol *protocol) tmp.append(llstr(val, buf)); protocol->store(tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1801,8 +1778,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 +#if defined(HAVE_REPLICATION)&& !defined(MYSQL_CLIENT) int Intvar_log_event::exec_event(struct st_relay_log_info* rli) { switch (type) { @@ -1817,8 +1793,7 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli) rli->inc_pending(get_event_len()); return 0; } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1834,8 +1809,7 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli) Rand_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Rand_log_event::pack_info(Protocol *protocol) { char buf1[256], *pos; @@ -1845,8 +1819,7 @@ void Rand_log_event::pack_info(Protocol *protocol) pos= int10_to_str((long) seed2, pos, 10); protocol->store(buf1, (uint) (pos-buf1)); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1899,8 +1872,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 +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Rand_log_event::exec_event(struct st_relay_log_info* rli) { thd->rand.seed1= (ulong) seed1; @@ -1908,8 +1880,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli) rli->inc_pending(get_event_len()); return 0; } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -1925,7 +1896,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli) Slave_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION #ifndef MYSQL_CLIENT void Slave_log_event::pack_info(Protocol *protocol) @@ -2150,7 +2121,7 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli) return 0; } #endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ /***************************************************************************** @@ -2276,8 +2247,7 @@ void Create_file_log_event::print(FILE* file, bool short_form, Create_file_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Create_file_log_event::pack_info(Protocol *protocol) { char buf1[256],buf[22], *end; @@ -2295,16 +2265,14 @@ void Create_file_log_event::pack_info(Protocol *protocol) tmp.append(buf, (uint32) (end-buf)); protocol->store((char*) tmp.ptr(), tmp.length()); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** Create_file_log_event::exec_event() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Create_file_log_event::exec_event(struct st_relay_log_info* rli) { char fname_buf[FN_REFLEN+10]; @@ -2361,8 +2329,7 @@ err: my_close(fd, MYF(0)); return error ? 1 : Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -2439,8 +2406,7 @@ void Append_block_log_event::print(FILE* file, bool short_form, Append_block_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Append_block_log_event::pack_info(Protocol *protocol) { char buf[256]; @@ -2450,16 +2416,14 @@ void Append_block_log_event::pack_info(Protocol *protocol) block_len)); protocol->store(buf, (int32) length); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** Append_block_log_event::exec_event() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Append_block_log_event::exec_event(struct st_relay_log_info* rli) { char fname[FN_REFLEN+10]; @@ -2487,8 +2451,7 @@ err: my_close(fd, MYF(0)); return error ? error : Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -2558,8 +2521,7 @@ void Delete_file_log_event::print(FILE* file, bool short_form, Delete_file_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Delete_file_log_event::pack_info(Protocol *protocol) { char buf[64]; @@ -2567,16 +2529,14 @@ void Delete_file_log_event::pack_info(Protocol *protocol) length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); protocol->store(buf, (int32) length); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** Delete_file_log_event::exec_event() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) { char fname[FN_REFLEN+10]; @@ -2589,8 +2549,7 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) mysql_bin_log.write(this); return Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ +#endif /***************************************************************************** @@ -2661,8 +2620,7 @@ void Execute_load_log_event::print(FILE* file, bool short_form, Execute_load_log_event::pack_info() ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY -#ifndef MYSQL_CLIENT +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Execute_load_log_event::pack_info(Protocol *protocol) { char buf[64]; @@ -2670,16 +2628,13 @@ void Execute_load_log_event::pack_info(Protocol *protocol) length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); 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) { char fname[FN_REFLEN+10]; @@ -2738,8 +2693,8 @@ err: } return error ? error : Log_event::exec_event(rli); } -#endif // !MYSQL_CLIENT -#endif /* EMBEDDED_LIBRARY */ + +#endif /***************************************************************************** diff --git a/sql/log_event.h b/sql/log_event.h index e0ebe4150bb..7ba203e7f30 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -268,11 +268,11 @@ public: pthread_mutex_t* log_lock); void set_log_pos(MYSQL_LOG* log); static void init_show_field_list(List<Item>* field_list); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION 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 */ +#endif /* HAVE_REPLICATION */ virtual const char* get_db() { return thd ? thd->db : 0; @@ -357,10 +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 +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -387,7 +387,7 @@ public: } }; -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION /***************************************************************************** @@ -409,10 +409,8 @@ 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 @@ -425,7 +423,7 @@ public: int write_data(IO_CACHE* file ); }; -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ /***************************************************************************** @@ -464,14 +462,14 @@ public: bool using_trans); void set_fields(List<Item> &fields_arg); const char* get_db() { return db; } -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION 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 */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -518,10 +516,10 @@ public: created = (uint32) when; memcpy(server_version, ::server_version, ST_SERVER_VER_LEN); } -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -555,10 +553,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 +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -589,10 +587,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 +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -611,7 +609,7 @@ class Rand_log_event: public Log_event Stop Log Event class ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION class Stop_log_event: public Log_event { @@ -619,9 +617,7 @@ 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 @@ -634,7 +630,7 @@ public: bool is_valid() { return 1; } }; -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ /***************************************************************************** @@ -659,10 +655,10 @@ public: pos(pos_arg),ident_len(ident_len_arg ? ident_len_arg : (uint) strlen(new_log_ident_arg)), alloced(0) {} -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -708,10 +704,10 @@ public: enum enum_duplicates handle_dup, char* block_arg, uint block_len_arg, bool using_trans); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -760,10 +756,10 @@ public: #ifndef MYSQL_CLIENT Append_block_log_event(THD* thd, char* block_arg, uint block_len_arg, bool using_trans); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION int exec_event(struct st_relay_log_info* rli); void pack_info(Protocol* protocol); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -788,10 +784,10 @@ public: #ifndef MYSQL_CLIENT Delete_file_log_event(THD* thd, bool using_trans); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, char* last_db = 0); #endif @@ -816,10 +812,10 @@ public: #ifndef MYSQL_CLIENT Execute_load_log_event(THD* thd, bool using_trans); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); int exec_event(struct st_relay_log_info* rli); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ #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 436b79b23c3..e7e72617c83 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -30,10 +30,9 @@ flush_io_cache(). */ -#ifndef EMBEDDED_LIBRARY - #define MAP_TO_USE_RAID #include "mysql_priv.h" +#ifdef HAVE_REPLICATION #ifdef HAVE_AIOWAIT #include <mysys_err.h> #include <errno.h> @@ -83,6 +82,6 @@ int _my_b_net_read(register IO_CACHE *info, byte *Buffer, } } /* extern "C" */ -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/mini_client.cc b/sql/mini_client.cc index b84f01da16c..d32154685f0 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -22,8 +22,9 @@ in case we decide to make them external at some point */ -#ifndef EMBEDDED_LIBRARY #include <my_global.h> +#ifdef HAVE_EXTERNAL_CLIENT + /* my_pthread must be included early to be able to fix things */ #if defined(THREAD) #include <my_pthread.h> /* because of signal() */ @@ -1473,4 +1474,4 @@ MYSQL_RES *mc_mysql_store_result(MYSQL *mysql) DBUG_RETURN(result); /* Data fetched */ } -#endif /*EMBEDDED_LIBRARY*/ +#endif /* HAVE_EXTERNAL_CLIENT */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 50b79949772..cf0cefd76da 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -879,14 +879,6 @@ 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, const 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 8869a642ed3..2bacdfc14bf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -875,7 +875,7 @@ void clean_up(bool print_message) DBUG_PRINT("exit",("clean_up")); if (cleanup_done++) return; /* purecov: inspected */ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION if (use_slave_mask) bitmap_free(&slave_error_mask); #endif @@ -900,14 +900,14 @@ 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 +#ifdef HAVE_REPLICATION 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 +#ifdef HAVE_REPLICATION end_slave_list(); #endif #ifdef USE_REGEX @@ -1948,7 +1948,7 @@ static int init_thread_environement() (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 +#ifdef HAVE_REPLICATION (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); #endif (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); @@ -1959,7 +1959,7 @@ static int init_thread_environement() (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 +#ifdef HAVE_REPLICATION (void) pthread_cond_init(&COND_rpl_status, NULL); #endif /* Parameter for threads created for connections */ @@ -2008,7 +2008,7 @@ static int init_server_components() randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); reset_floating_point_exceptions(); init_thr_lock(); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION init_slave_list(); #endif /* Setup log files */ @@ -2269,6 +2269,7 @@ The server will not act as a slave."); if (opt_bootstrap) { + printf("###stdin as bootstrap\n"); int error=bootstrap(stdin); end_thr_alarm(); // Don't allow alarms unireg_abort(error ? 1 : 0); @@ -2338,6 +2339,7 @@ The server will not act as a slave."); #endif /* EMBEDDED_LIBRARY */ + /**************************************************************************** Main and thread entry function for Win32 (all this is needed only to run mysqld as a service on WinNT) @@ -3498,7 +3500,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 +#ifdef HAVE_REPLICATION {"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, @@ -3517,7 +3519,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 */ +#endif /* HAVE_REPLICATION */ {"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}, @@ -3660,7 +3662,7 @@ 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 +#ifdef HAVE_REPLICATION {"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}, @@ -3995,7 +3997,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 +#ifdef HAVE_REPLICATION {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, "Max space to use for all relay logs", (gptr*) &relay_log_space_limit, @@ -4354,7 +4356,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'o': protocol_version=PROTOCOL_VERSION-1; break; -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION case OPT_SLAVE_SKIP_ERRORS: init_slave_skip_errors(argument); break; @@ -4398,7 +4400,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 +#ifdef HAVE_REPLICATION case (int) OPT_INIT_RPL_ROLE: { int role; @@ -4523,7 +4525,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_reckless_slave = 1; init_slave_skip_errors("all"); break; -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ case (int) OPT_SLOW_QUERY_LOG: opt_slow_log=1; break; @@ -4900,7 +4902,7 @@ static void fix_paths(void) if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) exit(1); -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION if (!slave_load_tmpdir) { if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE)))) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index bcea522cb6d..c8b1ad380d4 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2162,28 +2162,18 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, tmp=1; // Max one record else { - if(tmp_min_flag & GEOM_FLAG) - { - tmp=param->table->file-> - records_in_range((int) keynr,(byte*)(param->min_key + 1), - min_key_length, (ha_rkey_function)(tmp_min_flag ^ GEOM_FLAG), - (byte *)NullS,0,HA_READ_KEY_EXACT); - } - else - { - tmp=param->table->file-> - records_in_range((int) keynr, - (byte*) (!min_key_length ? NullS : - param->min_key), - min_key_length, - tmp_min_flag & NEAR_MIN ? - HA_READ_AFTER_KEY : HA_READ_KEY_EXACT, - (byte*) (!max_key_length ? NullS : - param->max_key), - max_key_length, - (tmp_max_flag & NEAR_MAX ? - HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY)); - } + tmp=param->table->file-> + records_in_range((int) keynr, + (byte*) (!min_key_length ? NullS : + param->min_key), + min_key_length, + tmp_min_flag & NEAR_MIN ? + HA_READ_AFTER_KEY : HA_READ_KEY_EXACT, + (byte*) (!max_key_length ? NullS : + param->max_key), + max_key_length, + (tmp_max_flag & NEAR_MAX ? + HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY)); } end: if (tmp == HA_POS_ERROR) // Impossible range diff --git a/sql/protocol.cc b/sql/protocol.cc index 0239d867f6b..9926d4a6432 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -27,6 +27,23 @@ #include <stdarg.h> #include <assert.h> +#ifndef EMBEDDED_LIBRARY +bool Protocol::net_store_data(const char *from, uint length) +{ + ulong packet_length=packet->length(); + if (packet_length+5+length > packet->alloced_length() && + packet->realloc(packet_length+5+length)) + return 1; + char *to=(char*) net_store_length((char*) packet->ptr()+packet_length, + (ulonglong) length); + memcpy(to,from,length); + packet->length((uint) (to+length-packet->ptr())); + return 0; +} + +#endif + + /* Send a error string to client */ void send_error(THD *thd, uint sql_errno, const char *err) @@ -402,23 +419,6 @@ char *net_store_length(char *pkg, uint length) } -/* - Used internally for storing strings in packet -*/ - -static bool net_store_data(String *packet, const char *from, uint length) -{ - ulong packet_length=packet->length(); - if (packet_length+5+length > packet->alloced_length() && - packet->realloc(packet_length+5+length)) - return 1; - char *to=(char*) net_store_length((char*) packet->ptr()+packet_length, - (ulonglong) length); - memcpy(to,from,length); - packet->length((uint) (to+length-packet->ptr())); - return 0; -} - /**************************************************************************** Functions used by the protocol functions (like send_ok) to store strings and numbers in the header result packet. @@ -574,15 +574,16 @@ err: DBUG_RETURN(1); /* purecov: inspected */ } -#endif - bool Protocol::write() { DBUG_ENTER("Protocol::write"); - DBUG_RETURN(SEND_ROW(thd, n_fields, packet->ptr(), packet->length())); + DBUG_RETURN(my_net_write(&thd->net, packet->ptr(), packet->length())); } +#endif /* EMBEDDED_LIBRARY */ + + /* Send \0 end terminated string @@ -640,6 +641,7 @@ bool Protocol::store(I_List<i_string>* str_list) ****************************************************************************/ +#ifndef EMBEDDED_LIBRARY void Protocol_simple::prepare_for_resend() { packet->length(0); @@ -647,6 +649,7 @@ void Protocol_simple::prepare_for_resend() field_pos= 0; #endif } +#endif bool Protocol_simple::store_null() { @@ -669,7 +672,7 @@ bool Protocol_simple::store(const char *from, uint length) #endif if (convert) return convert->store(packet, from, length); - return net_store_data(packet, from, length); + return net_store_data(from, length); } @@ -679,7 +682,7 @@ bool Protocol_simple::store_tiny(longlong from) DBUG_ASSERT(field_types == 0 || field_types[field_pos++] == MYSQL_TYPE_TINY); #endif char buff[20]; - return net_store_data(packet,(char*) buff, + return net_store_data((char*) buff, (uint) (int10_to_str((int) from,buff, -10)-buff)); } @@ -690,7 +693,7 @@ bool Protocol_simple::store_short(longlong from) field_types[field_pos++] == MYSQL_TYPE_SHORT); #endif char buff[20]; - return net_store_data(packet,(char*) buff, + return net_store_data((char*) buff, (uint) (int10_to_str((int) from,buff, -10)-buff)); } @@ -700,7 +703,7 @@ bool Protocol_simple::store_long(longlong from) DBUG_ASSERT(field_types == 0 || field_types[field_pos++] == MYSQL_TYPE_LONG); #endif char buff[20]; - return net_store_data(packet,(char*) buff, + return net_store_data((char*) buff, (uint) (int10_to_str((int) from,buff, -10)-buff)); } @@ -712,7 +715,7 @@ bool Protocol_simple::store_longlong(longlong from, bool unsigned_flag) field_types[field_pos++] == MYSQL_TYPE_LONGLONG); #endif char buff[22]; - return net_store_data(packet,(char*) buff, + return net_store_data((char*) buff, (uint) (longlong10_to_str(from,buff, unsigned_flag ? 10 : -10)- buff)); @@ -726,7 +729,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer) field_types[field_pos++] == MYSQL_TYPE_FLOAT); #endif buffer->set((double) from, decimals, thd->variables.thd_charset); - return net_store_data(packet,(char*) buffer->ptr(), buffer->length()); + return net_store_data((char*) buffer->ptr(), buffer->length()); } bool Protocol_simple::store(double from, uint32 decimals, String *buffer) @@ -736,7 +739,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer) field_types[field_pos++] == MYSQL_TYPE_DOUBLE); #endif buffer->set(from, decimals, thd->variables.thd_charset); - return net_store_data(packet,(char*) buffer->ptr(), buffer->length()); + return net_store_data((char*) buffer->ptr(), buffer->length()); } @@ -752,7 +755,7 @@ bool Protocol_simple::store(Field *field) field->val_str(&tmp,&tmp); if (convert) return convert->store(packet, tmp.ptr(), tmp.length()); - return net_store_data(packet, tmp.ptr(), tmp.length()); + return net_store_data(tmp.ptr(), tmp.length()); } @@ -773,7 +776,7 @@ bool Protocol_simple::store(TIME *tm) (int) tm->hour, (int) tm->minute, (int) tm->second)); - return net_store_data(packet, (char*) buff, length); + return net_store_data((char*) buff, length); } @@ -789,7 +792,7 @@ bool Protocol_simple::store_date(TIME *tm) (int) tm->year, (int) tm->month, (int) tm->day)); - return net_store_data(packet, (char*) buff, length); + return net_store_data((char*) buff, length); } @@ -806,7 +809,7 @@ bool Protocol_simple::store_time(TIME *tm) (long) tm->day*3600L+(long) tm->hour, (int) tm->minute, (int) tm->second)); - return net_store_data(packet, (char*) buff, length); + return net_store_data((char*) buff, length); } @@ -816,8 +819,7 @@ bool Protocol_simple::store_time(TIME *tm) bool Protocol_prep::prepare_for_send(List<Item> *item_list) { - field_count=item_list->elements; - set_nfields(item_list->elements); + Protocol::prepare_for_send(item_list); bit_fields= (field_count+3)/8; if (packet->alloc(bit_fields)) return 1; @@ -846,7 +848,7 @@ bool Protocol_prep::store(const char *from,uint length) field_pos++; if (convert) return convert->store(packet, from, length); - return net_store_data(packet, from, length); + return net_store_data(from, length); } diff --git a/sql/protocol.h b/sql/protocol.h index cc20e158243..cf41e404c93 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -33,8 +33,11 @@ protected: #ifndef DEBUG_OFF enum enum_field_types *field_types; #endif + uint field_count; + bool net_store_data(const char *from, uint length); #ifdef EMBEDDED_LIBRARY - uint n_fields; + char **next_field; + MEM_ROOT *alloc; #endif public: @@ -56,13 +59,11 @@ public: inline bool store(ulonglong from) { return store_longlong((longlong) from, 1); } -#ifdef EMBEDDED_LIBRARY - inline void set_nfields(uint fields_count) { n_fields= fields_count; } -#else - inline void set_nfields(uint fields_count) {} -#endif - - virtual bool prepare_for_send(List<Item> *item_list) { return 0;} + virtual bool prepare_for_send(List<Item> *item_list) + { + field_count=item_list->elements; + return 0; + } virtual void prepare_for_resend()=0; virtual bool store_null()=0; @@ -106,7 +107,7 @@ public: class Protocol_prep :public Protocol { private: - uint field_count, bit_fields; + uint bit_fields; public: Protocol_prep() {} Protocol_prep(THD *thd) :Protocol(thd) {} @@ -126,7 +127,6 @@ public: virtual bool store(Field *field); }; - void send_warning(THD *thd, uint sql_errno, const char *err=0); void net_printf(THD *thd,uint sql_errno, ...); void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 4942dd9cfd8..6ef252467c3 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -16,9 +16,9 @@ // Sasha Pachev <sasha@mysql.com> is currently in charge of this file -#ifndef EMBEDDED_LIBRARY - #include "mysql_priv.h" +#ifdef HAVE_REPLICATION + #include "repl_failsafe.h" #include "sql_repl.h" #include "slave.h" @@ -896,5 +896,5 @@ err: return error; } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index e517f0a5a8a..72ea0cf2a56 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -1,4 +1,4 @@ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION #ifndef REPL_FAILSAFE_H #define REPL_FAILSAFE_H @@ -36,4 +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 */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/set_var.cc b/sql/set_var.cc index dd30d2e377d..66aded8422f 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -206,7 +206,7 @@ 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 +#ifdef HAVE_REPLICATION sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout", &slave_net_timeout); #endif @@ -299,7 +299,7 @@ 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 +#ifdef HAVE_REPLICATION 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"); @@ -383,7 +383,7 @@ sys_var *sys_variables[]= &sys_safe_updates, &sys_select_limit, &sys_server_id, -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION &sys_slave_compressed_protocol, &sys_slave_net_timeout, &sys_slave_skip_counter, @@ -480,7 +480,7 @@ 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 +#ifdef HAVE_REPLICATION {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL}, #endif {"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL}, @@ -534,7 +534,7 @@ 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 +#ifdef HAVE_REPLICATION {sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS}, #endif {"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, @@ -636,7 +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 +#ifdef HAVE_REPLICATION static void fix_net_read_timeout(THD *thd, enum_var_type type) { if (type != OPT_GLOBAL) @@ -655,14 +655,17 @@ 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)) +#else /* HAVE_REPLICATION */ +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_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)) +static void fix_net_retry_count(THD *thd __attribute__(unused), + enum_var_type type __attribute__(unused)) {} -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ static void fix_query_cache_size(THD *thd, enum_var_type type) @@ -1079,7 +1082,7 @@ byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type) } -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION bool sys_var_slave_skip_counter::check(THD *thd, set_var *var) { int result= 0; @@ -1115,7 +1118,7 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var) UNLOCK_ACTIVE_MI; return 0; } -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ bool sys_var_rand_seed1::update(THD *thd, set_var *var) { diff --git a/sql/slave.cc b/sql/slave.cc index 24ec1fc2536..0fbf4f67846 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -14,8 +14,10 @@ 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" + +#ifdef HAVE_REPLICATION + #include <mysql.h> #include <myisam.h> #include "mini_client.h" @@ -26,6 +28,7 @@ #include <my_dir.h> #include <assert.h> + bool use_slave_mask = 0; MY_BITMAP slave_error_mask; @@ -3182,4 +3185,4 @@ template class I_List_iterator<i_string>; template class I_List_iterator<i_string_pair>; #endif -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/slave.h b/sql/slave.h index 84685b7e429..358762306e2 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -1,4 +1,4 @@ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION #ifndef SLAVE_H #define SLAVE_H @@ -466,4 +466,4 @@ extern I_List<THD> threads; #else #define SLAVE_IO 1 #define SLAVE_SQL 2 -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c3bdbabab60..7d9dc05b4cf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -842,6 +842,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); while (fgets(buff, thd->net.max_packet, file)) { + printf("%s", buff); uint length=(uint) strlen(buff); while (length && (my_isspace(system_charset_info, buff[length-1]) || buff[length-1] == ';')) @@ -3469,7 +3470,8 @@ 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_GEOMETRY)) + 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 */ diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 0c21ffe3f95..fde81ad9044 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -141,6 +141,8 @@ static bool send_prep_stmt(PREP_STMT *stmt, uint columns) int2store(buff+4, columns); int2store(buff+6, stmt->param_count); #ifndef EMBEDDED_LIBRARY + /* This should be fixed to work with prepared statements + */ return (my_net_write(net, buff, sizeof(buff)) || net_flush(net)); #else return true; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 3bffeaccb15..7c247302e02 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -16,9 +16,9 @@ // Sasha Pachev <sasha@mysql.com> is currently in charge of this file -#ifndef EMBEDDED_LIBRARY - #include "mysql_priv.h" +#ifdef HAVE_REPLICATION + #include "sql_repl.h" #include "sql_acl.h" #include "log_event.h" @@ -1156,6 +1156,6 @@ int log_loaded_block(IO_CACHE* file) return 0; } -#endif +#endif /* HAVE_REPLICATION */ diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 5ba7d0ce74e..f1fda45fe4b 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -1,4 +1,4 @@ -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_REPLICATION #include "slave.h" typedef struct st_slave_info @@ -55,5 +55,5 @@ typedef struct st_load_file_info int log_loaded_block(IO_CACHE* file); -#endif /* EMBEDDED_LIBRARY */ +#endif /* HAVE_REPLICATION */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index be444cdd3cd..78bae8d29dc 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -52,6 +52,7 @@ 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) { @@ -648,6 +649,7 @@ 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) @@ -1240,7 +1242,6 @@ public: template class I_List<thread_info>; #endif -#ifndef EMBEDDED_LIBRARY void mysqld_list_processes(THD *thd,const char *user, bool verbose) { Item *field; @@ -1272,8 +1273,13 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) THD *tmp; while ((tmp=it++)) { +#ifndef EMBEDDED_LIBRARY if ((tmp->net.vio || tmp->system_thread) && (!user || (tmp->user && !strcmp(tmp->user,user)))) +#else + if (tmp->system_thread && + (!user || (tmp->user && !strcmp(tmp->user,user)))) +#endif { thread_info *thd_info=new thread_info; @@ -1291,6 +1297,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) if (tmp->mysys_var) pthread_mutex_lock(&tmp->mysys_var->mutex); thd_info->proc_info= (char*) (tmp->killed ? "Killed" : 0); +#ifndef EMBEDDED_LIBRARY thd_info->state_info= (char*) (tmp->locked ? "Locked" : tmp->net.reading_or_writing ? (tmp->net.reading_or_writing == 2 ? @@ -1301,6 +1308,9 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) tmp->mysys_var && tmp->mysys_var->current_cond ? "Waiting on cond" : NullS); +#else + thd_info->state_info= (char*)"Writing to net"; +#endif if (tmp->mysys_var) pthread_mutex_unlock(&tmp->mysys_var->mutex); @@ -1353,12 +1363,6 @@ 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 @@ -1666,6 +1670,8 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, case SHOW_UNDEF: // Show never happen case SHOW_SYS: break; // Return empty string + default: + break; } if (protocol->store(pos, (uint32) (end - pos)) || protocol->write()) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b7aaeb89f25..49e84db62c9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1032,7 +1032,6 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table, { Protocol *protocol= thd->protocol; - protocol->set_nfields(4); protocol->prepare_for_resend(); protocol->store(table->alias); protocol->store((char*) operator_name); |