diff options
author | Andrey Hristov <andrey@php.net> | 2015-04-07 21:39:29 +0200 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2015-04-07 21:39:29 +0200 |
commit | ed0f134a642e7caed94966450435ed5e2a21f426 (patch) | |
tree | 8dbb53af534121a8a65227d3d57906b3947d0d5f /ext/mysqlnd | |
parent | a970ae76e27618c81add2a92370280818a04ac16 (diff) | |
download | php-git-ed0f134a642e7caed94966450435ed5e2a21f426.tar.gz |
Split mysqlnd_stmt::execute in 2 logical parts :
- mysqlnd_stmt::send_execute() which just creates the wire message by using
an aux function and sends it to the server
- mysqlnd_stmt::parse_execute_respose() which is responsible for handling
the bytes sent from the server in response to COM_EXECUTE.
This makes it possible to implement finer method overwriting in mysqlnd
plugins.
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r-- | ext/mysqlnd/mysqlnd.h | 4 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_enum_n_def.h | 14 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps.c | 39 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_structs.h | 20 |
4 files changed, 59 insertions, 18 deletions
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h index da8e39de22..bbd0e82b1f 100644 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@ -22,8 +22,8 @@ #ifndef MYSQLND_H #define MYSQLND_H -#define PHP_MYSQLND_VERSION "mysqlnd 5.0.11-dev - 20120503 - $Id$" -#define MYSQLND_VERSION_ID 50011 +#define PHP_MYSQLND_VERSION "mysqlnd 5.0.12-dev - 20150407 - $Id$" +#define MYSQLND_VERSION_ID 50012 #define MYSQLND_PLUGIN_API_VERSION 2 diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index e98bffc639..62f45a4f18 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -168,6 +168,20 @@ typedef enum mysqlnd_reap_result_type MYSQLND_REAP_RESULT_EXPLICIT } enum_mysqlnd_reap_result_type; +typedef enum mysqlnd_send_execute_type +{ + MYSQLND_SEND_EXECUTE_IMPLICIT = 0, + MYSQLND_SEND_EXECUTE_EXPLICIT +} enum_mysqlnd_send_execute_type; + +typedef enum mysqlnd_parse_exec_response_type +{ + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT = 0, + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_NEXT_RESULT, + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_OUT_VARIABLES, + MYSQLND_PARSE_EXEC_RESPONSE_EXPLICIT, +} enum_mysqlnd_parse_exec_response_type; + typedef enum mysqlnd_option { MYSQL_OPT_CONNECT_TIMEOUT, diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 5e2c619261..70ea4e4874 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -247,7 +247,7 @@ MYSQLND_METHOD(mysqlnd_stmt, next_result)(MYSQLND_STMT * s) /* Free space for next result */ s->m->free_stmt_result(s); { - enum_func_status ret = s->m->parse_execute_response(s); + enum_func_status ret = s->m->parse_execute_response(s, MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_NEXT_RESULT); DBG_RETURN(ret); } } @@ -489,7 +489,7 @@ fail: /* {{{ mysqlnd_stmt_execute_parse_response */ static enum_func_status -mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s) +mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s, enum_mysqlnd_parse_exec_response_type type) { MYSQLND_STMT_DATA * stmt = s? s->data:NULL; enum_func_status ret; @@ -590,10 +590,16 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s) s->m->free_stmt_content(s); DBG_INF("PS OUT Variable RSet, skipping"); /* OUT params result set. Skip for now to retain compatibility */ - ret = mysqlnd_stmt_execute_parse_response(s); + ret = mysqlnd_stmt_execute_parse_response(s, MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_OUT_VARIABLES); } #endif + DBG_INF_FMT("server_status=%u cursor=%u", stmt->upsert_status->server_status, stmt->upsert_status->server_status & SERVER_STATUS_CURSOR_EXISTS); + + if (ret == PASS && conn->last_query_type == QUERY_UPSERT && stmt->upsert_status->affected_rows) { + MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_ROWS_AFFECTED_PS, stmt->upsert_status->affected_rows); + } + DBG_INF(ret == PASS? "PASS":"FAIL"); DBG_RETURN(ret); } @@ -604,6 +610,21 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s) static enum_func_status MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s) { + DBG_ENTER("mysqlnd_stmt::execute"); + if (FAIL == s->m->send_execute(s, MYSQLND_SEND_EXECUTE_IMPLICIT, NULL, NULL) || + FAIL == s->m->parse_execute_response(s, MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT)) + { + DBG_RETURN(FAIL); + } + DBG_RETURN(PASS); +} +/* }}} */ + + +/* {{{ mysqlnd_stmt::send_execute */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_send_execute_type type, zval * read_cb, zval * err_cb) +{ MYSQLND_STMT_DATA * stmt = s? s->data:NULL; enum_func_status ret; MYSQLND_CONN_DATA * conn; @@ -611,7 +632,7 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s) size_t request_len; zend_bool free_request; - DBG_ENTER("mysqlnd_stmt::execute"); + DBG_ENTER("mysqlnd_stmt::send_execute"); if (!stmt || !stmt->conn) { DBG_RETURN(FAIL); } @@ -720,14 +741,7 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s) } stmt->execute_count++; - ret = s->m->parse_execute_response(s); - - DBG_INF_FMT("server_status=%u cursor=%u", stmt->upsert_status->server_status, stmt->upsert_status->server_status & SERVER_STATUS_CURSOR_EXISTS); - - if (ret == PASS && conn->last_query_type == QUERY_UPSERT && stmt->upsert_status->affected_rows) { - MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_ROWS_AFFECTED_PS, stmt->upsert_status->affected_rows); - } - DBG_RETURN(ret); + DBG_RETURN(PASS); } /* }}} */ @@ -2301,6 +2315,7 @@ MYSQLND_METHOD(mysqlnd_stmt, free_result_bind)(MYSQLND_STMT * const s, MYSQLND_R MYSQLND_CLASS_METHODS_START(mysqlnd_stmt) MYSQLND_METHOD(mysqlnd_stmt, prepare), + MYSQLND_METHOD(mysqlnd_stmt, send_execute), MYSQLND_METHOD(mysqlnd_stmt, execute), MYSQLND_METHOD(mysqlnd_stmt, use_result), MYSQLND_METHOD(mysqlnd_stmt, store_result), diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 73dfaa80c5..84c78e2c85 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -746,6 +746,7 @@ struct st_mysqlnd_res_meta_methods typedef enum_func_status (*func_mysqlnd_stmt__prepare)(MYSQLND_STMT * const stmt, const char * const query, unsigned int query_len); +typedef enum_func_status (*func_mysqlnd_stmt__send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_send_execute_type type, zval * read_cb, zval * err_cb); typedef enum_func_status (*func_mysqlnd_stmt__execute)(MYSQLND_STMT * const stmt); typedef MYSQLND_RES * (*func_mysqlnd_stmt__use_result)(MYSQLND_STMT * const stmt); typedef MYSQLND_RES * (*func_mysqlnd_stmt__store_result)(MYSQLND_STMT * const stmt); @@ -783,7 +784,7 @@ typedef void (*func_mysqlnd_stmt__free_parameter_bind)(MYSQLND_STMT * const typedef void (*func_mysqlnd_stmt__free_result_bind)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND *); typedef unsigned int (*func_mysqlnd_stmt__server_status)(const MYSQLND_STMT * const stmt); typedef enum_func_status (*func_mysqlnd_stmt__generate_execute_request)(MYSQLND_STMT * const s, zend_uchar ** request, size_t *request_len, zend_bool * free_buffer); -typedef enum_func_status (*func_mysqlnd_stmt__parse_execute_response)(MYSQLND_STMT * const s); +typedef enum_func_status (*func_mysqlnd_stmt__parse_execute_response)(MYSQLND_STMT * const s, enum_mysqlnd_parse_exec_response_type type); typedef void (*func_mysqlnd_stmt__free_stmt_content)(MYSQLND_STMT * const s); typedef enum_func_status (*func_mysqlnd_stmt__flush)(MYSQLND_STMT * const stmt); typedef void (*func_mysqlnd_stmt__free_stmt_result)(MYSQLND_STMT * const s); @@ -791,6 +792,7 @@ typedef void (*func_mysqlnd_stmt__free_stmt_result)(MYSQLND_STMT * const s); struct st_mysqlnd_stmt_methods { func_mysqlnd_stmt__prepare prepare; + func_mysqlnd_stmt__send_execute send_execute; func_mysqlnd_stmt__execute execute; func_mysqlnd_stmt__use_result use_result; func_mysqlnd_stmt__store_result store_result; @@ -968,6 +970,11 @@ struct st_mysqlnd_connection_data unsigned int client_api_capabilities; + zval async_read_cb; + zval async_err_cb; + zend_bool in_async_read_cb; + zend_bool in_async_err_cb; + struct st_mysqlnd_conn_data_methods * m; /* persistent connection */ @@ -1121,8 +1128,8 @@ struct st_mysqlnd_result_bind struct st_mysqlnd_stmt_data { MYSQLND_CONN_DATA *conn; - zend_ulong stmt_id; - zend_ulong flags;/* cursor is set here */ + zend_ulong stmt_id; + zend_ulong flags;/* cursor is set here */ enum_mysqlnd_stmt_state state; unsigned int warning_count; MYSQLND_RES *result; @@ -1141,11 +1148,16 @@ struct st_mysqlnd_stmt_data MYSQLND_ERROR_INFO error_info_impl; zend_bool update_max_length; - zend_ulong prefetch_rows; + zend_ulong prefetch_rows; zend_bool cursor_exists; mysqlnd_stmt_use_or_store_func default_rset_handler; + zval execute_read_cb; + zval execute_err_cb; + zend_bool in_execute_read_cb; + zend_bool in_execute_err_cb; + MYSQLND_CMD_BUFFER execute_cmd_buffer; unsigned int execute_count;/* count how many times the stmt was executed */ }; |