You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Added missing status callbacks outside of ma_read_ok_packet
This commit is contained in:
@@ -57,4 +57,14 @@ MA_FIELD_EXTENSION *ma_field_extension_deep_dup(MA_MEM_ROOT *memroot,
|
||||
MYSQL_FIELD *ma_duplicate_resultset_metadata(MYSQL_FIELD *fields, size_t count,
|
||||
MA_MEM_ROOT *memroot);
|
||||
|
||||
extern void ma_save_session_track_info(void *ptr, enum enum_mariadb_status_info type, ...);
|
||||
|
||||
#define ma_status_callback(mysql, last_status)\
|
||||
if ((mysql)->server_status != last_status && \
|
||||
(mysql)->options.extension->status_callback != ma_save_session_track_info)\
|
||||
{\
|
||||
(mysql)->options.extension->status_callback((mysql)->options.extension->status_data,\
|
||||
STATUS_TYPE, (mysql)->server_status);\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1185,10 +1185,12 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
||||
/* save status */
|
||||
if (pkt_len > 1)
|
||||
{
|
||||
unsigned int last_status= mysql->server_status;
|
||||
cp++;
|
||||
mysql->warning_count= uint2korr(cp);
|
||||
cp+= 2;
|
||||
mysql->server_status= uint2korr(cp);
|
||||
ma_status_callback(mysql, last_status)
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
@@ -1211,8 +1213,10 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
||||
|
||||
if (pkt_len <= 8 && mysql->net.read_pos[0] == 254)
|
||||
{
|
||||
unsigned int last_status= mysql->server_status;
|
||||
mysql->warning_count= uint2korr(mysql->net.read_pos + 1);
|
||||
mysql->server_status= uint2korr(mysql->net.read_pos + 3);
|
||||
ma_status_callback(mysql, last_status);
|
||||
return 1; /* End of data */
|
||||
}
|
||||
prev_pos= 0; /* allowed to write at packet[-1] */
|
||||
@@ -2547,7 +2551,7 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length)
|
||||
{
|
||||
uchar *end= mysql->net.read_pos+length;
|
||||
size_t item_len;
|
||||
unsigned int last_server_status= mysql->server_status;
|
||||
unsigned int last_status= mysql->server_status;
|
||||
mysql->affected_rows= net_field_length_ll(&pos);
|
||||
mysql->insert_id= net_field_length_ll(&pos);
|
||||
mysql->server_status=uint2korr(pos);
|
||||
@@ -2556,10 +2560,7 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length)
|
||||
mysql->net.last_error[0]= mysql->net.last_errno= mysql->net.extension->extended_errno= 0;
|
||||
|
||||
/* callback */
|
||||
if (mysql->options.extension->status_callback &&
|
||||
mysql->server_status != last_server_status)
|
||||
mysql->options.extension->status_callback(mysql->options.extension->status_data,
|
||||
STATUS_TYPE, mysql->server_status);
|
||||
ma_status_callback(mysql, last_status);
|
||||
pos+=2;
|
||||
mysql->warning_count=uint2korr(pos);
|
||||
pos+=2;
|
||||
@@ -2832,6 +2833,7 @@ get_info:
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int last_status= mysql->server_status;
|
||||
/* Read EOF, to get the status and warning count. */
|
||||
if ((length= ma_net_safe_read(mysql)) == packet_error)
|
||||
{
|
||||
@@ -2844,6 +2846,7 @@ get_info:
|
||||
}
|
||||
mysql->warning_count= uint2korr(pos + 1);
|
||||
mysql->server_status= uint2korr(pos + 3);
|
||||
ma_status_callback(mysql, last_status);
|
||||
}
|
||||
mysql->status=MYSQL_STATUS_GET_RESULT;
|
||||
mysql->field_count=field_count;
|
||||
|
@@ -286,12 +286,14 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
|
||||
result->rows++;
|
||||
} else /* end of stream */
|
||||
{
|
||||
unsigned int last_status= stmt->mysql->server_status;
|
||||
*pprevious= 0;
|
||||
/* sace status info */
|
||||
p++;
|
||||
stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p);
|
||||
p+=2;
|
||||
stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p);
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
stmt->result_cursor= result->data;
|
||||
return(0);
|
||||
}
|
||||
@@ -355,13 +357,16 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
||||
stmt->state < MYSQL_STMT_FETCH_DONE;
|
||||
while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error)
|
||||
{
|
||||
unsigned int last_status= stmt->mysql->server_status;
|
||||
uchar *pos= stmt->mysql->net.read_pos;
|
||||
|
||||
if (!in_resultset && *pos == 0) /* OK */
|
||||
{
|
||||
pos++;
|
||||
net_field_length(&pos);
|
||||
net_field_length(&pos);
|
||||
stmt->mysql->server_status= uint2korr(pos);
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
goto end;
|
||||
}
|
||||
if (packet_len < 8 && *pos == 254) /* EOF */
|
||||
@@ -369,6 +374,7 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
||||
if (mariadb_connection(stmt->mysql))
|
||||
{
|
||||
stmt->mysql->server_status= uint2korr(pos + 3);
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
if (in_resultset)
|
||||
goto end;
|
||||
in_resultset= 1;
|
||||
@@ -1902,6 +1908,7 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
int ret;
|
||||
unsigned int last_status= mysql->server_status;
|
||||
|
||||
if (!mysql)
|
||||
return(1);
|
||||
@@ -1956,6 +1963,7 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
}
|
||||
stmt->upsert_status.last_insert_id= mysql->insert_id;
|
||||
stmt->upsert_status.server_status= mysql->server_status;
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
stmt->upsert_status.warning_count= mysql->warning_count;
|
||||
|
||||
CLEAR_CLIENT_ERROR(mysql);
|
||||
@@ -2232,7 +2240,8 @@ static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
my_bool ret= 1;
|
||||
unsigned int flags= MADB_RESET_LONGDATA | MADB_RESET_BUFFER | MADB_RESET_ERROR;
|
||||
unsigned int flags= MADB_RESET_LONGDATA | MADB_RESET_BUFFER | MADB_RESET_ERROR,
|
||||
last_status= mysql->server_status;
|
||||
|
||||
if (!mysql)
|
||||
{
|
||||
@@ -2277,6 +2286,7 @@ static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close)
|
||||
stmt->upsert_status.affected_rows= mysql->affected_rows;
|
||||
stmt->upsert_status.last_insert_id= mysql->insert_id;
|
||||
stmt->upsert_status.server_status= mysql->server_status;
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
stmt->upsert_status.warning_count= mysql->warning_count;
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
|
||||
@@ -2444,9 +2454,11 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
||||
rc= madb_alloc_stmt_fields(stmt);
|
||||
else
|
||||
{
|
||||
unsigned int last_status= stmt->mysql->server_status;
|
||||
stmt->upsert_status.affected_rows= stmt->mysql->affected_rows;
|
||||
stmt->upsert_status.last_insert_id= stmt->mysql->insert_id;
|
||||
stmt->upsert_status.server_status= stmt->mysql->server_status;
|
||||
ma_status_callback(stmt->mysql, last_status);
|
||||
stmt->upsert_status.warning_count= stmt->mysql->warning_count;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user