From: Georg Richter Date: Mon, 1 Nov 2004 07:19:26 +0000 (+0000) Subject: Fixed tests for empty dates (see http://bugs.mysql.com/?id=6058) X-Git-Tag: RELEASE_0_2~778 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8863135a2202013c48d2933c61183279e44ae60;p=php Fixed tests for empty dates (see http://bugs.mysql.com/?id=6058) Fixed memleak in mysqli_stmt_bind_result Fixed error handling for mysqli_multi_query --- diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 3d333bcbfa..4e3dda9d3f 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -217,6 +217,16 @@ PHP_FUNCTION(mysqli_stmt_bind_result) zval *mysql_stmt; MYSQL_BIND *bind; + if (getThis()) { + start = 0; + } + + if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { + return; + } + + MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt"); + if (argc < (getThis() ? 1 : 2)) { WRONG_PARAM_COUNT; } @@ -228,16 +238,6 @@ PHP_FUNCTION(mysqli_stmt_bind_result) WRONG_PARAM_COUNT; } - if (getThis()) { - start = 0; - } - - if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt"); - var_cnt = argc - start; if (var_cnt != mysql_stmt_field_count(stmt->stmt)) { diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index cf6fe7960c..0429281675 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -222,8 +222,23 @@ PHP_FUNCTION(mysqli_multi_query) MYSQLI_ENABLE_MQ; if (mysql_real_query(mysql->mysql, query, query_len)) { - MYSQLI_DISABLE_MQ; + char s_error[MYSQL_ERRMSG_SIZE], s_sqlstate[SQLSTATE_LENGTH+1]; + unsigned int s_errno; MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); + + /* we have to save error information, cause + MYSQLI_DISABLE_MQ will reset error information */ + strcpy(s_error, mysql_error(mysql->mysql)); + strcpy(s_sqlstate, mysql_sqlstate(mysql->mysql)); + s_errno = mysql_errno(mysql->mysql); + + MYSQLI_DISABLE_MQ; + + /* restore error information */ + strcpy(mysql->mysql->net.last_error, s_error); + strcpy(mysql->mysql->net.sqlstate, s_sqlstate); + mysql->mysql->net.last_errno = s_errno; + RETURN_FALSE; } RETURN_TRUE; diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt index 5535e9fb40..906bf28dec 100644 --- a/ext/mysqli/tests/003.phpt +++ b/ext/mysqli/tests/003.phpt @@ -50,7 +50,7 @@ array(7) { [4]=> string(19) "2010-07-10 00:00:00" [5]=> - string(0) "" + string(19) "0000-00-00 00:00:00" [6]=> string(19) "1999-12-29 00:00:00" } diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt index 5aa244329f..d08930fed9 100644 --- a/ext/mysqli/tests/020.phpt +++ b/ext/mysqli/tests/020.phpt @@ -58,7 +58,7 @@ array(7) { [4]=> string(19) "2010-07-10 00:00:00" [5]=> - string(0) "" + string(19) "0000-00-00 00:00:00" [6]=> string(19) "1999-12-29 00:00:00" }