From c9c0e7b52f4e78a9228661456ea868773a6ff1c9 Mon Sep 17 00:00:00 2001 From: Nick Grey <19329407+NGrey5@users.noreply.github.com> Date: Sun, 16 Aug 2026 16:25:31 -0500 Subject: [PATCH] fix long column data fetching Signed-off-by: Nick Grey <19329407+NGrey5@users.noreply.github.com> --- src/odbc.h | 1 + src/odbc_connection.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/odbc.h b/src/odbc.h index 9a971aa..099e355 100644 --- a/src/odbc.h +++ b/src/odbc.h @@ -210,6 +210,7 @@ typedef struct StatementData { SQLUINTEGER fetch_size; SQLULEN rows_fetched; bool result_set_end_reached = false; + bool has_long_data = false; bool fetch_array = false; diff --git a/src/odbc_connection.cpp b/src/odbc_connection.cpp index 5486179..80b14c6 100644 --- a/src/odbc_connection.cpp +++ b/src/odbc_connection.cpp @@ -3430,7 +3430,7 @@ fetch_and_store(StatementData* data, bool set_position, bool* alloc_error) { // iterate through all of the rows fetched (but not the fetch size) 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) { // In case the result set contains columns that contain LONG data // types, use SQLSetPos to set the row we are transferring bound data // from, and use SQLGetData in the same loop. @@ -3460,6 +3460,9 @@ fetch_and_store(StatementData* data, bool set_position, bool* alloc_error) { // SQLBindCol, and therefore there is no data to move from a buffer. // Instead, call SQLGetData, and adjust buffer size accordingly if (data->columns[column_index]->is_long_data) { + // Set the statement data as having long data + data->has_long_data = true; + SQLPOINTER target_buffer; SQLLEN buffer_size = data->query_options.initial_long_data_buffer_size;