microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
122 stars 40 forks source link

SQL_MORE_DATA - When is bound buffer filled? #66

Closed matthew-wozniczka closed 7 years ago

matthew-wozniczka commented 7 years ago

In section 3.8 (Variable Length Columns) it states:

When the driver returns SQL_MORE_DATA, the application calls SQLNextColumn in order to determine the column of partially fetched data. The bound buffer will be populated and the str_len_or_ind_ptr will indicate the total amount of data available, if known, or SQL_NO_TOTAL if the driver does not know how much additional data is to be written.

Is the buffer populated after SQLFetch/SQLFetchScroll returns, or only after SQLNextColumn does? I would expect the former, but the text implies the latter (Only relevant since the application can determine which bindings were filled thanks to the new SQL_DATA_UNAVAILABLE).

mikepizzo commented 7 years ago

Contract is that the buffer is populated once SQLNextColumn is called. Driver could populate sooner, but client should not expect it to be populated when SQLNextColumn is called.

matthew-wozniczka commented 7 years ago

Related to #101

mikepizzo commented 7 years ago

Sorry; misread that this is the SQL_MORE_DATA state. At the time SQL_MORE_DATA is returned, the buffer should contain up to the first BufferLength number of characters, and str_len_or_ind_ptr should indicate the total amount of data available, if known. This is a hint to the application how much buffer to allocate in SqlGetData for the remaining data.

mikepizzo commented 7 years ago

Clarified in section 3.8: When the length of data exceeds the bound buffer for string or binary data, and the application has set SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR to SQL_LE_REPORT, the driver populates as much data as fits in the allocated buffer, sets str_len_or_ind_ptr to indicate the total amount of data available, if known, or SQL_NO_TOTAL if the driver does not know how much additional data is to be written, and returns SQL_MORE_DATA.