]> granicus.if.org Git - php/commitdiff
Split mysqlnd_stmt::execute in 2 logical parts :
authorAndrey Hristov <andrey@php.net>
Tue, 7 Apr 2015 19:39:29 +0000 (21:39 +0200)
committerAndrey Hristov <andrey@php.net>
Tue, 7 Apr 2015 19:39:29 +0000 (21:39 +0200)
- 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.

ext/mysqlnd/mysqlnd.h
ext/mysqlnd/mysqlnd_enum_n_def.h
ext/mysqlnd/mysqlnd_ps.c
ext/mysqlnd/mysqlnd_structs.h

index da8e39de2278dfd986fdda5c6f285b48e4cda140..bbd0e82b1fd36fc394a9043c813057b68ea0e7e9 100644 (file)
@@ -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
 
index e98bffc63959c67ee37fb0b42da49f4276a97f7c..62f45a4f186449c76df85335904216a875073e5c 100644 (file)
@@ -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,
index 5e2c61926139c3cb40827b6f1076cd0cfc717e57..70ea4e487412f4637adf71dce8482248f8b80694 100644 (file)
@@ -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);
 }
@@ -603,6 +609,21 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s)
 /* {{{ mysqlnd_stmt::execute */
 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;
@@ -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),
index 73dfaa80c500c0b7a60ed07d40d7dde985992013..84c78e2c8586375d629f6d99258cc3a14ed40a61 100644 (file)
@@ -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 */
 };