Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

Refine assert in result_impl::position with SQL_ROW_NUMBER_UNKNOWN #70

Merged
merged 2 commits into from Nov 30, 2015
Merged

Refine assert in result_impl::position with SQL_ROW_NUMBER_UNKNOWN #70

merged 2 commits into from Nov 30, 2015

Conversation

mloskot
Copy link
Contributor

@mloskot mloskot commented Nov 26, 2015

Apparently, not all drivers support SQLGetStmtAttr query for SQL_ATTR_ROW_NUMBER or there may be differences in behaviour.
For example, SQLiteODBC driver reports SQL_ROW_NUMBER_UNKNOWN(-2) which needs to be taken into account in the assertion.

NOTE: Behaviour of the position() function has not changed.
But, it may be sensible to check if SQL_ROW_NUMBER_UNKNOWN is returned, then use it as position() return value.
Currently, in such case, the function returns arguable value: SQL_ROW_NUMBER_UNKNOWN - 1 + rowset_position_.

See my SO question where I asked about implementation differences (I have checked their code) between various drivers: SQLite3, PostgreSQL, MySQL:
SQLGetStmtAttr output value for SQL_ATTR_ROW_NUMBER

Also, check in basic_test::simple_test might need refinements:

BOOST_CHECK(results.position());

All of the above has been reproduced and tested on Windows 10 using Visual Studio 2015 + SQLite ODBC driver 32-bit and 64-bit, building the library for both platforms, 32-bit and 64-bit.

Apparently, not all drivers support SQLGetStmtAttr query for
SQL_ATTR_ROW_NUMBER or there may be differences in behaviour.
For example, SQLite3 reports SQL_ROW_NUMBER_UNKNOWN(-2) which
needs to be taken into account in the assertion.

NOTE: Behaviour of the position() function has not changed.
But, it may be sensible to check if SQL_ROW_NUMBER_UNKNOWN
is returned, then use it as position() return value.
Currently, in such case, the function returns arguable value:
SQL_ROW_NUMBER_UNKNOWN - 1 + rowset_position_,

ALso, check in basic_test::simple_test might need refinements:
BOOST_CHECK(results.position());
Avoids comparison between signed and unsigned integer expressions [-Werror=sign-compare]
lexicalunit added a commit that referenced this pull request Nov 30, 2015
Refine assert in result_impl::position with SQL_ROW_NUMBER_UNKNOWN
@lexicalunit lexicalunit merged commit c036ced into lexicalunit:master Nov 30, 2015
@mloskot mloskot deleted the sqlite3-position branch December 2, 2015 10:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants