You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2021/05/31 09:39:53 UTC
[ignite] branch master updated: IGNITE-13188 ODBC Fix
SQLBindParameter with null StrLen_or_IndPtr
This is an automated email from the ASF dual-hosted git repository.
isapego pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new ab1d3a1 IGNITE-13188 ODBC Fix SQLBindParameter with null StrLen_or_IndPtr
ab1d3a1 is described below
commit ab1d3a1f2d9f2b3395744219ab05dd4e0197a2df
Author: Igor Sapego <is...@apache.org>
AuthorDate: Mon May 31 11:53:17 2021 +0300
IGNITE-13188 ODBC Fix SQLBindParameter with null StrLen_or_IndPtr
This closes #9136
---
.../platforms/cpp/odbc-test/src/sql_types_test.cpp | 48 ++++++++++++++++++++++
.../cpp/odbc/src/app/application_data_buffer.cpp | 2 +-
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
index 65feef0..35cf33c 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
@@ -153,6 +153,54 @@ BOOST_AUTO_TEST_CASE(TestByteArrayParamInsert)
BOOST_REQUIRE_EQUAL_COLLECTIONS(out.i8ArrayField.begin(), out.i8ArrayField.end(), paramData.begin(), paramData.end());
}
+BOOST_AUTO_TEST_CASE(TestStingParamNullLen)
+{
+ SQLRETURN ret;
+
+ TestType in;
+ in.i8Field = 45;
+ in.strField = "Lorem Ipsum";
+
+ testCache.Put(1, in);
+
+ SQLLEN colLen = 0;
+ SQLCHAR colData = 0;
+
+ ret = SQLBindCol(stmt, 1, SQL_C_TINYINT, &colData, sizeof(colData), &colLen);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ SQLCHAR request[] = "SELECT i8Field FROM TestType WHERE strField = ?";
+
+ ret = SQLPrepare(stmt, request, SQL_NTS);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ std::vector<SQLCHAR> paramData(in.strField.begin(), in.strField.end());
+ SQLLEN paramLen = static_cast<SQLLEN>(paramData.size());
+
+ ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ paramData.size(), 0, ¶mData[0], paramLen, 0);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLExecute(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_REQUIRE_EQUAL(colData, in.i8Field);
+ BOOST_REQUIRE_EQUAL(colLen, sizeof(colData));
+
+ ret = SQLFetch(stmt);
+ BOOST_REQUIRE(ret == SQL_NO_DATA);
+}
+
BOOST_AUTO_TEST_CASE(TestByteParamInsert)
{
SQLRETURN ret;
diff --git a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
index 35af8cf..2942def 100644
--- a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
+++ b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
@@ -1767,7 +1767,7 @@ namespace ignite
{
const SqlLen *len = GetResLen();
- return len ? *len : SQL_DEFAULT_PARAM;
+ return len ? *len : SQL_NTS;
}
return GetDataAtExecSize();