]> granicus.if.org Git - php/commitdiff
MDNR:
authorAndrey Hristov <andrey@php.net>
Mon, 19 Oct 2015 16:20:28 +0000 (18:20 +0200)
committerAndrey Hristov <andrey@php.net>
Thu, 12 Nov 2015 15:19:16 +0000 (16:19 +0100)
- Refactor the command factory. Let the factory be exchangeable.

ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd_driver.c
ext/mysqlnd/mysqlnd_enum_n_def.h
ext/mysqlnd/mysqlnd_ext_plugin.c
ext/mysqlnd/mysqlnd_ext_plugin.h
ext/mysqlnd/mysqlnd_priv.h
ext/mysqlnd/mysqlnd_ps.c
ext/mysqlnd/mysqlnd_structs.h
ext/mysqlnd/mysqlnd_wireprotocol.c

index a4a5294f4091c1b9f0ebac218ab70869ca7b0b1f..001956e8a0d0e6b8e175ae5b86be779799b6b9f7 100644 (file)
@@ -355,7 +355,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_server_option)(MYSQLND_CONN_DATA * const c
        enum_func_status ret = FAIL;
        DBG_ENTER("mysqlnd_conn_data::set_server_option");
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_SET_OPTION, conn, option);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_SET_OPTION, conn, option);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1190,7 +1190,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_query)(MYSQLND_CONN_DATA * conn, const ch
        if (type == MYSQLND_SEND_QUERY_IMPLICIT || PASS == conn->m->local_tx_start(conn, this_func))
        {
                const MYSQLND_CSTRING query_string = {query, query_len};
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_QUERY, conn, query_string);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_QUERY, conn, query_string);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1219,7 +1219,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, reap_query)(MYSQLND_CONN_DATA * conn, enum_mys
        DBG_INF_FMT("conn->server_status=%u", conn->upsert_status->server_status);
        if (type == MYSQLND_REAP_RESULT_IMPLICIT || PASS == conn->m->local_tx_start(conn, this_func))
        {
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_REAP_RESULT, conn);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_REAP_RESULT, conn);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1447,7 +1447,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, list_fields)(MYSQLND_CONN_DATA * conn, const c
                        const MYSQLND_CSTRING tbl = {table, strlen(table)};
                        const MYSQLND_CSTRING wildcard = {achtung_wild, strlen(achtung_wild)};
 
-                       struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_FIELD_LIST, conn, tbl, wildcard);
+                       struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_FIELD_LIST, conn, tbl, wildcard);
                        if (command) {
                                ret = command->run(command);
                                command->free_command(command);
@@ -1624,7 +1624,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, dump_debug_info)(MYSQLND_CONN_DATA * const con
        DBG_ENTER("mysqlnd_conn_data::dump_debug_info");
        DBG_INF_FMT("conn=%llu", conn->thread_id);
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_DEBUG, conn);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_DEBUG, conn);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1650,7 +1650,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, select_db)(MYSQLND_CONN_DATA * const conn, con
 
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
                const MYSQLND_CSTRING database = {db, db_len};
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_INIT_DB, conn, database);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_INIT_DB, conn, database);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1691,7 +1691,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, ping)(MYSQLND_CONN_DATA * const conn)
        DBG_INF_FMT("conn=%llu", conn->thread_id);
 
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_PING, conn);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_PING, conn);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1723,7 +1723,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri
 
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
                do {
-                       struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STATISTICS, conn);
+                       struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STATISTICS, conn);
                        if (command) {
                                ret = command->run(command);
                                command->free_command(command);
@@ -1768,7 +1768,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, kill)(MYSQLND_CONN_DATA * conn, unsigned int p
                unsigned int process_id = pid;
                /* 'unsigned char' is promoted to 'int' when passed through '...' */
                unsigned int read_response = (pid != conn->thread_id);
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_PROCESS_KILL, conn, process_id, read_response);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_PROCESS_KILL, conn, process_id, read_response);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1841,7 +1841,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, refresh)(MYSQLND_CONN_DATA * const conn, uint8
 
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
                unsigned int options_param = (unsigned int) options;
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_REFRESH, conn, options_param);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_REFRESH, conn, options_param);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1864,7 +1864,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, shutdown)(MYSQLND_CONN_DATA * const conn, uint
 
        if (PASS == conn->m->local_tx_start(conn, this_func)) {
                unsigned int level_param = (unsigned int) level;
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_SHUTDOWN, conn, level_param);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_SHUTDOWN, conn, level_param);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -1900,7 +1900,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn)
                case CONN_READY:
                        DBG_INF("Connection clean, sending COM_QUIT");
                        if (net_stream) {
-                               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_QUIT, conn);
+                               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_QUIT, conn);
                                if (command) {
                                        ret = command->run(command);
                                        command->free_command(command);
@@ -3149,1051 +3149,6 @@ mysqlnd_connection_init(unsigned int client_flags, zend_bool persistent, struct
 /* }}} */
 
 
-struct st_mysqlnd_protocol_no_params_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_protocol_no_params_command_context
-       {
-               MYSQLND_CONN_DATA * conn;
-       } context;
-};
-
-/* {{{ mysqlnd_com_no_params_free_command */
-static void
-mysqlnd_com_no_params_free_command(void * command)
-{
-       DBG_ENTER("mysqlnd_com_no_params_free_command");
-       mnd_efree(command);
-       DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/************************** COM_SET_OPTION ******************************************/
-struct st_mysqlnd_protocol_com_set_option_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_set_option_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               enum_mysqlnd_server_option option;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_set_option_run */
-enum_func_status
-mysqlnd_com_set_option_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_set_option_command * command = (struct st_mysqlnd_protocol_com_set_option_command *) cmd;
-       zend_uchar buffer[2];
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-       enum_mysqlnd_server_option option = command->context.option;
-
-       DBG_ENTER("mysqlnd_com_set_option_run");
-       int2store(buffer, (unsigned int) option);
-
-       ret = conn->m->send_command_do_request(conn, COM_SET_OPTION, buffer, sizeof(buffer), FALSE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_EOF_PACKET, FALSE, COM_SET_OPTION, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_set_option_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_set_option_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_set_option_command * command;
-       DBG_ENTER("mysqlnd_com_set_option_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_set_option_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.option = va_arg(args, enum_mysqlnd_server_option);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_set_option_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_DEBUG ******************************************/
-/* {{{ mysqlnd_com_debug_run */
-static enum_func_status
-mysqlnd_com_debug_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_debug_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_DEBUG, NULL, 0, FALSE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_EOF_PACKET, COM_DEBUG, COM_DEBUG, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_debug_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_debug_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_no_params_command * command;
-       DBG_ENTER("mysqlnd_com_debug_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-
-               command->parent.run = mysqlnd_com_debug_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_INIT_DB ******************************************/
-struct st_mysqlnd_protocol_com_init_db_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_init_db_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING db;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_init_db_run */
-static enum_func_status
-mysqlnd_com_init_db_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_init_db_command * command = (struct st_mysqlnd_protocol_com_init_db_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_init_db_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_INIT_DB, (zend_uchar*) command->context.db.s, command->context.db.l, FALSE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_INIT_DB, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_init_db_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_init_db_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_init_db_command * command;
-       DBG_ENTER("mysqlnd_com_init_db_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_init_db_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.db = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_init_db_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_PING ******************************************/
-/* {{{ mysqlnd_com_ping_run */
-static enum_func_status
-mysqlnd_com_ping_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_ping_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_PING, NULL, 0, TRUE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, TRUE, COM_PING, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_ping_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_ping_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_no_params_command * command;
-       DBG_ENTER("mysqlnd_com_ping_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-
-               command->parent.run = mysqlnd_com_ping_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-/************************** COM_FIELD_LIST ******************************************/
-struct st_mysqlnd_protocol_com_field_list_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_field_list_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING table;
-               MYSQLND_CSTRING achtung_wild;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_field_list_run */
-static enum_func_status
-mysqlnd_com_field_list_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_field_list_command * command = (struct st_mysqlnd_protocol_com_field_list_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-       /* db + \0 + wild + \0 (for wild) */
-       zend_uchar buff[MYSQLND_MAX_ALLOWED_DB_LEN * 2 + 1 + 1], *p;
-       size_t table_len, wild_len;
-
-       DBG_ENTER("mysqlnd_com_field_list_run");
-
-       if (command->context.table.s && command->context.table.l) {
-               size_t to_copy = MIN(command->context.table.l, MYSQLND_MAX_ALLOWED_DB_LEN);
-               memcpy(p, command->context.table.s, to_copy);
-               p += to_copy;
-               *p++ = '\0';
-       }
-
-       if (command->context.achtung_wild.s && command->context.achtung_wild.l) {
-               size_t to_copy = MIN(command->context.achtung_wild.l, MYSQLND_MAX_ALLOWED_DB_LEN);
-               memcpy(p, command->context.achtung_wild.s, to_copy);
-               p += to_copy;
-               *p++ = '\0';
-       }
-
-       ret = conn->m->send_command_do_request(conn, COM_FIELD_LIST, buff, p - buff, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_field_list_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_field_list_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_field_list_command * command;
-       DBG_ENTER("mysqlnd_com_field_list_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_field_list_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.table = va_arg(args, MYSQLND_CSTRING);
-               command->context.achtung_wild = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_field_list_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STATISTICS ******************************************/
-/* {{{ mysqlnd_com_statistics_run */
-static enum_func_status
-mysqlnd_com_statistics_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_statistics_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STATISTICS, NULL, 0, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_statistics_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_statistics_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_no_params_command * command;
-       DBG_ENTER("mysqlnd_com_statistics_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-
-               command->parent.run = mysqlnd_com_statistics_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-/************************** COM_PROCESS_KILL ******************************************/
-struct st_mysqlnd_protocol_com_process_kill_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_process_kill_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               unsigned int process_id;
-               zend_bool read_response;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_process_kill_run */
-enum_func_status
-mysqlnd_com_process_kill_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_process_kill_command * command = (struct st_mysqlnd_protocol_com_process_kill_command *) cmd;
-       zend_uchar buff[4];
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_process_kill_run");
-       int4store(buff, command->context.process_id);
-
-       ret = conn->m->send_command_do_request(conn, COM_PROCESS_KILL, buff, 4, FALSE, TRUE);
-       if (PASS == ret && command->context.read_response) {
-               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_process_kill_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_process_kill_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_process_kill_command * command;
-       DBG_ENTER("mysqlnd_com_process_kill_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_process_kill_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.process_id = va_arg(args, unsigned int);
-               command->context.read_response = va_arg(args, unsigned int)? TRUE:FALSE;
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_process_kill_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-/************************** COM_REFRESH ******************************************/
-struct st_mysqlnd_protocol_com_refresh_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_refresh_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               uint8_t options;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_refresh_run */
-enum_func_status
-mysqlnd_com_refresh_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_refresh_command * command = (struct st_mysqlnd_protocol_com_refresh_command *) cmd;
-       zend_uchar bits[1];
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_refresh_run");
-       int1store(bits, command->context.options);
-
-       ret = conn->m->send_command_do_request(conn, COM_REFRESH, bits, 1, FALSE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_REFRESH, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_refresh_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_refresh_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_refresh_command * command;
-       DBG_ENTER("mysqlnd_com_refresh_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_refresh_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.options = va_arg(args, unsigned int);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_refresh_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_SHUTDOWN ******************************************/
-struct st_mysqlnd_protocol_com_shutdown_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_shutdown_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               uint8_t level;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_shutdown_run */
-enum_func_status
-mysqlnd_com_shutdown_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_shutdown_command * command = (struct st_mysqlnd_protocol_com_shutdown_command *) cmd;
-       zend_uchar bits[1];
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_shutdown_run");
-       int1store(bits, command->context.level);
-
-       ret = conn->m->send_command_do_request(conn, COM_SHUTDOWN, bits, 1, FALSE, TRUE);
-       if (PASS == ret) {
-               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_SHUTDOWN, TRUE);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_shutdown_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_shutdown_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_shutdown_command * command;
-       DBG_ENTER("mysqlnd_com_shutdown_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_shutdown_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.level = va_arg(args, unsigned int);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_shutdown_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_QUIT ******************************************/
-struct st_mysqlnd_protocol_com_quit_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_quit_context
-       {
-               MYSQLND_CONN_DATA * conn;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_quit_run */
-enum_func_status
-mysqlnd_com_quit_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_quit_command * command = (struct st_mysqlnd_protocol_com_quit_command *) cmd;
-       zend_uchar bits[1];
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_quit_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_QUIT, NULL, 0, TRUE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_quit_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_quit_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_quit_command * command;
-       DBG_ENTER("mysqlnd_com_quit_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_quit_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_quit_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-/************************** COM_QUERY ******************************************/
-struct st_mysqlnd_protocol_com_query_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_query_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING query;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_query_run */
-static enum_func_status
-mysqlnd_com_query_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_query_command * command = (struct st_mysqlnd_protocol_com_query_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_query_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_QUERY, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE, FALSE);
-
-       if (PASS == ret) {
-               CONN_SET_STATE(conn, CONN_QUERY_SENT);
-       }
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_query_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_query_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_query_command * command;
-       DBG_ENTER("mysqlnd_com_query_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_query_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.query = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_query_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-/************************** COM_CHANGE_USER ******************************************/
-struct st_mysqlnd_protocol_com_change_user_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_change_user_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-               zend_bool silent;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_change_user_run */
-static enum_func_status
-mysqlnd_com_change_user_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_change_user_command * command = (struct st_mysqlnd_protocol_com_change_user_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_change_user_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_CHANGE_USER, (zend_uchar*) command->context.payload.s, command->context.payload.l, command->context.silent, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_change_user_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_change_user_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_change_user_command * command;
-       DBG_ENTER("mysqlnd_com_change_user_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_change_user_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-               command->context.silent = va_arg(args, unsigned int);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_change_user_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_REAP_RESULT ******************************************/
-struct st_mysqlnd_protocol_com_reap_result_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_reap_result_context
-       {
-               MYSQLND_CONN_DATA * conn;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_reap_result_run */
-static enum_func_status
-mysqlnd_com_reap_result_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_reap_result_command * command = (struct st_mysqlnd_protocol_com_reap_result_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-       enum_mysqlnd_connection_state state = CONN_GET_STATE(conn);
-
-       DBG_ENTER("mysqlnd_com_reap_result_run");
-       if (state <= CONN_READY || state == CONN_QUIT_SENT) {
-               php_error_docref(NULL, E_WARNING, "Connection not opened, clear or has been closed");
-               DBG_ERR_FMT("Connection not opened, clear or has been closed. State=%u", state);
-               DBG_RETURN(ret);
-       }
-       ret = conn->m->query_read_result_set_header(conn, NULL);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_reap_result_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_reap_result_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_reap_result_command * command;
-       DBG_ENTER("mysqlnd_com_reap_result_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_reap_result_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_reap_result_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_PREPARE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_prepare_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_prepare_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING query;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_prepare_run */
-static enum_func_status
-mysqlnd_com_stmt_prepare_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_prepare_command * command = (struct st_mysqlnd_protocol_com_stmt_prepare_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_prepare_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_PREPARE, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_prepare_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_prepare_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_prepare_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_prepare_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_prepare_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.query = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_prepare_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_EXECUTE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_execute_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_execute_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_execute_run */
-static enum_func_status
-mysqlnd_com_stmt_execute_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_execute_command * command = (struct st_mysqlnd_protocol_com_stmt_execute_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_execute_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_EXECUTE, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, FALSE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_execute_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_execute_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_execute_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_execute_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_execute_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_execute_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_FETCH ******************************************/
-struct st_mysqlnd_protocol_com_stmt_fetch_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_fetch_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_fetch_run */
-static enum_func_status
-mysqlnd_com_stmt_fetch_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_fetch_command * command = (struct st_mysqlnd_protocol_com_stmt_fetch_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_fetch_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_FETCH, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_fetch_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_fetch_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_fetch_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_fetch_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_fetch_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_fetch_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_RESET ******************************************/
-struct st_mysqlnd_protocol_com_stmt_reset_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_reset_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_reset_run */
-static enum_func_status
-mysqlnd_com_stmt_reset_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_reset_command * command = (struct st_mysqlnd_protocol_com_stmt_reset_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_reset_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_RESET, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_reset_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_reset_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_reset_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_reset_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_reset_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_reset_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_SEND_LONG_DATA ******************************************/
-struct st_mysqlnd_protocol_com_stmt_send_long_data_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_send_long_data_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_send_long_data_run */
-static enum_func_status
-mysqlnd_com_stmt_send_long_data_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_send_long_data_command * command = (struct st_mysqlnd_protocol_com_stmt_send_long_data_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_send_long_data_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_SEND_LONG_DATA, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_send_long_data_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_send_long_data_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_send_long_data_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_send_long_data_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_send_long_data_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_send_long_data_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/************************** COM_STMT_CLOSE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_close_command
-{
-       struct st_mysqlnd_protocol_command parent;
-       struct st_mysqlnd_com_stmt_close_context
-       {
-               MYSQLND_CONN_DATA * conn;
-               MYSQLND_CSTRING payload;
-       } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_close_run */
-static enum_func_status
-mysqlnd_com_stmt_close_run(void *cmd)
-{
-       struct st_mysqlnd_protocol_com_stmt_close_command * command = (struct st_mysqlnd_protocol_com_stmt_close_command *) cmd;
-       enum_func_status ret = FAIL;
-       MYSQLND_CONN_DATA * conn = command->context.conn;
-
-       DBG_ENTER("mysqlnd_com_stmt_close_run");
-
-       ret = conn->m->send_command_do_request(conn, COM_STMT_CLOSE, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
-
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_close_create_command */
-static struct st_mysqlnd_protocol_command *
-mysqlnd_com_stmt_close_create_command(va_list args)
-{
-       struct st_mysqlnd_protocol_com_stmt_close_command * command;
-       DBG_ENTER("mysqlnd_com_stmt_close_create_command");
-       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_close_command));
-       if (command) {
-               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-               command->context.payload = va_arg(args, MYSQLND_CSTRING);
-
-               command->parent.free_command = mysqlnd_com_no_params_free_command;
-               command->parent.run = mysqlnd_com_stmt_close_run;
-       }
-
-       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_get_command */
-struct st_mysqlnd_protocol_command *
-mysqlnd_get_command(enum php_mysqlnd_server_command command, ...)
-{
-       struct st_mysqlnd_protocol_command * ret;
-       va_list args;
-       DBG_ENTER("mysqlnd_get_command");
-
-       va_start(args, command);
-       switch (command) {
-               case COM_SET_OPTION:
-                       ret = mysqlnd_com_set_option_create_command(args);
-                       break;
-               case COM_DEBUG:
-                       ret = mysqlnd_com_debug_create_command(args);
-                       break;
-               case COM_INIT_DB:
-                       ret = mysqlnd_com_init_db_create_command(args);
-                       break;
-               case COM_PING:
-                       ret = mysqlnd_com_ping_create_command(args);
-                       break;
-               case COM_FIELD_LIST:
-                       ret = mysqlnd_com_field_list_create_command(args);
-                       break;
-               case COM_STATISTICS:
-                       ret = mysqlnd_com_statistics_create_command(args);
-                       break;
-               case COM_PROCESS_KILL:
-                       ret = mysqlnd_com_process_kill_create_command(args);
-                       break;
-               case COM_REFRESH:
-                       ret = mysqlnd_com_refresh_create_command(args);
-                       break;
-               case COM_SHUTDOWN:
-                       ret = mysqlnd_com_shutdown_create_command(args);
-                       break;
-               case COM_QUIT:
-                       ret = mysqlnd_com_quit_create_command(args);
-                       break;
-               case COM_QUERY:
-                       ret = mysqlnd_com_query_create_command(args);
-                       break;
-               case COM_REAP_RESULT:
-                       ret = mysqlnd_com_reap_result_create_command(args);
-                       break;
-               case COM_CHANGE_USER:
-                       ret = mysqlnd_com_change_user_create_command(args);
-                       break;
-               case COM_STMT_PREPARE:
-                       ret = mysqlnd_com_stmt_prepare_create_command(args);
-                       break;
-               case COM_STMT_EXECUTE:
-                       ret = mysqlnd_com_stmt_execute_create_command(args);
-                       break;
-               case COM_STMT_FETCH:
-                       ret = mysqlnd_com_stmt_fetch_create_command(args);
-                       break;
-               case COM_STMT_RESET:
-                       ret = mysqlnd_com_stmt_reset_create_command(args);
-                       break;
-               case COM_STMT_SEND_LONG_DATA:
-                       ret = mysqlnd_com_stmt_send_long_data_create_command(args);
-                       break;
-               case COM_STMT_CLOSE:
-                       ret = mysqlnd_com_stmt_close_create_command(args);
-                       break;
-               default:
-                       break;
-       }
-       va_end(args);
-       DBG_RETURN(ret);
-}
-/* }}} */
-
-
 /*
  * Local variables:
  * tab-width: 4
index fa7643c9250a8e7ca8a6a5af470237bf566e496e..00e38adde22392246e268853ee208deb0ee125b7 100644 (file)
@@ -155,6 +155,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(struct st_mysqlnd_object_
 
        data->net = mysqlnd_net_init(persistent, data->stats, data->error_info);
        data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
+       data->command_factory = mysqlnd_command_factory_get();
 
        if (!data->net || !data->payload_decoder_factory) {
                new_object->m->dtor(new_object);
index a8a2c4ba0e0f4cc9a313ad1f658aa9440fe1016a..c1094292cf1f64cfde1c649db531719adcd971ad 100644 (file)
@@ -49,6 +49,9 @@
 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE                        4096
 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR            "4096"
 
+#define MYSQLND_STMT_ID_LENGTH 4
+
+
 #define SERVER_STATUS_IN_TRANS                                 1       /* Transaction has started */
 #define SERVER_STATUS_AUTOCOMMIT                               2       /* Server in auto_commit mode */
 #define SERVER_MORE_RESULTS_EXISTS                             8       /* Multi query - next query exists */
index b8909d4126b604769efbc641bace7af3c29b0a9a..52ca9055b82d91c982238c65f1a1f8b3a083b314 100644 (file)
@@ -327,6 +327,25 @@ _mysqlnd_net_set_methods(struct st_mysqlnd_net_methods * methods)
 /* }}} */
 
 
+/* {{{ mysqlnd_command_factory_get */
+static func_mysqlnd__command_factory
+_mysqlnd_command_factory_get()
+{
+       return mysqlnd_command_factory;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_command_factory_set */
+static void
+_mysqlnd_command_factory_set(func_mysqlnd__command_factory factory)
+{
+       mysqlnd_command_factory = factory;
+}
+/* }}} */
+
+
+
 struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters =
 {
        {
@@ -363,7 +382,11 @@ struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters =
        },
        {
                _mysqlnd_net_get_methods,
-               _mysqlnd_net_set_methods
+               _mysqlnd_net_set_methods,
+       },
+       {
+               _mysqlnd_command_factory_get,
+               _mysqlnd_command_factory_set,
        },
 };
 
index 746757030bf01decfab82bd85e61804c90104167..b136e5e58f5cce15b0dfe5b74e3e6619b0a16615 100644 (file)
@@ -67,7 +67,7 @@ struct st_mysqlnd_plugin_methods_xetters
                void (*set)(struct st_mysqlnd_conn_data_methods * methods);
        } connection_data;
 
-       struct st_mnd_result_etters
+       struct st_mnd_result_xetters
        {
                struct st_mysqlnd_res_methods * (*get)();
                void (*set)(struct st_mysqlnd_res_methods * methods);
@@ -102,6 +102,12 @@ struct st_mysqlnd_plugin_methods_xetters
                struct st_mysqlnd_net_methods * (*get)();
                void (*set)(struct st_mysqlnd_net_methods * methods);
        } io;
+
+       struct st_mnd_command_factory_xetters
+       {
+               func_mysqlnd__command_factory (*get)();
+               void (*set)(func_mysqlnd__command_factory factory);
+       } command_factory;
 };
 
 extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters;
@@ -134,6 +140,10 @@ extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters;
 #define mysqlnd_net_get_methods()              mysqlnd_plugin_methods_xetters.io.get()
 #define mysqlnd_net_set_methods(m)             mysqlnd_plugin_methods_xetters.io.set((m))
 
+
+#define mysqlnd_command_factory_get()          mysqlnd_plugin_methods_xetters.command_factory.get()
+#define mysqlnd_command_factory_set(m)         mysqlnd_plugin_methods_xetters.command_factory.set((m))
+
 #endif /* MYSQLND_EXT_PLUGIN_H */
 
 /*
index 831b30d13f3a7f39f0bd2a75aa92256ef3abb00b..fdd663276f4a9a3b0f512d484825c97f0c4b8038 100644 (file)
@@ -240,10 +240,7 @@ mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
                                                                size_t * switch_to_auth_protocol_data_len
                                                                );
 
-/* {{{ mysqlnd_get_command */
-struct st_mysqlnd_protocol_command *
-mysqlnd_get_command(enum php_mysqlnd_server_command command, ...);
-
+extern func_mysqlnd__command_factory mysqlnd_command_factory;
 
 #endif /* MYSQLND_PRIV_H */
 
index bffa15eb12c9afff9043bceed405a2175305e882..8fa22544dc51684f4194f823da71b5c07365295a 100644 (file)
@@ -420,7 +420,7 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const s, const char * const
        {
                enum_func_status ret = FAIL;
                const MYSQLND_CSTRING query_string = {query, query_len};
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_PREPARE, stmt_to_prepare->conn, query_string);
+               struct st_mysqlnd_protocol_command * command = stmt_to_prepare->conn->command_factory(COM_STMT_PREPARE, stmt_to_prepare->conn, query_string);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -734,7 +734,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_
        ret = s->m->generate_execute_request(s, &request, &request_len, &free_request);
        if (ret == PASS) {
                const MYSQLND_CSTRING payload = {request, request_len};
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_EXECUTE, stmt->conn, payload);
+               struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_EXECUTE, stmt->conn, payload);
                ret = FAIL;
                if (command) {
                        ret = command->run(command);
@@ -1033,8 +1033,6 @@ MYSQLND_METHOD(mysqlnd_stmt, use_result)(MYSQLND_STMT * s)
 /* }}} */
 
 
-#define STMT_ID_LENGTH 4
-
 /* {{{ mysqlnd_fetch_row_cursor */
 enum_func_status
 mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything)
@@ -1042,7 +1040,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, unsigned int f
        enum_func_status ret;
        MYSQLND_STMT * s = (MYSQLND_STMT *) param;
        MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
-       zend_uchar buf[STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
+       zend_uchar buf[MYSQLND_STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
        MYSQLND_PACKET_ROW * row_packet;
 
        DBG_ENTER("mysqlnd_fetch_stmt_row_cursor");
@@ -1069,11 +1067,11 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, unsigned int f
        SET_EMPTY_ERROR(*stmt->conn->error_info);
 
        int4store(buf, stmt->stmt_id);
-       int4store(buf + STMT_ID_LENGTH, 1); /* for now fetch only one row */
+       int4store(buf + MYSQLND_STMT_ID_LENGTH, 1); /* for now fetch only one row */
 
        {
                const MYSQLND_CSTRING payload = {buf, sizeof(buf)};
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_FETCH, stmt->conn, payload);
+               struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_FETCH, stmt->conn, payload);
                ret = FAIL;
                if (command) {
                        ret = command->run(command);
@@ -1262,7 +1260,6 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s)
 {
        MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
        enum_func_status ret = PASS;
-       zend_uchar cmd_buf[STMT_ID_LENGTH /* statement id */];
 
        DBG_ENTER("mysqlnd_stmt::reset");
        if (!stmt || !stmt->conn) {
@@ -1294,11 +1291,9 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s)
                  be separated before that.
                */
 
-               int4store(cmd_buf, stmt->stmt_id);
-
                if (CONN_GET_STATE(conn) == CONN_READY) {
-                       const MYSQLND_CSTRING payload = {cmd_buf, sizeof(cmd_buf)};
-                       struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_RESET, stmt->conn, payload);
+                       size_t stmt_id = stmt->stmt_id;
+                       struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_RESET, stmt->conn, stmt_id);
                        ret = FAIL;
                        if (command) {
                                ret = command->run(command);
@@ -1411,18 +1406,18 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
 
        if (CONN_GET_STATE(conn) == CONN_READY) {
                size_t packet_len;
-               cmd_buf = mnd_emalloc(packet_len = STMT_ID_LENGTH + 2 + length);
+               cmd_buf = mnd_emalloc(packet_len = MYSQLND_STMT_ID_LENGTH + 2 + length);
                if (cmd_buf) {
                        stmt->param_bind[param_no].flags |= MYSQLND_PARAM_BIND_BLOB_USED;
 
                        int4store(cmd_buf, stmt->stmt_id);
-                       int2store(cmd_buf + STMT_ID_LENGTH, param_no);
-                       memcpy(cmd_buf + STMT_ID_LENGTH + 2, data, length);
+                       int2store(cmd_buf + MYSQLND_STMT_ID_LENGTH, param_no);
+                       memcpy(cmd_buf + MYSQLND_STMT_ID_LENGTH + 2, data, length);
 
                        /* COM_STMT_SEND_LONG_DATA doesn't send an OK packet*/
                        {
                                const MYSQLND_CSTRING payload = {cmd_buf, packet_len};
-                               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_SEND_LONG_DATA, stmt->conn, payload);
+                               struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_SEND_LONG_DATA, stmt->conn, payload);
                                ret = FAIL;
                                if (command) {
                                        ret = command->run(command);
@@ -2207,7 +2202,6 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const s, zend_boo
 {
        MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
        MYSQLND_CONN_DATA * conn;
-       zend_uchar cmd_buf[STMT_ID_LENGTH /* statement id */];
        enum_mysqlnd_collected_stats statistic = STAT_LAST;
 
        DBG_ENTER("mysqlnd_stmt::net_close");
@@ -2247,11 +2241,10 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const s, zend_boo
                MYSQLND_INC_GLOBAL_STATISTIC(implicit == TRUE?  STAT_FREE_RESULT_IMPLICIT:
                                                                                                                STAT_FREE_RESULT_EXPLICIT);
 
-               int4store(cmd_buf, stmt->stmt_id);
                if (CONN_GET_STATE(conn) == CONN_READY) {
                        enum_func_status ret = FAIL;
-                       const MYSQLND_CSTRING payload = {cmd_buf, sizeof(cmd_buf)};
-                       struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_STMT_CLOSE, conn, payload);
+                       size_t stmt_id = stmt->stmt_id;
+                       struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STMT_CLOSE, conn, stmt_id);
                        if (command) {
                                ret = command->run(command);
                                command->free_command(command);
index 9489f1d2c78035b844befcd291ca680b28205c7d..959c9a2cb875954b7b922a9201ab1faf2e467d6c 100644 (file)
@@ -900,6 +900,15 @@ struct st_mysqlnd_protocol_payload_decoder_factory
 };
 
 
+struct st_mysqlnd_protocol_command
+{
+       enum_func_status (*run)(void *cmd);
+       void (*free_command)(void * cmd);
+};
+
+typedef struct st_mysqlnd_protocol_command * (*func_mysqlnd__command_factory)(enum php_mysqlnd_server_command command, ...);
+
+
 struct st_mysqlnd_connection_data
 {
 /* Operation related */
@@ -978,6 +987,7 @@ struct st_mysqlnd_connection_data
        zend_bool               in_async_err_cb;
 
        struct st_mysqlnd_object_factory_methods object_factory;
+       func_mysqlnd__command_factory command_factory;
 
        struct st_mysqlnd_conn_data_methods * m;
 
@@ -1240,11 +1250,4 @@ struct st_mysqlnd_authentication_plugin
        } methods;
 };
 
-
-struct st_mysqlnd_protocol_command
-{
-       enum_func_status (*run)(void *cmd);
-       void (*free_command)(void * cmd);
-};
-
 #endif /* MYSQLND_STRUCTS_H */
index b37ffe8dbb9461099fccb53827f9057c85365e51..d686677a582928ad49d24406e9ae5b41eb447d22 100644 (file)
@@ -658,7 +658,7 @@ size_t php_mysqlnd_auth_write(void * _packet)
                enum_func_status ret = FAIL;
                const MYSQLND_CSTRING payload = {buffer + MYSQLND_HEADER_SIZE, p - (buffer + MYSQLND_HEADER_SIZE)};
                const unsigned int silent = packet->silent;
-               struct st_mysqlnd_protocol_command * command = mysqlnd_get_command(COM_CHANGE_USER, conn, payload, silent);
+               struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_CHANGE_USER, conn, payload, silent);
                if (command) {
                        ret = command->run(command);
                        command->free_command(command);
@@ -2659,6 +2659,1058 @@ mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_F
 /* }}} */
 
 
+
+
+struct st_mysqlnd_protocol_no_params_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_protocol_no_params_command_context
+       {
+               MYSQLND_CONN_DATA * conn;
+       } context;
+};
+
+/* {{{ mysqlnd_com_no_params_free_command */
+static void
+mysqlnd_com_no_params_free_command(void * command)
+{
+       DBG_ENTER("mysqlnd_com_no_params_free_command");
+       mnd_efree(command);
+       DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+/************************** COM_SET_OPTION ******************************************/
+struct st_mysqlnd_protocol_com_set_option_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_set_option_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               enum_mysqlnd_server_option option;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_set_option_run */
+enum_func_status
+mysqlnd_com_set_option_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_set_option_command * command = (struct st_mysqlnd_protocol_com_set_option_command *) cmd;
+       zend_uchar buffer[2];
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+       enum_mysqlnd_server_option option = command->context.option;
+
+       DBG_ENTER("mysqlnd_com_set_option_run");
+       int2store(buffer, (unsigned int) option);
+
+       ret = conn->m->send_command_do_request(conn, COM_SET_OPTION, buffer, sizeof(buffer), FALSE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_EOF_PACKET, FALSE, COM_SET_OPTION, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_set_option_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_set_option_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_set_option_command * command;
+       DBG_ENTER("mysqlnd_com_set_option_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_set_option_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.option = va_arg(args, enum_mysqlnd_server_option);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_set_option_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_DEBUG ******************************************/
+/* {{{ mysqlnd_com_debug_run */
+static enum_func_status
+mysqlnd_com_debug_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_debug_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_DEBUG, NULL, 0, FALSE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_EOF_PACKET, COM_DEBUG, COM_DEBUG, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_debug_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_debug_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_no_params_command * command;
+       DBG_ENTER("mysqlnd_com_debug_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+
+               command->parent.run = mysqlnd_com_debug_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_INIT_DB ******************************************/
+struct st_mysqlnd_protocol_com_init_db_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_init_db_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING db;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_init_db_run */
+static enum_func_status
+mysqlnd_com_init_db_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_init_db_command * command = (struct st_mysqlnd_protocol_com_init_db_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_init_db_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_INIT_DB, (zend_uchar*) command->context.db.s, command->context.db.l, FALSE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_INIT_DB, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_init_db_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_init_db_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_init_db_command * command;
+       DBG_ENTER("mysqlnd_com_init_db_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_init_db_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.db = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_init_db_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_PING ******************************************/
+/* {{{ mysqlnd_com_ping_run */
+static enum_func_status
+mysqlnd_com_ping_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_ping_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_PING, NULL, 0, TRUE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, TRUE, COM_PING, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_ping_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_ping_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_no_params_command * command;
+       DBG_ENTER("mysqlnd_com_ping_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+
+               command->parent.run = mysqlnd_com_ping_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+/************************** COM_FIELD_LIST ******************************************/
+struct st_mysqlnd_protocol_com_field_list_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_field_list_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING table;
+               MYSQLND_CSTRING achtung_wild;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_field_list_run */
+static enum_func_status
+mysqlnd_com_field_list_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_field_list_command * command = (struct st_mysqlnd_protocol_com_field_list_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+       /* db + \0 + wild + \0 (for wild) */
+       zend_uchar buff[MYSQLND_MAX_ALLOWED_DB_LEN * 2 + 1 + 1], *p;
+       size_t table_len, wild_len;
+
+       DBG_ENTER("mysqlnd_com_field_list_run");
+
+       if (command->context.table.s && command->context.table.l) {
+               size_t to_copy = MIN(command->context.table.l, MYSQLND_MAX_ALLOWED_DB_LEN);
+               memcpy(p, command->context.table.s, to_copy);
+               p += to_copy;
+               *p++ = '\0';
+       }
+
+       if (command->context.achtung_wild.s && command->context.achtung_wild.l) {
+               size_t to_copy = MIN(command->context.achtung_wild.l, MYSQLND_MAX_ALLOWED_DB_LEN);
+               memcpy(p, command->context.achtung_wild.s, to_copy);
+               p += to_copy;
+               *p++ = '\0';
+       }
+
+       ret = conn->m->send_command_do_request(conn, COM_FIELD_LIST, buff, p - buff, FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_field_list_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_field_list_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_field_list_command * command;
+       DBG_ENTER("mysqlnd_com_field_list_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_field_list_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.table = va_arg(args, MYSQLND_CSTRING);
+               command->context.achtung_wild = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_field_list_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STATISTICS ******************************************/
+/* {{{ mysqlnd_com_statistics_run */
+static enum_func_status
+mysqlnd_com_statistics_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_statistics_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_STATISTICS, NULL, 0, FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_statistics_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_statistics_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_no_params_command * command;
+       DBG_ENTER("mysqlnd_com_statistics_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_no_params_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+
+               command->parent.run = mysqlnd_com_statistics_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+/************************** COM_PROCESS_KILL ******************************************/
+struct st_mysqlnd_protocol_com_process_kill_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_process_kill_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               unsigned int process_id;
+               zend_bool read_response;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_process_kill_run */
+enum_func_status
+mysqlnd_com_process_kill_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_process_kill_command * command = (struct st_mysqlnd_protocol_com_process_kill_command *) cmd;
+       zend_uchar buff[4];
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_process_kill_run");
+       int4store(buff, command->context.process_id);
+
+       ret = conn->m->send_command_do_request(conn, COM_PROCESS_KILL, buff, 4, FALSE, TRUE);
+       if (PASS == ret && command->context.read_response) {
+               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_process_kill_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_process_kill_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_process_kill_command * command;
+       DBG_ENTER("mysqlnd_com_process_kill_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_process_kill_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.process_id = va_arg(args, unsigned int);
+               command->context.read_response = va_arg(args, unsigned int)? TRUE:FALSE;
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_process_kill_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+/************************** COM_REFRESH ******************************************/
+struct st_mysqlnd_protocol_com_refresh_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_refresh_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               uint8_t options;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_refresh_run */
+enum_func_status
+mysqlnd_com_refresh_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_refresh_command * command = (struct st_mysqlnd_protocol_com_refresh_command *) cmd;
+       zend_uchar bits[1];
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_refresh_run");
+       int1store(bits, command->context.options);
+
+       ret = conn->m->send_command_do_request(conn, COM_REFRESH, bits, 1, FALSE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_REFRESH, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_refresh_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_refresh_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_refresh_command * command;
+       DBG_ENTER("mysqlnd_com_refresh_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_refresh_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.options = va_arg(args, unsigned int);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_refresh_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_SHUTDOWN ******************************************/
+struct st_mysqlnd_protocol_com_shutdown_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_shutdown_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               uint8_t level;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_shutdown_run */
+enum_func_status
+mysqlnd_com_shutdown_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_shutdown_command * command = (struct st_mysqlnd_protocol_com_shutdown_command *) cmd;
+       zend_uchar bits[1];
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_shutdown_run");
+       int1store(bits, command->context.level);
+
+       ret = conn->m->send_command_do_request(conn, COM_SHUTDOWN, bits, 1, FALSE, TRUE);
+       if (PASS == ret) {
+               ret = conn->m->send_command_handle_response(conn, PROT_OK_PACKET, FALSE, COM_SHUTDOWN, TRUE);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_shutdown_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_shutdown_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_shutdown_command * command;
+       DBG_ENTER("mysqlnd_com_shutdown_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_shutdown_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.level = va_arg(args, unsigned int);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_shutdown_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_QUIT ******************************************/
+struct st_mysqlnd_protocol_com_quit_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_quit_context
+       {
+               MYSQLND_CONN_DATA * conn;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_quit_run */
+enum_func_status
+mysqlnd_com_quit_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_quit_command * command = (struct st_mysqlnd_protocol_com_quit_command *) cmd;
+       zend_uchar bits[1];
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_quit_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_QUIT, NULL, 0, TRUE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_quit_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_quit_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_quit_command * command;
+       DBG_ENTER("mysqlnd_com_quit_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_quit_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_quit_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+/************************** COM_QUERY ******************************************/
+struct st_mysqlnd_protocol_com_query_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_query_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING query;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_query_run */
+static enum_func_status
+mysqlnd_com_query_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_query_command * command = (struct st_mysqlnd_protocol_com_query_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_query_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_QUERY, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE, FALSE);
+
+       if (PASS == ret) {
+               CONN_SET_STATE(conn, CONN_QUERY_SENT);
+       }
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_query_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_query_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_query_command * command;
+       DBG_ENTER("mysqlnd_com_query_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_query_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.query = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_query_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+/************************** COM_CHANGE_USER ******************************************/
+struct st_mysqlnd_protocol_com_change_user_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_change_user_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING payload;
+               zend_bool silent;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_change_user_run */
+static enum_func_status
+mysqlnd_com_change_user_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_change_user_command * command = (struct st_mysqlnd_protocol_com_change_user_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_change_user_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_CHANGE_USER, (zend_uchar*) command->context.payload.s, command->context.payload.l, command->context.silent, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_change_user_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_change_user_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_change_user_command * command;
+       DBG_ENTER("mysqlnd_com_change_user_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_change_user_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.payload = va_arg(args, MYSQLND_CSTRING);
+               command->context.silent = va_arg(args, unsigned int);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_change_user_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_REAP_RESULT ******************************************/
+struct st_mysqlnd_protocol_com_reap_result_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_reap_result_context
+       {
+               MYSQLND_CONN_DATA * conn;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_reap_result_run */
+static enum_func_status
+mysqlnd_com_reap_result_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_reap_result_command * command = (struct st_mysqlnd_protocol_com_reap_result_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+       enum_mysqlnd_connection_state state = CONN_GET_STATE(conn);
+
+       DBG_ENTER("mysqlnd_com_reap_result_run");
+       if (state <= CONN_READY || state == CONN_QUIT_SENT) {
+               php_error_docref(NULL, E_WARNING, "Connection not opened, clear or has been closed");
+               DBG_ERR_FMT("Connection not opened, clear or has been closed. State=%u", state);
+               DBG_RETURN(ret);
+       }
+       ret = conn->m->query_read_result_set_header(conn, NULL);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_reap_result_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_reap_result_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_reap_result_command * command;
+       DBG_ENTER("mysqlnd_com_reap_result_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_reap_result_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_reap_result_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_PREPARE ******************************************/
+struct st_mysqlnd_protocol_com_stmt_prepare_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_prepare_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING query;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_prepare_run */
+static enum_func_status
+mysqlnd_com_stmt_prepare_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_stmt_prepare_command * command = (struct st_mysqlnd_protocol_com_stmt_prepare_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_prepare_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_STMT_PREPARE, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_prepare_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_prepare_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_prepare_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_prepare_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_prepare_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.query = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_prepare_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_EXECUTE ******************************************/
+struct st_mysqlnd_protocol_com_stmt_execute_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_execute_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING payload;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_execute_run */
+static enum_func_status
+mysqlnd_com_stmt_execute_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_stmt_execute_command * command = (struct st_mysqlnd_protocol_com_stmt_execute_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_execute_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_STMT_EXECUTE, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, FALSE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_execute_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_execute_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_execute_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_execute_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_execute_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.payload = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_execute_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_FETCH ******************************************/
+struct st_mysqlnd_protocol_com_stmt_fetch_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_fetch_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING payload;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_fetch_run */
+static enum_func_status
+mysqlnd_com_stmt_fetch_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_stmt_fetch_command * command = (struct st_mysqlnd_protocol_com_stmt_fetch_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_fetch_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_STMT_FETCH, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_fetch_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_fetch_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_fetch_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_fetch_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_fetch_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.payload = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_fetch_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_RESET ******************************************/
+struct st_mysqlnd_protocol_com_stmt_reset_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_reset_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               zend_ulong stmt_id;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_reset_run */
+static enum_func_status
+mysqlnd_com_stmt_reset_run(void *cmd)
+{
+       zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
+       struct st_mysqlnd_protocol_com_stmt_reset_command * command = (struct st_mysqlnd_protocol_com_stmt_reset_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_reset_run");
+
+       int4store(cmd_buf, command->context.stmt_id);
+       ret = conn->m->send_command_do_request(conn, COM_STMT_RESET, cmd_buf, sizeof(cmd_buf), FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_reset_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_reset_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_reset_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_reset_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_reset_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.stmt_id = va_arg(args, size_t);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_reset_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_SEND_LONG_DATA ******************************************/
+struct st_mysqlnd_protocol_com_stmt_send_long_data_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_send_long_data_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               MYSQLND_CSTRING payload;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_send_long_data_run */
+static enum_func_status
+mysqlnd_com_stmt_send_long_data_run(void *cmd)
+{
+       struct st_mysqlnd_protocol_com_stmt_send_long_data_command * command = (struct st_mysqlnd_protocol_com_stmt_send_long_data_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_send_long_data_run");
+
+       ret = conn->m->send_command_do_request(conn, COM_STMT_SEND_LONG_DATA, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_send_long_data_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_send_long_data_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_send_long_data_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_send_long_data_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_send_long_data_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.payload = va_arg(args, MYSQLND_CSTRING);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_send_long_data_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/************************** COM_STMT_CLOSE ******************************************/
+struct st_mysqlnd_protocol_com_stmt_close_command
+{
+       struct st_mysqlnd_protocol_command parent;
+       struct st_mysqlnd_com_stmt_close_context
+       {
+               MYSQLND_CONN_DATA * conn;
+               zend_ulong stmt_id;
+       } context;
+};
+
+
+/* {{{ mysqlnd_com_stmt_close_run */
+static enum_func_status
+mysqlnd_com_stmt_close_run(void *cmd)
+{
+       zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
+       struct st_mysqlnd_protocol_com_stmt_close_command * command = (struct st_mysqlnd_protocol_com_stmt_close_command *) cmd;
+       enum_func_status ret = FAIL;
+       MYSQLND_CONN_DATA * conn = command->context.conn;
+
+       DBG_ENTER("mysqlnd_com_stmt_close_run");
+
+       int4store(cmd_buf, command->context.stmt_id);
+       ret = conn->m->send_command_do_request(conn, COM_STMT_CLOSE, cmd_buf, sizeof(cmd_buf), FALSE, TRUE);
+
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_com_stmt_close_create_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_com_stmt_close_create_command(va_list args)
+{
+       struct st_mysqlnd_protocol_com_stmt_close_command * command;
+       DBG_ENTER("mysqlnd_com_stmt_close_create_command");
+       command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_stmt_close_command));
+       if (command) {
+               command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
+               command->context.stmt_id = va_arg(args, size_t);
+
+               command->parent.free_command = mysqlnd_com_no_params_free_command;
+               command->parent.run = mysqlnd_com_stmt_close_run;
+       }
+
+       DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_get_command */
+static struct st_mysqlnd_protocol_command *
+mysqlnd_get_command(enum php_mysqlnd_server_command command, ...)
+{
+       struct st_mysqlnd_protocol_command * ret;
+       va_list args;
+       DBG_ENTER("mysqlnd_get_command");
+
+       va_start(args, command);
+       switch (command) {
+               case COM_SET_OPTION:
+                       ret = mysqlnd_com_set_option_create_command(args);
+                       break;
+               case COM_DEBUG:
+                       ret = mysqlnd_com_debug_create_command(args);
+                       break;
+               case COM_INIT_DB:
+                       ret = mysqlnd_com_init_db_create_command(args);
+                       break;
+               case COM_PING:
+                       ret = mysqlnd_com_ping_create_command(args);
+                       break;
+               case COM_FIELD_LIST:
+                       ret = mysqlnd_com_field_list_create_command(args);
+                       break;
+               case COM_STATISTICS:
+                       ret = mysqlnd_com_statistics_create_command(args);
+                       break;
+               case COM_PROCESS_KILL:
+                       ret = mysqlnd_com_process_kill_create_command(args);
+                       break;
+               case COM_REFRESH:
+                       ret = mysqlnd_com_refresh_create_command(args);
+                       break;
+               case COM_SHUTDOWN:
+                       ret = mysqlnd_com_shutdown_create_command(args);
+                       break;
+               case COM_QUIT:
+                       ret = mysqlnd_com_quit_create_command(args);
+                       break;
+               case COM_QUERY:
+                       ret = mysqlnd_com_query_create_command(args);
+                       break;
+               case COM_REAP_RESULT:
+                       ret = mysqlnd_com_reap_result_create_command(args);
+                       break;
+               case COM_CHANGE_USER:
+                       ret = mysqlnd_com_change_user_create_command(args);
+                       break;
+               case COM_STMT_PREPARE:
+                       ret = mysqlnd_com_stmt_prepare_create_command(args);
+                       break;
+               case COM_STMT_EXECUTE:
+                       ret = mysqlnd_com_stmt_execute_create_command(args);
+                       break;
+               case COM_STMT_FETCH:
+                       ret = mysqlnd_com_stmt_fetch_create_command(args);
+                       break;
+               case COM_STMT_RESET:
+                       ret = mysqlnd_com_stmt_reset_create_command(args);
+                       break;
+               case COM_STMT_SEND_LONG_DATA:
+                       ret = mysqlnd_com_stmt_send_long_data_create_command(args);
+                       break;
+               case COM_STMT_CLOSE:
+                       ret = mysqlnd_com_stmt_close_create_command(args);
+                       break;
+               default:
+                       break;
+       }
+       va_end(args);
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+func_mysqlnd__command_factory mysqlnd_command_factory = mysqlnd_get_command;
+
 /*
  * Local variables:
  * tab-width: 4