@@ -331,7 +331,9 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const stmt, const char * co
331
331
no metadata at prepare.
332
332
*/
333
333
if (stmt_to_prepare -> field_count ) {
334
- MYSQLND_RES * result = mysqlnd_result_init (stmt_to_prepare -> field_count , NULL TSRMLS_CC );
334
+ MYSQLND_RES * result = mysqlnd_result_init (stmt_to_prepare -> field_count ,
335
+ mysqlnd_palloc_get_thd_cache_reference (stmt -> conn -> zval_cache )
336
+ TSRMLS_CC );
335
337
/* Allocate the result now as it is needed for the reading of metadata */
336
338
stmt_to_prepare -> result = result ;
337
339
@@ -731,37 +733,16 @@ MYSQLND_METHOD(mysqlnd_stmt, use_result)(MYSQLND_STMT *stmt TSRMLS_DC)
731
733
}
732
734
733
735
SET_EMPTY_ERROR (stmt -> error_info );
734
- SET_EMPTY_ERROR (stmt -> conn -> error_info );
735
736
736
737
MYSQLND_INC_CONN_STATISTIC (& stmt -> conn -> stats , STAT_PS_UNBUFFERED_SETS );
737
-
738
- result = stmt -> result ;
739
- result -> type = MYSQLND_RES_PS_UNBUF ;
740
- result -> m .fetch_row = stmt -> cursor_exists ? mysqlnd_fetch_stmt_row_cursor :
741
- mysqlnd_stmt_fetch_row_unbuffered ;
742
- result -> m .fetch_lengths = NULL ; /* makes no sense */
743
- result -> zval_cache = mysqlnd_palloc_get_thd_cache_reference (conn -> zval_cache );
744
-
745
- result -> unbuf = mnd_ecalloc (1 , sizeof (MYSQLND_RES_UNBUFFERED ));
746
-
747
- DBG_INF_FMT ("cursor=%d zval_cache=%p" , stmt -> cursor_exists , result -> zval_cache );
748
- /*
749
- Will be freed in the mysqlnd_internal_free_result_contents() called
750
- by the resource destructor. mysqlnd_fetch_row_unbuffered() expects
751
- this to be not NULL.
752
- */
753
- PACKET_INIT (result -> row_packet , PROT_ROW_PACKET , php_mysql_packet_row * );
754
- result -> row_packet -> field_count = result -> field_count ;
755
- result -> row_packet -> binary_protocol = TRUE;
756
- result -> row_packet -> fields_metadata = stmt -> result -> meta -> fields ;
757
- result -> row_packet -> bit_fields_count = result -> meta -> bit_fields_count ;
758
- result -> row_packet -> bit_fields_total_len = result -> meta -> bit_fields_total_len ;
759
- result -> lengths = NULL ;
738
+ result = stmt -> result ;
739
+
740
+ result -> m .use_result (stmt -> result , TRUE TSRMLS_CC );
741
+ result -> m .fetch_row = stmt -> cursor_exists ? mysqlnd_fetch_stmt_row_cursor :
742
+ mysqlnd_stmt_fetch_row_unbuffered ;
760
743
761
744
stmt -> state = MYSQLND_STMT_USE_OR_STORE_CALLED ;
762
745
763
- /* No multithreading issues as we don't share the connection :) */
764
-
765
746
DBG_INF_FMT ("%p" , result );
766
747
DBG_RETURN (result );
767
748
}
@@ -1164,6 +1145,31 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_param)(MYSQLND_STMT * const stmt,
1164
1145
/* }}} */
1165
1146
1166
1147
1148
+ /* {{{ _mysqlnd_stmt_refresh_bind_param */
1149
+ static enum_func_status
1150
+ MYSQLND_METHOD (mysqlnd_stmt , refresh_bind_param )(MYSQLND_STMT * const stmt TSRMLS_DC )
1151
+ {
1152
+ DBG_ENTER ("mysqlnd_stmt::refresh_bind_param" );
1153
+ DBG_INF_FMT ("stmt=%lu param_count=%u" , stmt -> stmt_id , stmt -> param_count );
1154
+
1155
+ if (stmt -> state < MYSQLND_STMT_PREPARED ) {
1156
+ SET_STMT_ERROR (stmt , CR_NO_PREPARE_STMT , UNKNOWN_SQLSTATE , mysqlnd_stmt_not_prepared );
1157
+ DBG_ERR ("not prepared" );
1158
+ DBG_RETURN (FAIL );
1159
+ }
1160
+
1161
+ SET_EMPTY_ERROR (stmt -> error_info );
1162
+ SET_EMPTY_ERROR (stmt -> conn -> error_info );
1163
+
1164
+ if (stmt -> param_count ) {
1165
+ stmt -> send_types_to_server = 1 ;
1166
+ }
1167
+ DBG_INF ("PASS" );
1168
+ DBG_RETURN (PASS );
1169
+ }
1170
+ /* }}} */
1171
+
1172
+
1167
1173
/* {{{ mysqlnd_stmt::bind_result */
1168
1174
static enum_func_status
1169
1175
MYSQLND_METHOD (mysqlnd_stmt , bind_result )(MYSQLND_STMT * const stmt ,
@@ -1535,7 +1541,7 @@ void mysqlnd_internal_free_stmt_content(MYSQLND_STMT *stmt TSRMLS_DC)
1535
1541
1536
1542
/* Destroy the input bind */
1537
1543
if (stmt -> param_bind ) {
1538
- int i ;
1544
+ unsigned int i ;
1539
1545
/*
1540
1546
Because only the bound variables can point to our internal buffers, then
1541
1547
separate or free only them. Free is possible because the user could have
@@ -1651,7 +1657,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, dtor)(MYSQLND_STMT * const stmt, zend_bool
1651
1657
{
1652
1658
enum_func_status ret ;
1653
1659
1654
- DBG_ENTER ("mysqlnd_stmt::close " );
1660
+ DBG_ENTER ("mysqlnd_stmt::dtor " );
1655
1661
DBG_INF_FMT ("stmt=%p" , stmt );
1656
1662
1657
1663
MYSQLND_INC_GLOBAL_STATISTIC (implicit == TRUE? STAT_STMT_CLOSE_IMPLICIT :
@@ -1683,6 +1689,7 @@ struct st_mysqlnd_stmt_methods mysqlnd_stmt_methods = {
1683
1689
MYSQLND_METHOD (mysqlnd_stmt , fetch ),
1684
1690
1685
1691
MYSQLND_METHOD (mysqlnd_stmt , bind_param ),
1692
+ MYSQLND_METHOD (mysqlnd_stmt , refresh_bind_param ),
1686
1693
MYSQLND_METHOD (mysqlnd_stmt , bind_result ),
1687
1694
MYSQLND_METHOD (mysqlnd_stmt , send_long_data ),
1688
1695
MYSQLND_METHOD (mysqlnd_stmt , param_metadata ),
0 commit comments