diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/pdo/pdo_stmt.c | 8 | ||||
-rw-r--r-- | ext/pdo_mysql/mysql_driver.c | 25 | ||||
-rw-r--r-- | ext/pdo_mysql/mysql_statement.c | 56 | ||||
-rw-r--r-- | ext/pdo_mysql/php_pdo_mysql_int.h | 30 |
4 files changed, 60 insertions, 59 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index a0a3a8b5fc..bb8a95eaff 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -404,13 +404,9 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s /* allocate storage for the parameter, keyed by its "canonical" name */ if (param->name) { - zval *zv; - zv = zend_hash_update_mem(hash, param->name, param, sizeof(struct pdo_bound_param_data)); - pparam = Z_PTR_P(zv); + pparam = zend_hash_update_mem(hash, param->name, param, sizeof(struct pdo_bound_param_data)); } else { - zval *zv; - zv = zend_hash_index_update_mem(hash, param->paramno, param, sizeof(struct pdo_bound_param_data)); - pparam = Z_PTR_P(zv); + pparam = zend_hash_index_update_mem(hash, param->paramno, param, sizeof(struct pdo_bound_param_data)); } /* tell the driver we just created a parameter */ diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 2201620817..fcc395d65a 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -376,26 +376,31 @@ static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_D switch (attr) { case PDO_ATTR_AUTOCOMMIT: convert_to_boolean(val); - /* ignore if the new value equals the old one */ - if (dbh->auto_commit ^ Z_BVAL_P(val)) { - dbh->auto_commit = Z_BVAL_P(val); + if (dbh->auto_commit ^ (Z_TYPE_P(val) == IS_TRUE)) { + dbh->auto_commit = (Z_TYPE_P(val) == IS_TRUE); mysql_handle_autocommit(dbh TSRMLS_CC); } PDO_DBG_RETURN(1); case PDO_MYSQL_ATTR_USE_BUFFERED_QUERY: - ((pdo_mysql_db_handle *)dbh->driver_data)->buffered = Z_BVAL_P(val); + convert_to_boolean(val); + /* ignore if the new value equals the old one */ + ((pdo_mysql_db_handle *)dbh->driver_data)->buffered = (Z_TYPE_P(val) == IS_TRUE); PDO_DBG_RETURN(1); case PDO_MYSQL_ATTR_DIRECT_QUERY: case PDO_ATTR_EMULATE_PREPARES: - ((pdo_mysql_db_handle *)dbh->driver_data)->emulate_prepare = Z_BVAL_P(val); + convert_to_boolean(val); + /* ignore if the new value equals the old one */ + ((pdo_mysql_db_handle *)dbh->driver_data)->emulate_prepare = (Z_TYPE_P(val) == IS_TRUE); PDO_DBG_RETURN(1); case PDO_ATTR_FETCH_TABLE_NAMES: - ((pdo_mysql_db_handle *)dbh->driver_data)->fetch_table_names = Z_BVAL_P(val); + convert_to_boolean(val); + ((pdo_mysql_db_handle *)dbh->driver_data)->fetch_table_names = (Z_TYPE_P(val) == IS_TRUE); PDO_DBG_RETURN(1); #ifndef PDO_USE_MYSQLND case PDO_MYSQL_ATTR_MAX_BUFFER_SIZE: + convert_to_long(val); if (Z_LVAL_P(val) < 0) { /* TODO: Johannes, can we throw a warning here? */ ((pdo_mysql_db_handle *)dbh->driver_data)->max_buffer_size = 1024*1024; @@ -423,15 +428,15 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value PDO_DBG_INF_FMT("attr=%l", attr); switch (attr) { case PDO_ATTR_CLIENT_VERSION: - ZVAL_STRING(return_value, (char *)mysql_get_client_info(), 1); + ZVAL_STRING(return_value, (char *)mysql_get_client_info()); break; case PDO_ATTR_SERVER_VERSION: - ZVAL_STRING(return_value, (char *)mysql_get_server_info(H->server), 1); + ZVAL_STRING(return_value, (char *)mysql_get_server_info(H->server)); break; case PDO_ATTR_CONNECTION_STATUS: - ZVAL_STRING(return_value, (char *)mysql_get_host_info(H->server), 1); + ZVAL_STRING(return_value, (char *)mysql_get_host_info(H->server)); break; case PDO_ATTR_SERVER_INFO: { char *tmp; @@ -442,7 +447,7 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value ZVAL_STRINGL(return_value, tmp, tmp_len, 0); #else if ((tmp = (char *)mysql_stat(H->server))) { - ZVAL_STRING(return_value, tmp, 1); + ZVAL_STRING(return_value, tmp); #endif } else { pdo_mysql_error(dbh); diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 1830a46c13..e2b0c40a12 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -342,7 +342,9 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ { pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_db_handle *H = S->H; +#if PDO_USE_MYSQLND long row_count; +#endif PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset"); PDO_DBG_INF_FMT("stmt=%p", S->stmt); @@ -493,7 +495,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da b = (PDO_MYSQL_PARAM_BIND*)param->driver_data; *b->is_null = 0; if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL || - Z_TYPE_P(param->parameter) == IS_NULL) { + Z_TYPE(param->parameter) == IS_NULL) { *b->is_null = 1; b->buffer_type = MYSQL_TYPE_STRING; b->buffer = NULL; @@ -508,14 +510,12 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da PDO_DBG_RETURN(0); case PDO_PARAM_LOB: PDO_DBG_INF("PDO_PARAM_LOB"); - if (Z_TYPE_P(param->parameter) == IS_RESOURCE) { + if (Z_TYPE(param->parameter) == IS_RESOURCE) { php_stream *stm; php_stream_from_zval_no_verify(stm, ¶m->parameter); if (stm) { SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter); - Z_TYPE_P(param->parameter) = IS_STRING; - Z_STRLEN_P(param->parameter) = php_stream_copy_to_mem(stm, - &Z_STRVAL_P(param->parameter), PHP_STREAM_COPY_ALL, 0); + ZVAL_STR(¶m->parameter, php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0)); } else { pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC); return 0; @@ -529,20 +529,20 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da #if PDO_USE_MYSQLND /* Is it really correct to check the zval's type? - But well, that's what the old code below does, too */ - PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE_P(param->parameter)); - switch (Z_TYPE_P(param->parameter)) { + PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE(param->parameter)); + switch (Z_TYPE(param->parameter)) { case IS_STRING: - mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, param->parameter, MYSQL_TYPE_VAR_STRING); + mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, ¶m->parameter, MYSQL_TYPE_VAR_STRING); break; case IS_LONG: #if SIZEOF_LONG==8 - mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, param->parameter, MYSQL_TYPE_LONGLONG); + mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, ¶m->parameter, MYSQL_TYPE_LONGLONG); #elif SIZEOF_LONG==4 - mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, param->parameter, MYSQL_TYPE_LONG); + mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, ¶m->parameter, MYSQL_TYPE_LONG); #endif /* SIZEOF_LONG */ break; case IS_DOUBLE: - mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, param->parameter, MYSQL_TYPE_DOUBLE); + mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, ¶m->parameter, MYSQL_TYPE_DOUBLE); break; default: PDO_DBG_RETURN(0); @@ -550,23 +550,23 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da PDO_DBG_RETURN(1); #else - PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE_P(param->parameter)); - switch (Z_TYPE_P(param->parameter)) { + PDO_DBG_INF_FMT("param->parameter->type=%d", Z_TYPE(param->parameter)); + switch (Z_TYPE(param->parameter)) { case IS_STRING: b->buffer_type = MYSQL_TYPE_STRING; - b->buffer = Z_STRVAL_P(param->parameter); - b->buffer_length = Z_STRLEN_P(param->parameter); - *b->length = Z_STRLEN_P(param->parameter); + b->buffer = Z_STRVAL(param->parameter); + b->buffer_length = Z_STRLEN(param->parameter); + *b->length = Z_STRLEN(param->parameter); PDO_DBG_RETURN(1); case IS_LONG: b->buffer_type = MYSQL_TYPE_LONG; - b->buffer = &Z_LVAL_P(param->parameter); + b->buffer = &Z_LVAL(param->parameter); PDO_DBG_RETURN(1); case IS_DOUBLE: b->buffer_type = MYSQL_TYPE_DOUBLE; - b->buffer = &Z_DVAL_P(param->parameter); + b->buffer = &Z_DVAL(param->parameter); PDO_DBG_RETURN(1); default: @@ -807,7 +807,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va { pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; const MYSQL_FIELD *F; - zval *flags; + zval flags; char *str; PDO_DBG_ENTER("pdo_mysql_stmt_col_meta"); @@ -821,8 +821,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va } array_init(return_value); - MAKE_STD_ZVAL(flags); - array_init(flags); + array_init(&flags); F = S->fields + colno; @@ -830,19 +829,19 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va add_assoc_string(return_value, "mysql:def", F->def); } if (IS_NOT_NULL(F->flags)) { - add_next_index_string(flags, "not_null"); + add_next_index_string(&flags, "not_null"); } if (IS_PRI_KEY(F->flags)) { - add_next_index_string(flags, "primary_key"); + add_next_index_string(&flags, "primary_key"); } if (F->flags & MULTIPLE_KEY_FLAG) { - add_next_index_string(flags, "multiple_key"); + add_next_index_string(&flags, "multiple_key"); } if (F->flags & UNIQUE_KEY_FLAG) { - add_next_index_string(flags, "unique_key"); + add_next_index_string(&flags, "unique_key"); } if (IS_BLOB(F->flags)) { - add_next_index_string(flags, "blob"); + add_next_index_string(&flags, "blob"); } str = type_to_name_native(F->type); if (str) { @@ -868,8 +867,9 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va } #endif - add_assoc_zval(return_value, "flags", flags); - add_assoc_string(return_value, "table", (char *) (F->table?F->table:"")); + add_assoc_zval(return_value, "flags", &flags); + add_assoc_string(return_value, "table", (char *) (F->table?F->table : "")); + PDO_DBG_RETURN(SUCCESS); } /* }}} */ diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index 26263222b9..4455dcbeb6 100644 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -118,31 +118,31 @@ typedef struct { typedef struct { pdo_mysql_db_handle *H; - MYSQL_RES *result; - const MYSQL_FIELD *fields; - MYSQL_ROW current_data; + MYSQL_RES *result; + const MYSQL_FIELD *fields; + MYSQL_ROW current_data; #if PDO_USE_MYSQLND - unsigned long *current_lengths; + unsigned long *current_lengths; #else - long *current_lengths; + long *current_lengths; #endif - pdo_mysql_error_info einfo; + pdo_mysql_error_info einfo; #if PDO_USE_MYSQLND - MYSQLND_STMT *stmt; + MYSQLND_STMT *stmt; #else - MYSQL_STMT *stmt; + MYSQL_STMT *stmt; #endif - int num_params; + int num_params; PDO_MYSQL_PARAM_BIND *params; #ifndef PDO_USE_MYSQLND - my_bool *in_null; - unsigned long *in_length; + my_bool *in_null; + unsigned long *in_length; #endif PDO_MYSQL_PARAM_BIND *bound_result; - my_bool *out_null; - unsigned long *out_length; - unsigned int params_given; - unsigned max_length:1; + my_bool *out_null; + unsigned long *out_length; + unsigned int params_given; + unsigned max_length:1; } pdo_mysql_stmt; extern pdo_driver_t pdo_mysql_driver; |