microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
121 stars 40 forks source link

SQL_ATTR_DYNAMIC_COLUMNS and nested statements #73

Closed matthew-wozniczka closed 7 years ago

matthew-wozniczka commented 7 years ago

Would it make sense to not allow child statements to enabled SQL_ATTR_DYNAMIC_COLUMNS if the parent statement had it disabled?

Allowing a child statement to enable the property may require to the driver to cache data until the nested object is retrieved, even though it's possible (and I would argue likely, since the application is probably going to enable SQL_ATTR_DYNAMIC_COLUMNS on the root statement if it's going to use it at all) that the application won't attempt to fetch nested dynamic columns.

SQL_ATTR_MAX_LENGTH, SQL_ATTR_MAX_LENGTH, SQL_ATTR_RETRIEVE_DATA, and SQL_ATTR_USE_BOOKMARKS also have similar issues.

mikepizzo commented 7 years ago

Yes; I would think SQL_ATTR_DYNAMIC_COLUMNS is applied when a statement is executed, and applies to all nested statement handles. Changing with an open cursor could either be an error (similar to SQL_ATTR_CONCURRENCY), or apply to the next execute (similar to SQL_ATTR_CURSOR_SCROLLABLE). I would favor the former (make it an error to set if the cursor is in an open state).

mikepizzo commented 7 years ago

Could allow clients to change SQL_ATTR_DYNAMIC_COLUMNS from true to false as an optimization after execution.

Spell out behavior for other statement attributes: when they can be set and what their meaning is.

mikepizzo commented 7 years ago

Added text: Applications may change SQL_ATTR_DYNAMIC_COLUMNS from True to False at any time to ignore dynamic columns. Attempting to set SQL_ATTR_DYNAMIC_COLUMNS from False to True on a statement handle with an open cursor results in HY010, Function Sequence Error.

matthew-wozniczka commented 7 years ago

IMO Option Value Changed would be better (it's not the function which was an issue, but an argument to it)

mikepizzo commented 7 years ago

SQL_ATTR_MAX_LENGTH, SQL_ATTR_RETRIEVE_DATA, and SQL_ATTR_USE_BOOKMARKS already have rules about attempting to apply to an open cursor (which would include a handle nested under an open cursor).

mikepizzo commented 7 years ago

I hate to use Option Value Changed here since it's a success code, and the client's intent (being able to retrieve dynamic columns) isn't met, potentially leading them to make wrong assumptions about the results (i.e., that there are no more additional columns).