Skip to content

Commit

Permalink
Fix for PECL bug php#8944. Could also be the same problem as pecl #7775.
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed Oct 11, 2006
1 parent ea2d323 commit 391ed04
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ext/pdo_odbc/odbc_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down
16 changes: 14 additions & 2 deletions ext/pdo_odbc/odbc_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -404,6 +404,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
* column. */
if (colsize < 256 && !S->going_long) {
S->cols[colno].data = emalloc(colsize+1);
S->cols[colno].is_long = 0;

rc = SQLBindCol(S->stmt, colno+1, SQL_C_CHAR, S->cols[colno].data,
S->cols[colno].datalen+1, &S->cols[colno].fetched_len);
Expand All @@ -417,6 +418,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
* "long" columns */
S->cols[colno].data = emalloc(256);
S->going_long = 1;
S->cols[colno].is_long = 1;
}

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

/* if it is a column containing "long" data, perform late binding now */
if (C->datalen > 255) {
if (C->is_long) {
unsigned long alloced = 4096;
unsigned long used = 0;
char *buf;
Expand Down Expand Up @@ -468,6 +470,11 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
if (rc == SQL_NO_DATA) {
/* we got the lot */
break;
} else if (rc != SQL_SUCCESS) {
pdo_odbc_stmt_error("SQLGetData");
if (rc != SQL_SUCCESS_WITH_INFO) {
break;
}
}

if (C->fetched_len == SQL_NO_TOTAL) {
Expand All @@ -476,6 +483,11 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
used += C->fetched_len;
}

if (rc == SQL_SUCCESS) {
/* this was the final fetch */
break;
}

/* we need to fetch another chunk; resize the
* buffer */
alloced *= 2;
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_odbc/pdo_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_odbc/php_pdo_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down
3 changes: 2 additions & 1 deletion ext/pdo_odbc/php_pdo_odbc_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -137,6 +137,7 @@ typedef struct {
long fetched_len;
SWORD coltype;
char colname[128];
unsigned is_long;
} pdo_odbc_column;

typedef struct {
Expand Down

0 comments on commit 391ed04

Please sign in to comment.