--- embedaddon/php/ext/mysqli/mysqli_api.c 2012/02/21 23:47:58 1.1 +++ embedaddon/php/ext/mysqli/mysqli_api.c 2014/06/15 20:03:51 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ | Ulf Wendel | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.1 2012/02/21 23:47:58 misho Exp $ + $Id: mysqli_api.c,v 1.1.1.4 2014/06/15 20:03:51 misho Exp $ */ #ifdef HAVE_CONFIG_H @@ -384,7 +384,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ** /* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */ my_bool tmp; #else - uint tmp = 0; + ulong tmp = 0; #endif stmt->result.buf[ofs].type = IS_STRING; /* @@ -535,7 +535,11 @@ PHP_FUNCTION(mysqli_change_user) old_charset = mysql->mysql->charset; #endif +#if defined(MYSQLI_USE_MYSQLND) + rc = mysqlnd_change_user_ex(mysql->mysql, user, password, dbname, FALSE, (size_t) password_len); +#else rc = mysql_change_user(mysql->mysql, user, password, dbname); +#endif MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); if (rc) { @@ -883,7 +887,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARA */ /* Even if the string is of length zero there is one byte alloced so efree() in all cases */ if (Z_TYPE_P(stmt->result.vars[i]) == IS_STRING) { - efree(stmt->result.vars[i]->value.str.val); + STR_FREE(stmt->result.vars[i]->value.str.val); } if (!stmt->result.is_null[i]) { switch (stmt->result.buf[i].type) { @@ -1047,12 +1051,12 @@ PHP_FUNCTION(mysqli_stmt_fetch) /* {{{ php_add_field_properties */ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRMLS_DC) { - add_property_string(value, "name", (char *) (field->name ? field->name : ""), 1); - add_property_string(value, "orgname", (char *) (field->org_name ? field->org_name : ""), 1); - add_property_string(value, "table", (char *) (field->table ? field->table : ""), 1); - add_property_string(value, "orgtable", (char *) (field->org_table ? field->org_table : ""), 1); - add_property_string(value, "def", (field->def ? field->def : ""), 1); - add_property_string(value, "db", (field->db ? field->db : ""), 1); + add_property_string(value, "name",(field->name ? field->name : ""), 1); + add_property_string(value, "orgname",(field->org_name ? field->org_name : ""), 1); + add_property_string(value, "table",(field->table ? field->table : ""), 1); + add_property_string(value, "orgtable",(field->org_table ? field->org_table : ""), 1); + add_property_string(value, "def",(field->def ? field->def : ""), 1); + add_property_string(value, "db",(field->db ? field->db : ""), 1); /* FIXME: manually set the catalog to "def" due to bug in * libmysqlclient which does not initialize field->catalog @@ -1287,8 +1291,11 @@ PHP_FUNCTION(mysqli_get_host_info) return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - +#if !defined(MYSQLI_USE_MYSQLND) RETURN_STRING((mysql->mysql->host_info) ? mysql->mysql->host_info : "", 1); +#else + RETURN_STRING((mysql->mysql->data->host_info) ? mysql->mysql->data->host_info : "", 1); +#endif } /* }}} */ @@ -1665,6 +1672,9 @@ static int mysqli_options_get_option_zval_type(int opt #ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT); #endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */ +#if MYSQL_VERSION_ID >= 50611 || defined(MYSQLI_USE_MYSQLND) + case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: +#endif return IS_LONG; #ifdef MYSQL_SHARED_MEMORY_BASE_NAME @@ -1800,7 +1810,7 @@ PHP_FUNCTION(mysqli_prepare) memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE); memcpy(sqlstate, mysql->mysql->net.sqlstate, SQLSTATE_LENGTH+1); #else - MYSQLND_ERROR_INFO error_info = mysql->mysql->error_info; + MYSQLND_ERROR_INFO error_info = *mysql->mysql->data->error_info; #endif mysqli_stmt_close(stmt->stmt, FALSE); stmt->stmt = NULL; @@ -1811,7 +1821,7 @@ PHP_FUNCTION(mysqli_prepare) memcpy(mysql->mysql->net.last_error, last_error, MYSQL_ERRMSG_SIZE); memcpy(mysql->mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH+1); #else - mysql->mysql->error_info = error_info; + *mysql->mysql->data->error_info = error_info; #endif } } @@ -1830,6 +1840,10 @@ PHP_FUNCTION(mysqli_prepare) efree(stmt); RETURN_FALSE; } +#ifndef MYSQLI_USE_MYSQLND + stmt->link_handle = Z_OBJ_HANDLE(*mysql_link); + zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC); +#endif mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = (void *)stmt; @@ -2358,6 +2372,10 @@ PHP_FUNCTION(mysqli_stmt_init) efree(stmt); RETURN_FALSE; } +#ifndef MYSQLI_USE_MYSQLND + stmt->link_handle = Z_OBJ_HANDLE(*mysql_link); + zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC); +#endif mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;