Skip to content

Commit 909b644

Browse files
committed
IGNITE-8838: Fixed ODBC issue with two inserts without closing cursor.
1 parent 3fff8a8 commit 909b644

File tree

8 files changed

+44
-17
lines changed

8 files changed

+44
-17
lines changed

modules/platforms/cpp/core-test/src/compute_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ BOOST_AUTO_TEST_CASE(IgniteBroadcastLocalSync)
513513
{
514514
Compute compute = node.GetCompute();
515515

516-
BOOST_CHECKPOINT("Broadcasting");;
516+
BOOST_CHECKPOINT("Broadcasting");
517517
std::vector<std::string> res = compute.Broadcast<std::string>(Func2(8, 5));
518518

519519
BOOST_CHECK_EQUAL(res.size(), 1);
@@ -524,7 +524,7 @@ BOOST_AUTO_TEST_CASE(IgniteBroadcastLocalAsync)
524524
{
525525
Compute compute = node.GetCompute();
526526

527-
BOOST_CHECKPOINT("Broadcasting");;
527+
BOOST_CHECKPOINT("Broadcasting");
528528
Future< std::vector<std::string> > res = compute.BroadcastAsync<std::string>(Func2(312, 245));
529529

530530
BOOST_CHECK(!res.IsReady());

modules/platforms/cpp/odbc-test/src/queries_test.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,4 +2024,39 @@ BOOST_AUTO_TEST_CASE(TestQueryAndConnectionTimeoutBoth)
20242024
InsertTestBatch(11, 20, 9);
20252025
}
20262026

2027+
BOOST_AUTO_TEST_CASE(TestSeveralInsertsWithoutClosing)
2028+
{
2029+
Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache");
2030+
2031+
SQLCHAR request[] = "INSERT INTO TestType(_key, i32Field) VALUES(?, ?)";
2032+
2033+
SQLRETURN ret = SQLPrepare(stmt, request, SQL_NTS);
2034+
2035+
if (!SQL_SUCCEEDED(ret))
2036+
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
2037+
2038+
int64_t key = 0;
2039+
ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_SBIGINT, SQL_BIGINT, 0, 0, &key, 0, 0);
2040+
2041+
if (!SQL_SUCCEEDED(ret))
2042+
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
2043+
2044+
int32_t data = 0;
2045+
ret = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &data, 0, 0);
2046+
2047+
if (!SQL_SUCCEEDED(ret))
2048+
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
2049+
2050+
for (int32_t i = 0; i < 10; ++i)
2051+
{
2052+
key = i;
2053+
data = i * 10;
2054+
2055+
ret = SQLExecute(stmt);
2056+
2057+
if (!SQL_SUCCEEDED(ret))
2058+
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
2059+
}
2060+
}
2061+
20272062
BOOST_AUTO_TEST_SUITE_END()

modules/platforms/cpp/odbc-test/src/sql_types_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(TestByteArrayParamInsert)
128128

129129
const int8_t data[] = { 'A','B','C','D','E','F','G','H','I','J' };
130130
std::vector<int8_t> paramData(data, data + sizeof(data) / sizeof(data[0]));
131-
SQLCHAR request[] = "INSERT INTO TestType(_key, i8ArrayField) VALUES(?, ?)";;
131+
SQLCHAR request[] = "INSERT INTO TestType(_key, i8ArrayField) VALUES(?, ?)";
132132

133133
ret = SQLPrepare(stmt, request, SQL_NTS);
134134

@@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(TestByteParamInsert)
161161
{
162162
SQLRETURN ret;
163163

164-
SQLCHAR request[] = "INSERT INTO TestType(_key, i8Field) VALUES(?, ?)";;
164+
SQLCHAR request[] = "INSERT INTO TestType(_key, i8Field) VALUES(?, ?)";
165165

166166
ret = SQLPrepare(stmt, request, SQL_NTS);
167167

modules/platforms/cpp/odbc-test/src/sql_value_expressions_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(TestCase)
5151
"THEN (i32Field / 2) "
5252
"ELSE (i32Field / 3) "
5353
"END "
54-
"FROM TestType", in.i32Field / 3);;
54+
"FROM TestType", in.i32Field / 3);
5555
}
5656

5757
BOOST_AUTO_TEST_CASE(TestCast)

modules/platforms/cpp/odbc/src/message.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ namespace ignite
274274
if (status == ResponseStatus::SUCCESS)
275275
ReadOnSuccess(reader, ver);
276276
else
277-
utility::ReadString(reader, error);;
277+
utility::ReadString(reader, error);
278278
}
279279

280280
void Response::ReadOnSuccess(impl::binary::BinaryReaderImpl&, const ProtocolVersion&)

modules/platforms/cpp/odbc/src/query/batch_query.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ namespace ignite
5050
SqlResult::Type BatchQuery::Execute()
5151
{
5252
if (executed)
53-
{
54-
diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query cursor is in open state already.");
55-
56-
return SqlResult::AI_ERROR;
57-
}
53+
Close();
5854

5955
int32_t maxPageSize = connection.GetConfiguration().GetPageSize();
6056
int32_t rowNum = params.GetParamSetSize();

modules/platforms/cpp/odbc/src/query/data_query.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ namespace ignite
5252
SqlResult::Type DataQuery::Execute()
5353
{
5454
if (cursor.get())
55-
{
56-
diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query cursor is in open state already.");
57-
58-
return SqlResult::AI_ERROR;
59-
}
55+
InternalClose();
6056

6157
return MakeRequestExecute();
6258
}

modules/platforms/cpp/odbc/src/query/type_info_query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ namespace ignite
394394

395395
bool TypeInfoQuery::DataAvailable() const
396396
{
397-
return cursor != types.end();;
397+
return cursor != types.end();
398398
}
399399

400400
int64_t TypeInfoQuery::AffectedRows() const

0 commit comments

Comments
 (0)