diff options
author | hf@genie.(none) <> | 2002-10-13 14:23:55 +0500 |
---|---|---|
committer | hf@genie.(none) <> | 2002-10-13 14:23:55 +0500 |
commit | 2be6f2721929bcb69324193a214a2954645eed64 (patch) | |
tree | 8f8ea36a2b281ff013909f6cfeef5d1b4e122e24 /libmysqld | |
parent | 55866b061558d13d40f56097ab0bfbbd23e6bf83 (diff) | |
download | mariadb-git-2be6f2721929bcb69324193a214a2954645eed64.tar.gz |
Changes in order to trim embedded library code
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/embedded_priv.h | 4 | ||||
-rw-r--r-- | libmysqld/lib_sql.cc | 99 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 77 |
3 files changed, 106 insertions, 74 deletions
diff --git a/libmysqld/embedded_priv.h b/libmysqld/embedded_priv.h index 20f74c3ae2f..d1c44a8d160 100644 --- a/libmysqld/embedded_priv.h +++ b/libmysqld/embedded_priv.h @@ -26,9 +26,9 @@ C_MODE_START extern void start_embedded_connection(NET * net); extern void end_embedded_connection(NET * net); extern void lib_connection_phase(NET *net, int phase); -extern bool lib_dispatch_command(enum enum_server_command command, NET *net, - const char *arg, ulong length); extern void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db); extern void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char *db); extern NET *get_mysql_net(MYSQL *mysql); +extern my_bool simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, + ulong length, my_bool skipp_check); C_MODE_END diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 3354bc1ea44..4254be397d4 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -32,6 +32,7 @@ #define SCRAMBLE_LENGTH 8 C_MODE_START #include "lib_vio.c" +#include "errmsg.h" static int check_connections1(THD * thd); static int check_connections2(THD * thd); @@ -41,16 +42,41 @@ static bool check_user(THD *thd, enum_server_command command, char * get_mysql_home(){ return mysql_home;}; char * get_mysql_real_data_home(){ return mysql_real_data_home;}; -bool lib_dispatch_command(enum enum_server_command command, NET *net, - const char *arg, ulong length) +my_bool simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, + ulong length, my_bool skipp_check) { + NET *net= &mysql->net; + my_bool result= 1; THD *thd=(THD *) net->vio->dest_thd; + + /* Check that we are calling the client functions in right order */ + if (mysql->status != MYSQL_STATUS_READY) + { + strmov(net->last_error,ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + return 1; + } + + /* Clear result variables */ + mysql->net.last_error[0]=0; + mysql->net.last_errno=0; + mysql->info=0; + mysql->affected_rows= ~(my_ulonglong) 0; + + /* Clear receive buffer and vio packet list */ + net_clear(net); + vio_reset(net->vio); + thd->store_globals(); // Fix if more than one connect - thd->net.last_error[0]=0; // Clear error message - thd->net.last_errno=0; +// thd->net.last_error[0]=0; // Clear error message +// thd->net.last_errno=0; + + net_new_transaction(net); + result= dispatch_command(command, thd, (char *) arg, length + 1); - net_new_transaction(&thd->net); - return dispatch_command(command, thd, (char *) arg, length + 1); + if (!skipp_check) + result= net->last_errno ? -1 : 0; + + return result; } #ifdef _DUMMY @@ -604,6 +630,7 @@ void end_embedded_connection(NET * net) } /* extern "C" */ +C_MODE_START NET *get_mysql_net(MYSQL *mysql) { return &((THD *)mysql->net.vio->dest_thd)->net; @@ -626,6 +653,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db) mysql->db= db; thd->mysql= mysql; } +C_MODE_END static int embedded_thd_net_init(NET *net, unsigned char *buff) { @@ -636,7 +664,7 @@ static int embedded_thd_net_init(NET *net, unsigned char *buff) net->vio= NULL; net->no_send_ok= 0; net->error=0; net->return_errno=0; net->return_status=0; - net->timeout=(uint) net_read_timeout; /* Timeout for read */ +// net->timeout=(uint) net_read_timeout; /* Timeout for read */ net->pkt_nr= net->compress_pkt_nr=0; net->write_pos= net->read_pos = net->buff; net->last_error[0]= 0; @@ -648,6 +676,8 @@ static int embedded_thd_net_init(NET *net, unsigned char *buff) return 0; } +C_MODE_START + void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char *db) { THD * thd= new THD; @@ -667,8 +697,8 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char * thd->dbug_thread_id= my_thread_id(); thd->thread_stack= (char*) &thd; - if (thd->max_join_size == HA_POS_ERROR) - thd->options |= OPTION_BIG_SELECTS; +// if (thd->max_join_size == HA_POS_ERROR) +// thd->options |= OPTION_BIG_SELECTS; thd->proc_info=0; // Remove 'login' thd->command=COM_SLEEP; @@ -676,11 +706,11 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char * thd->set_time(); init_sql_alloc(&thd->mem_root,8192,8192); thd->client_capabilities= client_flag; - thd->max_packet_length= max_allowed_packet; +// thd->max_packet_length= max_allowed_packet; thd->net.vio = vio; - if (thd->client_capabilities & CLIENT_INTERACTIVE) - thd->inactive_timeout= net_interactive_timeout; +// if (thd->client_capabilities & CLIENT_INTERACTIVE) +// thd->inactive_timeout= net_interactive_timeout; if (thd->client_capabilities & CLIENT_TRANSACTIONS) thd->net.return_status= &thd->server_status; @@ -691,6 +721,7 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char * return thd; } +C_MODE_END bool send_fields(THD *thd, List<Item> &list, uint flag) { @@ -762,7 +793,7 @@ bool send_fields(THD *thd, List<Item> &list, uint flag) return 0; err: - send_error(&thd->net,ER_OUT_OF_RESOURCES); /* purecov: inspected */ + send_error(thd, ER_OUT_OF_RESOURCES); /* purecov: inspected */ return 1; /* purecov: inspected */ } @@ -886,8 +917,8 @@ bool do_command(THD *thd) thd->current_tablenr=0; packet=0; - old_timeout=net->timeout; - net->timeout=(uint) thd->inactive_timeout; // Wait max for 8 hours +// old_timeout=net->timeout; +// net->timeout=(uint) thd->inactive_timeout; // Wait max for 8 hours net->last_error[0]=0; // Clear error message net->last_errno=0; @@ -901,18 +932,20 @@ bool do_command(THD *thd) else { packet=(char*) net->read_pos; - command = (enum enum_server_command) (uchar) packet[0]; + + command = (enum enum_server_command) (uchar) packet[0]; DBUG_PRINT("info",("Command on %s = %d (%s)", vio_description(net->vio), command, command_name[command])); } - net->timeout=old_timeout; // Timeout for writing +// net->timeout=old_timeout; // Timeout for writing DBUG_RETURN(dispatch_command(command,thd, packet+1, (uint) packet_length)); } void -send_ok(NET *net,ha_rows affected_rows,ulonglong id,const char *message) +send_ok(THD *thd,ha_rows affected_rows,ulonglong id,const char *message) { + NET *net= &thd->net; if (net->no_send_ok) // hack for re-parsing queries return; @@ -930,6 +963,36 @@ send_ok(NET *net,ha_rows affected_rows,ulonglong id,const char *message) DBUG_VOID_RETURN; } +void +send_eof(THD *thd, bool no_flush) +{ +/* static char eof_buff[1]= { (char) 254 }; + NET *net= &thd->net; + DBUG_ENTER("send_eof"); + if (net->vio != 0) + { + if (!no_flush && (thd->client_capabilities & CLIENT_PROTOCOL_41)) + { + char buff[5]; + uint tmp= min(thd->total_warn_count, 65535); + buff[0]=254; + int2store(buff+1, tmp); + int2store(buff+3, 0); // No flags yet + VOID(my_net_write(net,buff,5)); + VOID(net_flush(net)); + } + else + { + VOID(my_net_write(net,eof_buff,1)); + if (!no_flush) + VOID(net_flush(net)); + } + } + DBUG_VOID_RETURN; +*/ +} + + int embedded_send_row(THD *thd, int n_fields, char *data, int data_len) { MYSQL *mysql= thd->mysql; diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 2e2ef58e4da..36401138b24 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -212,39 +212,6 @@ static void free_rows(MYSQL_DATA *cur) } } - -my_bool -simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, - ulong length, my_bool skipp_check) -{ - NET *net= &mysql->net; - my_bool result= 1; - - /* Check that we are calling the client functions in right order */ - if (mysql->status != MYSQL_STATUS_READY) - { - strmov(net->last_error,ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); - goto end; - } - - /* Clear result variables */ - mysql->net.last_error[0]=0; - mysql->net.last_errno=0; - mysql->info=0; - mysql->affected_rows= ~(my_ulonglong) 0; - - /* Clear receive buffer and vio packet list */ - net_clear(net); - vio_reset(net->vio); - - result = lib_dispatch_command(command, net, arg,length); - if (!skipp_check) - result= mysql->net.last_errno ? -1 : 0; - end: - return result; -} - - static void free_old_query(MYSQL *mysql) { DBUG_ENTER("free_old_query"); @@ -1046,22 +1013,6 @@ mysql_query(MYSQL *mysql, const char *query) return mysql_real_query(mysql,query, (ulong) strlen(query)); } -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); /* Free old result */ - - return simple_command(mysql, COM_QUERY, query, length, 1); -} - - my_bool STDCALL mysql_read_query_result(MYSQL *mysql) { @@ -1180,6 +1131,23 @@ 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) @@ -1187,16 +1155,17 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length) DBUG_ENTER("mysql_real_query"); DBUG_PRINT("enter",("handle: %lx",mysql)); DBUG_PRINT("query",("Query = \"%s\"",query)); -/* if (mysql->options.separate_thread) + + if (mysql->options.separate_thread) { - DBUG_RETURN(0); + return -1; } mysql->result= NULL; - free_old_query(mysql); -*/ - if (mysql_send_query(mysql, query, length)) + free_old_query(mysql); /* Free old result */ + + if (simple_command(mysql, COM_QUERY, query, length, 1)) DBUG_RETURN(-1); DBUG_RETURN(mysql_read_query_result(mysql)); |