summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mysql/php_mysql.c12
-rw-r--r--ext/mysqli/mysqli_api.c10
-rw-r--r--ext/mysqli/mysqli_prop.c9
-rw-r--r--ext/mysqlnd/mysqlnd.c7
-rw-r--r--ext/mysqlnd/mysqlnd.h2
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h2
-rw-r--r--ext/pdo_mysql/mysql_driver.c9
7 files changed, 24 insertions, 27 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 6518f8d36a..30cac98b65 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -1310,11 +1310,13 @@ PHP_FUNCTION(mysql_stat)
{
php_mysql_conn *mysql;
zval *mysql_link = NULL;
+#ifndef MYSQL_USE_MYSQLND
char *stat;
-#ifdef MYSQL_USE_MYSQLND
- uint stat_len;
+#else
+ zend_string *stat;
#endif
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
return;
}
@@ -1332,10 +1334,8 @@ PHP_FUNCTION(mysql_stat)
if ((stat = (char *)mysql_stat(mysql->conn))) {
RETURN_STRING(stat);
#else
- if (mysqlnd_stat(mysql->conn, &stat, &stat_len) == PASS) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL(stat, stat_len);
- efree(stat);
+ if (mysqlnd_stat(mysql->conn, &stat) == PASS) {
+ RETURN_STR(stat);
#endif
} else {
RETURN_FALSE;
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 195eb41b5c..19f12417fe 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -2262,9 +2262,10 @@ PHP_FUNCTION(mysqli_stat)
{
MY_MYSQL *mysql;
zval *mysql_link;
- char *stat;
#if defined(MYSQLI_USE_MYSQLND)
- uint stat_len;
+ zend_string *stat;
+#else
+ char *stat;
#endif
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
@@ -2277,10 +2278,9 @@ PHP_FUNCTION(mysqli_stat)
{
RETURN_STRING(stat);
#else
- if (mysqlnd_stat(mysql->mysql, &stat, &stat_len) == PASS)
+ if (mysqlnd_stat(mysql->mysql, &stat) == PASS)
{
- RETVAL_STRINGL(stat, stat_len);
- efree(stat);
+ RETURN_STR(stat);
#endif
} else {
RETURN_FALSE;
diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c
index b772511647..cd0639d98f 100644
--- a/ext/mysqli/mysqli_prop.c
+++ b/ext/mysqli/mysqli_prop.c
@@ -250,14 +250,13 @@ static zval *link_stat_read(mysqli_object *obj, zval *retval TSRMLS_DC)
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (mysql) {
- char * stat_msg;
#if defined(MYSQLI_USE_MYSQLND)
- uint stat_msg_len;
- if (mysqlnd_stat(mysql->mysql, &stat_msg, &stat_msg_len) == PASS) {
- ZVAL_STRINGL(retval, stat_msg, stat_msg_len);
- efree(stat_msg);
+ zend_string * stat_msg;
+ if (mysqlnd_stat(mysql->mysql, &stat_msg) == PASS) {
+ ZVAL_STR(retval, stat_msg);
}
#else
+ char * stat_msg;
if ((stat_msg = (char *)mysql_stat(mysql->mysql))) {
ZVAL_STRING(retval, stat_msg);
}
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index e3f52c1d0d..e05d6844bc 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -1727,7 +1727,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, ping)(MYSQLND_CONN_DATA * const conn TSRMLS_DC
/* {{{ mysqlnd_conn_data::statistic */
static enum_func_status
-MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, char **message, unsigned int * message_len TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_string **message TSRMLS_DC)
{
size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, get_server_statistics);
enum_func_status ret = FAIL;
@@ -1750,9 +1750,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, char **me
if (PASS == (ret = PACKET_READ(stats_header, conn))) {
/* will be freed by Zend, thus don't use the mnd_ allocator */
- *message = estrndup(stats_header->message, stats_header->message_len);
- *message_len = stats_header->message_len;
- DBG_INF(*message);
+ *message = STR_INIT(stats_header->message, stats_header->message_len, 0);
+ DBG_INF((*message)->val);
}
PACKET_FREE(stats_header);
} while (0);
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h
index a4e54f2408..94620d9369 100644
--- a/ext/mysqlnd/mysqlnd.h
+++ b/ext/mysqlnd/mysqlnd.h
@@ -208,7 +208,7 @@ void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn);
#define mysqlnd_refresh(conn, options) ((conn)->data)->m->refresh_server((conn)->data, (options) TSRMLS_CC)
#define mysqlnd_shutdown(conn, level) ((conn)->data)->m->shutdown_server((conn)->data, (level) TSRMLS_CC)
#define mysqlnd_set_character_set(conn, cs) ((conn)->data)->m->set_charset((conn)->data, (cs) TSRMLS_CC)
-#define mysqlnd_stat(conn, msg, msg_len) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg), (msg_len) TSRMLS_CC)
+#define mysqlnd_stat(conn, msg) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg) TSRMLS_CC)
#define mysqlnd_options(conn, opt, value) ((conn)->data)->m->set_client_option((conn)->data, (opt), (value) TSRMLS_CC)
#define mysqlnd_options4(conn, opt, k, v) ((conn)->data)->m->set_client_option_2d((conn)->data, (opt), (k), (v) TSRMLS_CC)
#define mysqlnd_set_server_option(conn, op) ((conn)->data)->m->set_server_option((conn)->data, (op) TSRMLS_CC)
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index 6b4fdf80d3..9ec924ead6 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -443,7 +443,7 @@ typedef void (*func_mysqlnd_conn_data__get_statistics)(const MYSQLND_CONN_DAT
typedef unsigned long (*func_mysqlnd_conn_data__get_server_version)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef const char * (*func_mysqlnd_conn_data__get_server_information)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
-typedef enum_func_status (*func_mysqlnd_conn_data__get_server_statistics)(MYSQLND_CONN_DATA * conn, char **message, unsigned int * message_len TSRMLS_DC);
+typedef enum_func_status (*func_mysqlnd_conn_data__get_server_statistics)(MYSQLND_CONN_DATA * conn, zend_string **message TSRMLS_DC);
typedef const char * (*func_mysqlnd_conn_data__get_host_information)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef unsigned int (*func_mysqlnd_conn_data__get_protocol_information)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef const char * (*func_mysqlnd_conn_data__get_last_message)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index d7c993509f..b39fdfaaa2 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -439,14 +439,13 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value
ZVAL_STRING(return_value, (char *)mysql_get_host_info(H->server));
break;
case PDO_ATTR_SERVER_INFO: {
- char *tmp;
#if defined(PDO_USE_MYSQLND)
- unsigned int tmp_len;
+ zend_string *tmp;
- if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
- ZVAL_STRINGL(return_value, tmp, tmp_len);
- efree(tmp);
+ if (mysqlnd_stat(H->server, &tmp) == PASS) {
+ ZVAL_STR(return_value, tmp);
#else
+ char *tmp;
if ((tmp = (char *)mysql_stat(H->server))) {
ZVAL_STRING(return_value, tmp);
#endif