diff options
Diffstat (limited to 'ext/mysqlnd/mysqlnd_connection.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_connection.c | 75 |
1 files changed, 8 insertions, 67 deletions
diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index d034fb0ca3..4d25488ee6 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -146,7 +146,7 @@ MYSQLND_CLASS_METHODS_END; /* {{{ mysqlnd_error_info_init */ -PHPAPI enum_func_status +PHPAPI void mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent) { DBG_ENTER("mysqlnd_error_info_init"); @@ -155,7 +155,7 @@ mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persist zend_llist_init(&info->error_list, sizeof(MYSQLND_ERROR_LIST_ELEMENT), (llist_dtor_func_t) mysqlnd_error_list_pdtor, persistent); info->persistent = persistent; - DBG_RETURN(PASS); + DBG_VOID_RETURN; } /* }}} */ @@ -456,7 +456,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands)(MYSQLND_CONN_DATA * con } do { if (conn->last_query_type == QUERY_SELECT) { - MYSQLND_RES * result = conn->m->use_result(conn, 0); + MYSQLND_RES * result = conn->m->use_result(conn); if (result) { result->m.free_result(result, TRUE); } @@ -709,17 +709,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, conn->connect_or_select_db.l = database.l; conn->connect_or_select_db.s = mnd_pestrndup(database.s, conn->connect_or_select_db.l, conn->persistent); - if (!conn->username.s || !conn->password.s|| !conn->connect_or_select_db.s) { - SET_OOM_ERROR(conn->error_info); - goto err; /* OOM */ - } - if (!unix_socket && !named_pipe) { conn->hostname.s = mnd_pestrndup(hostname.s, hostname.l, conn->persistent); - if (!conn->hostname.s) { - SET_OOM_ERROR(conn->error_info); - goto err; /* OOM */ - } conn->hostname.l = hostname.l; { char *p; @@ -730,10 +721,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, } conn->host_info = mnd_pestrdup(p, conn->persistent); mnd_sprintf_free(p); - if (!conn->host_info) { - SET_OOM_ERROR(conn->error_info); - goto err; /* OOM */ - } } } else { conn->unix_socket.s = mnd_pestrdup(socket_or_pipe.s, conn->persistent); @@ -746,12 +733,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, SET_OOM_ERROR(conn->error_info); goto err; /* OOM */ } - conn->host_info = mnd_pestrdup(p, conn->persistent); + conn->host_info = mnd_pestrdup(p, conn->persistent); mnd_sprintf_free(p); - if (!conn->host_info) { - SET_OOM_ERROR(conn->error_info); - goto err; /* OOM */ - } } else { php_error_docref(NULL, E_WARNING, "Impossible. Should be either socket or a pipe. Report a bug!"); } @@ -945,7 +928,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, list_method)(MYSQLND_CONN_DATA * conn, const c } if (PASS == conn->m->query(conn, show_query, show_query_len)) { - result = conn->m->store_result(conn, MYSQLND_STORE_NO_COPY); + result = conn->m->store_result(conn); } if (show_query != query) { mnd_sprintf_free(show_query); @@ -1653,11 +1636,9 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c case MYSQL_SERVER_PUBLIC_KEY: ret = conn->protocol_frame_codec->data->m.set_client_option(conn->protocol_frame_codec, option, value); break; -#ifdef MYSQLND_STRING_TO_INT_CONVERSION case MYSQLND_OPT_INT_AND_FLOAT_NATIVE: conn->options->int_and_float_native = *(unsigned int*) value; break; -#endif case MYSQL_OPT_LOCAL_INFILE: if (value && (*(unsigned int*) value) ? 1 : 0) { conn->options->flags |= CLIENT_LOCAL_FILES; @@ -1672,14 +1653,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c /* when num_commands is 0, then realloc will be effectively a malloc call, internally */ /* Don't assign to conn->options->init_commands because in case of OOM we will lose the pointer and leak */ new_init_commands = mnd_perealloc(conn->options->init_commands, sizeof(char *) * (conn->options->num_commands + 1), conn->persistent); - if (!new_init_commands) { - goto oom; - } conn->options->init_commands = new_init_commands; new_command = mnd_pestrdup(value, conn->persistent); - if (!new_command) { - goto oom; - } conn->options->init_commands[conn->options->num_commands] = new_command; ++conn->options->num_commands; break; @@ -1702,9 +1677,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c } new_charset_name = mnd_pestrdup(value, conn->persistent); - if (!new_charset_name) { - goto oom; - } if (conn->options->charset_name) { mnd_pefree(conn->options->charset_name, conn->persistent); } @@ -1740,9 +1712,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c case MYSQLND_OPT_AUTH_PROTOCOL: { char * new_auth_protocol = value? mnd_pestrdup(value, conn->persistent) : NULL; - if (value && !new_auth_protocol) { - goto oom; - } if (conn->options->auth_protocol) { mnd_pefree(conn->options->auth_protocol, conn->persistent); } @@ -1781,9 +1750,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c } conn->m->local_tx_end(conn, this_func, ret); DBG_RETURN(ret); -oom: - SET_OOM_ERROR(conn->error_info); - conn->m->local_tx_end(conn, this_func, FAIL); end: DBG_RETURN(FAIL); } @@ -1811,9 +1777,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons if (!conn->options->connect_attr) { DBG_INF("Initializing connect_attr hash"); conn->options->connect_attr = mnd_pemalloc(sizeof(HashTable), conn->persistent); - if (!conn->options->connect_attr) { - goto oom; - } zend_hash_init(conn->options->connect_attr, 0, NULL, conn->persistent ? ZVAL_INTERNAL_PTR_DTOR : ZVAL_PTR_DTOR, conn->persistent); } DBG_INF_FMT("Adding [%s][%s]", key, value); @@ -1839,9 +1802,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons } conn->m->local_tx_end(conn, this_func, ret); DBG_RETURN(ret); -oom: - SET_OOM_ERROR(conn->error_info); - conn->m->local_tx_end(conn, this_func, FAIL); end: DBG_RETURN(FAIL); } @@ -1850,7 +1810,7 @@ end: /* {{{ mysqlnd_conn_data::use_result */ static MYSQLND_RES * -MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn, const unsigned int flags) +MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn) { const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), use_result); MYSQLND_RES * result = NULL; @@ -1892,7 +1852,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn, co /* {{{ mysqlnd_conn_data::store_result */ static MYSQLND_RES * -MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn, const unsigned int flags) +MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn) { const size_t this_func = STRUCT_OFFSET(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data), store_result); MYSQLND_RES * result = NULL; @@ -1902,7 +1862,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn, if (PASS == conn->m->local_tx_start(conn, this_func)) { do { - unsigned int f = flags; if (!conn->current_result) { break; } @@ -1915,25 +1874,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn, } MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_BUFFERED_SETS); - - /* overwrite */ - if ((conn->m->get_client_api_capabilities(conn) & MYSQLND_CLIENT_KNOWS_RSET_COPY_DATA)) { - if (MYSQLND_G(fetch_data_copy)) { - f &= ~MYSQLND_STORE_NO_COPY; - f |= MYSQLND_STORE_COPY; - } - } else { - /* if for some reason PDO borks something */ - if (!(f & (MYSQLND_STORE_NO_COPY | MYSQLND_STORE_COPY))) { - f |= MYSQLND_STORE_COPY; - } - } - if (!(f & (MYSQLND_STORE_NO_COPY | MYSQLND_STORE_COPY))) { - SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Unknown fetch mode"); - DBG_ERR("Unknown fetch mode"); - break; - } - result = conn->current_result->m.store_result(conn->current_result, conn, f); + result = conn->current_result->m.store_result(conn->current_result, conn, NULL); if (!result) { conn->current_result->m.free_result(conn->current_result, TRUE); } |