diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 610d3d66ec9..cb7e62ad4b6 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -793,6 +793,7 @@ net_field_length(uchar **packet) return (ulong) uint4korr(pos+1); } + bool select_send::send_data(List &items) { List_iterator_fast li(items); @@ -956,7 +957,7 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len) result->prev_ptr= &cur->next; to= (char*) (cur->data+n_fields+1); cp= (uchar *)data; - end_field= cur->data + n_fields + 1; + end_field= cur->data + n_fields; for (cur_field=cur->data; cur_fieldmax_length=len; } } + + *cur_field= to; + DBUG_RETURN(0); } diff --git a/sql/item.cc b/sql/item.cc index 81c5168b72d..275e43618ba 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -469,6 +469,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 for (SELECT_LEX *sl= thd->lex.select->outer_select(); sl && !tmp; sl= sl->outer_select()) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 1aee4e7d553..a782e818d2f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1248,10 +1248,15 @@ String *Item_func_database::val_str(String *str) String *Item_func_user::val_str(String *str) { THD *thd=current_thd; +#ifdef EMBEDDED_LIBRARY + if (str->copy("localuser@localhost", (uint)strlen("localuser@localhost"))) + return &empty_string; +#else if (str->copy((const char*) thd->user,(uint) strlen(thd->user)) || str->append('@') || str->append(thd->host ? thd->host : thd->ip ? thd->ip : "")) return &empty_string; +#endif return str; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b39779141b6..9fb1a745d3a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5249,6 +5249,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_table.cc b/sql/sql_table.cc index f06713c836e..27fcc62e074 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -939,8 +939,7 @@ static int send_check_errmsg(THD* thd, TABLE_LIST* table, net_store_data(packet, "error"); net_store_data(packet, errmsg); thd->net.last_error[0]=0; - if (my_net_write(&thd->net, (char*) thd->packet.ptr(), - packet->length())) + if (SEND_ROW(thd, &thd->net, 4, (char*) thd->packet.ptr(), packet->length())) return -1; return 1; } @@ -1150,6 +1149,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 packet->length(0); net_store_data(packet, table_name); net_store_data(packet, operator_name);