]> granicus.if.org Git - php/commitdiff
mysqlnd_error_info_init() cannot fail
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 14 Dec 2020 11:31:45 +0000 (12:31 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 14 Dec 2020 11:31:45 +0000 (12:31 +0100)
ext/mysqlnd/mysqlnd_connection.c
ext/mysqlnd/mysqlnd_connection.h
ext/mysqlnd/mysqlnd_driver.c
ext/mysqlnd/mysqlnd_result.c

index 1c7e25dbb5d745d80c82cd4a6412360f8c17b011..21eb7e703be5d61625448ae2d57c0666e69738af 100644 (file)
@@ -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;
 }
 /* }}} */
 
index 795ec3c5ea3928b1093b2afcf3d1a4caa124f670..412913e6a74a0e3e3a1ea9fc38959d7e5d209d8e 100644 (file)
@@ -65,7 +65,7 @@ void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status);
        }
 
 
-PHPAPI enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent);
+PHPAPI void mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent);
 PHPAPI void    mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info);
 
 #define GET_CONNECTION_STATE(state_struct)             (state_struct)->m->get((state_struct))
index 61a03fea29c744f7522c08bf2e320089318309c9..d5e2dc7cd610c2a5bb5be842f4cbbbbabd9f2664 100644 (file)
@@ -116,10 +116,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(MYSQLND_CLASS_METHODS_TYP
        new_object->m = mysqlnd_conn_get_methods();
        data = new_object->data;
 
-       if (FAIL == mysqlnd_error_info_init(&data->error_info_impl, persistent)) {
-               new_object->m->dtor(new_object);
-               DBG_RETURN(NULL);
-       }
+       mysqlnd_error_info_init(&data->error_info_impl, persistent);
        data->error_info = &data->error_info_impl;
 
        data->options = &(data->options_impl);
@@ -191,44 +188,29 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
        MYSQLND_STMT_DATA * stmt = NULL;
 
        DBG_ENTER("mysqlnd_object_factory::get_prepared_statement");
-       do {
-               ret->m = mysqlnd_stmt_get_methods();
+       ret->m = mysqlnd_stmt_get_methods();
 
-               stmt = ret->data = mnd_ecalloc(1, sizeof(MYSQLND_STMT_DATA));
-               DBG_INF_FMT("stmt=%p", stmt);
+       stmt = ret->data = mnd_ecalloc(1, sizeof(MYSQLND_STMT_DATA));
+       DBG_INF_FMT("stmt=%p", stmt);
 
-               if (FAIL == mysqlnd_error_info_init(&stmt->error_info_impl, 0)) {
-                       break;
-               }
-               stmt->error_info = &stmt->error_info_impl;
-
-               mysqlnd_upsert_status_init(&stmt->upsert_status_impl);
-               stmt->upsert_status = &(stmt->upsert_status_impl);
-               stmt->state = MYSQLND_STMT_INITTED;
-               stmt->execute_cmd_buffer.length = 4096;
-               stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length);
-               if (!stmt->execute_cmd_buffer.buffer) {
-                       break;
-               }
+       mysqlnd_error_info_init(&stmt->error_info_impl, 0);
+       stmt->error_info = &stmt->error_info_impl;
 
-               stmt->prefetch_rows = MYSQLND_DEFAULT_PREFETCH_ROWS;
+       mysqlnd_upsert_status_init(&stmt->upsert_status_impl);
+       stmt->upsert_status = &(stmt->upsert_status_impl);
+       stmt->state = MYSQLND_STMT_INITTED;
+       stmt->execute_cmd_buffer.length = 4096;
+       stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length);
+       stmt->prefetch_rows = MYSQLND_DEFAULT_PREFETCH_ROWS;
 
-               /*
-                 Mark that we reference the connection, thus it won't be
-                 be destructed till there is open statements. The last statement
-                 or normal query result will close it then.
-               */
-               stmt->conn = conn->m->get_reference(conn);
+       /*
+         Mark that we reference the connection, thus it won't be
+         be destructed till there is open statements. The last statement
+         or normal query result will close it then.
+       */
+       stmt->conn = conn->m->get_reference(conn);
 
-               DBG_RETURN(ret);
-       } while (0);
-
-       SET_OOM_ERROR(conn->error_info);
-       if (ret) {
-               ret->m->dtor(ret, TRUE);
-               ret = NULL;
-       }
-       DBG_RETURN(NULL);
+       DBG_RETURN(ret);
 }
 /* }}} */
 
index 277b3204f7a92da7e8782a784d11cf114531789d..bfcff5a088d508e578ecb51890ff932d4d7f507f 100644 (file)
@@ -1388,17 +1388,9 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
 
        if (flags & MYSQLND_STORE_NO_COPY) {
                result->stored_data     = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result, 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, 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;
        }
        ret = result->m.store_result_fetch_data(conn, result, result->meta, row_buffers, flags & MYSQLND_STORE_PS);
@@ -1965,9 +1957,7 @@ mysqlnd_result_buffered_zval_init(MYSQLND_RES * result, const unsigned int field
        ret = pool->get_chunk(pool, alloc_size);
        memset(ret, 0, alloc_size);
 
-       if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) {
-               DBG_RETURN(NULL);
-       }
+       mysqlnd_error_info_init(&ret->error_info, /* persistent */ 0);
 
        ret->lengths = pool->get_chunk(pool, field_count * sizeof(size_t));
        memset(ret->lengths, 0, field_count * sizeof(size_t));
@@ -2006,9 +1996,7 @@ mysqlnd_result_buffered_c_init(MYSQLND_RES * result, const unsigned int field_co
        ret = pool->get_chunk(pool, alloc_size);
        memset(ret, 0, alloc_size);
 
-       if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) {
-               DBG_RETURN(NULL);
-       }
+       mysqlnd_error_info_init(&ret->error_info, /* persistent */ 0);
 
        ret->lengths = pool->get_chunk(pool, field_count * sizeof(size_t));
        memset(ret->lengths, 0, field_count * sizeof(size_t));