]> granicus.if.org Git - php/commitdiff
Fix for PECL bug #8944. Could also be the same problem as pecl #7775.
authorWez Furlong <wez@php.net>
Wed, 11 Oct 2006 02:10:56 +0000 (02:10 +0000)
committerWez Furlong <wez@php.net>
Wed, 11 Oct 2006 02:10:56 +0000 (02:10 +0000)
ext/pdo_odbc/odbc_driver.c
ext/pdo_odbc/odbc_stmt.c
ext/pdo_odbc/pdo_odbc.c
ext/pdo_odbc/php_pdo_odbc.h
ext/pdo_odbc/php_pdo_odbc_int.h

index 5585cecf381f681ce8488d6621073f3ed0d98322..1f0114156e4fdf0c757c42fbebe336b315f9c8fc 100755 (executable)
@@ -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        |
index 628779f03346b6c0f0238c433b72900b069c0427..ae751cb5ec3ce30dc6861e6987bb50151292ca97 100755 (executable)
@@ -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        |
@@ -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);
@@ -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;
@@ -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;
@@ -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) {
@@ -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;
index 65c999df8f4bfe539ebb9e5a25d58fdceeda4015..38cd3e7f15f0b8c30578e7aa2d8663f3b4caa8b9 100755 (executable)
@@ -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        |
index 8d290b38b4ef5aa5ec9a0304a8d4624288715ef3..d089d8311edbcd98994ac00c9ddacf3f241e083b 100644 (file)
@@ -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        |
index 8e6630052ea03c4e6b212db4330b5bf354fddca1..2653ced6b38980c517c1be74f86b90c7474f9a6e 100755 (executable)
@@ -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        |
@@ -137,6 +137,7 @@ typedef struct {
        long fetched_len;
        SWORD   coltype;
        char colname[128];
+       unsigned is_long;
 } pdo_odbc_column;
 
 typedef struct {