Skip to content

Commit 4138c4d

Browse files
committed
Moved helper function 'proxy_mysql_stmt_close' from 'gen_utils' to 'MySQL_Protocol' #3525
1 parent 66cf642 commit 4138c4d

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

include/MySQL_Protocol.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ class MySQL_Prepared_Stmt_info {
6464

6565
uint8_t mysql_decode_length(unsigned char *ptr, uint64_t *len);
6666

67+
/**
68+
* @brief ProxySQL replacement function for 'mysql_stmt_close'. Closes a
69+
* MYSQL_STMT avoiding any blocking commands that are sent by default
70+
* 'mysql_stmt_close'.
71+
*
72+
* NOTE: This function is not safe, caller must check that the supplied
73+
* argument is not NULL.
74+
*
75+
* @param mysql_stmt An already initialized 'MYSQL_STMT'. Caller must ensure
76+
* that the supplied argument is not NULL.
77+
*
78+
* @return The result of calling 'mysql_stmt_close' function over the internally
79+
* modified 'MYSQL_STMT'.
80+
*/
81+
my_bool proxy_mysql_stmt_close(MYSQL_STMT* mysql_stmt);
82+
6783
class MySQL_Protocol {
6884
private:
6985
MySQL_Connection_userinfo *userinfo;

include/gen_utils.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,6 @@ inline unsigned long long realtime_time() {
230230
return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
231231
}
232232

233-
/**
234-
* @brief ProxySQL replacement function for 'mysql_stmt_close'. Closes a
235-
* MYSQL_STMT avoiding any blocking commands that are sent by default
236-
* 'mysql_stmt_close'.
237-
*
238-
* NOTE: This function is not safe, caller must check that the supplied
239-
* argument is not NULL.
240-
*
241-
* @param mysql_stmt An already initialized 'MYSQL_STMT'. Caller must ensure
242-
* that the supplied argument is not NULL.
243-
*
244-
* @return The result of calling 'mysql_stmt_close' function over the internally
245-
* modified 'MYSQL_STMT'.
246-
*/
247-
my_bool proxy_mysql_stmt_close(MYSQL_STMT* mysql_stmt);
248-
249233
#endif /* __GEN_FUNCTIONS */
250234

251235
bool Proxy_file_exists(const char *);

lib/MySQL_PreparedStatement.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "SpookyV2.h"
55

66
#include "MySQL_PreparedStatement.h"
7+
#include "MySQL_Protocol.h"
78

89
//extern MySQL_STMT_Manager *GloMyStmt;
910
//static uint32_t add_prepared_statement_calls = 0;

lib/MySQL_Protocol.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,3 +3072,15 @@ unsigned long long MySQL_ResultSet::current_size() {
30723072
}
30733073
return intsize;
30743074
}
3075+
3076+
my_bool proxy_mysql_stmt_close(MYSQL_STMT* stmt) {
3077+
// Clean internal structures for 'stmt->mysql->stmts'.
3078+
if (stmt->mysql) {
3079+
stmt->mysql->stmts =
3080+
list_delete(stmt->mysql->stmts, &stmt->list);
3081+
}
3082+
// Nullify 'mysql' field to avoid sending a blocking command to the server.
3083+
stmt->mysql = NULL;
3084+
// Perform the regular close operation.
3085+
return mysql_stmt_close(stmt);
3086+
}

lib/gen_utils.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,3 @@ bool Proxy_file_regular(const char *path) {
220220
return false;
221221
}
222222

223-
my_bool proxy_mysql_stmt_close(MYSQL_STMT* stmt) {
224-
// Clean internal structures for 'stmt->mysql->stmts'.
225-
if (stmt->mysql) {
226-
stmt->mysql->stmts =
227-
list_delete(stmt->mysql->stmts, &stmt->list);
228-
}
229-
// Nullify 'mysql' field to avoid sending a blocking command to the server.
230-
stmt->mysql = NULL;
231-
// Perform the regular close operation.
232-
return mysql_stmt_close(stmt);
233-
}

0 commit comments

Comments
 (0)