[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/mysqlnd/ mysqlnd_result.c
andrey Mon, 05 Sep 2011 15:37:58 + Revision: http://svn.php.net/viewvc?view=revisionrevision=316189 Log: missing from previous commit for #55582 Bug: https://bugs.php.net/55582 (Closed) mysqli_num_rows() returns always 0 for unbuffered, when mysqlnd is used Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-09-05 15:29:45 UTC (rev 316188) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-09-05 15:37:58 UTC (rev 316189) @@ -616,19 +616,18 @@ static unsigned long * mysqlnd_fetch_lengths_unbuffered(MYSQLND_RES * const result TSRMLS_DC) { - return result-lengths; + /* simulate output of libmysql */ + return (!result-unbuf || result-unbuf-last_row_data || result-unbuf-eof_reached)? result-lengths:NULL; } /* }}} */ -#if !defined(MYSQLND_USE_OPTIMISATIONS) || MYSQLND_USE_OPTIMISATIONS == 0 /* {{{ mysqlnd_res::fetch_lengths */ PHPAPI unsigned long * _mysqlnd_fetch_lengths(MYSQLND_RES * const result TSRMLS_DC) { return result-m.fetch_lengths? result-m.fetch_lengths(result TSRMLS_CC) : NULL; } /* }}} */ -#endif /* {{{ mysqlnd_fetch_row_unbuffered_c */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c branches/PHP_5_4/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 17 May 2011 09:44:11 + Revision: http://svn.php.net/viewvc?view=revisionrevision=311122 Log: exchange a trap with an error Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-05-17 05:16:29 UTC (rev 311121) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-05-17 09:44:11 UTC (rev 311122) @@ -1583,7 +1583,7 @@ } else if (result-m.fetch_row == result-m.fetch_row_normal_unbuffered) { DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC)); } else { - *((int*)NULL) = 1; + php_error_docref(NULL TSRMLS_CC, E_ERROR, result-m.fetch_row has invalid value. Report to the developers); } } DBG_RETURN(ret); Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_result.c 2011-05-17 05:16:29 UTC (rev 311121) +++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_result.c 2011-05-17 09:44:11 UTC (rev 311122) @@ -1546,7 +1546,7 @@ } else if (result-m.fetch_row == result-m.fetch_row_normal_unbuffered) { DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC)); } else { - *((int*)NULL) = 1; + php_error_docref(NULL TSRMLS_CC, E_ERROR, result-m.fetch_row has invalid value. Report to the developers); } } DBG_RETURN(ret); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-05-17 05:16:29 UTC (rev 311121) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-05-17 09:44:11 UTC (rev 311122) @@ -1546,7 +1546,7 @@ } else if (result-m.fetch_row == result-m.fetch_row_normal_unbuffered) { DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC)); } else { - *((int*)NULL) = 1; + php_error_docref(NULL TSRMLS_CC, E_ERROR, result-m.fetch_row has invalid value. Report to the developers); } } DBG_RETURN(ret); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 22 Mar 2011 12:54:02 + Revision: http://svn.php.net/viewvc?view=revisionrevision=309557 Log: remove more unneeded includes Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-03-22 12:53:59 UTC (rev 309556) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-03-22 12:54:02 UTC (rev 309557) @@ -27,9 +27,7 @@ #include mysqlnd_result.h #include mysqlnd_result_meta.h #include mysqlnd_statistics.h -#include mysqlnd_charset.h #include mysqlnd_debug.h -#include ext/standard/basic_functions.h #define MYSQLND_SILENT Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-03-22 12:53:59 UTC (rev 309556) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-03-22 12:54:02 UTC (rev 309557) @@ -27,9 +27,7 @@ #include mysqlnd_result.h #include mysqlnd_result_meta.h #include mysqlnd_statistics.h -#include mysqlnd_charset.h #include mysqlnd_debug.h -#include ext/standard/basic_functions.h #define MYSQLND_SILENT -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 22 Mar 2011 14:39:58 + Revision: http://svn.php.net/viewvc?view=revisionrevision=309562 Log: palloc is long dead, use more appropriate name Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-03-22 14:39:36 UTC (rev 309561) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-03-22 14:39:58 UTC (rev 309562) @@ -84,11 +84,11 @@ /* }}} */ -/* {{{ mysqlnd_palloc_zval_ptr_dtor */ -static -void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) +/* {{{ mysqlnd_rset_zval_ptr_dtor */ +static void +mysqlnd_rset_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) { - DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor); + DBG_ENTER(mysqlnd_rset_zval_ptr_dtor); if (!zv || !*zv) { *copy_ctor_called = FALSE; DBG_ERR_FMT(zv was NULL); @@ -158,7 +158,7 @@ DBG_INF_FMT(%u columns to free, result-field_count); for (i = 0; i result-field_count; i++) { - mysqlnd_palloc_zval_ptr_dtor((unbuf-last_row_data[i]), result-type, copy_ctor_called TSRMLS_CC); + mysqlnd_rset_zval_ptr_dtor((unbuf-last_row_data[i]), result-type, copy_ctor_called TSRMLS_CC); if (copy_ctor_called) { ++ctor_called_count; } @@ -212,7 +212,7 @@ for (col = field_count - 1; col = 0; --col) { if (current_row[col]) { zend_bool copy_ctor_called; - mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); + mysqlnd_rset_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); #if MYSQLND_DEBUG_MEMORY DBG_INF_FMT(Copy_ctor_called=%u, copy_ctor_called); #endif Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-03-22 14:39:36 UTC (rev 309561) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-03-22 14:39:58 UTC (rev 309562) @@ -83,11 +83,11 @@ /* }}} */ -/* {{{ mysqlnd_palloc_zval_ptr_dtor */ -static -void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) +/* {{{ mysqlnd_rset_zval_ptr_dtor */ +static void +mysqlnd_rset_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) { - DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor); + DBG_ENTER(mysqlnd_rset_zval_ptr_dtor); if (!zv || !*zv) { *copy_ctor_called = FALSE; DBG_ERR_FMT(zv was NULL); @@ -155,7 +155,7 @@ MYSQLND_STATS *global_stats = result-conn? result-conn-stats:NULL; for (i = 0; i result-field_count; i++) { - mysqlnd_palloc_zval_ptr_dtor((unbuf-last_row_data[i]), result-type, copy_ctor_called TSRMLS_CC); + mysqlnd_rset_zval_ptr_dtor((unbuf-last_row_data[i]), result-type, copy_ctor_called TSRMLS_CC); if (copy_ctor_called) { ++ctor_called_count; } @@ -207,7 +207,7 @@ for (col = field_count - 1; col = 0; --col) { if (current_row[col]) { zend_bool copy_ctor_called; - mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); + mysqlnd_rset_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); if (copy_ctor_called) { ++copy_on_write_performed; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Mon, 21 Feb 2011 16:24:37 + Revision: http://svn.php.net/viewvc?view=revisionrevision=308540 Log: fix invalid memory read. Thank you, valgrind Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-02-21 15:56:25 UTC (rev 308539) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2011-02-21 16:24:37 UTC (rev 308540) @@ -1271,7 +1271,7 @@ /* libmysql's documentation says it should be so for SELECT statements */ conn-upsert_status.affected_rows = set-row_count; } - DBG_INF_FMT(ret=%s row_count=MYSQLND_LLU_SPEC warnings=%u server_status=%u, + DBG_INF_FMT(ret=%s row_count=%u warnings=%u server_status=%u, ret == PASS? PASS:FAIL, (uint) set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); end: PACKET_FREE(row_packet); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-02-21 15:56:25 UTC (rev 308539) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2011-02-21 16:24:37 UTC (rev 308540) @@ -1271,7 +1271,7 @@ /* libmysql's documentation says it should be so for SELECT statements */ conn-upsert_status.affected_rows = set-row_count; } - DBG_INF_FMT(ret=%s row_count=MYSQLND_LLU_SPEC warnings=%u server_status=%u, + DBG_INF_FMT(ret=%s row_count=%u warnings=%u server_status=%u, ret == PASS? PASS:FAIL, (uint) set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); end: PACKET_FREE(row_packet); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Thu, 16 Dec 2010 12:18:54 + Revision: http://svn.php.net/viewvc?view=revisionrevision=306405 Log: Fix sprintf modifier to be right, wrong data reported in the log Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-12-16 12:10:03 UTC (rev 306404) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-12-16 12:18:54 UTC (rev 306405) @@ -1270,8 +1270,8 @@ /* libmysql's documentation says it should be so for SELECT statements */ conn-upsert_status.affected_rows = set-row_count; } - DBG_INF_FMT(ret=%s row_count=%u warnings=%u server_status=%u, ret == PASS? PASS:FAIL, - set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); + DBG_INF_FMT(ret=%s row_count=MYSQLND_LLU_SPEC warnings=%u server_status=%u, + ret == PASS? PASS:FAIL, (uint) set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); end: PACKET_FREE(row_packet); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-12-16 12:10:03 UTC (rev 306404) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-12-16 12:18:54 UTC (rev 306405) @@ -1270,8 +1270,8 @@ /* libmysql's documentation says it should be so for SELECT statements */ conn-upsert_status.affected_rows = set-row_count; } - DBG_INF_FMT(ret=%s row_count=%u warnings=%u server_status=%u, ret == PASS? PASS:FAIL, - set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); + DBG_INF_FMT(ret=%s row_count=MYSQLND_LLU_SPEC warnings=%u server_status=%u, + ret == PASS? PASS:FAIL, (uint) set-row_count, conn-upsert_status.warning_count, conn-upsert_status.server_status); end: PACKET_FREE(row_packet); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Wed, 06 Oct 2010 07:09:37 + Revision: http://svn.php.net/viewvc?view=revisionrevision=304134 Log: more variable hiding fixes Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-06 06:17:42 UTC (rev 304133) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-06 07:09:37 UTC (rev 304134) @@ -679,7 +679,7 @@ if (!row_packet-skip_extraction) { MYSQLND_FIELD *field = result-meta-fields; - struct mysqlnd_field_hash_key *zend_hash_key = result-meta-zend_hash_keys; + struct mysqlnd_field_hash_key * hash_key = result-meta-zend_hash_keys; enum_func_status rc = result-m.row_decoder(result-unbuf-last_row_buffer, result-unbuf-last_row_data, @@ -695,7 +695,7 @@ retrow = mnd_malloc(result-field_count * sizeof(char *)); if (retrow) { -for (i = 0; i field_count; i++, field++, zend_hash_key++) { +for (i = 0; i field_count; i++, field++, hash_key++) { zval *data = result-unbuf-last_row_data[i]; unsigned int len; @@ -794,7 +794,7 @@ if (!row_packet-skip_extraction) { HashTable *row_ht = Z_ARRVAL_P(row); MYSQLND_FIELD *field = result-meta-fields; - struct mysqlnd_field_hash_key *zend_hash_key = result-meta-zend_hash_keys; + struct mysqlnd_field_hash_key * hash_key = result-meta-zend_hash_keys; unsigned int i, field_count = result-field_count; unsigned long *lengths = result-lengths; @@ -809,7 +809,7 @@ if (PASS != rc) { DBG_RETURN(FAIL); } - for (i = 0; i field_count; i++, field++, zend_hash_key++) { + for (i = 0; i field_count; i++, field++, hash_key++) { zval *data = result-unbuf-last_row_data[i]; unsigned int len = (Z_TYPE_P(data) == IS_NULL)? 0:Z_STRLEN_P(data); @@ -830,23 +830,23 @@ hashing of the column name, which is not needed as it can be precomputed. */ Z_ADDREF_P(data); - if (zend_hash_key-is_numeric == FALSE) { + if (hash_key-is_numeric == FALSE) { #if MYSQLND_UNICODE zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE, - zend_hash_key-ustr, - zend_hash_key-ulen + 1, - zend_hash_key-key, + hash_key-ustr, + hash_key-ulen + 1, + hash_key-key, (void *) data, sizeof(zval *), NULL); #else zend_hash_quick_update(Z_ARRVAL_P(row), field-name, field-name_length + 1, - zend_hash_key-key, + hash_key-key, (void *) data, sizeof(zval *), NULL); #endif } else { zend_hash_index_update(Z_ARRVAL_P(row), - zend_hash_key-key, + hash_key-key, (void *) data, sizeof(zval *), NULL); } } @@ -962,7 +962,7 @@ { zval **current_row = set-data_cursor; MYSQLND_FIELD *field = result-meta-fields; - struct mysqlnd_field_hash_key *zend_hash_key = result-meta-zend_hash_keys; + struct mysqlnd_field_hash_key * hash_key = result-meta-zend_hash_keys; unsigned int i; if (NULL == current_row[0]) { @@ -999,7 +999,7 @@ ret = mnd_malloc(result-field_count * sizeof(char *)); if (ret) { - for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { + for (i = 0; i result-field_count; i++, field++, hash_key++) { zval *data = current_row[i]; if (Z_TYPE_P(data) != IS_NULL) { @@ -1038,7 +1038,7 @@ { zval **current_row = set-data_cursor; MYSQLND_FIELD *field = result-meta-fields; - struct mysqlnd_field_hash_key *zend_hash_key = result-meta-zend_hash_keys; + struct mysqlnd_field_hash_key * hash_key = result-meta-zend_hash_keys; if (NULL == current_row[0]) { uint64_t row_num = (set-data_cursor - set-data) / result-meta-field_count; @@ -1069,7 +1069,7 @@ } } - for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { + for (i = 0; i result-field_count; i++, field++, hash_key++) { zval *data = current_row[i]; if (flags MYSQLND_FETCH_NUM) { @@ -1085,23 +1085,23 @@ hashing of the column name, which is not needed as it can be precomputed. */ Z_ADDREF_P(data); -if (zend_hash_key-is_numeric == FALSE) { +if (hash_key-is_numeric == FALSE) { #if MYSQLND_UNICODE zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE, - zend_hash_key-ustr, - zend_hash_key-ulen + 1, - zend_hash_key-key, + hash_key-ustr, + hash_key-ulen + 1, + hash_key-key, (void *) data, sizeof(zval *), NULL); #else zend_hash_quick_update(Z_ARRVAL_P(row), field-name, field-name_length + 1, - zend_hash_key-key, + hash_key-key,
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 05 Oct 2010 16:54:14 + Revision: http://svn.php.net/viewvc?view=revisionrevision=304113 Log: Fix compiler warnings - on 32bit size_t is smaller than uint64_t, although we will never hit this the compiler should be happy. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-05 16:27:49 UTC (rev 304112) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-05 16:54:14 UTC (rev 304113) @@ -1147,7 +1147,7 @@ goto end; } if (free_rows) { - set-row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache); + set-row_buffers = mnd_pemalloc((size_t)(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)), to_cache); if (!set-row_buffers) { SET_OOM_ERROR(conn-error_info); ret = FAIL; @@ -1181,8 +1181,15 @@ uint64_t total_allocated_rows = free_rows = next_extend = next_extend * 11 / 10; /* extend with 10% */ MYSQLND_MEMORY_POOL_CHUNK ** new_row_buffers; total_allocated_rows += set-row_count; + + /* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */ + if (total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *) SIZE_MAX) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } new_row_buffers = mnd_perealloc(set-row_buffers, - total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), + (size_t)(total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)), set-persistent); if (!new_row_buffers) { SET_OOM_ERROR(conn-error_info); @@ -1209,8 +1216,14 @@ } /* Overflow ? */ if (set-row_count) { + /* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */ + if (set-row_count * meta-field_count * sizeof(zval *) SIZE_MAX) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } /* if pecalloc is used valgrind barks gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux) */ - set-data = mnd_pemalloc(set-row_count * meta-field_count * sizeof(zval *), to_cache); + set-data = mnd_pemalloc((size_t)(set-row_count * meta-field_count * sizeof(zval *)), to_cache); if (!set-data) { SET_OOM_ERROR(conn-error_info); ret = FAIL; @@ -1231,8 +1244,14 @@ } /* save some memory */ if (free_rows) { + /* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */ + if (set-row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *) SIZE_MAX) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } set-row_buffers = mnd_perealloc(set-row_buffers, - set-row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), + (size_t) (set-row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)), set-persistent); } @@ -1593,7 +1612,8 @@ DBG_VOID_RETURN; } - mysqlnd_array_init(return_value, (unsigned int) set? set-row_count : 4); /* 4 is a magic value */ + /* 4 is a magic value. The cast is safe, if larger then the array will be later extended - no big deal :) */ + mysqlnd_array_init(return_value, (unsigned int) set? (uint) set-row_count : 4); do { MAKE_STD_ZVAL(row); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-10-05 16:27:49 UTC (rev
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 05 Oct 2010 17:10:47 + Revision: http://svn.php.net/viewvc?view=revisionrevision=304115 Log: two more compiler warnings fixed - size does matter Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-05 17:03:50 UTC (rev 304114) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-05 17:10:47 UTC (rev 304115) @@ -42,7 +42,7 @@ zval **data_cursor = result-stored_data? result-stored_data-data:NULL; zval **data_begin = result-stored_data? result-stored_data-data:NULL; unsigned int field_count = result-meta? result-meta-field_count : 0; - unsigned int row_count = result-stored_data? result-stored_data-row_count:0; + uint64_t row_count = result-stored_data? result-stored_data-row_count:0; enum_func_status ret = PASS; DBG_ENTER(mysqlnd_res::initialize_result_set_rest); @@ -208,10 +208,10 @@ for (row = set-row_count - 1; row = 0; row--) { zval **current_row = set-data + row * field_count; MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; - int col; + int64_t col; if (current_row != NULL) { - for (col = (int64_t) field_count - 1; col = 0; --col) { + for (col = field_count - 1; col = 0; --col) { if (current_row[col]) { zend_bool copy_ctor_called; mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-10-05 17:03:50 UTC (rev 304114) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-10-05 17:10:47 UTC (rev 304115) @@ -42,7 +42,7 @@ zval **data_cursor = result-stored_data? result-stored_data-data:NULL; zval **data_begin = result-stored_data? result-stored_data-data:NULL; unsigned int field_count = result-meta? result-meta-field_count : 0; - unsigned int row_count = result-stored_data? result-stored_data-row_count:0; + uint64_t row_count = result-stored_data? result-stored_data-row_count:0; enum_func_status ret = PASS; DBG_ENTER(mysqlnd_res::initialize_result_set_rest); @@ -208,10 +208,10 @@ for (row = set-row_count - 1; row = 0; row--) { zval **current_row = set-data + row * field_count; MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; - int col; + int64_t col; if (current_row != NULL) { - for (col = (int64_t) field_count - 1; col = 0; --col) { + for (col = field_count - 1; col = 0; --col) { if (current_row[col]) { zend_bool copy_ctor_called; mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c trunk/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_wireprotocol
andrey Mon, 04 Oct 2010 14:52:14 + Revision: http://svn.php.net/viewvc?view=revisionrevision=304029 Log: fix two more warnings Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-04 14:21:09 UTC (rev 304028) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-10-04 14:52:14 UTC (rev 304029) @@ -49,7 +49,7 @@ if (!data_cursor || row_count == result-stored_data-initialized_rows) { DBG_RETURN(ret); } - while ((data_cursor - data_begin) (row_count * field_count)) { + while ((data_cursor - data_begin) (int)(row_count * field_count)) { if (NULL == data_cursor[0]) { enum_func_status rc = result-m.row_decoder( result-stored_data-row_buffers[(data_cursor - data_begin) / field_count], Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-10-04 14:21:09 UTC (rev 304028) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-10-04 14:52:14 UTC (rev 304029) @@ -243,7 +243,7 @@ } } if ((buf_len - (p - buf)) 0) { - error_msg_len = MIN((buf_len - (p - buf)), error_buf_len - 1); + error_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1)); memcpy(error, p, error_msg_len); } } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-10-04 14:21:09 UTC (rev 304028) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-10-04 14:52:14 UTC (rev 304029) @@ -49,7 +49,7 @@ if (!data_cursor || row_count == result-stored_data-initialized_rows) { DBG_RETURN(ret); } - while ((data_cursor - data_begin) (row_count * field_count)) { + while ((data_cursor - data_begin) (int)(row_count * field_count)) { if (NULL == data_cursor[0]) { enum_func_status rc = result-m.row_decoder( result-stored_data-row_buffers[(data_cursor - data_begin) / field_count], Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c2010-10-04 14:21:09 UTC (rev 304028) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c2010-10-04 14:52:14 UTC (rev 304029) @@ -243,7 +243,7 @@ } } if ((buf_len - (p - buf)) 0) { - error_msg_len = MIN((buf_len - (p - buf)), error_buf_len - 1); + error_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1)); memcpy(error, p, error_msg_len); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/mysqlnd/ mysqlnd_result.c
andrey Wed, 25 Aug 2010 15:06:47 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302776 Log: Fix for bug #52221 Misbehaviour of magic_quotes_runtime (get/set)) Bug: http://bugs.php.net/52221 (Assigned) Misbehaviour of magic_quotes_runtime (get/set)) Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-25 15:02:02 UTC (rev 302775) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-25 15:06:47 UTC (rev 302776) @@ -1540,6 +1540,8 @@ break; default:exit(0); } + } else if (extension == MYSQLND_MYSQLI PG(magic_quotes_runtime)) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, magic_quotes_runtime are not supported by mysqlnd. They were deprecated in PHP 5.3 ); } /* return_value is IS_NULL for no more data and an array for data. Thus it's ok -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/mysqlnd/ mysqlnd_result.c
On 25 August 2010 23:06, Andrey Hristov and...@php.net wrote: + php_error_docref(NULL TSRMLS_CC, E_ERROR, magic_quotes_runtime are not supported by mysqlnd. They were deprecated in PHP 5.3 ); Is E_ERROR the appropriate level here? This could break code between 5.3 point releases. OK, you could argue that code is broken already, but I think I'd be more comfortable with a warning. Adam -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/mysqlnd/ mysqlnd_result.c
Adam Harvey wrote: On 25 August 2010 23:06, Andrey Hristov and...@php.net wrote: + Â Â Â Â Â Â Â php_error_docref(NULL TSRMLS_CC, E_ERROR, magic_quotes_runtime are not supported by mysqlnd. They were deprecated in PHP 5.3 ); Is E_ERROR the appropriate level here? This could break code between 5.3 point releases. OK, you could argue that code is broken already, but I think I'd be more comfortable with a warning. Adam Users might run with warnings disabled, but if the application doesn't run at all - due to E_ERROR, then they will definitely be notified and will take measures. According to Johannes this deficiency of current mysqlnd can lead to security problems. Andrey -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 17 Aug 2010 18:08:25 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302398 Log: Fix for Bug #52613 crash in mysqlnd Bug: http://bugs.php.net/52613 (Assigned) crash in mysqlnd Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-17 18:07:19 UTC (rev 302397) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-17 18:08:25 UTC (rev 302398) @@ -91,7 +91,11 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) { DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor); - + if (!zv || !*zv) { + *copy_ctor_called = FALSE; + DBG_ERR_FMT(zv was NULL); + DBG_VOID_RETURN; + } /* This zval is not from the cache block. Thus the refcount is -1 than of a zval from the cache, @@ -158,17 +162,16 @@ for (i = 0; i result-field_count; i++) { mysqlnd_palloc_zval_ptr_dtor((unbuf-last_row_data[i]), result-type, copy_ctor_called TSRMLS_CC); if (copy_ctor_called) { - ctor_called_count++; + ++ctor_called_count; } } DBG_INF_FMT(copy_ctor_called_count=%u, ctor_called_count); /* By using value3 macros we hold a mutex only once, there is no value2 */ - MYSQLND_INC_CONN_STATISTIC_W_VALUE3(global_stats, + MYSQLND_INC_CONN_STATISTIC_W_VALUE2(global_stats, STAT_COPY_ON_WRITE_PERFORMED, ctor_called_count, STAT_COPY_ON_WRITE_SAVED, - result-field_count - ctor_called_count, - STAT_COPY_ON_WRITE_PERFORMED, 0); + result-field_count - ctor_called_count); /* Free last row's zvals */ mnd_efree(unbuf-last_row_data); @@ -199,6 +202,8 @@ DBG_INF(Freeing data row_buffer); if (set-data) { + unsigned int copy_on_write_performed = 0; + unsigned int copy_on_write_saved = 0; DBG_INF_FMT(before: real_usage=%lu usage=%lu, zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC)); for (row = set-row_count - 1; row = 0; row--) { @@ -206,16 +211,21 @@ MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; int col; - for (col = field_count - 1; col = 0; --col) { - zend_bool copy_ctor_called; - if (current_row == NULL || current_row[0] == NULL) { - break;/* row that was never initialized */ - } - mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); + if (current_row != NULL) { + for (col = field_count - 1; col = 0; --col) { + if (current_row[col]) { + zend_bool copy_ctor_called; + mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); #if MYSQLND_DEBUG_MEMORY - DBG_INF_FMT(Copy_ctor_called=%u, copy_ctor_called); + DBG_INF_FMT(Copy_ctor_called=%u, copy_ctor_called); #endif - MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED: STAT_COPY_ON_WRITE_SAVED); + if (copy_ctor_called) { + ++copy_on_write_performed; + } else { + ++copy_on_write_saved; + } + } + } } #if MYSQLND_DEBUG_MEMORY DBG_INF(Freeing
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Thu, 12 Aug 2010 14:17:31 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302144 Log: Make this function static, as it is used only in this file. Add additional comment about how it works. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-12 13:23:16 UTC (rev 302143) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-12 14:17:31 UTC (rev 302144) @@ -86,12 +86,11 @@ /* }}} */ - /* {{{ mysqlnd_palloc_zval_ptr_dtor */ +static void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) { DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor); - *copy_ctor_called = FALSE; /* This zval is not from the cache block. @@ -99,6 +98,7 @@ because the zvals from the cache are owned by it. */ if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) { + *copy_ctor_called = FALSE; ; /* do nothing, zval_ptr_dtor will do the job*/ } else if (Z_REFCOUNT_PP(zv) 1) { /* @@ -120,6 +120,12 @@ } *copy_ctor_called = TRUE; } else { + /* + noone but us point to this, so we can safely ZVAL_NULL the zval, + so Zend does not try to free what the zval points to - which is + in result set buffers + */ + *copy_ctor_called = FALSE; if (Z_TYPE_PP(zv) == IS_STRING) { ZVAL_NULL(*zv); } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-08-12 13:23:16 UTC (rev 302143) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-08-12 14:17:31 UTC (rev 302144) @@ -86,12 +86,11 @@ /* }}} */ - /* {{{ mysqlnd_palloc_zval_ptr_dtor */ +static void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC) { DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor); - *copy_ctor_called = FALSE; /* This zval is not from the cache block. @@ -99,6 +98,7 @@ because the zvals from the cache are owned by it. */ if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) { + *copy_ctor_called = FALSE; ; /* do nothing, zval_ptr_dtor will do the job*/ } else if (Z_REFCOUNT_PP(zv) 1) { /* @@ -120,6 +120,12 @@ } *copy_ctor_called = TRUE; } else { + /* + noone but us point to this, so we can safely ZVAL_NULL the zval, + so Zend does not try to free what the zval points to - which is + in result set buffers + */ + *copy_ctor_called = FALSE; if (Z_TYPE_PP(zv) == IS_STRING) { ZVAL_NULL(*zv); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Tue, 13 Jul 2010 13:02:00 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301234 Log: Give an error when USE_RESULT is used with fetch_all Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-07-13 12:45:00 UTC (rev 301233) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-07-13 13:02:00 UTC (rev 301234) @@ -1569,6 +1569,10 @@ /* mysqlnd_res::fetch_all works with buffered resultsets only */ if (result-unbuf || (!result-unbuf !set)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, fetch_all can be used only with buffered sets); + if (result-conn) { + SET_CLIENT_ERROR(result-conn-error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, fetch_all can be used only with buffered sets); + } RETVAL_NULL(); DBG_VOID_RETURN; } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-07-13 12:45:00 UTC (rev 301233) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-07-13 13:02:00 UTC (rev 301234) @@ -1569,6 +1569,10 @@ /* mysqlnd_res::fetch_all works with buffered resultsets only */ if (result-unbuf || (!result-unbuf !set)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, fetch_all can be used only with buffered sets); + if (result-conn) { + SET_CLIENT_ERROR(result-conn-error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, fetch_all can be used only with buffered sets); + } RETVAL_NULL(); DBG_VOID_RETURN; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c trunk/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result_meta.c
andrey Thu, 27 May 2010 12:05:02 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299844 Log: Fix possible crashes, in case of OOM, due to half-baken objects. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-27 12:00:48 UTC (rev 299843) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-27 12:05:02 UTC (rev 299844) @@ -326,6 +326,10 @@ } result-meta = result-m.result_meta_init(result-field_count, result-persistent TSRMLS_CC); + if (!result-meta) { + SET_OOM_ERROR(conn-error_info); + DBG_RETURN(FAIL); + } /* 1. Read all fields metadata */ Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c 2010-05-27 12:00:48 UTC (rev 299843) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c 2010-05-27 12:05:02 UTC (rev 299844) @@ -475,17 +475,30 @@ MYSQLND_RES_METADATA *ret = mnd_pecalloc(1, alloc_size, persistent); DBG_ENTER(mysqlnd_result_meta_init); DBG_INF_FMT(persistent=%d, persistent); + + do { + if (!ret) { + break; + } + ret-m = mysqlnd_mysqlnd_res_meta_methods; - ret-persistent = persistent; - ret-field_count = field_count; - /* +1 is to have empty marker at the end */ - ret-fields = mnd_pecalloc(field_count + 1, sizeof(MYSQLND_FIELD), ret-persistent); - ret-zend_hash_keys = mnd_pecalloc(field_count, sizeof(struct mysqlnd_field_hash_key), ret-persistent); - - ret-m = mysqlnd_mysqlnd_res_meta_methods; - DBG_INF_FMT(meta=%p, ret); - DBG_RETURN(ret); + ret-persistent = persistent; + ret-field_count = field_count; + /* +1 is to have empty marker at the end */ + ret-fields = mnd_pecalloc(field_count + 1, sizeof(MYSQLND_FIELD), ret-persistent); + ret-zend_hash_keys = mnd_pecalloc(field_count, sizeof(struct mysqlnd_field_hash_key), ret-persistent); + if (!ret-fields || !ret-zend_hash_keys) { + break; + } + DBG_INF_FMT(meta=%p, ret); + DBG_RETURN(ret); + } while (0); + if (ret) { + ret-m-free_metadata(ret TSRMLS_CC); + } + DBG_RETURN(NULL); } +/* }}} */ /* {{{ mysqlnd_res_meta_get_methods */ Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-27 12:00:48 UTC (rev 299843) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-27 12:05:02 UTC (rev 299844) @@ -326,6 +326,10 @@ } result-meta = result-m.result_meta_init(result-field_count, result-persistent TSRMLS_CC); + if (!result-meta) { + SET_OOM_ERROR(conn-error_info); + DBG_RETURN(FAIL); + } /* 1. Read all fields metadata */ Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c 2010-05-27 12:00:48 UTC (rev 299843) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c 2010-05-27 12:05:02 UTC (rev 299844) @@ -475,17 +475,30 @@ MYSQLND_RES_METADATA *ret = mnd_pecalloc(1, alloc_size, persistent); DBG_ENTER(mysqlnd_result_meta_init); DBG_INF_FMT(persistent=%d, persistent); + + do { + if (!ret) { + break; + } + ret-m = mysqlnd_mysqlnd_res_meta_methods; - ret-persistent = persistent; - ret-field_count = field_count; - /* +1 is to have empty marker at the end */ - ret-fields = mnd_pecalloc(field_count + 1, sizeof(MYSQLND_FIELD), ret-persistent); - ret-zend_hash_keys = mnd_pecalloc(field_count, sizeof(struct mysqlnd_field_hash_key), ret-persistent); - - ret-m = mysqlnd_mysqlnd_res_meta_methods; - DBG_INF_FMT(meta=%p, ret); - DBG_RETURN(ret); + ret-persistent = persistent; + ret-field_count = field_count; + /* +1 is to have empty marker at the end */ + ret-fields = mnd_pecalloc(field_count + 1, sizeof(MYSQLND_FIELD), ret-persistent); +
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Fri, 21 May 2010 13:37:18 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299579 Log: Check set-data for validity before using it. Prevents crashes after OOM. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-21 13:06:52 UTC (rev 299578) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-21 13:37:18 UTC (rev 299579) @@ -186,34 +186,37 @@ DBG_ENTER(mysqlnd_res::free_buffered_data); DBG_INF_FMT(Freeing MYSQLND_LLU_SPEC row(s), set-row_count); - DBG_INF_FMT(before: real_usage=%lu usage=%lu, zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC)); - for (row = set-row_count - 1; row = 0; row--) { - zval **current_row = set-data + row * field_count; - MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; - int col; + DBG_INF(Freeing data row_buffer); + if (set-data) { - for (col = field_count - 1; col = 0; --col) { - zend_bool copy_ctor_called; - if (current_row[0] == NULL) { - break;/* row that was never initialized */ - } + DBG_INF_FMT(before: real_usage=%lu usage=%lu, zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC)); + for (row = set-row_count - 1; row = 0; row--) { + zval **current_row = set-data + row * field_count; + MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; + int col; + + for (col = field_count - 1; col = 0; --col) { + zend_bool copy_ctor_called; + if (current_row == NULL || current_row[0] == NULL) { + break;/* row that was never initialized */ + } mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC); #if MYSQLND_DEBUG_MEMORY - DBG_INF_FMT(Copy_ctor_called=%d, copy_ctor_called); + DBG_INF_FMT(Copy_ctor_called=%d, copy_ctor_called); #endif - MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED: + MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED: STAT_COPY_ON_WRITE_SAVED); - } + } #if MYSQLND_DEBUG_MEMORY - DBG_INF(Freeing current_row current_buffer); + DBG_INF(Freeing current_row current_buffer); #endif - current_buffer-free_chunk(current_buffer TSRMLS_CC); - } - DBG_INF(Freeing data row_buffer); - if (set-data) { + current_buffer-free_chunk(current_buffer TSRMLS_CC); + } + mnd_pefree(set-data, set-persistent); set-data = NULL; } + if (set-row_buffers) { mnd_pefree(set-row_buffers, set-persistent); set-row_buffers= NULL; Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-21 13:06:52 UTC (rev 299578) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-21 13:37:18 UTC (rev 299579) @@ -186,34 +186,37 @@ DBG_ENTER(mysqlnd_res::free_buffered_data); DBG_INF_FMT(Freeing MYSQLND_LLU_SPEC row(s), set-row_count); - DBG_INF_FMT(before: real_usage=%lu usage=%lu, zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC)); - for (row = set-row_count - 1; row = 0; row--) { - zval **current_row = set-data + row * field_count; - MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set-row_buffers[row]; - int col; + DBG_INF(Freeing data row_buffer); + if (set-data) { - for (col = field_count - 1; col = 0; --col) { - zend_bool copy_ctor_called; - if (current_row[0] == NULL) { - break;/* row that was never initialized */ - } + DBG_INF_FMT(before: real_usage=%lu usage=%lu, zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC)); + for (row = set-row_count - 1; row = 0; row--) { +
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h trunk/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_structs.h
andrey Fri, 14 May 2010 15:11:56 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299382 Log: Allow overloading of mysqlnd_result_meta_init(). Add free space for future hooks. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-14 13:41:35 UTC (rev 299381) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-14 15:11:56 UTC (rev 299382) @@ -322,7 +322,7 @@ result-meta = NULL; } - result-meta = mysqlnd_result_meta_init(result-field_count, result-persistent TSRMLS_CC); + result-meta = result-m.result_meta_init(result-field_count, result-persistent TSRMLS_CC); /* 1. Read all fields metadata */ @@ -1613,7 +1613,8 @@ MYSQLND_METHOD(mysqlnd_res, free_buffered_data), MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data), - NULL /* row_decoder */ + NULL /* row_decoder */, + mysqlnd_result_meta_init MYSQLND_CLASS_METHODS_END; Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h 2010-05-14 13:41:35 UTC (rev 299381) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h 2010-05-14 15:11:56 UTC (rev 299382) @@ -277,6 +277,12 @@ func_mysqlnd_net__free_contents free_contents; func_mysqlnd_net__enable_ssl enable_ssl; func_mysqlnd_net__disable_ssl disable_ssl; + + void * unused1; + void * unused2; + void * unused3; + void * unused4; + void * unused5; }; @@ -318,6 +324,12 @@ func_mysqlnd_protocol__get_stats_packet get_stats_packet; func_mysqlnd_protocol__get_prepare_response_packet get_prepare_response_packet; func_mysqlnd_protocol__get_change_user_response_packet get_change_user_response_packet; + + void * unused1; + void * unused2; + void * unused3; + void * unused4; + void * unused5; }; @@ -507,6 +519,8 @@ zend_bool as_unicode, zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); +typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res__result_meta_init)(unsigned int field_count, zend_bool persistent TSRMLS_DC); + struct st_mysqlnd_res_methods { mysqlnd_fetch_row_func fetch_row; @@ -541,6 +555,14 @@ /* for decoding - binary or text protocol */ func_mysqlnd_res__row_decoder row_decoder; + + func_mysqlnd_res__result_meta_init result_meta_init; + + void * unused1; + void * unused2; + void * unused3; + void * unused4; + void * unused5; }; Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-14 13:41:35 UTC (rev 299381) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-14 15:11:56 UTC (rev 299382) @@ -322,7 +322,7 @@ result-meta = NULL; } - result-meta = mysqlnd_result_meta_init(result-field_count, result-persistent TSRMLS_CC); + result-meta = result-m.result_meta_init(result-field_count, result-persistent TSRMLS_CC); /* 1. Read all fields metadata */ @@ -1613,7 +1613,8 @@ MYSQLND_METHOD(mysqlnd_res, free_buffered_data), MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data), - NULL /* row_decoder */ + NULL /* row_decoder */, + mysqlnd_result_meta_init MYSQLND_CLASS_METHODS_END; Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h 2010-05-14 13:41:35 UTC (rev 299381) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h 2010-05-14 15:11:56 UTC (rev 299382) @@ -277,6 +277,12 @@ func_mysqlnd_net__free_contents free_contents; func_mysqlnd_net__enable_ssl enable_ssl; func_mysqlnd_net__disable_ssl disable_ssl; + + void * unused1; + void * unused2; + void * unused3; + void * unused4; + void * unused5; }; @@ -318,6 +324,12 @@ func_mysqlnd_protocol__get_stats_packet get_stats_packet; func_mysqlnd_protocol__get_prepare_response_packet get_prepare_response_packet; func_mysqlnd_protocol__get_change_user_response_packet
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.h trunk/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.h
andrey Thu, 13 May 2010 15:29:08 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299348 Log: - initialize some variables - initialize the methods in a shorter way, use the compiler. = on structures copies them. Allows also exportability of the methods. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.h U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.h Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-13 15:26:35 UTC (rev 299347) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-13 15:29:08 UTC (rev 299348) @@ -352,8 +352,8 @@ { MYSQLND_STMT_DATA * stmt = s ? s-data:NULL; enum_func_status ret; - MYSQLND_PACKET_RSET_HEADER * rset_header; - MYSQLND_PACKET_EOF * fields_eof; + MYSQLND_PACKET_RSET_HEADER * rset_header = NULL; + MYSQLND_PACKET_EOF * fields_eof = NULL; DBG_ENTER(mysqlnd_query_read_result_set_header); DBG_INF_FMT(stmt=%d, stmt? stmt-stmt_id:0); @@ -1078,7 +1078,7 @@ zend_bool to_cache TSRMLS_DC) { enum_func_status ret; - MYSQLND_PACKET_ROW *row_packet; + MYSQLND_PACKET_ROW *row_packet = NULL; unsigned int next_extend = STORE_RESULT_PREALLOCATED_SET_IF_NOT_EMPTY, free_rows = 1; MYSQLND_RES_BUFFERED *set; @@ -1581,6 +1581,42 @@ /* }}} */ +static +MYSQLND_CLASS_METHODS_START(mysqlnd_res) + NULL, /* fetch_row */ + mysqlnd_fetch_row_buffered, + mysqlnd_fetch_row_unbuffered, + MYSQLND_METHOD(mysqlnd_res, use_result), + MYSQLND_METHOD(mysqlnd_res, store_result), + MYSQLND_METHOD(mysqlnd_res, fetch_into), + MYSQLND_METHOD(mysqlnd_res, fetch_row_c), + MYSQLND_METHOD(mysqlnd_res, fetch_all), + MYSQLND_METHOD(mysqlnd_res, fetch_field_data), + MYSQLND_METHOD(mysqlnd_res, num_rows), + MYSQLND_METHOD(mysqlnd_res, num_fields), + MYSQLND_METHOD(mysqlnd_res, skip_result), + MYSQLND_METHOD(mysqlnd_res, data_seek), + MYSQLND_METHOD(mysqlnd_res, field_seek), + MYSQLND_METHOD(mysqlnd_res, field_tell), + MYSQLND_METHOD(mysqlnd_res, fetch_field), + MYSQLND_METHOD(mysqlnd_res, fetch_field_direct), + MYSQLND_METHOD(mysqlnd_res, fetch_fields), + MYSQLND_METHOD(mysqlnd_res, read_result_metadata), + NULL, /* fetch_lengths */ + MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data), + MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest), + MYSQLND_METHOD(mysqlnd_res, free_result_buffers), + MYSQLND_METHOD(mysqlnd_res, free_result), + + mysqlnd_internal_free_result, /* free_result_internal */ + mysqlnd_internal_free_result_contents, /* free_result_contents */ + MYSQLND_METHOD(mysqlnd_res, free_buffered_data), + MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data), + + NULL /* row_decoder */ +MYSQLND_CLASS_METHODS_END; + + /* {{{ mysqlnd_result_init_ex */ PHPAPI MYSQLND_RES * mysqlnd_result_init(unsigned int field_count, zend_bool persistent TSRMLS_DC) @@ -1597,38 +1633,8 @@ ret-persistent = persistent; ret-field_count = field_count; + ret-m = mysqlnd_mysqlnd_res_methods; - ret-m.use_result = MYSQLND_METHOD(mysqlnd_res, use_result); - ret-m.store_result = MYSQLND_METHOD(mysqlnd_res, store_result); - ret-m.free_result = MYSQLND_METHOD(mysqlnd_res, free_result); - ret-m.seek_data = MYSQLND_METHOD(mysqlnd_res, data_seek); - ret-m.num_rows = MYSQLND_METHOD(mysqlnd_res, num_rows); - ret-m.num_fields = MYSQLND_METHOD(mysqlnd_res, num_fields); - ret-m.fetch_into = MYSQLND_METHOD(mysqlnd_res, fetch_into); - ret-m.fetch_row_c = MYSQLND_METHOD(mysqlnd_res, fetch_row_c); - ret-m.fetch_all = MYSQLND_METHOD(mysqlnd_res, fetch_all); - ret-m.fetch_field_data = MYSQLND_METHOD(mysqlnd_res, fetch_field_data); - ret-m.seek_field = MYSQLND_METHOD(mysqlnd_res, field_seek); - ret-m.field_tell = MYSQLND_METHOD(mysqlnd_res, field_tell); - ret-m.fetch_field = MYSQLND_METHOD(mysqlnd_res, fetch_field); - ret-m.fetch_field_direct = MYSQLND_METHOD(mysqlnd_res, fetch_field_direct); - ret-m.fetch_fields = MYSQLND_METHOD(mysqlnd_res, fetch_fields); - - ret-m.skip_result = MYSQLND_METHOD(mysqlnd_res, skip_result); - ret-m.free_result_buffers = MYSQLND_METHOD(mysqlnd_res, free_result_buffers); - ret-m.free_result_internal = mysqlnd_internal_free_result; - ret-m.free_result_contents = mysqlnd_internal_free_result_contents; - ret-m.free_buffered_data = MYSQLND_METHOD(mysqlnd_res, free_buffered_data); - ret-m.unbuffered_free_last_data = MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data); - - ret-m.read_result_metadata = MYSQLND_METHOD(mysqlnd_res, read_result_metadata); - ret-m.store_result_fetch_data = MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data); - ret-m.initialize_result_set_rest = MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest); - - ret-m.fetch_row_normal_buffered = mysqlnd_fetch_row_buffered; -
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Mon, 03 May 2010 19:02:48 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298922 Log: Handle OOM in mysqlnd_fetch_row_unbuffered_c() Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 18:53:10 UTC (rev 298921) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:02:48 UTC (rev 298922) @@ -646,27 +646,30 @@ result-conn-stats TSRMLS_CC); retrow = mnd_malloc(result-field_count * sizeof(char *)); + if (retrow) { + for (i = 0; i field_count; i++, field++, zend_hash_key++) { + zval *data = result-unbuf-last_row_data[i]; + unsigned int len; - for (i = 0; i field_count; i++, field++, zend_hash_key++) { - zval *data = result-unbuf-last_row_data[i]; - unsigned int len; + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + retrow[i] = Z_STRVAL_P(data); + len = Z_STRLEN_P(data); + } else { + retrow[i] = NULL; + len = 0; + } - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - retrow[i] = Z_STRVAL_P(data); - len = Z_STRLEN_P(data); - } else { - retrow[i] = NULL; - len = 0; - } + if (lengths) { + lengths[i] = len; + } - if (lengths) { - lengths[i] = len; + if (field-max_length len) { + field-max_length = len; + } } - - if (field-max_length len) { - field-max_length = len; - } + } else { + SET_OOM_ERROR(result-conn-error_info); } } } else if (ret == FAIL) { Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 18:53:10 UTC (rev 298921) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:02:48 UTC (rev 298922) @@ -646,27 +646,30 @@ result-conn-stats TSRMLS_CC); retrow = mnd_malloc(result-field_count * sizeof(char *)); + if (retrow) { + for (i = 0; i field_count; i++, field++, zend_hash_key++) { + zval *data = result-unbuf-last_row_data[i]; + unsigned int len; - for (i = 0; i field_count; i++, field++, zend_hash_key++) { - zval *data = result-unbuf-last_row_data[i]; - unsigned int len; + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + retrow[i] = Z_STRVAL_P(data); + len = Z_STRLEN_P(data); + } else { + retrow[i] = NULL; + len = 0; + } - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - retrow[i] = Z_STRVAL_P(data); - len = Z_STRLEN_P(data); - } else { -
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Mon, 03 May 2010 19:09:45 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298925 Log: Handle OOM in mysqlnd_fetch_row_buffered_c() Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:08:26 UTC (rev 298924) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:09:45 UTC (rev 298925) @@ -939,20 +939,23 @@ } } + set-data_cursor += result-meta-field_count; + MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); + ret = mnd_malloc(result-field_count * sizeof(char *)); + if (ret) { + for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { + zval *data = current_row[i]; - for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { - zval *data = current_row[i]; - - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - ret[i] = Z_STRVAL_P(data); - } else { - ret[i] = NULL; + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + ret[i] = Z_STRVAL_P(data); + } else { + ret[i] = NULL; + } } } - set-data_cursor += result-meta-field_count; - MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); + /* there is no conn handle in this function thus we can't set OOM in error_info */ } else { set-data_cursor = NULL; DBG_INF(EOF reached); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:08:26 UTC (rev 298924) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:09:45 UTC (rev 298925) @@ -939,20 +939,23 @@ } } + set-data_cursor += result-meta-field_count; + MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); + ret = mnd_malloc(result-field_count * sizeof(char *)); + if (ret) { + for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { + zval *data = current_row[i]; - for (i = 0; i result-field_count; i++, field++, zend_hash_key++) { - zval *data = current_row[i]; - - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - ret[i] = Z_STRVAL_P(data); - } else { - ret[i] = NULL; + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + ret[i] = Z_STRVAL_P(data); + } else { + ret[i] = NULL; + } } } - set-data_cursor += result-meta-field_count; - MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); + /* there is no conn handle in this function thus we can't set OOM in error_info */ } else { set-data_cursor = NULL; DBG_INF(EOF reached); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Mon, 03 May 2010 19:32:07 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298929 Log: Handle OOM in mysqlnd_res::store_result_fetch_data Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:31:50 UTC (rev 298928) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:32:07 UTC (rev 298929) @@ -1080,8 +1080,18 @@ conn-thread_id, binary_protocol, to_cache); result-stored_data = set = mnd_pecalloc(1, sizeof(MYSQLND_RES_BUFFERED), to_cache); + if (!set) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } if (free_rows) { set-row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache); + if (!set-row_buffers) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } } set-persistent = to_cache; set-references = 1; @@ -1091,6 +1101,11 @@ /* non-persistent */ row_packet = conn-protocol-m.get_row_packet(conn-protocol, FALSE TSRMLS_CC); + if (!row_packet) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } row_packet-result_set_memory_pool = result-result_set_memory_pool; row_packet-field_count = meta-field_count; row_packet-binary_protocol = binary_protocol; @@ -1103,10 +1118,17 @@ while (FAIL != (ret = PACKET_READ(row_packet, conn)) !row_packet-eof) { if (!free_rows) { uint64_t total_allocated_rows = free_rows = next_extend = next_extend * 11 / 10; /* extend with 10% */ + MYSQLND_MEMORY_POOL_CHUNK ** new_row_buffers; total_allocated_rows += set-row_count; - set-row_buffers = mnd_perealloc(set-row_buffers, - total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), - set-persistent); + new_row_buffers = mnd_perealloc(set-row_buffers, + total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), + set-persistent); + if (!new_row_buffers) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } + set-row_buffers = new_row_buffers; } free_rows--; set-row_buffers[set-row_count] = row_packet-row_buffer; @@ -1128,6 +1150,11 @@ if (set-row_count) { /* if pecalloc is used valgrind barks gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux) */ set-data = mnd_pemalloc(set-row_count * meta-field_count * sizeof(zval *), to_cache); + if (!set-data) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } memset(set-data, 0, set-row_count * meta-field_count * sizeof(zval *)); } @@ -1163,6 +1190,7 @@ /* libmysql's documentation says it should be so for SELECT statements */ conn-upsert_status.affected_rows = set-row_count; } +end: PACKET_FREE(row_packet); DBG_INF_FMT(ret=%s row_count=%u warnings=%u server_status=%u, ret == PASS? PASS:FAIL, Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:31:50 UTC (rev 298928) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-05-03 19:32:07 UTC (rev 298929) @@ -1080,8 +1080,18 @@ conn-thread_id, binary_protocol, to_cache); result-stored_data = set = mnd_pecalloc(1, sizeof(MYSQLND_RES_BUFFERED), to_cache); + if (!set) { + SET_OOM_ERROR(conn-error_info); + ret = FAIL; + goto end; + } if (free_rows) { set-row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache); +
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
uw Fri, 23 Oct 2009 12:44:05 + Revision: http://svn.php.net/viewvc?view=revisionrevision=289885 Log: Fix: log slow queries in stats regardless of mysqlnd.log_mask setting. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2009-10-23 10:24:48 UTC (rev 289884) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2009-10-23 12:44:05 UTC (rev 289885) @@ -621,8 +621,8 @@ php_log_err(backtrace TSRMLS_CC); efree(backtrace); #endif - MYSQLND_INC_CONN_STATISTIC(conn-stats, stat); } + MYSQLND_INC_CONN_STATISTIC(conn-stats, stat); } PACKET_FREE_ALLOCA(fields_eof); Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2009-10-23 10:24:48 UTC (rev 289884) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2009-10-23 12:44:05 UTC (rev 289885) @@ -621,8 +621,8 @@ php_log_err(backtrace TSRMLS_CC); efree(backtrace); #endif - MYSQLND_INC_CONN_STATISTIC(conn-stats, stat); } + MYSQLND_INC_CONN_STATISTIC(conn-stats, stat); } PACKET_FREE_ALLOCA(fields_eof); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c
andrey Wed, 30 Sep 2009 22:26:19 + Revision: http://svn.php.net/viewvc?view=revisionrevision=289027 Log: Fix trace output. DBG_RETURN should be used in traced functions. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2009-09-30 21:58:19 UTC (rev 289026) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2009-09-30 22:26:19 UTC (rev 289027) @@ -1882,9 +1882,9 @@ if (result-m.fetch_row) { if (result-m.fetch_row == result-m.fetch_row_normal_buffered) { - return mysqlnd_fetch_row_buffered_c(result TSRMLS_CC); + DBG_RETURN(mysqlnd_fetch_row_buffered_c(result TSRMLS_CC)); } else if (result-m.fetch_row == result-m.fetch_row_normal_unbuffered) { - return mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC); + DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC)); } else { *((int*)NULL) = 1; } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c === --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2009-09-30 21:58:19 UTC (rev 289026) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2009-09-30 22:26:19 UTC (rev 289027) @@ -1882,9 +1882,9 @@ if (result-m.fetch_row) { if (result-m.fetch_row == result-m.fetch_row_normal_buffered) { - return mysqlnd_fetch_row_buffered_c(result TSRMLS_CC); + DBG_RETURN(mysqlnd_fetch_row_buffered_c(result TSRMLS_CC)); } else if (result-m.fetch_row == result-m.fetch_row_normal_unbuffered) { - return mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC); + DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC)); } else { *((int*)NULL) = 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php