-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Github CI] Enable Oracle database tests
Signed-off-by: Christian Parpart <[email protected]>
- Loading branch information
1 parent
dd7dc01
commit 26dfbae
Showing
12 changed files
with
214 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "BasicStringBinder.hpp" | ||
#include "Primitives.hpp" | ||
#include "SqlFixedString.hpp" | ||
|
||
template <typename Int64Type, SQLSMALLINT TheCType> | ||
SQLRETURN Int64DataBinderHelper<Int64Type, TheCType>::InputParameter(SQLHSTMT stmt, | ||
SQLUSMALLINT column, | ||
Int64Type const& value, | ||
SqlDataBinderCallback& cb) noexcept | ||
{ | ||
if (cb.ServerType() == SqlServerType::ORACLE) | ||
{ | ||
using StringType = SqlFixedString<21>; | ||
auto strValue = std::make_shared<StringType>(); | ||
std::to_chars(strValue->data(), strValue->data() + strValue->capacity(), value, 10); | ||
cb.PlanPostExecuteCallback([strValue]() {}); // Defer the destruction of the string until after the execute | ||
return SqlDataBinder<StringType>::InputParameter(stmt, column, *strValue, cb); | ||
} | ||
else | ||
{ | ||
return SqlSimpleDataBinder<Int64Type, TheCType, SQL_BIGINT, SqlColumnTypeDefinitions::Bigint {}>:: | ||
InputParameter(stmt, column, value, cb); | ||
} | ||
} | ||
|
||
template <typename Int64Type, SQLSMALLINT TheCType> | ||
SQLRETURN Int64DataBinderHelper<Int64Type, TheCType>::OutputColumn( | ||
SQLHSTMT stmt, SQLUSMALLINT column, Int64Type* result, SQLLEN* indicator, SqlDataBinderCallback& cb) noexcept | ||
{ | ||
if (cb.ServerType() == SqlServerType::ORACLE) | ||
{ | ||
using StringType = SqlFixedString<21>; | ||
auto buffer = std::make_shared<StringType>(); | ||
auto const sqlResult = SqlDataBinder<StringType>::OutputColumn(stmt, column, buffer.get(), indicator, cb); | ||
if (SQL_SUCCEEDED(sqlResult)) | ||
{ | ||
cb.PlanPostProcessOutputColumn([buffer, result, indicator]() { | ||
if (*indicator != SQL_NULL_DATA && *indicator != SQL_NO_TOTAL) | ||
{ | ||
std::from_chars(buffer->data(), buffer->data() + buffer->size(), *result, 10); | ||
} | ||
}); | ||
} | ||
return sqlResult; | ||
} | ||
else | ||
{ | ||
return SqlSimpleDataBinder<Int64Type, TheCType, SQL_BIGINT, SqlColumnTypeDefinitions::Bigint {}>::OutputColumn( | ||
stmt, column, result, indicator, cb); | ||
} | ||
} | ||
|
||
template <typename Int64Type, SQLSMALLINT TheCType> | ||
SQLRETURN Int64DataBinderHelper<Int64Type, TheCType>::GetColumn( | ||
SQLHSTMT stmt, SQLUSMALLINT column, Int64Type* result, SQLLEN* indicator, SqlDataBinderCallback const& cb) noexcept | ||
{ | ||
if (cb.ServerType() == SqlServerType::ORACLE) | ||
{ | ||
using StringType = SqlFixedString<21>; | ||
auto buffer = StringType {}; | ||
auto const sqlResult = SqlDataBinder<StringType>::GetColumn(stmt, column, &buffer, indicator, cb); | ||
if (SQL_SUCCEEDED(sqlResult) && *indicator != SQL_NULL_DATA && *indicator != SQL_NO_TOTAL) | ||
{ | ||
std::from_chars(buffer.data(), buffer.data() + buffer.size(), *result, 10); | ||
} | ||
return sqlResult; | ||
} | ||
else | ||
{ | ||
return SqlSimpleDataBinder<Int64Type, TheCType, SQL_BIGINT, SqlColumnTypeDefinitions::Bigint {}>::GetColumn( | ||
stmt, column, result, indicator, cb); | ||
} | ||
} | ||
|
||
template struct Int64DataBinderHelper<int64_t, SQL_C_SBIGINT>; | ||
template struct Int64DataBinderHelper<uint64_t, SQL_C_UBIGINT>; | ||
|
||
#if !defined(_WIN32) && !defined(__APPLE__) | ||
template struct Int64DataBinderHelper<long long, SQL_C_SBIGINT>; | ||
template struct Int64DataBinderHelper<unsigned long long, SQL_C_UBIGINT>; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.