Skip to content

Commit

Permalink
TMP: Fix MSVC ODBC unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zann1x committed May 4, 2022
1 parent 779b973 commit 74a0e67
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
21 changes: 17 additions & 4 deletions src/backends/odbc/standard-use-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void* odbc_standard_use_type_backend::prepare_for_bind(
size = sizeof(int16_t);
break;
case x_uint16:
sqlType = SQL_SMALLINT;
sqlType = SQL_INTEGER;
cType = SQL_C_USHORT;
size = sizeof(uint16_t);
break;
Expand All @@ -50,9 +50,22 @@ void* odbc_standard_use_type_backend::prepare_for_bind(
size = sizeof(int32_t);
break;
case x_uint32:
sqlType = SQL_INTEGER;
cType = SQL_C_ULONG;
size = sizeof(uint32_t);
if (use_string_for_bigint())
{
sqlType = SQL_NUMERIC;
cType = SQL_C_CHAR;
size = max_bigint_length;
buf_ = new char[size];
snprintf(buf_, size, "%u",
exchange_type_cast<x_uint32>(data_));
indHolder_ = SQL_NTS;
}
else // Normal case, use ODBC support.
{
sqlType = SQL_BIGINT;
cType = SQL_C_ULONG;
size = sizeof(uint32_t);
}
break;
case x_int64:
if (use_string_for_bigint())
Expand Down
28 changes: 21 additions & 7 deletions src/backends/odbc/vector-use-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void* odbc_vector_use_type_backend::prepare_for_bind(SQLUINTEGER &size,
break;
case x_uint16:
{
sqlType = SQL_SMALLINT;
sqlType = SQL_INTEGER;
cType = SQL_C_USHORT;
size = sizeof(uint16_t);
std::vector<uint16_t> *vp = static_cast<std::vector<uint16_t> *>(data_);
Expand All @@ -102,13 +102,27 @@ void* odbc_vector_use_type_backend::prepare_for_bind(SQLUINTEGER &size,
break;
case x_uint32:
{
sqlType = SQL_INTEGER;
cType = SQL_C_ULONG;
size = sizeof(SQLINTEGER);
std::vector<uint32_t> *vp = static_cast<std::vector<uint32_t> *>(data_);
std::vector<uint32_t> *vp =
static_cast<std::vector<uint32_t> *>(data_);
std::vector<uint32_t> &v(*vp);
prepare_indicators(v.size());
data = &v[0];
std::size_t const vsize = v.size();
prepare_indicators(vsize);

if (use_string_for_bigint())
{
sqlType = SQL_NUMERIC;
cType = SQL_C_CHAR;
size = max_bigint_length;
buf_ = new char[size * vsize];
data = buf_;
}
else // Normal case, use ODBC support.
{
sqlType = SQL_BIGINT;
cType = SQL_C_ULONG;
size = sizeof(uint32_t);
data = &v[0];
}
}
break;
case x_int64:
Expand Down

0 comments on commit 74a0e67

Please sign in to comment.