Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-13793: Implement SQLRowCount for SELECT #8525

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions modules/platforms/cpp/odbc-test/src/queries_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ BOOST_AUTO_TEST_CASE(TestErrorMessage)

BOOST_AUTO_TEST_CASE(TestAffectedRows)
{
Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache");
Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache;PAGE_SIZE=1024");

const int recordsNum = 100;

Expand Down Expand Up @@ -1670,7 +1670,41 @@ BOOST_AUTO_TEST_CASE(TestAffectedRows)
if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));

BOOST_CHECK_EQUAL(affected, 0);
BOOST_CHECK_EQUAL(affected, 1024);
}

BOOST_AUTO_TEST_CASE(TestAffectedRowsOnSelect)
{
Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache;PAGE_SIZE=123");

const int recordsNum = 1000;

// Inserting values.
InsertTestStrings(recordsNum);

// Just selecting everything to make sure everything is OK
SQLCHAR selectReq[] = "SELECT _key, strField FROM TestType ORDER BY _key";

SQLRETURN ret = SQLExecDirect(stmt, selectReq, sizeof(selectReq));

if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));

for (int i = 0; i < 200; ++i)
{
SQLLEN affected = -1;
ret = SQLRowCount(stmt, &affected);

if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));

BOOST_CHECK_EQUAL(affected, 123);

ret = SQLFetch(stmt);

if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
}

BOOST_AUTO_TEST_CASE(TestMultipleSelects)
Expand Down
7 changes: 5 additions & 2 deletions modules/platforms/cpp/odbc/src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ namespace ignite
{
namespace odbc
{
Cursor::Cursor(int64_t queryId) : queryId(queryId), currentPage(),
currentPagePos(0), currentRow()
Cursor::Cursor(int64_t queryId) :
queryId(queryId),
currentPage(),
currentPagePos(0),
currentRow()
{
// No-op.
}
Expand Down
6 changes: 5 additions & 1 deletion modules/platforms/cpp/odbc/src/query/data_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ namespace ignite
int64_t DataQuery::AffectedRows() const
{
int64_t affected = rowsAffectedIdx < rowsAffected.size() ? rowsAffected[rowsAffectedIdx] : 0;
return affected < 0 ? 0 : affected;

if (affected >= 0)
return affected;

return connection.GetConfiguration().GetPageSize();
}

SqlResult::Type DataQuery::NextResultSet()
Expand Down