@@ -628,27 +628,7 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s TSRMLS_DC)
628
628
}
629
629
#endif
630
630
631
- /*
632
- If right after execute() we have to call the appropriate
633
- use_result() or store_result() and clean.
634
- */
635
- if (stmt -> state == MYSQLND_STMT_WAITING_USE_OR_STORE ) {
636
- DBG_INF ("fetching result set header" );
637
- /* Do implicit use_result and then flush the result */
638
- stmt -> default_rset_handler = s -> m -> use_result ;
639
- stmt -> default_rset_handler (s TSRMLS_CC );
640
- }
641
-
642
- if (stmt -> state > MYSQLND_STMT_WAITING_USE_OR_STORE ) {
643
- DBG_INF ("skipping result" );
644
- /* Flush if anything is left and unbuffered set */
645
- stmt -> result -> m .skip_result (stmt -> result TSRMLS_CC );
646
- }
647
-
648
- if (stmt -> state > MYSQLND_STMT_PREPARED ) {
649
- /* As the buffers have been freed, we should go back to PREPARED */
650
- stmt -> state = MYSQLND_STMT_PREPARED ;
651
- }
631
+ s -> m -> flush (s TSRMLS_CC );
652
632
653
633
/*
654
634
Executed, but the user hasn't started to fetch
@@ -1228,6 +1208,45 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s TSRMLS_DC)
1228
1208
}
1229
1209
}
1230
1210
1211
+ s -> m -> flush (s TSRMLS_CC );
1212
+
1213
+ /*
1214
+ Don't free now, let the result be usable. When the stmt will again be
1215
+ executed then the result set will be cleaned, the bound variables will
1216
+ be separated before that.
1217
+ */
1218
+
1219
+ int4store (cmd_buf , stmt -> stmt_id );
1220
+ if (CONN_GET_STATE (conn ) == CONN_READY &&
1221
+ FAIL == (ret = conn -> m -> simple_command (conn , COM_STMT_RESET , cmd_buf ,
1222
+ sizeof (cmd_buf ), PROT_OK_PACKET ,
1223
+ FALSE, TRUE TSRMLS_CC ))) {
1224
+ stmt -> error_info = conn -> error_info ;
1225
+ }
1226
+ stmt -> upsert_status = conn -> upsert_status ;
1227
+
1228
+ stmt -> state = MYSQLND_STMT_PREPARED ;
1229
+ }
1230
+ DBG_INF (ret == PASS ? "PASS" :"FAIL" );
1231
+ DBG_RETURN (ret );
1232
+ }
1233
+ /* }}} */
1234
+
1235
+
1236
+ /* {{{ mysqlnd_stmt::flush */
1237
+ static enum_func_status
1238
+ MYSQLND_METHOD (mysqlnd_stmt , flush )(MYSQLND_STMT * const s TSRMLS_DC )
1239
+ {
1240
+ MYSQLND_STMT_DATA * stmt = s ? s -> data :NULL ;
1241
+ enum_func_status ret = PASS ;
1242
+
1243
+ DBG_ENTER ("mysqlnd_stmt::flush" );
1244
+ if (!stmt || !stmt -> conn ) {
1245
+ DBG_RETURN (FAIL );
1246
+ }
1247
+ DBG_INF_FMT ("stmt=%lu" , stmt -> stmt_id );
1248
+
1249
+ if (stmt -> stmt_id ) {
1231
1250
/*
1232
1251
If the user decided to close the statement right after execute()
1233
1252
We have to call the appropriate use_result() or store_result() and
@@ -1246,21 +1265,6 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s TSRMLS_DC)
1246
1265
}
1247
1266
} while (mysqlnd_stmt_more_results (s ) && mysqlnd_stmt_next_result (s ) == PASS );
1248
1267
1249
- /*
1250
- Don't free now, let the result be usable. When the stmt will again be
1251
- executed then the result set will be cleaned, the bound variables will
1252
- be separated before that.
1253
- */
1254
-
1255
- int4store (cmd_buf , stmt -> stmt_id );
1256
- if (CONN_GET_STATE (conn ) == CONN_READY &&
1257
- FAIL == (ret = conn -> m -> simple_command (conn , COM_STMT_RESET , cmd_buf ,
1258
- sizeof (cmd_buf ), PROT_OK_PACKET ,
1259
- FALSE, TRUE TSRMLS_CC ))) {
1260
- stmt -> error_info = conn -> error_info ;
1261
- }
1262
- stmt -> upsert_status = conn -> upsert_status ;
1263
-
1264
1268
stmt -> state = MYSQLND_STMT_PREPARED ;
1265
1269
}
1266
1270
DBG_INF (ret == PASS ? "PASS" :"FAIL" );
@@ -2335,7 +2339,8 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_stmt)
2335
2339
MYSQLND_METHOD (mysqlnd_stmt , server_status ),
2336
2340
mysqlnd_stmt_execute_generate_request ,
2337
2341
mysqlnd_stmt_execute_parse_response ,
2338
- MYSQLND_METHOD (mysqlnd_stmt , free_stmt_content )
2342
+ MYSQLND_METHOD (mysqlnd_stmt , free_stmt_content ),
2343
+ MYSQLND_METHOD (mysqlnd_stmt , flush )
2339
2344
MYSQLND_CLASS_METHODS_END ;
2340
2345
2341
2346
0 commit comments