Commit 896bc7d0 authored by unknown's avatar unknown

Update libmysqld to use 4.1 protocol.


BitKeeper/etc/ignore:
  added sql_error.cc sql_prepare.cc
BitKeeper/deleted/.del-sql_error.cc~2f1caca8d2485dbe:
  deleted
BitKeeper/deleted/.del-sql_prepare.cc~f703729793935ed6:
  deleted
libmysqld/libmysqld.c:
  Update to use 4.1 protocol.
  Added mysql_warning_count() and mysql_warnings()
myisam/rt_test.c:
  Added missing variable
parent aecdd699
...@@ -503,3 +503,5 @@ vio/test-ssl ...@@ -503,3 +503,5 @@ vio/test-ssl
vio/test-sslclient vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
sql_error.cc
sql_prepare.cc
...@@ -50,7 +50,7 @@ static my_bool mysql_client_init=0; ...@@ -50,7 +50,7 @@ static my_bool mysql_client_init=0;
uint mysql_port=0; uint mysql_port=0;
my_string mysql_unix_port=0; my_string mysql_unix_port=0;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41)
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError() #define ERRNO WSAGetLastError()
...@@ -412,7 +412,7 @@ mysql_free_result(MYSQL_RES *result) ...@@ -412,7 +412,7 @@ mysql_free_result(MYSQL_RES *result)
uint pkt_len; uint pkt_len;
if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error) if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error)
break; break;
if (pkt_len == 1 && result->handle->net.read_pos[0] == 254) if (pkt_len <= 8 && result->handle->net.read_pos[0] == 254)
break; /* End of data */ break; /* End of data */
} }
result->handle->status=MYSQL_STATUS_READY; result->handle->status=MYSQL_STATUS_READY;
...@@ -632,7 +632,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -632,7 +632,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
result->rows=0; result->rows=0;
result->fields=fields; result->fields=fields;
while (*(cp=net->read_pos) != 254 || pkt_len != 1) while (*(cp=net->read_pos) != 254 || pkt_len >= 8)
{ {
result->rows++; result->rows++;
if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc, if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc,
...@@ -676,6 +676,8 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -676,6 +676,8 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
} }
} }
*prev_ptr=0; /* last pointer is null */ *prev_ptr=0; /* last pointer is null */
mysql->warning_count= uint2korr(cp+1);
DBUG_PRINT("info",("warning_count: %ld", mysql->warning_count));
DBUG_PRINT("exit",("Got %d rows",result->rows)); DBUG_PRINT("exit",("Got %d rows",result->rows));
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -696,8 +698,11 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) ...@@ -696,8 +698,11 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
if ((pkt_len=net_safe_read(mysql)) == packet_error) if ((pkt_len=net_safe_read(mysql)) == packet_error)
return -1; return -1;
if (pkt_len == 1 && mysql->net.read_pos[0] == 254) if (pkt_len <= 8 && mysql->net.read_pos[0] == 254)
{
mysql->warning_count= uint2korr(mysql->net.read_pos+1);
return 1; /* End of data */ return 1; /* End of data */
}
prev_pos= 0; /* allowed to write at packet[-1] */ prev_pos= 0; /* allowed to write at packet[-1] */
pos=mysql->net.read_pos; pos=mysql->net.read_pos;
for (field=0 ; field < fields ; field++) for (field=0 ; field < fields ; field++)
...@@ -1142,10 +1147,8 @@ mysql_read_query_result(MYSQL *mysql) ...@@ -1142,10 +1147,8 @@ mysql_read_query_result(MYSQL *mysql)
{ {
mysql->affected_rows= net_field_length_ll(&pos); mysql->affected_rows= net_field_length_ll(&pos);
mysql->insert_id= net_field_length_ll(&pos); mysql->insert_id= net_field_length_ll(&pos);
if (mysql->server_capabilities & CLIENT_TRANSACTIONS) mysql->server_status=uint2korr(pos); pos+=2;
{ mysql->warning_count=uint2korr(pos); pos+=2;
mysql->server_status=uint2korr(pos); pos+=2;
}
if (pos < mysql->net.read_pos+length && net_field_length(&pos)) if (pos < mysql->net.read_pos+length && net_field_length(&pos))
mysql->info=(char*) pos; mysql->info=(char*) pos;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1170,6 +1173,7 @@ mysql_read_query_result(MYSQL *mysql) ...@@ -1170,6 +1173,7 @@ mysql_read_query_result(MYSQL *mysql)
DBUG_RETURN(1); DBUG_RETURN(1);
mysql->status=MYSQL_STATUS_GET_RESULT; mysql->status=MYSQL_STATUS_GET_RESULT;
mysql->field_count=field_count; mysql->field_count=field_count;
mysql->warning_count= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1881,6 +1885,11 @@ const char * STDCALL mysql_error(MYSQL *mysql) ...@@ -1881,6 +1885,11 @@ const char * STDCALL mysql_error(MYSQL *mysql)
return (mysql)->net.last_error; return (mysql)->net.last_error;
} }
uint STDCALL mysql_warning_count(MYSQL *mysql)
{
return mysql->warning_count;
}
const char *STDCALL mysql_info(MYSQL *mysql) const char *STDCALL mysql_info(MYSQL *mysql)
{ {
return (mysql)->info; return (mysql)->info;
...@@ -1906,6 +1915,18 @@ uint STDCALL mysql_thread_safe(void) ...@@ -1906,6 +1915,18 @@ uint STDCALL mysql_thread_safe(void)
#endif #endif
} }
MYSQL_RES *STDCALL mysql_warnings(MYSQL *mysql)
{
uint warning_count;
DBUG_ENTER("mysql_warnings");
/* Save warning count as mysql_real_query may change this */
warning_count= mysql->warning_count;
if (mysql_real_query(mysql, "SHOW WARNINGS", 13))
DBUG_RETURN(0);
mysql->warning_count= warning_count;
DBUG_RETURN(mysql_store_result(mysql));
}
/**************************************************************************** /****************************************************************************
** Some support functions ** Some support functions
****************************************************************************/ ****************************************************************************/
......
...@@ -63,6 +63,7 @@ int run_test(const char *filename) ...@@ -63,6 +63,7 @@ int run_test(const char *filename)
int row_count=0; int row_count=0;
char record[MAX_REC_LENGTH]; char record[MAX_REC_LENGTH];
char read_record[MAX_REC_LENGTH]; char read_record[MAX_REC_LENGTH];
int upd= 10;
ha_rows hrows; ha_rows hrows;
......
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