@@ -1460,8 +1460,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
1460
1460
MYSQLND_ERROR_INFO * error_info ,
1461
1461
MYSQLND_MEMORY_POOL * pool ,
1462
1462
MYSQLND_MEMORY_POOL_CHUNK * * buffer ,
1463
- size_t * data_size , zend_bool persistent_alloc ,
1464
- unsigned int prealloc_more_bytes )
1463
+ size_t * data_size , zend_bool persistent_alloc )
1465
1464
{
1466
1465
enum_func_status ret = PASS ;
1467
1466
MYSQLND_PACKET_HEADER header ;
@@ -1478,7 +1477,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
1478
1477
zero-length byte, don't read the body, there is no such.
1479
1478
*/
1480
1479
1481
- * data_size = prealloc_more_bytes ;
1480
+ * data_size = 0 ;
1482
1481
while (1 ) {
1483
1482
if (FAIL == mysqlnd_read_header (pfc , vio , & header , stats , error_info )) {
1484
1483
ret = FAIL ;
@@ -1527,7 +1526,6 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
1527
1526
pool -> free_chunk (pool , * buffer );
1528
1527
* buffer = NULL ;
1529
1528
}
1530
- * data_size -= prealloc_more_bytes ;
1531
1529
DBG_RETURN (ret );
1532
1530
}
1533
1531
/* }}} */
@@ -1634,8 +1632,6 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
1634
1632
zval * current_field , * end_field , * start_field ;
1635
1633
zend_uchar * p = row_buffer -> ptr ;
1636
1634
size_t data_size = row_buffer -> app ;
1637
- /* we allocate from here. In pre-7.0 it was +1, as there was an additional \0 for the last string in the packet - because of the zval optimizations - using no-copy */
1638
- zend_uchar * bit_area = (zend_uchar * ) row_buffer -> ptr + data_size ;
1639
1635
const zend_uchar * const packet_end = (zend_uchar * ) row_buffer -> ptr + data_size ;
1640
1636
1641
1637
DBG_ENTER ("php_mysqlnd_rowp_read_text_protocol_aux" );
@@ -1746,46 +1742,22 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
1746
1742
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */
1747
1743
if (fields_metadata [i ].type == MYSQL_TYPE_BIT ) {
1748
1744
/*
1749
- BIT fields are specially handled. As they come as bit mask, we have
1750
- to convert it to human-readable representation. As the bits take
1751
- less space in the protocol than the numbers they represent, we don't
1752
- have enough space in the packet buffer to overwrite inside.
1753
- Thus, a bit more space is pre-allocated at the end of the buffer,
1754
- see php_mysqlnd_rowp_read(). And we add the strings at the end.
1755
- Definitely not nice, _hackish_ :(, but works.
1745
+ BIT fields are specially handled. As they come as bit mask, they have
1746
+ to be converted to human-readable representation.
1756
1747
*/
1757
- zend_uchar * start = bit_area ;
1758
1748
ps_fetch_from_1_to_8_bytes (current_field , & (fields_metadata [i ]), 0 , (const zend_uchar * * ) & p , len );
1759
1749
/*
1760
1750
We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because
1761
1751
later in this function there will be an advancement.
1762
1752
*/
1763
1753
p -= len ;
1764
- if (Z_TYPE_P (current_field ) == IS_LONG ) {
1765
- /*
1766
- Andrey : See below. No need of bit_area, as we can use on stack for this.
1767
- The bit area should be removed - the `prealloc_more_bytes` in php_mysqlnd_read_row_ex()
1768
-
1769
- char tmp[22];
1770
- const size_t tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, Z_LVAL_P(current_field));
1771
- ZVAL_STRINGL(current_field, tmp, tmp_len);
1772
- */
1773
- bit_area += 1 + sprintf ((char * )start , ZEND_LONG_FMT , Z_LVAL_P (current_field ));
1774
- ZVAL_STRINGL (current_field , (char * ) start , bit_area - start - 1 );
1754
+ if (Z_TYPE_P (current_field ) == IS_LONG && !as_int_or_float ) {
1755
+ /* we are using the text protocol, so convert to string */
1756
+ char tmp [22 ];
1757
+ const size_t tmp_len = sprintf ((char * )& tmp , MYSQLND_LLU_SPEC , Z_LVAL_P (current_field ));
1758
+ ZVAL_STRINGL (current_field , tmp , tmp_len );
1775
1759
} else if (Z_TYPE_P (current_field ) == IS_STRING ) {
1776
- /*
1777
- Andrey : This is totally sensless, but I am not gonna remove it in a production version.
1778
- This copies the data from the zval to the bit area. The destroys the original value
1779
- and creates the same one from the bit area. No need. It was making sense in pre-7.0
1780
- when we used zval IS_STRING with no-copy that referred to the bit area.
1781
- The bit area has no sense in both the case of IS_LONG and IS_STRING as 7.0 zval
1782
- IS_STRING always copies.
1783
- */
1784
- memcpy (bit_area , Z_STRVAL_P (current_field ), Z_STRLEN_P (current_field ));
1785
- bit_area += Z_STRLEN_P (current_field );
1786
- * bit_area ++ = '\0' ;
1787
- zval_dtor (current_field );
1788
- ZVAL_STRINGL (current_field , (char * ) start , bit_area - start - 1 );
1760
+ /* nothing to do here, as we want a string and ps_fetch_from_1_to_8_bytes() has given us one */
1789
1761
}
1790
1762
} else {
1791
1763
ZVAL_STRINGL (current_field , (char * )p , len );
@@ -1842,20 +1814,13 @@ php_mysqlnd_rowp_read(void * _packet)
1842
1814
MYSQLND_STATS * stats = packet -> header .stats ;
1843
1815
zend_uchar * p ;
1844
1816
enum_func_status ret = PASS ;
1845
- size_t post_alloc_for_bit_fields = 0 ;
1846
1817
size_t data_size = 0 ;
1847
1818
1848
1819
DBG_ENTER ("php_mysqlnd_rowp_read" );
1849
1820
1850
- if (!packet -> binary_protocol && packet -> bit_fields_count ) {
1851
- /* For every field we need terminating \0 */
1852
- post_alloc_for_bit_fields = packet -> bit_fields_total_len + packet -> bit_fields_count ;
1853
- }
1854
-
1855
1821
ret = php_mysqlnd_read_row_ex (pfc , vio , stats , error_info ,
1856
1822
packet -> result_set_memory_pool , & packet -> row_buffer , & data_size ,
1857
- packet -> persistent_alloc , post_alloc_for_bit_fields
1858
- );
1823
+ packet -> persistent_alloc );
1859
1824
if (FAIL == ret ) {
1860
1825
goto end ;
1861
1826
}
0 commit comments