diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-07 12:28:51 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-11 15:49:06 +0100 |
| commit | e219ec144ef6682b71e135fd18654ee1bb4676b4 (patch) | |
| tree | e4a3ae2b619cdc9fe50ee8e1fa5adb99d804dddf /ext/mysqlnd/mysqlnd_ps.c | |
| parent | fe8fdfa3bd588d80ce60f6b3848058239e0a760f (diff) | |
| download | php-git-e219ec144ef6682b71e135fd18654ee1bb4676b4.tar.gz | |
Implement typed properties
RFC: https://wiki.php.net/rfc/typed_properties_v2
This is a squash of PR #3734, which is a squash of PR #3313.
Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
Co-authored-by: Joe Watkins <krakjoe@php.net>
Co-authored-by: Dmitry Stogov <dmitry@zend.com>
Diffstat (limited to 'ext/mysqlnd/mysqlnd_ps.c')
| -rw-r--r-- | ext/mysqlnd/mysqlnd_ps.c | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index d8671b9da0..703c1f050a 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -761,15 +761,11 @@ mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, const unsign } for (i = 0; i < result->field_count; i++) { - zval *result = &stmt->result_bind[i].zv; - - ZVAL_DEREF(result); - /* Clean what we copied last time */ - zval_ptr_dtor(result); /* copy the type */ + zval *resultzv = &stmt->result_bind[i].zv; if (stmt->result_bind[i].bound == TRUE) { DBG_INF_FMT("i=%u type=%u", i, Z_TYPE(current_row[i])); - ZVAL_COPY(result, ¤t_row[i]); + ZEND_TRY_ASSIGN_COPY_EX(resultzv, ¤t_row[i], 0); } } } @@ -849,17 +845,15 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi } for (i = 0; i < field_count; i++) { + zval *resultzv = &stmt->result_bind[i].zv; if (stmt->result_bind[i].bound == TRUE) { zval *data = &result->unbuf->last_row_data[i]; - zval *result = &stmt->result_bind[i].zv; if (Z_TYPE_P(data) == IS_STRING && (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))){ meta->fields[i].max_length = Z_STRLEN_P(data); } - ZVAL_DEREF(result); - zval_ptr_dtor(result); - ZVAL_COPY_VALUE(result, data); + ZEND_TRY_ASSIGN_VALUE_EX(resultzv, data, 0); /* copied data, thus also the ownership. Thus null data */ ZVAL_NULL(data); } @@ -1025,12 +1019,10 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, const unsigned /* If no result bind, do nothing. We consumed the data */ for (i = 0; i < field_count; i++) { + zval *resultzv = &stmt->result_bind[i].zv; if (stmt->result_bind[i].bound == TRUE) { zval *data = &result->unbuf->last_row_data[i]; - zval *result = &stmt->result_bind[i].zv; - ZVAL_DEREF(result); - zval_ptr_dtor(result); DBG_INF_FMT("i=%u bound_var=%p type=%u refc=%u", i, &stmt->result_bind[i].zv, Z_TYPE_P(data), Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->result_bind[i].zv) : 0); @@ -1040,7 +1032,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, const unsigned meta->fields[i].max_length = Z_STRLEN_P(data); } - ZVAL_COPY_VALUE(result, data); + ZEND_TRY_ASSIGN_VALUE_EX(resultzv, data, 0); /* copied data, thus also the ownership. Thus null data */ ZVAL_NULL(data); } @@ -1120,28 +1112,6 @@ MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const s, zend_bool * const fe SET_EMPTY_ERROR(stmt->error_info); SET_EMPTY_ERROR(conn->error_info); - DBG_INF_FMT("result_bind=%p separated_once=%u", &stmt->result_bind, stmt->result_zvals_separated_once); - /* - The user might have not bound any variables for result. - Do the binding once she does it. - */ - if (stmt->result_bind && !stmt->result_zvals_separated_once) { - unsigned int i; - /* - mysqlnd_stmt_store_result() has been called free the bind - variables to prevent leaking of their previous content. - */ - for (i = 0; i < stmt->result->field_count; i++) { - if (stmt->result_bind[i].bound == TRUE) { - zval *result = &stmt->result_bind[i].zv; - ZVAL_DEREF(result); - zval_ptr_dtor(result); - ZVAL_NULL(result); - } - } - stmt->result_zvals_separated_once = TRUE; - } - ret = stmt->result->m.fetch_row(stmt->result, (void*)s, 0, fetched_anything); DBG_RETURN(ret); } @@ -1537,7 +1507,6 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const s, } mysqlnd_stmt_separate_result_bind(s); - stmt->result_zvals_separated_once = FALSE; stmt->result_bind = result_bind; for (i = 0; i < stmt->field_count; i++) { /* Prevent from freeing */ |
