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,
|
MYSQL_FIELD *ma_duplicate_resultset_metadata(MYSQL_FIELD *fields, size_t count,
|
||||||
MA_MEM_ROOT *memroot);
|
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
|
#endif
|
||||||
|
@@ -1185,10 +1185,12 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
|||||||
/* save status */
|
/* save status */
|
||||||
if (pkt_len > 1)
|
if (pkt_len > 1)
|
||||||
{
|
{
|
||||||
|
unsigned int last_status= mysql->server_status;
|
||||||
cp++;
|
cp++;
|
||||||
mysql->warning_count= uint2korr(cp);
|
mysql->warning_count= uint2korr(cp);
|
||||||
cp+= 2;
|
cp+= 2;
|
||||||
mysql->server_status= uint2korr(cp);
|
mysql->server_status= uint2korr(cp);
|
||||||
|
ma_status_callback(mysql, last_status)
|
||||||
}
|
}
|
||||||
return(result);
|
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)
|
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->warning_count= uint2korr(mysql->net.read_pos + 1);
|
||||||
mysql->server_status= uint2korr(mysql->net.read_pos + 3);
|
mysql->server_status= uint2korr(mysql->net.read_pos + 3);
|
||||||
|
ma_status_callback(mysql, last_status);
|
||||||
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] */
|
||||||
@@ -2547,7 +2551,7 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length)
|
|||||||
{
|
{
|
||||||
uchar *end= mysql->net.read_pos+length;
|
uchar *end= mysql->net.read_pos+length;
|
||||||
size_t item_len;
|
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->affected_rows= net_field_length_ll(&pos);
|
||||||
mysql->insert_id= net_field_length_ll(&pos);
|
mysql->insert_id= net_field_length_ll(&pos);
|
||||||
mysql->server_status=uint2korr(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;
|
mysql->net.last_error[0]= mysql->net.last_errno= mysql->net.extension->extended_errno= 0;
|
||||||
|
|
||||||
/* callback */
|
/* callback */
|
||||||
if (mysql->options.extension->status_callback &&
|
ma_status_callback(mysql, last_status);
|
||||||
mysql->server_status != last_server_status)
|
|
||||||
mysql->options.extension->status_callback(mysql->options.extension->status_data,
|
|
||||||
STATUS_TYPE, mysql->server_status);
|
|
||||||
pos+=2;
|
pos+=2;
|
||||||
mysql->warning_count=uint2korr(pos);
|
mysql->warning_count=uint2korr(pos);
|
||||||
pos+=2;
|
pos+=2;
|
||||||
@@ -2832,6 +2833,7 @@ get_info:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
unsigned int last_status= mysql->server_status;
|
||||||
/* Read EOF, to get the status and warning count. */
|
/* Read EOF, to get the status and warning count. */
|
||||||
if ((length= ma_net_safe_read(mysql)) == packet_error)
|
if ((length= ma_net_safe_read(mysql)) == packet_error)
|
||||||
{
|
{
|
||||||
@@ -2844,6 +2846,7 @@ get_info:
|
|||||||
}
|
}
|
||||||
mysql->warning_count= uint2korr(pos + 1);
|
mysql->warning_count= uint2korr(pos + 1);
|
||||||
mysql->server_status= uint2korr(pos + 3);
|
mysql->server_status= uint2korr(pos + 3);
|
||||||
|
ma_status_callback(mysql, last_status);
|
||||||
}
|
}
|
||||||
mysql->status=MYSQL_STATUS_GET_RESULT;
|
mysql->status=MYSQL_STATUS_GET_RESULT;
|
||||||
mysql->field_count=field_count;
|
mysql->field_count=field_count;
|
||||||
|
@@ -286,12 +286,14 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
|
|||||||
result->rows++;
|
result->rows++;
|
||||||
} else /* end of stream */
|
} else /* end of stream */
|
||||||
{
|
{
|
||||||
|
unsigned int last_status= stmt->mysql->server_status;
|
||||||
*pprevious= 0;
|
*pprevious= 0;
|
||||||
/* sace status info */
|
/* sace status info */
|
||||||
p++;
|
p++;
|
||||||
stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p);
|
stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p);
|
||||||
p+=2;
|
p+=2;
|
||||||
stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p);
|
stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p);
|
||||||
|
ma_status_callback(stmt->mysql, last_status);
|
||||||
stmt->result_cursor= result->data;
|
stmt->result_cursor= result->data;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -355,13 +357,16 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
|||||||
stmt->state < MYSQL_STMT_FETCH_DONE;
|
stmt->state < MYSQL_STMT_FETCH_DONE;
|
||||||
while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error)
|
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;
|
uchar *pos= stmt->mysql->net.read_pos;
|
||||||
|
|
||||||
if (!in_resultset && *pos == 0) /* OK */
|
if (!in_resultset && *pos == 0) /* OK */
|
||||||
{
|
{
|
||||||
pos++;
|
pos++;
|
||||||
net_field_length(&pos);
|
net_field_length(&pos);
|
||||||
net_field_length(&pos);
|
net_field_length(&pos);
|
||||||
stmt->mysql->server_status= uint2korr(pos);
|
stmt->mysql->server_status= uint2korr(pos);
|
||||||
|
ma_status_callback(stmt->mysql, last_status);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (packet_len < 8 && *pos == 254) /* EOF */
|
if (packet_len < 8 && *pos == 254) /* EOF */
|
||||||
@@ -369,6 +374,7 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
|||||||
if (mariadb_connection(stmt->mysql))
|
if (mariadb_connection(stmt->mysql))
|
||||||
{
|
{
|
||||||
stmt->mysql->server_status= uint2korr(pos + 3);
|
stmt->mysql->server_status= uint2korr(pos + 3);
|
||||||
|
ma_status_callback(stmt->mysql, last_status);
|
||||||
if (in_resultset)
|
if (in_resultset)
|
||||||
goto end;
|
goto end;
|
||||||
in_resultset= 1;
|
in_resultset= 1;
|
||||||
@@ -1902,6 +1908,7 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt)
|
|||||||
{
|
{
|
||||||
MYSQL *mysql= stmt->mysql;
|
MYSQL *mysql= stmt->mysql;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned int last_status= mysql->server_status;
|
||||||
|
|
||||||
if (!mysql)
|
if (!mysql)
|
||||||
return(1);
|
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.last_insert_id= mysql->insert_id;
|
||||||
stmt->upsert_status.server_status= mysql->server_status;
|
stmt->upsert_status.server_status= mysql->server_status;
|
||||||
|
ma_status_callback(stmt->mysql, last_status);
|
||||||
stmt->upsert_status.warning_count= mysql->warning_count;
|
stmt->upsert_status.warning_count= mysql->warning_count;
|
||||||
|
|
||||||
CLEAR_CLIENT_ERROR(mysql);
|
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;
|
MYSQL *mysql= stmt->mysql;
|
||||||
my_bool ret= 1;
|
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)
|
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.affected_rows= mysql->affected_rows;
|
||||||
stmt->upsert_status.last_insert_id= mysql->insert_id;
|
stmt->upsert_status.last_insert_id= mysql->insert_id;
|
||||||
stmt->upsert_status.server_status= mysql->server_status;
|
stmt->upsert_status.server_status= mysql->server_status;
|
||||||
|
ma_status_callback(stmt->mysql, last_status);
|
||||||
stmt->upsert_status.warning_count= mysql->warning_count;
|
stmt->upsert_status.warning_count= mysql->warning_count;
|
||||||
mysql->status= MYSQL_STATUS_READY;
|
mysql->status= MYSQL_STATUS_READY;
|
||||||
|
|
||||||
@@ -2444,9 +2454,11 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
|||||||
rc= madb_alloc_stmt_fields(stmt);
|
rc= madb_alloc_stmt_fields(stmt);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
unsigned int last_status= stmt->mysql->server_status;
|
||||||
stmt->upsert_status.affected_rows= stmt->mysql->affected_rows;
|
stmt->upsert_status.affected_rows= stmt->mysql->affected_rows;
|
||||||
stmt->upsert_status.last_insert_id= stmt->mysql->insert_id;
|
stmt->upsert_status.last_insert_id= stmt->mysql->insert_id;
|
||||||
stmt->upsert_status.server_status= stmt->mysql->server_status;
|
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;
|
stmt->upsert_status.warning_count= stmt->mysql->warning_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user