diff options
| author | Anatol Belski <ab@php.net> | 2015-04-28 15:02:48 +0200 |
|---|---|---|
| committer | Anatol Belski <ab@php.net> | 2015-04-28 15:02:48 +0200 |
| commit | 268eb1999b1598a2a1a875c5f0172d5b615811ac (patch) | |
| tree | 35ebe4386b2499610a9a9538e1e0b0454f31b71d /ext/odbc/php_odbc.c | |
| parent | ac275f9e31379b058050a0139ec9b4dea8ea0013 (diff) | |
| download | php-git-268eb1999b1598a2a1a875c5f0172d5b615811ac.tar.gz | |
fix bug #69381
a simpler version is to be backported
Diffstat (limited to 'ext/odbc/php_odbc.c')
| -rw-r--r-- | ext/odbc/php_odbc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 3015441c39..9e51dca75f 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -993,6 +993,27 @@ int odbc_bindcols(odbc_result *result) default: rc = PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)(i+1), colfieldid, NULL, 0, NULL, &displaysize); +#if defined(ODBCVER) && (ODBCVER >= 0x0300) + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO && colfieldid == SQL_DESC_OCTET_LENGTH) { + SQLINTEGER err; + SQLCHAR errtxt[128]; + SQLCHAR state[6]; + + memset(errtxt, '\0', 128); + memset(state, '\0', 6); + + if (SQL_SUCCESS == SQLGetDiagRec(SQL_HANDLE_STMT, result->stmt, 1, state, &err, errtxt, 128, NULL)) { + errtxt[127] = '\0'; + state[5] = '\0'; + php_error_docref(NULL, E_WARNING, "SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH: [%s] %s", state, errtxt); + } + /* This is a quirk for ODBC 2.0 compatibility for broken driver implementations. + */ + charextraalloc = 1; + rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_DISPLAY_SIZE, + NULL, 0, NULL, &displaysize); + } +#endif /* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */ if (result->values[i].coltype == SQL_TIMESTAMP) { displaysize += 3; |
