Skip to content

Report INT_MAX instead of SQL_NO_TOTAL for SQLGetTypeInfo COLUMN_SIZE (#215) - #218

Merged
davecramer merged 1 commit into
mainfrom
fix-215-no-total-column-size
Oct 7, 2026
Merged

davecramer merged 1 commit into
mainfrom
fix-215-no-total-column-size

Conversation

@davecramer

Copy link
Copy Markdown
Contributor

Fixes #215.

With ByteaAsLongVarBinary=1 (the default), SQLGetTypeInfo reports COLUMN_SIZE = SQL_NO_TOTAL (-4) for bytea, and likewise for the large object type. SQL_NO_TOTAL is a length/indicator value, not a column size.

MSDASQL binds COLUMN_SIZE as SQL_C_ULONG. Before #210 the -4 silently wrapped to 4294967292. Since #210 added the 22003 range check, SQLFetch fails on the bytea row, MSDASQL never learns about the type, and ADO bytea parameters fail with "Type is invalid". This is a regression in 18.00.0003 and 18.00.0004.

This change reports INT_MAX (2147483647) instead, the largest size the INT4 column can hold. NULL would not help: MSDASQL binds without an indicator, so a NULL fails with 22002 instead.

Test

New typeinfo-column-size test fetches every SQLGetTypeInfo(SQL_ALL_TYPES) row with COLUMN_SIZE bound as SQL_C_ULONG and no indicator:

  • before: SQLFetch failed / 22003=Numeric value out of range
  • after: bytea: COLUMN_SIZE=2147483647

Full regression suite passes locally (65/65).

Not changed

SQLColumns, SQLSpecialColumns and SQLProcedureColumns can still return -4 in their size columns: for bytea and large object columns, and for all columns under UnknownSizes=DontKnow, where -4 is the behaviour that setting selects. No failure has been reported there, so they are left for a follow-up if needed.

Assisted-By: Claude

…#215)

With ByteaAsLongVarBinary=1 (the default), SQLGetTypeInfo reported
COLUMN_SIZE = SQL_NO_TOTAL (-4) for bytea, and likewise for the large
object type.  SQL_NO_TOTAL is a length/indicator value, not a column
size.  MSDASQL binds COLUMN_SIZE as SQL_C_ULONG; before #210 the -4
silently wrapped to 4294967292, but since the 22003 range check was
added SQLFetch fails on the bytea row, MSDASQL never learns the type,
and ADO bytea parameters fail with "Type is invalid".

Report INT_MAX (2147483647) instead, the largest size the INT4 column
can hold.  NULL is not an option: MSDASQL binds without an indicator,
so a NULL would fail with 22002 instead.

New typeinfo-column-size test fetches every SQLGetTypeInfo(SQL_ALL_TYPES)
row with COLUMN_SIZE bound as SQL_C_ULONG and no indicator.

Assisted-By: Claude
@davecramer
davecramer force-pushed the fix-215-no-total-column-size branch from 42c4565 to a8679f5 Compare October 7, 2026 15:32
@davecramer
davecramer merged commit 4686624 into main Oct 7, 2026
11 checks passed
@davecramer
davecramer deleted the fix-215-no-total-column-size branch October 7, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bytea parameters don't work with MSDASQL OleDB provider

1 participant