Skip to content

Commit

Permalink
Revert "Attempt to resolve AWS TS ODBC driver style error"
Browse files Browse the repository at this point in the history
This reverts commit 7cf4f4b.
As an attempt to fix the ODBC driver build.
  • Loading branch information
alinaliBQ committed Nov 24, 2023
1 parent 3679c51 commit beba3f1
Show file tree
Hide file tree
Showing 161 changed files with 9,390 additions and 6,968 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ const wchar_t* const query = L"SELECT * FROM ODBCTest.IoT limit 10000";
int Setup(SQLHENV* env, SQLHDBC* conn, SQLHSTMT* hstmt) {
SQLTCHAR out_conn_string[1024];
SQLSMALLINT out_conn_string_length;
if (SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, env)) &&
SQL_SUCCEEDED(SQLSetEnvAttr(*env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0)) &&
SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_DBC, *env, conn)) &&
SQL_SUCCEEDED(SQLDriverConnect(*conn, NULL, (SQLTCHAR*)dsn_conn_string.c_str(),
SQL_NTS, out_conn_string,
HELPER_SIZEOF(out_conn_string),
&out_conn_string_length, SQL_DRIVER_COMPLETE)) &&
SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_STMT, *conn, hstmt))) {
if (SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, env))
&& SQL_SUCCEEDED(
SQLSetEnvAttr(*env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0))
&& SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_DBC, *env, conn))
&& SQL_SUCCEEDED(SQLDriverConnect(
*conn, NULL, (SQLTCHAR*)dsn_conn_string.c_str(), SQL_NTS,
out_conn_string, HELPER_SIZEOF(out_conn_string),
&out_conn_string_length, SQL_DRIVER_COMPLETE))
&& SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_STMT, *conn, hstmt))) {
return SQL_SUCCESS;
}
return SQL_ERROR;
Expand All @@ -67,9 +68,10 @@ int QueryExecutionTime() {
auto start = std::chrono::steady_clock::now();
ret = SQLExecDirect(hstmt, (SQLTCHAR*)query, SQL_NTS);
auto end = std::chrono::steady_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
<< std::endl;
std::cout << std::chrono::duration_cast< std::chrono::milliseconds >(
end - start)
.count()
<< std::endl;
SQLCloseCursor(hstmt);
}
Teardown(&conn, &env);
Expand All @@ -80,4 +82,6 @@ int QueryExecutionTime() {
return ret;
}

int main() { return QueryExecutionTime(); }
int main() {
return QueryExecutionTime();
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
*/

#include "performance_helper.h"
#include <cstdlib>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <cstdlib>
#include <regex>

std::string sqltcharToStr(const SQLTCHAR* sqltchar) {
if (sizeof(SQLTCHAR) == 2) {
std::u16string temp((const char16_t*)sqltchar);
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(
temp);
return std::wstring_convert< std::codecvt_utf8_utf16< char16_t >,
char16_t >{}
.to_bytes(temp);
} else if (sizeof(SQLTCHAR) == 4) {
std::u32string temp((const char32_t*)sqltchar);
return std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t>{}.to_bytes(temp);
return std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t >{}
.to_bytes(temp);
} else {
return std::string((const char*)sqltchar);
}
Expand Down Expand Up @@ -75,9 +77,10 @@ int currentMemUsage() {
#ifdef _WIN32
int currentMemUsage() {
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc,
sizeof(pmc));
// PrivateUsage is in bytes, return as KB
return static_cast<int>(pmc.PrivateUsage / 1000);
return static_cast< int >(pmc.PrivateUsage / 1000);
}
#endif //_WIN32

Expand All @@ -86,12 +89,13 @@ int currentMemUsage() {
struct task_basic_info t_info;
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;

if (KERN_SUCCESS !=
task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) {
if (KERN_SUCCESS
!= task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info,
&t_info_count)) {
return -1;
}
// virtual_size is in bytes, return KB
return static_cast<int>(t_info.virtual_size / 1000);
return static_cast< int >(t_info.virtual_size / 1000);
}
#endif //__APPLE__

Expand Down Expand Up @@ -121,11 +125,12 @@ void logDiagnostics(SQLSMALLINT handleType, SQLHANDLE handle, SQLRETURN ret,
SQLSMALLINT recordNumber = 0;
do {
recordNumber++;
diagRet = SQLGetDiagRec(handleType, handle, recordNumber, sqlState, &errorCode,
msgReturn == nullptr ? diagMessage : msgReturn,
msgReturn == nullptr ? HELPER_SIZEOF(diagMessage) : size,
&messageLen);
std::string diagStr = sqltcharToStr((msgReturn == nullptr) ? diagMessage : msgReturn);
diagRet = SQLGetDiagRec(
handleType, handle, recordNumber, sqlState, &errorCode,
msgReturn == nullptr ? diagMessage : msgReturn,
msgReturn == nullptr ? HELPER_SIZEOF(diagMessage) : size, &messageLen);
std::string diagStr =
sqltcharToStr((msgReturn == nullptr) ? diagMessage : msgReturn);
std::string stateStr = sqltcharToStr(sqlState);
if (diagRet == SQL_INVALID_HANDLE) {
std::cout << "Invalid handle\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#endif

#ifdef __linux__
#include <cstring>
#include "stdio.h"
#include "stdlib.h"
#include "stdio.h"
#include <cstring>
#endif

#include <sql.h>
Expand All @@ -45,7 +45,8 @@
#include <vector>

#define HELPER_SIZEOF(x) (x == nullptr ? 0 : (sizeof(x) / sizeof(x[0])))
#define TO_SQLTCHAR(str) const_cast<SQLTCHAR*>(reinterpret_cast<const SQLTCHAR*>(str))
#define TO_SQLTCHAR(str) \
const_cast< SQLTCHAR* >(reinterpret_cast< const SQLTCHAR* >(str))

#ifdef __linux__
typedef std::u16string testString;
Expand Down
Loading

0 comments on commit beba3f1

Please sign in to comment.