diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:46:04 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:46:04 -0600 |
commit | 89055361b9203be1d4e813b00aa5dfbc6e9b0caa (patch) | |
tree | f15f127921d230171bb0ac60a5a854a61af3b185 /libmysql | |
parent | 5ee900d38a1d20247823ab23a441cbb78ac9942a (diff) | |
parent | 6bede5bed1add70fb5bb442ba70fe029c4c534f7 (diff) | |
download | mariadb-git-89055361b9203be1d4e813b00aa5dfbc6e9b0caa.tar.gz |
Merge
client/mysqltest.c:
Auto merged
include/mysql.h:
Auto merged
include/mysql_com.h:
Auto merged
libmysql/libmysql.c:
Auto merged
libmysqld/libmysqld.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/item_func.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
acinclude.m4:
SCCS merged
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 57 | ||||
-rw-r--r-- | libmysql/net.c | 48 |
2 files changed, 55 insertions, 50 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 16d460f8ed3..dd42ed8cd33 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -316,11 +316,11 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host, ** or packet is an error message *****************************************************************************/ -uint +ulong net_safe_read(MYSQL *mysql) { NET *net= &mysql->net; - uint len=0; + ulong len=0; init_sigpipe_variables /* Don't give sigpipe errors if the client doesn't want them */ @@ -338,7 +338,7 @@ net_safe_read(MYSQL *mysql) CR_NET_PACKET_TOO_LARGE: CR_SERVER_LOST); strmov(net->last_error,ER(net->last_errno)); - return(packet_error); + return (packet_error); } if (net->read_pos[0] == 255) { @@ -349,7 +349,7 @@ net_safe_read(MYSQL *mysql) pos+=2; len-=2; (void) strmake(net->last_error,(char*) pos, - min(len,sizeof(net->last_error)-1)); + min((uint) len,(uint) sizeof(net->last_error)-1)); } else { @@ -440,7 +440,7 @@ static void free_rows(MYSQL_DATA *cur) int simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, - uint length, my_bool skipp_check) + ulong length, my_bool skipp_check) { NET *net= &mysql->net; int result= -1; @@ -671,8 +671,8 @@ mysql_free_result(MYSQL_RES *result) DBUG_PRINT("warning",("Not all rows in set were read; Ignoring rows")); for (;;) { - uint pkt_len; - if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error) + ulong pkt_len; + if ((pkt_len=net_safe_read(result->handle)) == packet_error) break; if (pkt_len == 1 && result->handle->net.read_pos[0] == 254) break; /* End of data */ @@ -866,7 +866,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, MYSQL_FIELD *field,*result; DBUG_ENTER("unpack_fields"); - field=result=(MYSQL_FIELD*) alloc_root(alloc,sizeof(MYSQL_FIELD)*fields); + field=result=(MYSQL_FIELD*) alloc_root(alloc, + (uint) sizeof(MYSQL_FIELD)*fields); if (!result) DBUG_RETURN(0); @@ -913,7 +914,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, NET *net = &mysql->net; DBUG_ENTER("read_rows"); - if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error) + if ((pkt_len= net_safe_read(mysql)) == packet_error) DBUG_RETURN(0); if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), MYF(MY_WME | MY_ZEROFILL)))) @@ -1020,7 +1021,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) /* perform query on master */ int STDCALL mysql_master_query(MYSQL *mysql, const char *q, - unsigned int length) + unsigned long length) { if (mysql_master_send_query(mysql, q, length)) return 1; @@ -1028,7 +1029,7 @@ int STDCALL mysql_master_query(MYSQL *mysql, const char *q, } int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, - unsigned int length) + unsigned long length) { MYSQL*master = mysql->master; if (!length) @@ -1042,7 +1043,7 @@ int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, /* perform query on slave */ int STDCALL mysql_slave_query(MYSQL *mysql, const char *q, - unsigned int length) + unsigned long length) { if (mysql_slave_send_query(mysql, q, length)) return 1; @@ -1050,7 +1051,7 @@ int STDCALL mysql_slave_query(MYSQL *mysql, const char *q, } int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, - unsigned int length) + unsigned long length) { MYSQL* last_used_slave, *slave_to_use = 0; @@ -1271,7 +1272,7 @@ STDCALL mysql_rpl_query_type(const char* q, int len) case 'c': /* create or check */ return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_MASTER ; case 's': /* select or show */ - return tolower(q[1] == 'h') ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE; + return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE; case 'f': /* flush */ case 'r': /* repair */ case 'g': /* grant */ @@ -1280,8 +1281,7 @@ STDCALL mysql_rpl_query_type(const char* q, int len) return MYSQL_RPL_SLAVE; } } - - return 0; + return MYSQL_RPL_MASTER; /* By default, send to master */ } @@ -1829,7 +1829,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->db=my_strdup(db,MYF(MY_WME)); db=0; } - if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net) || + if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net) || net_safe_read(mysql) == packet_error) goto error; if (client_flag & CLIENT_COMPRESS) /* We will use compression */ @@ -1935,7 +1935,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, pos=scramble(pos, mysql->scramble_buff, passwd, (my_bool) (mysql->protocol_version == 9)); pos=strmov(pos+1,db ? db : ""); - if (simple_command(mysql,COM_CHANGE_USER, buff,(uint) (pos-buff),0)) + if (simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (pos-buff),0)) DBUG_RETURN(1); my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); @@ -1960,7 +1960,7 @@ mysql_select_db(MYSQL *mysql, const char *db) DBUG_ENTER("mysql_select_db"); DBUG_PRINT("enter",("db: '%s'",db)); - if ((error=simple_command(mysql,COM_INIT_DB,db,(uint) strlen(db),0))) + if ((error=simple_command(mysql,COM_INIT_DB,db,(ulong) strlen(db),0))) DBUG_RETURN(error); my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); mysql->db=my_strdup(db,MYF(MY_WME)); @@ -2111,7 +2111,7 @@ STDCALL mysql_add_slave(MYSQL* mysql, const char* host, */ int STDCALL -mysql_send_query(MYSQL* mysql, const char* query, uint length) +mysql_send_query(MYSQL* mysql, const char* query, ulong length) { if (mysql->options.rpl_parse && mysql->rpl_pivot) { @@ -2179,13 +2179,13 @@ get_info: CLIENT_LONG_FLAG)))) DBUG_RETURN(-1); mysql->status=MYSQL_STATUS_GET_RESULT; - mysql->field_count=field_count; + mysql->field_count= (uint) field_count; DBUG_RETURN(0); } int STDCALL -mysql_real_query(MYSQL *mysql, const char *query, uint length) +mysql_real_query(MYSQL *mysql, const char *query, ulong length) { DBUG_ENTER("mysql_real_query"); DBUG_PRINT("enter",("handle: %lx",mysql)); @@ -2276,8 +2276,9 @@ mysql_store_result(MYSQL *mysql) DBUG_RETURN(0); } mysql->status=MYSQL_STATUS_READY; /* server is ready */ - if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+ - sizeof(ulong)*mysql->field_count, + if (!(result=(MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+ + sizeof(ulong) * + mysql->field_count), MYF(MY_WME | MY_ZEROFILL)))) { mysql->net.last_errno=CR_OUT_OF_MEMORY; @@ -2433,7 +2434,7 @@ mysql_fetch_lengths(MYSQL_RES *res) continue; } if (start) /* Found end of prev string */ - *prev_length= (uint) (*column-start-1); + *prev_length= (ulong) (*column-start-1); start= *column; prev_length=lengths; } @@ -2534,7 +2535,7 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) LINT_INIT(query); end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128); - if (simple_command(mysql,COM_FIELD_LIST,buff,(uint) (end-buff),1) || + if (simple_command(mysql,COM_FIELD_LIST,buff,(ulong) (end-buff),1) || !(query = read_rows(mysql,(MYSQL_FIELD*) 0,6))) DBUG_RETURN(NULL); @@ -2590,7 +2591,7 @@ mysql_create_db(MYSQL *mysql, const char *db) { DBUG_ENTER("mysql_createdb"); DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (uint) strlen(db),0)); + DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (ulong) strlen(db),0)); } @@ -2599,7 +2600,7 @@ mysql_drop_db(MYSQL *mysql, const char *db) { DBUG_ENTER("mysql_drop_db"); DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(uint) strlen(db),0)); + DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(ulong) strlen(db),0)); } #endif diff --git a/libmysql/net.c b/libmysql/net.c index 1f21fd2f2f9..44e3dd14f80 100644 --- a/libmysql/net.c +++ b/libmysql/net.c @@ -31,6 +31,7 @@ #include <winsock.h> #endif #include <my_global.h> +#include "mysql_embed.h" #include <mysql_com.h> #include <violite.h> #include <my_sys.h> @@ -89,7 +90,7 @@ extern ulong mysqld_net_retry_count; typedef my_bool thr_alarm_t; typedef my_bool ALARM; #define thr_alarm_init(A) (*(A))=0 -#define thr_alarm_in_use(A) (*(A)!= 0) +#define thr_alarm_in_use(A) (*(A) != 0) #define thr_end_alarm(A) #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) @@ -129,7 +130,7 @@ int my_net_init(NET *net, Vio* vio) 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->pkt_nr=0; + net->pkt_nr=net->compress_pkt_nr=0; net->write_pos=net->read_pos = net->buff; net->last_error[0]=0; net->compress=0; net->reading_or_writing=0; @@ -190,7 +191,7 @@ static my_bool net_realloc(NET *net, ulong length) void net_clear(NET *net) { #ifndef EXTRA_DEBUG - int count; + int count; /* One may get 'unused' warn */ bool is_blocking=vio_is_blocking(net->vio); if (is_blocking) vio_blocking(net->vio, FALSE); @@ -204,7 +205,7 @@ void net_clear(NET *net) vio_blocking(net->vio, TRUE); } #endif /* EXTRA_DEBUG */ - net->pkt_nr=0; /* Ready for new command */ + net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */ net->write_pos=net->buff; } @@ -217,9 +218,12 @@ int net_flush(NET *net) if (net->buff != net->write_pos) { error=net_real_write(net,(char*) net->buff, - (uint) (net->write_pos - net->buff)); + (ulong) (net->write_pos - net->buff)); net->write_pos=net->buff; } + /* Sync packet number if using compression */ + if (net->compress) + net->pkt_nr=net->compress_pkt_nr; DBUG_RETURN(error); } @@ -248,7 +252,7 @@ my_net_write(NET *net,const char *packet,ulong len) { const ulong z_size = MAX_THREE_BYTES; int3store(buff, z_size); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); + buff[3]= net->pkt_nr++; if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) || net_write_buff(net, packet, z_size)) return 1; @@ -257,7 +261,7 @@ my_net_write(NET *net,const char *packet,ulong len) } /* Write last packet */ int3store(buff,len); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); + buff[3]= net->pkt_nr++; if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) return 1; return net_write_buff(net,packet,len); @@ -275,7 +279,7 @@ my_net_write(NET *net,const char *packet,ulong len) int net_write_command(NET *net,uchar command,const char *packet,ulong len) { - uint length=len+1; /* 1 extra byte for command */ + ulong length=len+1; /* 1 extra byte for command */ uchar buff[NET_HEADER_SIZE+1]; uint header_size=NET_HEADER_SIZE+1; buff[4]=command; /* For first packet */ @@ -287,7 +291,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) do { int3store(buff, MAX_THREE_BYTES); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); + buff[3]= net->pkt_nr++; if (net_write_buff(net,(char*) buff, header_size) || net_write_buff(net,packet,len)) return 1; @@ -299,7 +303,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) len=length; /* Data left to be written */ } int3store(buff,length); - buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); + buff[3]= net->pkt_nr++; return test(net_write_buff(net,(char*) buff,header_size) || net_write_buff(net,packet,len) || net_flush(net)); } @@ -312,7 +316,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) static int net_write_buff(NET *net,const char *packet,ulong len) { - uint left_length=(uint) (net->buff_end - net->write_pos); + ulong left_length=(ulong) (net->buff_end - net->write_pos); while (len > left_length) { @@ -338,7 +342,7 @@ net_write_buff(NET *net,const char *packet,ulong len) int net_real_write(NET *net,const char *packet,ulong len) { - int length; + long int length; char *pos,*end; thr_alarm_t alarmed; #if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) @@ -378,7 +382,7 @@ net_real_write(NET *net,const char *packet,ulong len) } int3store(&b[NET_HEADER_SIZE],complen); int3store(b,len); - b[3]=(uchar) (net->pkt_nr++); + b[3]=(uchar) (net->compress_pkt_nr++); len+= header_length; packet= (char*) b; } @@ -396,7 +400,7 @@ net_real_write(NET *net,const char *packet,ulong len) pos=(char*) packet; end=pos+len; while (pos != end) { - if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0) + if ((long) (length=vio_write(net->vio,pos,(ulong) (end-pos))) <= 0) { my_bool interrupted = vio_should_retry(net->vio); #if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) @@ -496,7 +500,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L) { my_bool interrupted = vio_should_retry(net->vio); - if (!thr_got_alarm(alarmed) && interrupted) + if (!thr_got_alarm(&alarmed) && interrupted) { /* Probably in MIT threads */ if (retry_count++ < RETRY_COUNT) continue; @@ -516,7 +520,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) This function reallocates the net->buff buffer if necessary. */ -static uint +static ulong my_real_read(NET *net, ulong *complen) { uchar *pos; @@ -627,9 +631,9 @@ my_real_read(NET *net, ulong *complen) if (net->buff[net->where_b] != (uchar) 255) { DBUG_PRINT("error", - ("Packets out of order (Found: %d, expected %d)", + ("Packets out of order (Found: %d, expected %u)", (int) net->buff[net->where_b + 3], - (uint) (uchar) net->pkt_nr)); + net->pkt_nr)); #ifdef EXTRA_DEBUG fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n", (int) net->buff[net->where_b + 3], @@ -642,7 +646,7 @@ my_real_read(NET *net, ulong *complen) #endif goto end; } - net->pkt_nr++; + net->compress_pkt_nr= ++net->pkt_nr; #ifdef HAVE_COMPRESS if (net->compress) { @@ -710,7 +714,7 @@ my_net_read(NET *net) if (len == MAX_THREE_BYTES) { /* First packet of a multi-packet. Concatenate the packets */ - int save_pos = net->where_b; + ulong save_pos = net->where_b; ulong total_length=0; do { @@ -820,8 +824,8 @@ my_net_read(NET *net) net->read_pos= net->buff+ first_packet_offset + NET_HEADER_SIZE; net->buf_length= buf_length; - net->remain_in_buf= buf_length - start_of_packet; - len = ((uint) (start_of_packet - first_packet_offset) - NET_HEADER_SIZE - + net->remain_in_buf= (ulong) (buf_length - start_of_packet); + len = ((ulong) (start_of_packet - first_packet_offset) - NET_HEADER_SIZE - multi_byte_packet); net->save_char= net->read_pos[len]; /* Must be saved */ net->read_pos[len]=0; /* Safeguard for mysql_use_result */ |