diff options
| author | Wez Furlong <wez@php.net> | 2006-10-11 03:07:29 +0000 |
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2006-10-11 03:07:29 +0000 |
| commit | 3028f7465d4b092f59208e9be0c31138d7b3ddbf (patch) | |
| tree | 75128ebf6fd6748c3b90175830380c35d8525fbe | |
| parent | 897b9ffca5c60cebe028d7a3769e4d1695462dbe (diff) | |
| download | php-git-3028f7465d4b092f59208e9be0c31138d7b3ddbf.tar.gz | |
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.
| -rwxr-xr-x | ext/pdo_odbc/odbc_stmt.c | 25 | ||||
| -rw-r--r-- | ext/pdo_odbc/tests/long_columns.phpt | 4 |
2 files changed, 24 insertions, 5 deletions
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index ae751cb5ec..d3ef4d3288 100755 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -359,7 +359,10 @@ static int odbc_stmt_fetch(pdo_stmt_t *stmt, } 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 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) 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; diff --git a/ext/pdo_odbc/tests/long_columns.phpt b/ext/pdo_odbc/tests/long_columns.phpt index bc3abe94ca..65ec2f96e9 100644 --- a/ext/pdo_odbc/tests/long_columns.phpt +++ b/ext/pdo_odbc/tests/long_columns.phpt @@ -12,7 +12,9 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); 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())); + } } } |
