Commit a6b0579f authored by hf@genie.(none)'s avatar hf@genie.(none)

Some code improvements

parent 8a88791f
......@@ -23,6 +23,11 @@
#define mysql_unix_port mysql_inix_port1
#define mysql_port mysql_port1
static int fake_argc= 1;
static char *fake_argv[]= {(char *)"", 0};
static const char *fake_groups[] = { "server", "embedded", 0 };
static char inited, org_my_init_done;
#if defined (__WIN__)
#include "../sql/mysqld.cpp"
#else
......@@ -302,9 +307,9 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
extern "C"
{
static my_bool inited, org_my_init_done;
ulong max_allowed_packet, net_buffer_length;
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
char glob_hostname[FN_REFLEN];
......@@ -587,7 +592,6 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
return 0;
}
void STDCALL mysql_server_end()
{
clean_up(0);
......@@ -1009,14 +1013,12 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len)
DBUG_ENTER("embedded_send_row");
result->rows++;
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS))) ||
!(cur->data=
(MYSQL_ROW)alloc_root(alloc,
(n_fields + 1) * sizeof(char *) + data_len)))
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (n_fields + 1) * sizeof(char *) + data_len)))
{
my_error(ER_OUT_OF_RESOURCES,MYF(0));
DBUG_RETURN(1);
}
cur->data= (MYSQL_ROW)((char *)cur) + sizeof(MYSQL_ROWS);
*result->prev_ptr= cur;
result->prev_ptr= &cur->next;
......@@ -1024,7 +1026,7 @@ int embedded_send_row(THD *thd, int n_fields, char *data, int data_len)
cp= (uchar *)data;
end_field= cur->data + n_fields;
for (cur_field=cur->data; cur_field<end_field; ++cur_field, ++mysql_fields)
for (cur_field=cur->data; cur_field<end_field; cur_field++, mysql_fields++)
{
if ((len= (ulong) net_field_length(&cp)) == NULL_LENGTH)
{
......
......@@ -723,6 +723,7 @@ static void mysql_once_init()
if (!mysql_client_init)
{
mysql_client_init=1;
my_init(); /* Will init threads */
init_client_errs();
mysql_port = MYSQL_PORT;
......@@ -1131,24 +1132,6 @@ my_bool my_connect(my_socket s, const struct sockaddr *name, uint namelen,
#endif
}
/*
int STDCALL
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
{
if (mysql->options.separate_thread)
{
return -1;
}
mysql->result= NULL;
free_old_query(mysql);
return simple_command(mysql, COM_QUERY, query, length, 1);
}
*/
int STDCALL
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
{
......@@ -1250,12 +1233,6 @@ mysql_store_result(MYSQL *mysql)
return result;
}
void _0dummy()
{
send_file_to_server(NULL, NULL);
net_field_length_ll(NULL);
}
/**************************************************************************
** Alloc struct for use with unbuffered reads. Data is fetched by domand
** when calling to mysql_fetch_row.
......
......@@ -79,7 +79,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
net_store_data(packet, msg_type);
net_store_data(packet, msgbuf);
if (SEND_ROW(thd, &thd->net, 4, (char*)thd->packet.ptr(), thd->packet.length()))
if (SEND_ROW(thd, 4, (char*)thd->packet.ptr(), thd->packet.length()))
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
msgbuf);
return;
......
......@@ -872,10 +872,10 @@ inline void mark_as_null_row(TABLE *table)
#ifdef EMBEDDED_LIBRARY
int embedded_send_row(THD *thd, int n_fields, char *data, int data_len);
#define SEND_ROW(thd, net, n_fields, data, 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, net, n_fields, data, data_len)\
my_net_write(net, data, data_len)
#define SEND_ROW(thd, n_fields, data, data_len)\
my_net_write(&thd->net, data, data_len)
#endif
This diff is collapsed.
......@@ -233,7 +233,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto err;
}
}
SEND_ROW(thd, &thd->net, list.elements, (char*)packet->ptr(), packet->length());
SEND_ROW(thd, list.elements, (char*)packet->ptr(), packet->length());
}
}
num_rows++;
......
......@@ -85,7 +85,7 @@ mysqld_show_dbs(THD *thd,const char *wild)
{
packet->length(0);
net_store_data(packet, thd->variables.convert_set, file_name);
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -125,7 +125,7 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
net_store_data(packet,convert, open_list->table);
net_store_data(packet,open_list->in_use);
net_store_data(packet,open_list->locked);
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
{
DBUG_RETURN(-1);
......@@ -168,7 +168,7 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
{
packet->length(0);
net_store_data(packet, thd->variables.convert_set, file_name);
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -635,7 +635,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
}
close_thread_tables(thd,0);
}
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -762,7 +762,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
net_store_data(packet,convert, tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
net_store_data(packet, field->comment.str,field->comment.length);
}
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -833,7 +833,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
int3store(p, create_len);
// now we are in business :-)
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -957,7 +957,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
net_store_data(packet,convert,table->file->index_type(i));
/* Comment */
net_store_data(packet,convert,"");
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
DBUG_RETURN(-1);
}
......@@ -1386,7 +1386,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
net_store_data(packet,convert,thd_info->query);
else
net_store_null(packet);
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet->ptr(), packet->length()))
break;
}
......@@ -1687,7 +1687,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
net_store_data(&packet2, ""); // Safety
break;
}
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)packet2.ptr(), packet2.length()))
goto err;
}
......
......@@ -1017,7 +1017,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 (SEND_ROW(thd, &thd->net, 4, (char*) thd->packet.ptr(), packet->length()))
if (SEND_ROW(thd, 4, (char*) thd->packet.ptr(), packet->length()))
return -1;
return 1;
}
......@@ -1211,7 +1211,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
net_store_data(packet, err_msg);
thd->net.last_error[0]=0;
if (SEND_ROW(thd, &thd->net, field_list.elements, (char*) thd->packet.ptr(),
if (SEND_ROW(thd, field_list.elements, (char*) thd->packet.ptr(),
packet->length()))
goto err;
continue;
......@@ -1226,7 +1226,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
net_store_data(packet, buff);
close_thread_tables(thd);
table->table=0; // For query cache
if (SEND_ROW(thd, &thd->net, field_list.elements, (char*) thd->packet.ptr(),
if (SEND_ROW(thd, field_list.elements, (char*) thd->packet.ptr(),
packet->length()))
goto err;
continue;
......@@ -1313,7 +1313,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
close_thread_tables(thd);
table->table=0; // For query cache
if (SEND_ROW(thd, &thd->net, field_list.elements,
if (SEND_ROW(thd, field_list.elements,
(char *)thd->packet.ptr(), thd->packet.length()))
goto err;
}
......
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