Honour SQL_ATTR_PARAM_OPERATION_PTR in parameter-array execution - #310
Open
fdcastel wants to merge 5 commits into
Open
Honour SQL_ATTR_PARAM_OPERATION_PTR in parameter-array execution#310fdcastel wants to merge 5 commits into
fdcastel wants to merge 5 commits into
Conversation
Eleven ArrayBindingTest cases were skipped citing a crash in the column-wise indicator offset. That crash was fixed in 0a7cc1f (SQLINTEGER to SQLLEN), so the skips come out. ParamOperationPtrSkipRows stays skipped because SQL_ATTR_PARAM_OPERATION_PTR is still not honoured, and the reactivated cases get the Firebird 6 guard the row-wise ones already have. Two new cases bind fixed-length C types with BufferLength = 0, the usage the ODBC specification describes for those types: one with the shape reported in FirebirdSQL#299 (INTEGER and BIGINT with a NULL in the third parameter set), one across DOUBLE, DATE and TIMESTAMP.
…h is 0 SQLBindParameter stores BufferLength as the element stride of a column-wise parameter array. The ODBC specification ignores BufferLength for fixed-length C types and applications pass 0 there, so every parameter set read element 0: the driver inserted N rows carrying the first set's values and reported SQL_SUCCESS. bindInputOutputParam now falls back to the C type size when the stride is 0, the way bindOutputColumn already does for SQLBindCol. getConciseSize gains SQL_C_GUID, for which it returned the type code (-11) and would have produced a negative stride. Character and binary C types keep BufferLength as their stride, so string arrays behave as before. Fixes FirebirdSQL#299
…fter SQLPrepare The executor is chosen at prepare time from the paramset size in force at that moment. An application that prepares first and sets SQL_ATTR_PARAMSET_SIZE afterwards, which the specification allows and which pyodbc's fast_executemany does, got a single execution of the first parameter set, reported as success. sqlExecute and sqlExecDirect now switch to executeStatementParamArray when the paramset size is greater than 1 at execute time.
ParamOperationPtrSkipRows and RowWiseWithOperationPtr were skipped because the driver does not honour the operation array. Both get the Firebird 6 guard the other array cases carry and run from here on.
The operation array was stored in the APD (SQL_DESC_ARRAY_STATUS_PTR) but executeStatementParamArray never read it, so a set marked SQL_PARAM_IGNORE was executed like any other and an application had no way to skip a row short of rebuilding its arrays. The loop now skips ignored sets, leaves their status at SQL_PARAM_UNUSED and does not count them in SQL_ATTR_PARAMS_PROCESSED_PTR. The status array is filled with SQL_PARAM_UNUSED before the loop, so sets that were never reached read as unused, and status elements are addressed by set number instead of through a moving pointer. The processed count is kept per set instead of being written once after the loop, so it includes a failed set as the specification describes.
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #308: its three commits show here until it merges. This PR is the last two commits.
The problem
SQL_ATTR_PARAM_OPERATION_PTRwas accepted and stored (the APD'sSQL_DESC_ARRAY_STATUS_PTR) butexecuteStatementParamArraynever read it. A set markedSQL_PARAM_IGNOREwas executed like any other: five sets with two ignored gave five rows, fiveSQL_PARAM_SUCCESSand a processed count of 5. An application that uses the operation array to skip rows had no way to know.The fix
The loop skips a set whose operation element is
SQL_PARAM_IGNORE, leaves its status atSQL_PARAM_UNUSEDand does not count it. The status array is filled withSQL_PARAM_UNUSEDbefore the loop and addressed by set number instead of through a moving pointer, and the processed count is kept per set instead of written once at the end, so after an error it holds the number of sets reached, including the failed one, as the specification describes.Tests
ParamOperationPtrSkipRows(column-wise, sets 2 and 4 ignored) andRowWiseWithOperationPtr(row-wise, set 2 ignored) were already in the suite, skipped. Against the #308 driver both fail and the other 17 array cases pass. With this branch the array suite is 19 of 19 on Firebird 5, nothing skipped. Full suite,CHARSET=UTF8andNONE: 390 ran, 237 passed, 153 skipped, 0 failed.Probe (ctypes, Windows x64, Firebird 5.0.3, Microsoft driver manager), five column-wise sets with sets 2 and 4 ignored:
OK OK OK OK OKOK UNUSED OK UNUSED OKRow-wise with one ignored set behaves the same way.
Still open
SQL_PARAM_ERROR. With the pre-fill here the sets after the error readSQL_PARAM_UNUSEDand the processed count is right; the pointer is not touched.SQLRowCountafter an array execute: separate PR, stacked on this one.