2
2
+----------------------------------------------------------------------+
3
3
| PHP Version 5 |
4
4
+----------------------------------------------------------------------+
5
- | Copyright (c) 1997-2005 The PHP Group |
5
+ | Copyright (c) 1997-2006 The PHP Group |
6
6
+----------------------------------------------------------------------+
7
7
| This source file is subject to version 3.0 of the PHP license, |
8
8
| that is bundled with this package in the file LICENSE, and is |
@@ -404,6 +404,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
404
404
* column. */
405
405
if (colsize < 256 && !S -> going_long ) {
406
406
S -> cols [colno ].data = emalloc (colsize + 1 );
407
+ S -> cols [colno ].is_long = 0 ;
407
408
408
409
rc = SQLBindCol (S -> stmt , colno + 1 , SQL_C_CHAR , S -> cols [colno ].data ,
409
410
S -> cols [colno ].datalen + 1 , & S -> cols [colno ].fetched_len );
@@ -417,6 +418,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
417
418
* "long" columns */
418
419
S -> cols [colno ].data = emalloc (256 );
419
420
S -> going_long = 1 ;
421
+ S -> cols [colno ].is_long = 1 ;
420
422
}
421
423
422
424
return 1 ;
@@ -428,7 +430,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
428
430
pdo_odbc_column * C = & S -> cols [colno ];
429
431
430
432
/* if it is a column containing "long" data, perform late binding now */
431
- if (C -> datalen > 255 ) {
433
+ if (C -> is_long ) {
432
434
unsigned long alloced = 4096 ;
433
435
unsigned long used = 0 ;
434
436
char * buf ;
@@ -468,6 +470,11 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
468
470
if (rc == SQL_NO_DATA ) {
469
471
/* we got the lot */
470
472
break ;
473
+ } else if (rc != SQL_SUCCESS ) {
474
+ pdo_odbc_stmt_error ("SQLGetData" );
475
+ if (rc != SQL_SUCCESS_WITH_INFO ) {
476
+ break ;
477
+ }
471
478
}
472
479
473
480
if (C -> fetched_len == SQL_NO_TOTAL ) {
@@ -476,6 +483,11 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
476
483
used += C -> fetched_len ;
477
484
}
478
485
486
+ if (rc == SQL_SUCCESS ) {
487
+ /* this was the final fetch */
488
+ break ;
489
+ }
490
+
479
491
/* we need to fetch another chunk; resize the
480
492
* buffer */
481
493
alloced *= 2 ;
0 commit comments