Skip to content

Commit 391ed04

Browse files
committed
Fix for PECL bug php#8944. Could also be the same problem as pecl #7775.
1 parent ea2d323 commit 391ed04

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

ext/pdo_odbc/odbc_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| PHP Version 5 |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2005 The PHP Group |
5+
| Copyright (c) 1997-2006 The PHP Group |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 3.0 of the PHP license, |
88
| that is bundled with this package in the file LICENSE, and is |

ext/pdo_odbc/odbc_stmt.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| PHP Version 5 |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2005 The PHP Group |
5+
| Copyright (c) 1997-2006 The PHP Group |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 3.0 of the PHP license, |
88
| 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)
404404
* column. */
405405
if (colsize < 256 && !S->going_long) {
406406
S->cols[colno].data = emalloc(colsize+1);
407+
S->cols[colno].is_long = 0;
407408

408409
rc = SQLBindCol(S->stmt, colno+1, SQL_C_CHAR, S->cols[colno].data,
409410
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)
417418
* "long" columns */
418419
S->cols[colno].data = emalloc(256);
419420
S->going_long = 1;
421+
S->cols[colno].is_long = 1;
420422
}
421423

422424
return 1;
@@ -428,7 +430,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
428430
pdo_odbc_column *C = &S->cols[colno];
429431

430432
/* if it is a column containing "long" data, perform late binding now */
431-
if (C->datalen > 255) {
433+
if (C->is_long) {
432434
unsigned long alloced = 4096;
433435
unsigned long used = 0;
434436
char *buf;
@@ -468,6 +470,11 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
468470
if (rc == SQL_NO_DATA) {
469471
/* we got the lot */
470472
break;
473+
} else if (rc != SQL_SUCCESS) {
474+
pdo_odbc_stmt_error("SQLGetData");
475+
if (rc != SQL_SUCCESS_WITH_INFO) {
476+
break;
477+
}
471478
}
472479

473480
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
476483
used += C->fetched_len;
477484
}
478485

486+
if (rc == SQL_SUCCESS) {
487+
/* this was the final fetch */
488+
break;
489+
}
490+
479491
/* we need to fetch another chunk; resize the
480492
* buffer */
481493
alloced *= 2;

ext/pdo_odbc/pdo_odbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| PHP Version 5 |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2005 The PHP Group |
5+
| Copyright (c) 1997-2006 The PHP Group |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 3.0 of the PHP license, |
88
| that is bundled with this package in the file LICENSE, and is |

ext/pdo_odbc/php_pdo_odbc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| PHP Version 5 |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2005 The PHP Group |
5+
| Copyright (c) 1997-2006 The PHP Group |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 3.0 of the PHP license, |
88
| that is bundled with this package in the file LICENSE, and is |

ext/pdo_odbc/php_pdo_odbc_int.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| PHP Version 5 |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2005 The PHP Group |
5+
| Copyright (c) 1997-2006 The PHP Group |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 3.0 of the PHP license, |
88
| that is bundled with this package in the file LICENSE, and is |
@@ -137,6 +137,7 @@ typedef struct {
137137
long fetched_len;
138138
SWORD coltype;
139139
char colname[128];
140+
unsigned is_long;
140141
} pdo_odbc_column;
141142

142143
typedef struct {

0 commit comments

Comments
 (0)