Skip to content

fix long column data fetching - #490

Open
NGrey5 wants to merge 1 commit into
IBM:mainfrom
NGrey5:fix/long-column-fetch
Open

NGrey5 wants to merge 1 commit into
IBM:mainfrom
NGrey5:fix/long-column-fetch

Conversation

@NGrey5

@NGrey5 NGrey5 commented Aug 16, 2026

Copy link
Copy Markdown

Batched cursor fetches are calling SQLSetPos for columns that contain LONG data even when the queries do not contain LONG data. This causes some drivers to fail as the SQLSetPos call is unnecessary.

These changes mark StatementData with has_long_data if any of the columns in it are LONG. The data is then checked if has_long_data = true before calling SQLSetPos

Signed-off-by: Nick Grey <19329407+NGrey5@users.noreply.github.com>
@NGrey5
NGrey5 force-pushed the fix/long-column-fetch branch from e027c01 to c9c0e7b Compare August 16, 2026 21:26
Comment thread src/odbc_connection.cpp
for (size_t row_index = 0; row_index < data->rows_fetched; row_index++) {
if (set_position && data->get_data_supports.block &&
data->fetch_size > 1) {
data->fetch_size > 1 && data->has_long_data) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of this is confusing since we're only setting the flag after this check, but this basically just always skips SQLSetPos for the first row. We shouldn't need to call SQLSetPos on the first row and by the second row we'll have set it, so that should work despite being a bit confusing.

Comment thread src/odbc_connection.cpp
Comment on lines +3463 to +3464
// Set the statement data as having long data
data->has_long_data = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce confusion, I think this should be moved into bind_buffers wherever we set is_long_data = true. This also means we don't have to set this value for every row, but only once per long data column.

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.

2 participants