Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ext/pdo_odbc/odbc_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,24 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
sizeof(S->cols[colno].colname)-1, &colnamelen,
&S->cols[colno].coltype, &colsize, NULL, NULL);

/* This fixes a known issue with SQL Server and (max) lengths,
may affect others as well. If we are SQL_VARCHAR,
SQL_VARBINARY, or SQL_WVARCHAR (or any of the long variations)
and zero is returned from colsize then consider it long */
if (0 == colsize && (
S->cols[colno].coltype == SQL_VARCHAR ||
S->cols[colno].coltype == SQL_LONGVARCHAR ||
#ifdef SQL_WVARCHAR
S->cols[colno].coltype == SQL_WVARCHAR ||
#endif
#ifdef SQL_WLONGVARCHAR
S->cols[colno].coltype == SQL_WLONGVARCHAR ||
#endif
S->cols[colno].coltype == SQL_VARBINARY ||
S->cols[colno].coltype == SQL_LONGVARBINARY)) {
S->going_long = 1;
}

if (rc != SQL_SUCCESS) {
pdo_odbc_stmt_error("SQLDescribeCol");
if (rc != SQL_SUCCESS_WITH_INFO) {
Expand Down