Commit 12e063b5 authored by unknown's avatar unknown

SCRUM: embedded library

mysql_fetch_length fixed for embedded library. Now data length is stored
before the data. Pointers in row still points to the data so you have to
get *(uint*)(data_ptr - sizeof(uint)) to get data length


libmysqld/lib_sql.cc:
  bug fixed - user didn't get error description
  Protocol::net_store_data changed to store data length before the data
libmysqld/libmysqld.c:
  emb_fetch_length changed to retrive data length stored before the data
parent 479c3766
...@@ -80,10 +80,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -80,10 +80,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if ((net->last_errno= thd->net.last_errno)) if ((net->last_errno= thd->net.last_errno))
{ {
memcpy(net->last_error, net->last_error, memcpy(net->last_error, thd->net.last_error, sizeof(net->last_error));
sizeof(net->last_error)); memcpy(net->sqlstate, thd->net.sqlstate, sizeof(net->sqlstate));
memcpy(net->sqlstate, thd->net.sqlstate,
sizeof(net->sqlstate));
} }
mysql->warning_count= ((THD*)mysql->thd)->total_warn_count; mysql->warning_count= ((THD*)mysql->thd)->total_warn_count;
return result; return result;
...@@ -482,15 +480,16 @@ bool Protocol_simple::store_null() ...@@ -482,15 +480,16 @@ bool Protocol_simple::store_null()
bool Protocol::net_store_data(const char *from, uint length) bool Protocol::net_store_data(const char *from, uint length)
{ {
if (!(*next_field=alloc_root(alloc, length + 1))) char *field_buf;
if (!(field_buf=alloc_root(alloc, length + sizeof(uint))))
return true; return true;
*(uint *)field_buf= length;
*next_field= field_buf + sizeof(uint);
memcpy(*next_field, from, length); memcpy(*next_field, from, length);
(*next_field)[length]= 0;
if (next_mysql_field->max_length < length) if (next_mysql_field->max_length < length)
next_mysql_field->max_length=length; next_mysql_field->max_length=length;
++next_field; ++next_field;
++next_mysql_field; ++next_mysql_field;
return false; return false;
} }
......
...@@ -176,9 +176,7 @@ static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_co ...@@ -176,9 +176,7 @@ static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_co
MYSQL_ROW end; MYSQL_ROW end;
for (end=column + field_count; column != end ; column++,to++) for (end=column + field_count; column != end ; column++,to++)
{ *to= *column ? *(uint *)((*column) - sizeof(uint)) : 0;
*to= *column ? strlen(*column) : 0;
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment