Skip to content

Commit

Permalink
New options MARIADB_CONNECTION_BYTES_READ/SENT
Browse files Browse the repository at this point in the history
Added new options MARIADB_CONNECTION_BYTES_READ and
MARIADB_CONNECTION_BYTES_SENT which can be passed to
mariadb_get_infov() api funcion to obtain the bytes sent
or read to/from database server.
  • Loading branch information
9EOR9 committed Jan 2, 2022
1 parent bc7bbd4 commit 510c7e5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/ma_pvio.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct st_ma_pvio {
PVIO_METHODS *methods;
void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const uchar *buffer, size_t length);
size_t bytes_read;
size_t bytes_sent;
};

typedef struct st_ma_pvio_cinfo
Expand Down
4 changes: 3 additions & 1 deletion include/mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ extern const char *SQLSTATE_UNKNOWN;
MARIADB_CONNECTION_SERVER_STATUS,
MARIADB_CONNECTION_SERVER_CAPABILITIES,
MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES,
MARIADB_CONNECTION_CLIENT_CAPABILITIES
MARIADB_CONNECTION_CLIENT_CAPABILITIES,
MARIADB_CONNECTION_BYTES_READ,
MARIADB_CONNECTION_BYTES_SENT
};

enum mysql_status { MYSQL_STATUS_READY,
Expand Down
4 changes: 4 additions & 0 deletions libmariadb/ma_pvio.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ ssize_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
p= p->next;
}
}
if (r > 0)
pvio->bytes_read+= r;
return r;
}
/* }}} */
Expand Down Expand Up @@ -391,6 +393,8 @@ ssize_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
p= p->next;
}
}
if (r > 0)
pvio->bytes_sent+= r;
return r;
}
/* }}} */
Expand Down
6 changes: 6 additions & 0 deletions libmariadb/mariadb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4495,6 +4495,12 @@ my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...
else
goto error;
break;
case MARIADB_CONNECTION_BYTES_READ:
*((size_t *)arg)= mysql->net.pvio->bytes_read;
break;
case MARIADB_CONNECTION_BYTES_SENT:
*((size_t *)arg)= mysql->net.pvio->bytes_sent;
break;
default:
va_end(ap);
return(-1);
Expand Down

0 comments on commit 510c7e5

Please sign in to comment.