@@ -80,13 +80,13 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
80
80
#endif /* PDO_USE_MYSQLND */
81
81
82
82
#ifdef HAVE_MYSQL_STMT_PREPARE
83
- if (S -> bound_result )
83
+ if (S -> bound_result )
84
84
{
85
85
int i ;
86
86
for (i = 0 ; i < stmt -> column_count ; i ++ ) {
87
87
pdo_free_bound_result (S -> bound_result [i ]);
88
88
}
89
-
89
+
90
90
efree (S -> bound_result );
91
91
efree (S -> out_null );
92
92
efree (S -> out_length );
@@ -101,13 +101,13 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
101
101
if (mysql_next_result (S -> H -> server ) != 0 ) {
102
102
break ;
103
103
}
104
-
104
+
105
105
res = mysql_store_result (S -> H -> server );
106
106
if (res ) {
107
107
mysql_free_result (res );
108
108
}
109
109
}
110
- }
110
+ }
111
111
#endif /* HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND */
112
112
#if PDO_USE_MYSQLND
113
113
if (!S -> stmt && S -> current_data ) {
@@ -186,23 +186,23 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC)
186
186
}
187
187
188
188
if (!S -> result ) {
189
- int i ;
190
-
191
- /* figure out the result set format, if any */
192
- S -> result = mysql_stmt_result_metadata (S -> stmt );
193
- if (S -> result ) {
194
- int calc_max_length = H -> buffered && S -> max_length == 1 ;
195
- S -> fields = mysql_fetch_fields (S -> result );
196
- if (S -> bound_result ) {
197
- int i ;
198
- for (i = 0 ; i < stmt -> column_count ; i ++ ) {
199
- efree (S -> bound_result [i ].buffer );
200
- }
201
- efree (S -> bound_result );
202
- efree (S -> out_null );
203
- efree (S -> out_length );
189
+ int i ;
190
+
191
+ /* figure out the result set format, if any */
192
+ S -> result = mysql_stmt_result_metadata (S -> stmt );
193
+ if (S -> result ) {
194
+ int calc_max_length = H -> buffered && S -> max_length == 1 ;
195
+ S -> fields = mysql_fetch_fields (S -> result );
196
+ if (S -> bound_result ) {
197
+ int i ;
198
+ for (i = 0 ; i < stmt -> column_count ; i ++ ) {
199
+ efree (S -> bound_result [i ].buffer );
200
+ }
201
+ efree (S -> bound_result );
202
+ efree (S -> out_null );
203
+ efree (S -> out_length );
204
204
}
205
-
205
+
206
206
stmt -> column_count = (int )mysql_num_fields (S -> result );
207
207
S -> bound_result = ecalloc (stmt -> column_count , sizeof (MYSQL_BIND ));
208
208
S -> out_null = ecalloc (stmt -> column_count , sizeof (my_bool ));
@@ -268,7 +268,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC)
268
268
}
269
269
}
270
270
}
271
-
271
+
272
272
pdo_mysql_stmt_set_row_count (stmt TSRMLS_CC );
273
273
PDO_DBG_RETURN (1 );
274
274
}
@@ -281,9 +281,9 @@ static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt TSRMLS_DC) /
281
281
pdo_mysql_stmt * S = stmt -> driver_data ;
282
282
pdo_mysql_db_handle * H = S -> H ;
283
283
int i ;
284
-
284
+
285
285
PDO_DBG_ENTER ("pdo_mysql_stmt_execute_prepared_mysqlnd" );
286
-
286
+
287
287
if (mysql_stmt_execute (S -> stmt )) {
288
288
pdo_mysql_error_stmt (stmt );
289
289
PDO_DBG_RETURN (0 );
@@ -311,7 +311,7 @@ static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt TSRMLS_DC) /
311
311
}
312
312
}
313
313
}
314
-
314
+
315
315
pdo_mysql_stmt_set_row_count (stmt TSRMLS_CC );
316
316
PDO_DBG_RETURN (1 );
317
317
}
@@ -330,7 +330,7 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
330
330
PDO_DBG_RETURN (pdo_mysql_stmt_execute_prepared (stmt ));
331
331
}
332
332
#endif
333
-
333
+
334
334
/* ensure that we free any previous unfetched results */
335
335
if (S -> result ) {
336
336
mysql_free_result (S -> result );
@@ -366,8 +366,8 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
366
366
}
367
367
368
368
if (!mysqlnd_stmt_more_results (S -> stmt )) {
369
- /*
370
- MySQL gives us n + 1 result sets for
369
+ /*
370
+ MySQL gives us n + 1 result sets for
371
371
CALL proc() and n result sets returned by the proc itself.
372
372
Result set n + 1 is about the procedure call itself.
373
373
As the PDO emulation does not return it, we skip it as well
@@ -422,7 +422,19 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
422
422
}
423
423
424
424
ret = mysql_next_result (H -> server );
425
-
425
+ #if PDO_USE_MYSQLND
426
+ /* for whatever reason mysqlnd breaks with libmysql compatibility at the C level, no -1 */
427
+ if (PASS != ret ) {
428
+ pdo_mysql_error_stmt (stmt );
429
+ PDO_DBG_RETURN (0 );
430
+ }
431
+ if (mysql_more_results (H -> server )) {
432
+ PDO_DBG_RETURN (pdo_mysql_fill_stmt_from_result (stmt TSRMLS_CC ));
433
+ } else {
434
+ /* No more results */
435
+ PDO_DBG_RETURN (0 );
436
+ }
437
+ #else
426
438
if (ret > 0 ) {
427
439
pdo_mysql_error_stmt (stmt );
428
440
PDO_DBG_RETURN (0 );
@@ -432,6 +444,8 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
432
444
} else {
433
445
PDO_DBG_RETURN (pdo_mysql_fill_stmt_from_result (stmt TSRMLS_CC ));
434
446
}
447
+ #endif
448
+
435
449
#else
436
450
strcpy (stmt -> error_code , "HYC00" );
437
451
PDO_DBG_RETURN (0 );
@@ -458,7 +472,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
458
472
PDO_MYSQL_PARAM_BIND * b ;
459
473
#endif
460
474
#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
461
- pdo_mysql_stmt * S = (pdo_mysql_stmt * )stmt -> driver_data ;
475
+ pdo_mysql_stmt * S = (pdo_mysql_stmt * )stmt -> driver_data ;
462
476
463
477
PDO_DBG_ENTER ("pdo_mysql_stmt_param_hook" );
464
478
PDO_DBG_INF_FMT ("stmt=%p" , S -> stmt );
@@ -498,18 +512,18 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
498
512
}
499
513
#else
500
514
b = (PDO_MYSQL_PARAM_BIND * )param -> driver_data ;
501
- * b -> is_null = 0 ;
502
- if (PDO_PARAM_TYPE (param -> param_type ) == PDO_PARAM_NULL ||
503
- Z_TYPE_P (param -> parameter ) == IS_NULL ) {
504
- * b -> is_null = 1 ;
505
- b -> buffer_type = MYSQL_TYPE_STRING ;
506
- b -> buffer = NULL ;
507
- b -> buffer_length = 0 ;
508
- * b -> length = 0 ;
515
+ * b -> is_null = 0 ;
516
+ if (PDO_PARAM_TYPE (param -> param_type ) == PDO_PARAM_NULL ||
517
+ Z_TYPE_P (param -> parameter ) == IS_NULL ) {
518
+ * b -> is_null = 1 ;
519
+ b -> buffer_type = MYSQL_TYPE_STRING ;
520
+ b -> buffer = NULL ;
521
+ b -> buffer_length = 0 ;
522
+ * b -> length = 0 ;
509
523
PDO_DBG_RETURN (1 );
510
- }
524
+ }
511
525
#endif /* PDO_USE_MYSQLND */
512
-
526
+
513
527
switch (PDO_PARAM_TYPE (param -> param_type )) {
514
528
case PDO_PARAM_STMT :
515
529
PDO_DBG_RETURN (0 );
@@ -533,7 +547,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
533
547
default :
534
548
;
535
549
}
536
-
550
+
537
551
#if PDO_USE_MYSQLND
538
552
/* Is it really correct to check the zval's type? - But well, that's what the old code below does, too */
539
553
PDO_DBG_INF_FMT ("param->parameter->type=%d" , Z_TYPE_P (param -> parameter ));
@@ -554,9 +568,9 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
554
568
default :
555
569
PDO_DBG_RETURN (0 );
556
570
}
557
-
571
+
558
572
PDO_DBG_RETURN (1 );
559
- #else
573
+ #else
560
574
PDO_DBG_INF_FMT ("param->parameter->type=%d" , Z_TYPE_P (param -> parameter ));
561
575
switch (Z_TYPE_P (param -> parameter )) {
562
576
case IS_STRING :
@@ -612,7 +626,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
612
626
#else
613
627
# if HAVE_MYSQL_STMT_PREPARE
614
628
int ret ;
615
-
629
+
616
630
if (S -> stmt ) {
617
631
ret = mysql_stmt_fetch (S -> stmt );
618
632
@@ -633,7 +647,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
633
647
}
634
648
# endif /* HAVE_MYSQL_STMT_PREPARE */
635
649
#endif /* PDO_USE_MYSQLND */
636
-
650
+
637
651
if (!S -> result ) {
638
652
strcpy (stmt -> error_code , "HY000" );
639
653
PDO_DBG_RETURN (0 );
@@ -653,7 +667,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
653
667
pdo_mysql_error_stmt (stmt );
654
668
}
655
669
PDO_DBG_RETURN (0 );
656
- }
670
+ }
657
671
658
672
S -> current_lengths = mysql_fetch_lengths (S -> result );
659
673
PDO_DBG_RETURN (1 );
@@ -677,8 +691,8 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
677
691
PDO_DBG_RETURN (0 );
678
692
}
679
693
680
- /* fetch all on demand, this seems easiest
681
- ** if we've been here before bail out
694
+ /* fetch all on demand, this seems easiest
695
+ ** if we've been here before bail out
682
696
*/
683
697
if (cols [0 ].name ) {
684
698
PDO_DBG_RETURN (1 );
@@ -694,10 +708,10 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
694
708
cols [i ].namelen = namelen ;
695
709
cols [i ].name = estrndup (S -> fields [i ].name , namelen );
696
710
}
697
-
711
+
698
712
cols [i ].precision = S -> fields [i ].decimals ;
699
713
cols [i ].maxlen = S -> fields [i ].length ;
700
-
714
+
701
715
#ifdef PDO_USE_MYSQLND
702
716
if (S -> stmt ) {
703
717
cols [i ].param_type = PDO_PARAM_ZVAL ;
@@ -818,7 +832,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
818
832
const MYSQL_FIELD * F ;
819
833
zval * flags ;
820
834
char * str ;
821
-
835
+
822
836
PDO_DBG_ENTER ("pdo_mysql_stmt_col_meta ");
823
837
PDO_DBG_INF_FMT ("stmt = %p ", S -> stmt ) ;
824
838
if (!S -> result ) {
@@ -876,7 +890,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
876
890
break ;
877
891
}
878
892
#endif
879
-
893
+
880
894
add_assoc_zval (return_value , "flags" , flags );
881
895
add_assoc_string (return_value , "table" ,(char * ) (F -> table ?F -> table :"" ), 1 );
882
896
PDO_DBG_RETURN (SUCCESS );
0 commit comments