Skip to content

Commit

Permalink
Ignore varchar max sizes that are too small / negative.
Browse files Browse the repository at this point in the history
Fixes #201.  It didn't occur to me that some drivers might return a *negative* maximum varchar
size, such as FileMaker.  In hindsight, -1 is sometimes used, such as SQL Server's
varchar(max) precision.
  • Loading branch information
mkleehammer committed Feb 25, 2017
1 parent 457f017 commit 36c69a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cnxninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ inline void GetColumnSize(Connection* cnxn, SQLSMALLINT sqltype, int* psize)
SQL_SUCCEEDED(SQLFetch(hstmt)) &&
SQL_SUCCEEDED(SQLGetData(hstmt, 3, SQL_INTEGER, &columnsize, sizeof(columnsize), 0)))
{
*psize = (int)columnsize;
// I believe some drivers are returning negative numbers for "unlimited" text fields,
// such as FileMaker. Ignore anything that seems too small.
if (columnsize >= 255)
*psize = (int)columnsize;
}

SQLFreeStmt(hstmt, SQL_CLOSE);
Expand Down

0 comments on commit 36c69a7

Please sign in to comment.