summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2015-10-19 18:20:28 +0200
committerAndrey Hristov <andrey@php.net>2015-11-12 16:19:16 +0100
commit10d4fb8a9428d2b84ac6093bb3987ef667916fd4 (patch)
tree47689094460b0b0cc008d839e67d43a32ef187d6 /ext/mysqlnd/mysqlnd.c
parente24dc94f325476e8921d8447970a27b9305d93c6 (diff)
downloadphp-git-10d4fb8a9428d2b84ac6093bb3987ef667916fd4.tar.gz
MDNR:
- Refactor the command factory. Let the factory be exchangeable.
Diffstat (limited to 'ext/mysqlnd/mysqlnd.c')
-rw-r--r--ext/mysqlnd/mysqlnd.c1069
1 files changed, 12 insertions, 1057 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index a4a5294f40..001956e8a0 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -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