diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-11-02 03:27:25 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-11-02 03:27:25 +0300 |
commit | a7305eb539596e175bd6c3ae9a20953358c5d677 (patch) | |
tree | 2f3c4fe063b1f204231facf5c4d9cdf21808c0ae | |
parent | 468fd78bff6d97776f12fe84b946e47a4c16040f (diff) | |
download | php-git-a7305eb539596e175bd6c3ae9a20953358c5d677.tar.gz |
Made "result", "statement" and "last_message" to always use Zend MM heap. (even for persistent connections these entities don't relive request boundary)
-rw-r--r-- | ext/mysqlnd/mysqlnd_auth.c | 2 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_commands.c | 16 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_connection.c | 22 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_connection.h | 10 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_driver.c | 12 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_loaddata.c | 3 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps.c | 41 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 78 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result.h | 8 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result_meta.c | 42 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result_meta.h | 2 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_structs.h | 22 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.c | 29 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.h | 2 |
14 files changed, 132 insertions, 157 deletions
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index a721781a14..5c295cbfc1 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -339,7 +339,7 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, goto end; } - SET_NEW_MESSAGE(conn->last_message.s, conn->last_message.l, auth_resp_packet->message, auth_resp_packet->message_len, conn->persistent); + SET_NEW_MESSAGE(conn->last_message.s, conn->last_message.l, auth_resp_packet->message, auth_resp_packet->message_len); ret = PASS; end: PACKET_FREE(change_auth_resp_packet); diff --git a/ext/mysqlnd/mysqlnd_commands.c b/ext/mysqlnd/mysqlnd_commands.c index 9bea4358ea..3f3635bf93 100644 --- a/ext/mysqlnd/mysqlnd_commands.c +++ b/ext/mysqlnd/mysqlnd_commands.c @@ -83,7 +83,7 @@ mysqlnd_com_set_option_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_EOF_PACKET, FALSE, COM_SET_OPTION, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } DBG_RETURN(ret); } @@ -132,7 +132,7 @@ mysqlnd_com_debug_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_EOF_PACKET, FALSE, COM_DEBUG, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } DBG_RETURN(ret); @@ -193,7 +193,7 @@ mysqlnd_com_init_db_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_INIT_DB, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } /* @@ -261,7 +261,7 @@ mysqlnd_com_ping_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, TRUE, COM_PING, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } /* The server sends 0 but libmysql doesn't read it and has established @@ -400,7 +400,7 @@ mysqlnd_com_process_kill_run(void *cmd) conn); if (PASS == ret && read_response) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } if (read_response) { @@ -474,7 +474,7 @@ mysqlnd_com_refresh_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_REFRESH, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } DBG_RETURN(ret); @@ -537,7 +537,7 @@ mysqlnd_com_shutdown_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_SHUTDOWN, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } DBG_RETURN(ret); @@ -990,7 +990,7 @@ mysqlnd_com_stmt_reset_run(void *cmd) conn); if (PASS == ret) { ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_STMT_RESET, TRUE, - conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent); + conn->error_info, conn->upsert_status, &conn->last_message); } DBG_RETURN(ret); diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index a788c45774..9bc3c851e4 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -102,7 +102,7 @@ MYSQLND_METHOD(mysqlnd_error_info, reset)(MYSQLND_ERROR_INFO * const info) info->error_no = 0; info->error[0] = '\0'; - memset(info->sqlstate, 0, sizeof(info->sqlstate)); + memset(&info->sqlstate, 0, sizeof(info->sqlstate)); if (info->error_list) { zend_llist_clean(info->error_list); } @@ -409,11 +409,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, restart_psession)(MYSQLND_CONN_DATA * conn) { DBG_ENTER("mysqlnd_conn_data::restart_psession"); MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CONNECT_REUSED); - /* Free here what should not be seen by the next script */ - if (conn->last_message.s) { - mnd_pefree(conn->last_message.s, conn->persistent); - conn->last_message.s = NULL; - } + conn->current_result = NULL; + conn->last_message.s = NULL; DBG_RETURN(PASS); } /* }}} */ @@ -424,6 +421,16 @@ static enum_func_status MYSQLND_METHOD(mysqlnd_conn_data, end_psession)(MYSQLND_CONN_DATA * conn) { DBG_ENTER("mysqlnd_conn_data::end_psession"); + /* Free here what should not be seen by the next script */ + if (conn->current_result) { + conn->current_result->m.free_result(conn->current_result, TRUE); + conn->current_result = NULL; + } + if (conn->last_message.s) { + mnd_efree(conn->last_message.s); + conn->last_message.s = NULL; + } + conn->error_info = &conn->error_info_impl; DBG_RETURN(PASS); } /* }}} */ @@ -1864,6 +1871,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), conn->persistent)); GC_MAKE_PERSISTENT_LOCAL(Z_COUNTED(attrz)); zend_hash_update(conn->options->connect_attr, str, &attrz); + zend_string_release(str); } break; default: @@ -2324,7 +2332,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, stmt_init)(MYSQLND_CONN_DATA * const conn) { MYSQLND_STMT * ret; DBG_ENTER("mysqlnd_conn_data::stmt_init"); - ret = conn->object_factory.get_prepared_statement(conn, conn->persistent); + ret = conn->object_factory.get_prepared_statement(conn); DBG_RETURN(ret); } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_connection.h b/ext/mysqlnd/mysqlnd_connection.h index 6d0efb99ab..92933e7174 100644 --- a/ext/mysqlnd/mysqlnd_connection.h +++ b/ext/mysqlnd/mysqlnd_connection.h @@ -44,23 +44,23 @@ void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status); /* Error handling */ -#define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \ +#define SET_NEW_MESSAGE(buf, buf_len, message, len) \ {\ if ((buf)) { \ - mnd_pefree((buf), (persistent)); \ + mnd_efree((buf)); \ } \ if ((message)) { \ - (buf) = mnd_pestrndup((message), (len), (persistent)); \ + (buf) = mnd_pestrndup((message), (len), 0); \ } else { \ (buf) = NULL; \ } \ (buf_len) = (len); \ } -#define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \ +#define SET_EMPTY_MESSAGE(buf, buf_len) \ {\ if ((buf)) { \ - mnd_pefree((buf), (persistent)); \ + mnd_efree((buf)); \ (buf) = NULL; \ } \ (buf_len) = 0; \ diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index 6db86c96b3..5ff8a0a235 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -186,10 +186,10 @@ MYSQLND_METHOD(mysqlnd_object_factory, clone_connection_object)(MYSQLND * to_be_ /* {{{ mysqlnd_object_factory::get_prepared_statement */ static MYSQLND_STMT * -MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA * const conn, const zend_bool persistent) +MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA * const conn) { size_t alloc_size = sizeof(MYSQLND_STMT) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_STMT * ret = mnd_pecalloc(1, alloc_size, conn->persistent); + MYSQLND_STMT * ret = mnd_ecalloc(1, alloc_size); MYSQLND_STMT_DATA * stmt = NULL; DBG_ENTER("mysqlnd_object_factory::get_prepared_statement"); @@ -198,16 +198,14 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA break; } ret->m = mysqlnd_stmt_get_methods(); - ret->persistent = conn->persistent; - stmt = ret->data = mnd_pecalloc(1, sizeof(MYSQLND_STMT_DATA), persistent); + stmt = ret->data = mnd_ecalloc(1, sizeof(MYSQLND_STMT_DATA)); DBG_INF_FMT("stmt=%p", stmt); if (!stmt) { break; } - stmt->persistent = persistent; - if (FAIL == mysqlnd_error_info_init(&stmt->error_info_impl, persistent)) { + if (FAIL == mysqlnd_error_info_init(&stmt->error_info_impl, 0)) { break; } stmt->error_info = &stmt->error_info_impl; @@ -216,7 +214,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA stmt->upsert_status = &(stmt->upsert_status_impl); stmt->state = MYSQLND_STMT_INITTED; stmt->execute_cmd_buffer.length = 4096; - stmt->execute_cmd_buffer.buffer = mnd_pemalloc(stmt->execute_cmd_buffer.length, stmt->persistent); + stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length); if (!stmt->execute_cmd_buffer.buffer) { break; } diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index 0ad5a4acb4..2bbcab99d6 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -216,8 +216,7 @@ infile_error: PROT_OK_PACKET, FALSE, COM_QUERY, FALSE, conn->error_info, conn->upsert_status, - &conn->last_message, - conn->persistent)) { + &conn->last_message)) { result = FAIL; } diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 41c024ab16..77e5840fe3 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -82,7 +82,7 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s) result->type = MYSQLND_RES_PS_BUF; /* result->m.row_decoder = php_mysqlnd_rowp_read_binary_protocol; */ - result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result->field_count, TRUE, result->persistent); + result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result->field_count, TRUE); if (!result->stored_data) { SET_OOM_ERROR(conn->error_info); DBG_RETURN(NULL); @@ -122,7 +122,7 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s) } else { COPY_CLIENT_ERROR(conn->error_info, result->stored_data->error_info); stmt->result->m.free_result_contents(stmt->result); - mnd_pefree(stmt->result, stmt->result->persistent); + mnd_efree(stmt->result); stmt->result = NULL; stmt->state = MYSQLND_STMT_PREPARED; } @@ -167,13 +167,13 @@ MYSQLND_METHOD(mysqlnd_stmt, get_result)(MYSQLND_STMT * const s) MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_BUFFERED_SETS); do { - result = conn->m->result_init(stmt->result->field_count, stmt->persistent); + result = conn->m->result_init(stmt->result->field_count); if (!result) { SET_OOM_ERROR(conn->error_info); break; } - result->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE); + result->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta); if (!result->meta) { SET_OOM_ERROR(conn->error_info); break; @@ -347,7 +347,7 @@ mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT * s) if (FAIL == (ret = PACKET_READ(fields_eof))) { if (stmt->result) { stmt->result->m.free_result_contents(stmt->result); - mnd_pefree(stmt->result, stmt->result->persistent); + mnd_efree(stmt->result); /* XXX: This will crash, because we will null also the methods. But seems it happens in extreme cases or doesn't. Should be fixed by exporting a function (from mysqlnd_driver.c?) to do the reset. @@ -444,7 +444,7 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const s, const char * const no metadata at prepare. */ if (stmt_to_prepare->field_count) { - MYSQLND_RES * result = conn->m->result_init(stmt_to_prepare->field_count, stmt_to_prepare->persistent); + MYSQLND_RES * result = conn->m->result_init(stmt_to_prepare->field_count); if (!result) { SET_OOM_ERROR(conn->error_info); goto fail; @@ -1543,7 +1543,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const s, unsigne if (stmt->param_count) { if (!stmt->param_bind) { - stmt->param_bind = mnd_pecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND), stmt->persistent); + stmt->param_bind = mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND)); if (!stmt->param_bind) { DBG_RETURN(FAIL); } @@ -1691,9 +1691,9 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_result)(MYSQLND_STMT * const s, unsigned i mysqlnd_stmt_separate_one_result_bind(s, param_no); /* Guaranteed is that stmt->result_bind is NULL */ if (!stmt->result_bind) { - stmt->result_bind = mnd_pecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND), stmt->persistent); + stmt->result_bind = mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND)); } else { - stmt->result_bind = mnd_perealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND), stmt->persistent); + stmt->result_bind = mnd_erealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND)); } if (!stmt->result_bind) { DBG_RETURN(FAIL); @@ -1868,17 +1868,17 @@ MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const s) be handled in a better way. */ do { - result_meta = conn->m->result_init(stmt->field_count, stmt->persistent); + result_meta = conn->m->result_init(stmt->field_count); if (!result_meta) { break; } result_meta->type = MYSQLND_RES_NORMAL; - result_meta->unbuf = mysqlnd_result_unbuffered_init(stmt->field_count, TRUE, result_meta->persistent); + result_meta->unbuf = mysqlnd_result_unbuffered_init(stmt->field_count, TRUE); if (!result_meta->unbuf) { break; } result_meta->unbuf->eof_reached = TRUE; - result_meta->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE); + result_meta->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta); if (!result_meta->meta) { break; } @@ -2132,7 +2132,7 @@ MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(MYSQLND_STMT * const s) } if (stmt->error_info->error_list) { zend_llist_clean(stmt->error_info->error_list); - mnd_pefree(stmt->error_info->error_list, s->persistent); + mnd_efree(stmt->error_info->error_list); stmt->error_info->error_list = NULL; } @@ -2252,7 +2252,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, close_on_server)(MYSQLND_STMT * const s, ze } if (stmt->execute_cmd_buffer.buffer) { - mnd_pefree(stmt->execute_cmd_buffer.buffer, stmt->persistent); + mnd_efree(stmt->execute_cmd_buffer.buffer); stmt->execute_cmd_buffer.buffer = NULL; } @@ -2273,7 +2273,6 @@ MYSQLND_METHOD(mysqlnd_stmt, dtor)(MYSQLND_STMT * const s, zend_bool implicit) { MYSQLND_STMT_DATA * stmt = (s != NULL) ? s->data:NULL; enum_func_status ret = FAIL; - zend_bool persistent = (s != NULL) ? s->persistent : 0; DBG_ENTER("mysqlnd_stmt::dtor"); if (stmt) { @@ -2283,9 +2282,9 @@ MYSQLND_METHOD(mysqlnd_stmt, dtor)(MYSQLND_STMT * const s, zend_bool implicit) STAT_STMT_CLOSE_EXPLICIT); ret = s->m->close_on_server(s, implicit); - mnd_pefree(stmt, persistent); + mnd_efree(stmt); } - mnd_pefree(s, persistent); + mnd_efree(s); DBG_INF(ret == PASS? "PASS":"FAIL"); DBG_RETURN(ret); @@ -2302,7 +2301,7 @@ MYSQLND_METHOD(mysqlnd_stmt, alloc_param_bind)(MYSQLND_STMT * const s) if (!stmt) { DBG_RETURN(NULL); } - DBG_RETURN(mnd_pecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND), stmt->persistent)); + DBG_RETURN(mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND))); } /* }}} */ @@ -2316,7 +2315,7 @@ MYSQLND_METHOD(mysqlnd_stmt, alloc_result_bind)(MYSQLND_STMT * const s) if (!stmt) { DBG_RETURN(NULL); } - DBG_RETURN(mnd_pecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND), stmt->persistent)); + DBG_RETURN(mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND))); } /* }}} */ @@ -2327,7 +2326,7 @@ MYSQLND_METHOD(mysqlnd_stmt, free_parameter_bind)(MYSQLND_STMT * const s, MYSQLN { MYSQLND_STMT_DATA * stmt = s? s->data : NULL; if (stmt) { - mnd_pefree(param_bind, stmt->persistent); + mnd_efree(param_bind); } } /* }}} */ @@ -2339,7 +2338,7 @@ MYSQLND_METHOD(mysqlnd_stmt, free_result_bind)(MYSQLND_STMT * const s, MYSQLND_R { MYSQLND_STMT_DATA * stmt = s? s->data : NULL; if (stmt) { - mnd_pefree(result_bind, stmt->persistent); + mnd_efree(result_bind); } } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 22d70f52bb..13c7b65271 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -184,7 +184,7 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, free_result)(MYSQLND_RES_UNBUFFERED * result->m.free_last_data(result, global_stats); if (result->lengths) { - mnd_pefree(result->lengths, result->persistent); + mnd_efree(result->lengths); result->lengths = NULL; } @@ -200,7 +200,7 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, free_result)(MYSQLND_RES_UNBUFFERED * } - mnd_pefree(result, result->persistent); + mnd_efree(result); DBG_VOID_RETURN; } /* }}} */ @@ -242,7 +242,7 @@ static void MYSQLND_METHOD(mysqlnd_result_buffered_c, free_result)(MYSQLND_RES_BUFFERED_C * const set) { DBG_ENTER("mysqlnd_result_buffered_c::free_result"); - mnd_pefree(set->initialized, set->persistent); + mnd_efree(set->initialized); set->initialized = NULL; DBG_VOID_RETURN; } @@ -274,7 +274,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered, free_result)(MYSQLND_RES_BUFFERED * cons } if (set->lengths) { - mnd_pefree(set->lengths, set->persistent); + mnd_efree(set->lengths); set->lengths = NULL; } @@ -290,7 +290,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered, free_result)(MYSQLND_RES_BUFFERED * cons set->row_count = 0; - mnd_pefree(set, set->persistent); + mnd_efree(set); DBG_VOID_RETURN; } @@ -349,7 +349,7 @@ void MYSQLND_METHOD(mysqlnd_res, free_result_internal)(MYSQLND_RES * result) result->conn = NULL; } - mnd_pefree(result, result->persistent); + mnd_efree(result); DBG_VOID_RETURN; } @@ -373,7 +373,7 @@ MYSQLND_METHOD(mysqlnd_res, read_result_metadata)(MYSQLND_RES * result, MYSQLND_ result->meta = NULL; } - result->meta = result->m.result_meta_init(result->field_count, result->persistent); + result->meta = result->m.result_meta_init(result->field_count); if (!result->meta) { SET_OOM_ERROR(conn->error_info); DBG_RETURN(FAIL); @@ -409,7 +409,6 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) MYSQLND_STMT_DATA * stmt = s ? s->data : NULL; MYSQLND_PACKET_RSET_HEADER * rset_header = NULL; MYSQLND_PACKET_EOF * fields_eof = NULL; - const zend_bool persistent = conn->persistent; DBG_ENTER("mysqlnd_query_read_result_set_header"); DBG_INF_FMT("stmt=%lu", stmt? stmt->stmt_id:0); @@ -476,8 +475,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) UPSERT_STATUS_SET_AFFECTED_ROWS(conn->upsert_status, rset_header->affected_rows); UPSERT_STATUS_SET_LAST_INSERT_ID(conn->upsert_status, rset_header->last_insert_id); SET_NEW_MESSAGE(conn->last_message.s, conn->last_message.l, - rset_header->info_or_local_file.s, rset_header->info_or_local_file.l, - persistent); + rset_header->info_or_local_file.s, rset_header->info_or_local_file.l); /* Result set can follow UPSERT statement, check server_status */ if (UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_status) & SERVER_MORE_RESULTS_EXISTS) { SET_CONNECTION_STATE(&conn->state, CONN_NEXT_RESULT_PENDING); @@ -492,7 +490,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) enum_mysqlnd_collected_stats statistic = STAT_LAST; DBG_INF("Result set pending"); - SET_EMPTY_MESSAGE(conn->last_message.s, conn->last_message.l, persistent); + SET_EMPTY_MESSAGE(conn->last_message.s, conn->last_message.l); MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_RSET_QUERY); UPSERT_STATUS_RESET(conn->upsert_status); @@ -504,7 +502,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) /* PS has already allocated it */ conn->field_count = rset_header->field_count; if (!stmt) { - result = conn->current_result = conn->m->result_init(rset_header->field_count, persistent); + result = conn->current_result = conn->m->result_init(rset_header->field_count); } else { if (!stmt->result) { DBG_INF("This is 'SHOW'/'EXPLAIN'-like query."); @@ -513,7 +511,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) prepared statements can't send result set metadata for these queries on prepare stage. Read it now. */ - result = stmt->result = conn->m->result_init(rset_header->field_count, stmt->persistent); + result = stmt->result = conn->m->result_init(rset_header->field_count); } else { /* Update result set metadata if it for some reason changed between @@ -948,7 +946,7 @@ MYSQLND_METHOD(mysqlnd_res, use_result)(MYSQLND_RES * const result, const zend_b result->type = MYSQLND_RES_PS_UNBUF; } - result->unbuf = mysqlnd_result_unbuffered_init(result->field_count, ps, result->persistent); + result->unbuf = mysqlnd_result_unbuffered_init(result->field_count, ps); if (!result->unbuf) { goto oom; } @@ -1426,14 +1424,14 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result, SET_CONNECTION_STATE(&conn->state, CONN_FETCHING_DATA); if (flags & MYSQLND_STORE_NO_COPY) { - result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result->field_count, flags & MYSQLND_STORE_PS, result->persistent); + result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result->field_count, flags & MYSQLND_STORE_PS); if (!result->stored_data) { SET_OOM_ERROR(conn->error_info); DBG_RETURN(NULL); } row_buffers = &result->stored_data->row_buffers; } else if (flags & MYSQLND_STORE_COPY) { - result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_c_init(result->field_count, flags & MYSQLND_STORE_PS, result->persistent); + result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_c_init(result->field_count, flags & MYSQLND_STORE_PS); if (!result->stored_data) { SET_OOM_ERROR(conn->error_info); DBG_RETURN(NULL); @@ -1473,7 +1471,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result, } else if (flags & MYSQLND_STORE_COPY) { MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result->stored_data; set->current_row = 0; - set->initialized = mnd_pecalloc((unsigned int) ((set->row_count / 8) + 1), sizeof(zend_uchar), set->persistent); /* +1 for safety */ + set->initialized = mnd_ecalloc((unsigned int) ((set->row_count / 8) + 1), sizeof(zend_uchar)); /* +1 for safety */ } } @@ -1920,10 +1918,10 @@ MYSQLND_CLASS_METHODS_END; /* {{{ mysqlnd_result_init */ PHPAPI MYSQLND_RES * -mysqlnd_result_init(const unsigned int field_count, const zend_bool persistent) +mysqlnd_result_init(const unsigned int field_count) { const size_t alloc_size = sizeof(MYSQLND_RES) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_RES * ret = mnd_pecalloc(1, alloc_size, persistent); + MYSQLND_RES * ret = mnd_ecalloc(1, alloc_size); DBG_ENTER("mysqlnd_result_init"); @@ -1931,7 +1929,6 @@ mysqlnd_result_init(const unsigned int field_count, const zend_bool persistent) DBG_RETURN(NULL); } - ret->persistent = persistent; ret->field_count = field_count; ret->m = *mysqlnd_result_get_methods(); @@ -1942,27 +1939,26 @@ mysqlnd_result_init(const unsigned int field_count, const zend_bool persistent) /* {{{ mysqlnd_result_unbuffered_init */ PHPAPI MYSQLND_RES_UNBUFFERED * -mysqlnd_result_unbuffered_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent) +mysqlnd_result_unbuffered_init(const unsigned int field_count, const zend_bool ps) { const size_t alloc_size = sizeof(MYSQLND_RES_UNBUFFERED) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_RES_UNBUFFERED * ret = mnd_pecalloc(1, alloc_size, persistent); + MYSQLND_RES_UNBUFFERED * ret = mnd_ecalloc(1, alloc_size); DBG_ENTER("mysqlnd_result_unbuffered_init"); if (!ret) { DBG_RETURN(NULL); } - if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(size_t), persistent))) { - mnd_pefree(ret, persistent); + if (!(ret->lengths = mnd_ecalloc(field_count, sizeof(size_t)))) { + mnd_efree(ret); DBG_RETURN(NULL); } if (!(ret->result_set_memory_pool = mysqlnd_mempool_create(MYSQLND_G(mempool_default_size)))) { mnd_efree(ret->lengths); - mnd_pefree(ret, persistent); + mnd_efree(ret); DBG_RETURN(NULL); } - ret->persistent = persistent; ret->field_count= field_count; ret->ps = ps; @@ -1982,31 +1978,30 @@ mysqlnd_result_unbuffered_init(const unsigned int field_count, const zend_bool p /* {{{ mysqlnd_result_buffered_zval_init */ PHPAPI MYSQLND_RES_BUFFERED_ZVAL * -mysqlnd_result_buffered_zval_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent) +mysqlnd_result_buffered_zval_init(const unsigned int field_count, const zend_bool ps) { const size_t alloc_size = sizeof(MYSQLND_RES_BUFFERED_ZVAL) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_RES_BUFFERED_ZVAL * ret = mnd_pecalloc(1, alloc_size, persistent); + MYSQLND_RES_BUFFERED_ZVAL * ret = mnd_ecalloc(1, alloc_size); DBG_ENTER("mysqlnd_result_buffered_zval_init"); if (!ret) { DBG_RETURN(NULL); } - if (FAIL == mysqlnd_error_info_init(&ret->error_info, persistent)) { - mnd_pefree(ret, persistent); + if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) { + mnd_efree(ret); DBG_RETURN(NULL); } - if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(size_t), persistent))) { - mnd_pefree(ret, persistent); + if (!(ret->lengths = mnd_ecalloc(field_count, sizeof(size_t)))) { + mnd_efree(ret); DBG_RETURN(NULL); } if (!(ret->result_set_memory_pool = mysqlnd_mempool_create(MYSQLND_G(mempool_default_size)))) { mnd_efree(ret->lengths); - mnd_pefree(ret, persistent); + mnd_efree(ret); DBG_RETURN(NULL); } - ret->persistent = persistent; ret->field_count= field_count; ret->ps = ps; ret->m = *mysqlnd_result_buffered_get_methods(); @@ -2029,31 +2024,30 @@ mysqlnd_result_buffered_zval_init(const unsigned int field_count, const zend_boo /* {{{ mysqlnd_result_buffered_c_init */ PHPAPI MYSQLND_RES_BUFFERED_C * -mysqlnd_result_buffered_c_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent) +mysqlnd_result_buffered_c_init(const unsigned int field_count, const zend_bool ps) { const size_t alloc_size = sizeof(MYSQLND_RES_BUFFERED_C) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_RES_BUFFERED_C * ret = mnd_pecalloc(1, alloc_size, persistent); + MYSQLND_RES_BUFFERED_C * ret = mnd_ecalloc(1, alloc_size); DBG_ENTER("mysqlnd_result_buffered_c_init"); if (!ret) { DBG_RETURN(NULL); } - if (FAIL == mysqlnd_error_info_init(&ret->error_info, persistent)) { - mnd_pefree(ret, persistent); + if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) { + mnd_efree(ret); DBG_RETURN(NULL); } - if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(size_t), persistent))) { - mnd_pefree(ret, persistent); + if (!(ret->lengths = mnd_ecalloc(field_count, sizeof(size_t)))) { + mnd_efree(ret); DBG_RETURN(NULL); } if (!(ret->result_set_memory_pool = mysqlnd_mempool_create(MYSQLND_G(mempool_default_size)))) { mnd_efree(ret->lengths); - mnd_pefree(ret, persistent); + mnd_efree(ret); DBG_RETURN(NULL); } - ret->persistent = persistent; ret->field_count= field_count; ret->ps = ps; ret->m = *mysqlnd_result_buffered_get_methods(); diff --git a/ext/mysqlnd/mysqlnd_result.h b/ext/mysqlnd/mysqlnd_result.h index 24ab81f6b2..f3b84f8508 100644 --- a/ext/mysqlnd/mysqlnd_result.h +++ b/ext/mysqlnd/mysqlnd_result.h @@ -20,10 +20,10 @@ #ifndef MYSQLND_RESULT_H #define MYSQLND_RESULT_H -PHPAPI MYSQLND_RES * mysqlnd_result_init(const unsigned int field_count, const zend_bool persistent); -PHPAPI MYSQLND_RES_UNBUFFERED * mysqlnd_result_unbuffered_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent); -PHPAPI MYSQLND_RES_BUFFERED_ZVAL * mysqlnd_result_buffered_zval_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent); -PHPAPI MYSQLND_RES_BUFFERED_C * mysqlnd_result_buffered_c_init(const unsigned int field_count, const zend_bool ps, const zend_bool persistent); +PHPAPI MYSQLND_RES * mysqlnd_result_init(const unsigned int field_count); +PHPAPI MYSQLND_RES_UNBUFFERED * mysqlnd_result_unbuffered_init(const unsigned int field_count, const zend_bool ps); +PHPAPI MYSQLND_RES_BUFFERED_ZVAL * mysqlnd_result_buffered_zval_init(const unsigned int field_count, const zend_bool ps); +PHPAPI MYSQLND_RES_BUFFERED_C * mysqlnd_result_buffered_c_init(const unsigned int field_count, const zend_bool ps); enum_func_status mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * stmt); diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c index 101758c466..bdee5cf8ea 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.c +++ b/ext/mysqlnd/mysqlnd_result_meta.c @@ -30,15 +30,15 @@ /* {{{ php_mysqlnd_free_field_metadata */ static void -php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent) +php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta) { if (meta) { if (meta->root) { - mnd_pefree(meta->root, persistent); + mnd_efree(meta->root); meta->root = NULL; } if (meta->def) { - mnd_pefree(meta->def, persistent); + mnd_efree(meta->def); meta->def = NULL; } if (meta->sname) { @@ -62,13 +62,12 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met SET_OOM_ERROR(conn->error_info); DBG_RETURN(FAIL); } - field_packet->persistent_alloc = meta->persistent; for (;i < meta->field_count; i++) { zend_ulong idx; if (meta->fields[i].root) { /* We re-read metadata for PS */ - mnd_pefree(meta->fields[i].root, meta->persistent); + mnd_efree(meta->fields[i].root); meta->fields[i].root = NULL; } @@ -110,25 +109,24 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA * meta) int i; MYSQLND_FIELD *fields; DBG_ENTER("mysqlnd_res_meta::free"); - DBG_INF_FMT("persistent=%u", meta->persistent); if ((fields = meta->fields)) { DBG_INF("Freeing fields metadata"); i = meta->field_count; while (i--) { - php_mysqlnd_free_field_metadata(fields++, meta->persistent); + php_mysqlnd_free_field_metadata(fields++); } - mnd_pefree(meta->fields, meta->persistent); + mnd_efree(meta->fields); meta->fields = NULL; } if (meta->zend_hash_keys) { DBG_INF("Freeing zend_hash_keys"); - mnd_pefree(meta->zend_hash_keys, meta->persistent); + mnd_efree(meta->zend_hash_keys); meta->zend_hash_keys = NULL; } DBG_INF("Freeing metadata structure"); - mnd_pefree(meta, meta->persistent); + mnd_efree(meta); DBG_VOID_RETURN; } @@ -137,7 +135,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA * meta) /* {{{ mysqlnd_res::clone_metadata */ static MYSQLND_RES_METADATA * -MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * const meta, const zend_bool persistent) +MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * const meta) { unsigned int i; /* +1 is to have empty marker at the end */ @@ -147,21 +145,19 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co size_t len = meta->field_count * sizeof(struct mysqlnd_field_hash_key); DBG_ENTER("mysqlnd_res_meta::clone_metadata"); - DBG_INF_FMT("persistent=%u", persistent); - new_meta = mnd_pecalloc(1, sizeof(MYSQLND_RES_METADATA), persistent); + new_meta = mnd_ecalloc(1, sizeof(MYSQLND_RES_METADATA)); if (!new_meta) { goto oom; } - new_meta->persistent = persistent; new_meta->m = meta->m; - new_fields = mnd_pecalloc(meta->field_count + 1, sizeof(MYSQLND_FIELD), persistent); + new_fields = mnd_ecalloc(meta->field_count + 1, sizeof(MYSQLND_FIELD)); if (!new_fields) { goto oom; } - new_meta->zend_hash_keys = mnd_pemalloc(len, persistent); + new_meta->zend_hash_keys = mnd_emalloc(len); if (!new_meta->zend_hash_keys) { goto oom; } @@ -174,7 +170,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co memcpy(new_fields, orig_fields, (meta->field_count) * sizeof(MYSQLND_FIELD)); for (i = 0; i < meta->field_count; i++) { /* First copy the root, then field by field adjust the pointers */ - new_fields[i].root = mnd_pemalloc(orig_fields[i].root_len, persistent); + new_fields[i].root = mnd_emalloc(orig_fields[i].root_len); if (!new_fields[i].root) { goto oom; @@ -208,7 +204,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co } /* def is not on the root, if allocated at all */ if (orig_fields[i].def) { - new_fields[i].def = mnd_pemalloc(orig_fields[i].def_length + 1, persistent); + new_fields[i].def = mnd_emalloc(orig_fields[i].def_length + 1); if (!new_fields[i].def) { goto oom; } @@ -309,12 +305,11 @@ MYSQLND_CLASS_METHODS_END; /* {{{ mysqlnd_result_meta_init */ PHPAPI MYSQLND_RES_METADATA * -mysqlnd_result_meta_init(unsigned int field_count, zend_bool persistent) +mysqlnd_result_meta_init(unsigned int field_count) { size_t alloc_size = sizeof(MYSQLND_RES_METADATA) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_RES_METADATA *ret = mnd_pecalloc(1, alloc_size, persistent); + MYSQLND_RES_METADATA *ret = mnd_ecalloc(1, alloc_size); DBG_ENTER("mysqlnd_result_meta_init"); - DBG_INF_FMT("persistent=%u", persistent); do { if (!ret) { @@ -322,11 +317,10 @@ mysqlnd_result_meta_init(unsigned int field_count, zend_bool persistent) } ret->m = & mysqlnd_mysqlnd_res_meta_methods; - ret->persistent = persistent; ret->field_count = field_count; /* +1 is to have empty marker at the end */ - ret->fields = mnd_pecalloc(field_count + 1, sizeof(MYSQLND_FIELD), ret->persistent); - ret->zend_hash_keys = mnd_pecalloc(field_count, sizeof(struct mysqlnd_field_hash_key), ret->persistent); + ret->fields = mnd_ecalloc(field_count + 1, sizeof(MYSQLND_FIELD)); + ret->zend_hash_keys = mnd_ecalloc(field_count, sizeof(struct mysqlnd_field_hash_key)); if (!ret->fields || !ret->zend_hash_keys) { break; } diff --git a/ext/mysqlnd/mysqlnd_result_meta.h b/ext/mysqlnd/mysqlnd_result_meta.h index 42a900e22f..475795fe30 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.h +++ b/ext/mysqlnd/mysqlnd_result_meta.h @@ -21,7 +21,7 @@ #ifndef MYSQLND_RESULT_META_H #define MYSQLND_RESULT_META_H -PHPAPI MYSQLND_RES_METADATA * mysqlnd_result_meta_init(unsigned int field_count, zend_bool persistent); +PHPAPI MYSQLND_RES_METADATA * mysqlnd_result_meta_init(unsigned int field_count); PHPAPI struct st_mysqlnd_res_meta_methods * mysqlnd_result_metadata_get_methods(); PHPAPI void ** _mysqlnd_plugin_get_plugin_result_metadata_data(const MYSQLND_RES_METADATA * meta, unsigned int plugin_id); diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 230ac573d5..a57e91c824 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -370,7 +370,7 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory); typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) * factory, const zend_bool persistent); typedef MYSQLND * (*func_mysqlnd_object_factory__clone_connection_object)(MYSQLND * conn); -typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn, const zend_bool persistent); +typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn); typedef MYSQLND_PFC * (*func_mysqlnd_object_factory__get_pfc)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); typedef MYSQLND_VIO * (*func_mysqlnd_object_factory__get_vio)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); typedef MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * (*func_mysqlnd_object_factory__get_protocol_payload_decoder_factory)(MYSQLND_CONN_DATA * conn, const zend_bool persistent); @@ -451,7 +451,7 @@ typedef enum_func_status (*func_mysqlnd_conn_data__send_close)(MYSQLND_CONN_DATA typedef enum_func_status (*func_mysqlnd_conn_data__ssl_set)(MYSQLND_CONN_DATA * const conn, const char * key, const char * const cert, const char * const ca, const char * const capath, const char * const cipher); -typedef MYSQLND_RES * (*func_mysqlnd_conn_data__result_init)(unsigned int field_count, zend_bool persistent); +typedef MYSQLND_RES * (*func_mysqlnd_conn_data__result_init)(unsigned int field_count); typedef enum_func_status (*func_mysqlnd_conn_data__set_autocommit)(MYSQLND_CONN_DATA * conn, unsigned int mode); typedef enum_func_status (*func_mysqlnd_conn_data__tx_commit)(MYSQLND_CONN_DATA * conn); @@ -618,7 +618,7 @@ typedef void (*func_mysqlnd_res__free_buffered_data)(MYSQLND_RES *result); typedef void (*func_mysqlnd_res__unbuffered_free_last_data)(MYSQLND_RES *result); -typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res__result_meta_init)(unsigned int field_count, zend_bool persistent); +typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res__result_meta_init)(unsigned int field_count); MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) { @@ -697,7 +697,7 @@ typedef const MYSQLND_FIELD * (*func_mysqlnd_res_meta__fetch_fields)(MYSQLND_RES typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res_meta__field_tell)(const MYSQLND_RES_METADATA * const meta); typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res_meta__field_seek)(MYSQLND_RES_METADATA * const meta, const MYSQLND_FIELD_OFFSET field_offset); typedef enum_func_status (*func_mysqlnd_res_meta__read_metadata)(MYSQLND_RES_METADATA * const meta, MYSQLND_CONN_DATA * conn); -typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res_meta__clone_metadata)(const MYSQLND_RES_METADATA * const meta, const zend_bool persistent); +typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res_meta__clone_metadata)(const MYSQLND_RES_METADATA * const meta); typedef void (*func_mysqlnd_res_meta__free_metadata)(MYSQLND_RES_METADATA * meta); MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res_meta) @@ -1005,8 +1005,7 @@ typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_c MYSQLND_ERROR_INFO * const error_info, MYSQLND_UPSERT_STATUS * const upsert_status, const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */ - MYSQLND_STRING * const last_message, - const zend_bool last_message_persistent); + MYSQLND_STRING * const last_message); typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_EOF)( MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory, @@ -1022,8 +1021,7 @@ typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_c MYSQLND_ERROR_INFO * error_info, MYSQLND_UPSERT_STATUS * upsert_status, - MYSQLND_STRING * last_message, - zend_bool last_message_persistent); + MYSQLND_STRING * last_message); MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) @@ -1152,8 +1150,6 @@ struct st_mysqlnd_result_metadata unsigned int current_field; unsigned int field_count; - - zend_bool persistent; }; @@ -1173,7 +1169,6 @@ struct st_mysqlnd_result_metadata \ unsigned int field_count; \ zend_bool ps; \ - zend_bool persistent; \ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered) m; \ enum mysqlnd_buffered_type type; \ void * unused1; \ @@ -1229,8 +1224,6 @@ struct st_mysqlnd_unbuffered_result zend_bool eof_reached; zend_bool ps; - zend_bool persistent; - }; @@ -1247,7 +1240,6 @@ struct st_mysqlnd_res MYSQLND_RES_BUFFERED *stored_data; MYSQLND_RES_UNBUFFERED *unbuf; - zend_bool persistent; MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) m; }; @@ -1279,7 +1271,6 @@ struct st_mysqlnd_stmt_data MYSQLND_PARAM_BIND *param_bind; MYSQLND_RESULT_BIND *result_bind; zend_bool result_zvals_separated_once; - zend_bool persistent; MYSQLND_UPSERT_STATUS * upsert_status; MYSQLND_UPSERT_STATUS upsert_status_impl; @@ -1307,7 +1298,6 @@ struct st_mysqlnd_stmt { MYSQLND_STMT_DATA * data; MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * m; - zend_bool persistent; }; diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index ed6931ef41..9c92ec5e36 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -1354,8 +1354,8 @@ php_mysqlnd_rset_field_read(void * _packet) len != MYSQLND_NULL_LENGTH) { BAIL_IF_NO_MORE_DATA; - DBG_INF_FMT("Def found, length %lu, persistent=%u", len, packet->persistent_alloc); - meta->def = mnd_pemalloc(len + 1, packet->persistent_alloc); + DBG_INF_FMT("Def found, length %lu", len); + meta->def = mnd_emalloc(len + 1); if (!meta->def) { SET_OOM_ERROR(error_info); DBG_RETURN(FAIL); @@ -1366,7 +1366,7 @@ php_mysqlnd_rset_field_read(void * _packet) p += len; } - root_ptr = meta->root = mnd_pemalloc(total_len, packet->persistent_alloc); + root_ptr = meta->root = mnd_emalloc(total_len); if (!root_ptr) { SET_OOM_ERROR(error_info); DBG_RETURN(FAIL); @@ -1375,7 +1375,7 @@ php_mysqlnd_rset_field_read(void * _packet) meta->root_len = total_len; if (meta->name != mysqlnd_empty_string) { - meta->sname = zend_string_init_interned(meta->name, meta->name_length, packet->persistent_alloc); + meta->sname = zend_string_init_interned(meta->name, meta->name_length, 0); } else { meta->sname = ZSTR_EMPTY_ALLOC(); } @@ -1418,7 +1418,7 @@ php_mysqlnd_rset_field_read(void * _packet) root_ptr++; } - DBG_INF_FMT("allocing root. persistent=%u", packet->persistent_alloc); + DBG_INF_FMT("allocing root."); DBG_INF_FMT("FIELD=[%s.%s.%s]", meta->db? meta->db:"*NA*", meta->table? meta->table:"*NA*", meta->name? meta->name:"*NA*"); @@ -1460,7 +1460,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc, MYSQLND_ERROR_INFO * error_info, MYSQLND_MEMORY_POOL * pool, MYSQLND_MEMORY_POOL_CHUNK ** buffer, - size_t * data_size, zend_bool persistent_alloc) + size_t * data_size) { enum_func_status ret = PASS; MYSQLND_PACKET_HEADER header; @@ -1830,8 +1830,7 @@ php_mysqlnd_rowp_read(void * _packet) DBG_ENTER("php_mysqlnd_rowp_read"); ret = php_mysqlnd_read_row_ex(pfc, vio, stats, error_info, - packet->result_set_memory_pool, &packet->row_buffer, &data_size, - packet->persistent_alloc); + packet->result_set_memory_pool, &packet->row_buffer, &data_size); if (FAIL == ret) { goto end; } @@ -1896,8 +1895,7 @@ php_mysqlnd_rowp_read(void * _packet) but mostly like old-API unbuffered and thus will populate this array with value. */ - packet->fields = mnd_pecalloc(packet->field_count, sizeof(zval), - packet->persistent_alloc); + packet->fields = mnd_ecalloc(packet->field_count, sizeof(zval)); } } else { MYSQLND_INC_CONN_STATISTIC(stats, @@ -2796,8 +2794,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_OK)( MYSQLND_ERROR_INFO * const error_info, MYSQLND_UPSERT_STATUS * const upsert_status, const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */ - MYSQLND_STRING * const last_message, - const zend_bool last_message_persistent) + MYSQLND_STRING * const last_message) { enum_func_status ret = FAIL; MYSQLND_PACKET_OK * ok_response = payload_decoder_factory->m.get_ok_packet(payload_decoder_factory, FALSE); @@ -2830,8 +2827,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_OK)( UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(upsert_status); } else { SET_NEW_MESSAGE(last_message->s, last_message->l, - ok_response->message, ok_response->message_len, - last_message_persistent); + ok_response->message, ok_response->message_len); if (!ignore_upsert_status) { UPSERT_STATUS_RESET(upsert_status); UPSERT_STATUS_SET_WARNINGS(upsert_status, ok_response->warning_count); @@ -2902,8 +2898,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_response)( MYSQLND_ERROR_INFO * error_info, MYSQLND_UPSERT_STATUS * upsert_status, - MYSQLND_STRING * last_message, - zend_bool last_message_persistent + MYSQLND_STRING * last_message ) { enum_func_status ret = FAIL; @@ -2913,7 +2908,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_response)( switch (ok_packet) { case PROT_OK_PACKET: - ret = payload_decoder_factory->m.send_command_handle_OK(payload_decoder_factory, error_info, upsert_status, ignore_upsert_status, last_message, last_message_persistent); + ret = payload_decoder_factory->m.send_command_handle_OK(payload_decoder_factory, error_info, upsert_status, ignore_upsert_status, last_message); break; case PROT_EOF_PACKET: ret = payload_decoder_factory->m.send_command_handle_EOF(payload_decoder_factory, error_info, upsert_status); diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h index 7722f8ee6b..ad6aa52409 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.h +++ b/ext/mysqlnd/mysqlnd_wireprotocol.h @@ -209,7 +209,6 @@ typedef struct st_mysqlnd_packet_res_field { MYSQLND_FIELD *metadata; /* For table definitions, empty for result sets */ zend_bool skip_parsing; - zend_bool persistent_alloc; MYSQLND_ERROR_INFO error_info; } MYSQLND_PACKET_RES_FIELD; @@ -233,7 +232,6 @@ typedef struct st_mysqlnd_packet_row { zend_bool skip_extraction; zend_bool binary_protocol; - zend_bool persistent_alloc; MYSQLND_FIELD *fields_metadata; /* If error packet, we use these */ |