wez             Wed Oct 11 03:07:29 2006 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/pdo_odbc       odbc_stmt.c 
    /php-src/ext/pdo_odbc/tests long_columns.phpt 
  Log:
  Fix for PECL #7755; use the displayable column width as the basis for our
  buffer size, as the raw column size can be too small when requesting
  a string representation.
  
  Also fix up bogus error output when fetching, and another one of the test
  cases to make it run against SQL Server 2005.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_odbc/odbc_stmt.c?r1=1.26.2.2.2.1&r2=1.26.2.2.2.2&diff_format=u
Index: php-src/ext/pdo_odbc/odbc_stmt.c
diff -u php-src/ext/pdo_odbc/odbc_stmt.c:1.26.2.2.2.1 
php-src/ext/pdo_odbc/odbc_stmt.c:1.26.2.2.2.2
--- php-src/ext/pdo_odbc/odbc_stmt.c:1.26.2.2.2.1       Wed Oct 11 02:10:56 2006
+++ php-src/ext/pdo_odbc/odbc_stmt.c    Wed Oct 11 03:07:28 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: odbc_stmt.c,v 1.26.2.2.2.1 2006/10/11 02:10:56 wez Exp $ */
+/* $Id: odbc_stmt.c,v 1.26.2.2.2.2 2006/10/11 03:07:28 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -359,7 +359,10 @@
        }
        rc = SQLFetchScroll(S->stmt, odbcori, offset);
 
-       if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
+       if (rc == SQL_SUCCESS) {
+               return 1;
+       }
+       if (rc == SQL_SUCCESS_WITH_INFO) {
                pdo_odbc_stmt_error("SQLFetchScroll");
                return 1;
        }
@@ -381,16 +384,30 @@
        zend_bool dyn = FALSE;
        RETCODE rc;
        SWORD   colnamelen;
-       SDWORD  colsize;
+       SDWORD  colsize, displaysize;
 
        rc = SQLDescribeCol(S->stmt, colno+1, S->cols[colno].colname,
                        sizeof(S->cols[colno].colname)-1, &colnamelen,
                        &S->cols[colno].coltype, &colsize, NULL, NULL);
 
        if (rc != SQL_SUCCESS) {
-               pdo_odbc_stmt_error("SQLBindCol");
-               return 0;
+               pdo_odbc_stmt_error("SQLDescribeCol");
+               if (rc != SQL_SUCCESS_WITH_INFO) {
+                       return 0;
+               }
+       }
+
+       rc = SQLColAttribute(S->stmt, colno+1,
+                       SQL_DESC_DISPLAY_SIZE,
+                       NULL, 0, NULL, &displaysize);
+
+       if (rc != SQL_SUCCESS) {
+               pdo_odbc_stmt_error("SQLColAttribute");
+               if (rc != SQL_SUCCESS_WITH_INFO) {
+                       return 0;
+               }
        }
+       colsize = displaysize;
 
        col->maxlen = S->cols[colno].datalen = colsize;
        col->namelen = colnamelen;
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_odbc/tests/long_columns.phpt?r1=1.2.2.1&r2=1.2.2.1.2.1&diff_format=u
Index: php-src/ext/pdo_odbc/tests/long_columns.phpt
diff -u php-src/ext/pdo_odbc/tests/long_columns.phpt:1.2.2.1 
php-src/ext/pdo_odbc/tests/long_columns.phpt:1.2.2.1.2.1
--- php-src/ext/pdo_odbc/tests/long_columns.phpt:1.2.2.1        Tue Sep 20 
00:46:02 2005
+++ php-src/ext/pdo_odbc/tests/long_columns.phpt        Wed Oct 11 03:07:29 2006
@@ -12,7 +12,9 @@
 
 if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data 
CLOB)')) {
        if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY 
KEY, data longtext)')) {
-               die("BORK: don't know how to create a long column here:\n" . 
implode(", ", $db->errorInfo()));
+               if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL 
PRIMARY KEY, data varchar(4000))')) {
+                       die("BORK: don't know how to create a long column 
here:\n" . implode(", ", $db->errorInfo()));
+               }
        }
 }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to