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
Method clean up:
- removed unused methods from MYSQL_STMT handle, (left over from PHP's mysqlnd) - Added execute_generate_request method: This will allow Connector/Python to prefill the execute buffer without numerous GIL acquire/release calls.
This commit is contained in:
@@ -161,46 +161,6 @@ typedef struct st_mysql_error_info
|
|||||||
char sqlstate[SQLSTATE_LENGTH + 1];
|
char sqlstate[SQLSTATE_LENGTH + 1];
|
||||||
} mysql_error_info;
|
} mysql_error_info;
|
||||||
|
|
||||||
|
|
||||||
struct st_mysqlnd_stmt_methods
|
|
||||||
{
|
|
||||||
my_bool (*prepare)(const MYSQL_STMT * stmt, const char * const query, size_t query_len);
|
|
||||||
my_bool (*execute)(const MYSQL_STMT * stmt);
|
|
||||||
MYSQL_RES * (*use_result)(const MYSQL_STMT * stmt);
|
|
||||||
MYSQL_RES * (*store_result)(const MYSQL_STMT * stmt);
|
|
||||||
MYSQL_RES * (*get_result)(const MYSQL_STMT * stmt);
|
|
||||||
my_bool (*free_result)(const MYSQL_STMT * stmt);
|
|
||||||
my_bool (*seek_data)(const MYSQL_STMT * stmt, unsigned long long row);
|
|
||||||
my_bool (*reset)(const MYSQL_STMT * stmt);
|
|
||||||
my_bool (*close)(const MYSQL_STMT * stmt); /* private */
|
|
||||||
my_bool (*dtor)(const MYSQL_STMT * stmt); /* use this for mysqlnd_stmt_close */
|
|
||||||
|
|
||||||
my_bool (*fetch)(const MYSQL_STMT * stmt, my_bool * const fetched_anything);
|
|
||||||
|
|
||||||
my_bool (*bind_param)(const MYSQL_STMT * stmt, const MYSQL_BIND bind);
|
|
||||||
my_bool (*refresh_bind_param)(const MYSQL_STMT * stmt);
|
|
||||||
my_bool (*bind_result)(const MYSQL_STMT * stmt, const MYSQL_BIND *bind);
|
|
||||||
my_bool (*send_long_data)(const MYSQL_STMT * stmt, unsigned int param_num,
|
|
||||||
const char * const data, size_t length);
|
|
||||||
MYSQL_RES *(*get_parameter_metadata)(const MYSQL_STMT * stmt);
|
|
||||||
MYSQL_RES *(*get_result_metadata)(const MYSQL_STMT * stmt);
|
|
||||||
unsigned long long (*get_last_insert_id)(const MYSQL_STMT * stmt);
|
|
||||||
unsigned long long (*get_affected_rows)(const MYSQL_STMT * stmt);
|
|
||||||
unsigned long long (*get_num_rows)(const MYSQL_STMT * stmt);
|
|
||||||
|
|
||||||
unsigned int (*get_param_count)(const MYSQL_STMT * stmt);
|
|
||||||
unsigned int (*get_field_count)(const MYSQL_STMT * stmt);
|
|
||||||
unsigned int (*get_warning_count)(const MYSQL_STMT * stmt);
|
|
||||||
|
|
||||||
unsigned int (*get_error_no)(const MYSQL_STMT * stmt);
|
|
||||||
const char * (*get_error_str)(const MYSQL_STMT * stmt);
|
|
||||||
const char * (*get_sqlstate)(const MYSQL_STMT * stmt);
|
|
||||||
|
|
||||||
my_bool (*get_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value);
|
|
||||||
my_bool (*set_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value);
|
|
||||||
void (*set_error)(MYSQL_STMT *stmt, unsigned int error_nr, const char *sqlstate, const char *format, ...);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef int (*mysql_stmt_fetch_row_func)(MYSQL_STMT *stmt, unsigned char **row);
|
typedef int (*mysql_stmt_fetch_row_func)(MYSQL_STMT *stmt, unsigned char **row);
|
||||||
typedef void (*ps_result_callback)(void *data, unsigned int column, unsigned char **row);
|
typedef void (*ps_result_callback)(void *data, unsigned int column, unsigned char **row);
|
||||||
typedef my_bool *(*ps_param_callback)(void *data, MYSQL_BIND *bind, unsigned int row_nr);
|
typedef my_bool *(*ps_param_callback)(void *data, MYSQL_BIND *bind, unsigned int row_nr);
|
||||||
@@ -239,13 +199,14 @@ struct st_mysql_stmt
|
|||||||
mysql_stmt_fetch_row_func fetch_row_func;
|
mysql_stmt_fetch_row_func fetch_row_func;
|
||||||
unsigned int execute_count;/* count how many times the stmt was executed */
|
unsigned int execute_count;/* count how many times the stmt was executed */
|
||||||
mysql_stmt_use_or_store_func default_rset_handler;
|
mysql_stmt_use_or_store_func default_rset_handler;
|
||||||
struct st_mysqlnd_stmt_methods *m;
|
unsigned char *request_buffer;
|
||||||
unsigned int array_size;
|
unsigned int array_size;
|
||||||
size_t row_size;
|
size_t row_size;
|
||||||
unsigned int prebind_params;
|
unsigned int prebind_params;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
ps_result_callback result_callback;
|
ps_result_callback result_callback;
|
||||||
ps_param_callback param_callback;
|
ps_param_callback param_callback;
|
||||||
|
size_t request_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*ps_field_fetch_func)(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row);
|
typedef void (*ps_field_fetch_func)(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row);
|
||||||
|
@@ -874,6 +874,7 @@ struct st_mariadb_methods {
|
|||||||
void (*invalidate_stmts)(MYSQL *mysql, const char *function_name);
|
void (*invalidate_stmts)(MYSQL *mysql, const char *function_name);
|
||||||
struct st_mariadb_api *api;
|
struct st_mariadb_api *api;
|
||||||
int (*db_read_execute_response)(MYSQL_STMT *stmt);
|
int (*db_read_execute_response)(MYSQL_STMT *stmt);
|
||||||
|
unsigned char* (*db_execute_generate_request)(MYSQL_STMT *stmt, size_t *request_len, my_bool internal);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* synonyms/aliases functions */
|
/* synonyms/aliases functions */
|
||||||
|
@@ -104,6 +104,7 @@ extern int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
|
|||||||
const char *data_plugin, const char *db);
|
const char *data_plugin, const char *db);
|
||||||
extern int net_add_multi_command(NET *net, uchar command, const uchar *packet,
|
extern int net_add_multi_command(NET *net, uchar command, const uchar *packet,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
extern unsigned char* ma_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *request_len, my_bool internal);
|
||||||
|
|
||||||
extern LIST *pvio_callback;
|
extern LIST *pvio_callback;
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ extern int mthd_stmt_fetch_row(MYSQL_STMT *stmt, unsigned char **row);
|
|||||||
extern int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row);
|
extern int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row);
|
||||||
extern int mthd_stmt_read_all_rows(MYSQL_STMT *stmt);
|
extern int mthd_stmt_read_all_rows(MYSQL_STMT *stmt);
|
||||||
extern void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt);
|
extern void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt);
|
||||||
extern my_bool _mariadb_read_options(MYSQL *mysql, const char *dir, const char *config_file, char *group, unsigned int recursion);
|
extern my_bool _mariadb_read_options(MYSQL *mysql, const char *dir, const char *config_file, const char *group, unsigned int recursion);
|
||||||
extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
|
extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
@@ -4518,5 +4519,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS = {
|
|||||||
/* API functions */
|
/* API functions */
|
||||||
&MARIADB_API,
|
&MARIADB_API,
|
||||||
/* read execute response */
|
/* read execute response */
|
||||||
mthd_stmt_read_execute_response
|
mthd_stmt_read_execute_response,
|
||||||
|
/* generate execute request */
|
||||||
|
ma_stmt_execute_generate_request,
|
||||||
};
|
};
|
||||||
|
@@ -673,8 +673,8 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ mysqlnd_stmt_execute_generate_simple_request */
|
/* {{{ ma_stmt_execute_generate_simple_request */
|
||||||
unsigned char* mysql_stmt_execute_generate_simple_request(MYSQL_STMT *stmt, size_t *request_len)
|
unsigned char* ma_stmt_execute_generate_simple_request(MYSQL_STMT *stmt, size_t *request_len)
|
||||||
{
|
{
|
||||||
/* execute packet has the following format:
|
/* execute packet has the following format:
|
||||||
Offset Length Description
|
Offset Length Description
|
||||||
@@ -854,8 +854,8 @@ my_bool mysql_stmt_skip_paramset(MYSQL_STMT *stmt, uint row)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ mysql_stmt_execute_generate_bulk_request */
|
/* {{{ ma_stmt_execute_generate_bulk_request */
|
||||||
unsigned char* mysql_stmt_execute_generate_bulk_request(MYSQL_STMT *stmt, size_t *request_len)
|
unsigned char* ma_stmt_execute_generate_bulk_request(MYSQL_STMT *stmt, size_t *request_len)
|
||||||
{
|
{
|
||||||
/* execute packet has the following format:
|
/* execute packet has the following format:
|
||||||
Offset Length Description
|
Offset Length Description
|
||||||
@@ -1046,6 +1046,40 @@ mem_error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char* ma_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *request_len, my_bool internal)
|
||||||
|
{
|
||||||
|
unsigned char *buf;
|
||||||
|
|
||||||
|
|
||||||
|
if (stmt->request_buffer)
|
||||||
|
{
|
||||||
|
*request_len= stmt->request_length;
|
||||||
|
buf= stmt->request_buffer;
|
||||||
|
/* store actual stmt id */
|
||||||
|
int4store(buf, stmt->stmt_id);
|
||||||
|
/* clear buffer, memory will be freed in execute */
|
||||||
|
stmt->request_buffer= NULL;
|
||||||
|
stmt->request_length= 0;
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
if (stmt->array_size > 0)
|
||||||
|
buf= ma_stmt_execute_generate_bulk_request(stmt, request_len);
|
||||||
|
else
|
||||||
|
buf= ma_stmt_execute_generate_simple_request(stmt, request_len);
|
||||||
|
|
||||||
|
if (internal)
|
||||||
|
{
|
||||||
|
if (stmt->request_buffer)
|
||||||
|
free(stmt->request_buffer);
|
||||||
|
stmt->request_buffer= buf;
|
||||||
|
stmt->request_length= *request_len;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
@@ -2056,11 +2090,8 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
|||||||
}
|
}
|
||||||
/* CONC-344: set row count to zero */
|
/* CONC-344: set row count to zero */
|
||||||
stmt->result.rows= 0;
|
stmt->result.rows= 0;
|
||||||
if (stmt->array_size > 0)
|
|
||||||
request= (char *)mysql_stmt_execute_generate_bulk_request(stmt, &request_len);
|
|
||||||
else
|
|
||||||
request= (char *)mysql_stmt_execute_generate_simple_request(stmt, &request_len);
|
|
||||||
|
|
||||||
|
request= (char *)ma_stmt_execute_generate_request(stmt, &request_len, 0);
|
||||||
if (!request)
|
if (!request)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user