Skip to content

Commit

Permalink
At 627 pagination (#10)
Browse files Browse the repository at this point in the history
* pagination\

* pagination

* added back cursor initialization

* cleaner next token logic

* rename cursor to next_token, remove debug comments

* rename server_cursor_id to next_token, remove unused AwsHttpResponseToString() function

Co-authored-by: Jerry Leung <[email protected]>
  • Loading branch information
yanw-bq and Jerry Leung authored Jan 28, 2021
1 parent efad3bb commit 806b53c
Show file tree
Hide file tree
Showing 19 changed files with 340 additions and 357 deletions.
60 changes: 54 additions & 6 deletions src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ class TestSQLExecDirect : public testing::Test {
~TestSQLExecDirect() {
// cleanup any pending stuff, but no exceptions allowed
}
int m_limit = 10;
std::wstring m_query =
L"SELECT * FROM test.IoT LIMIT " + std::to_wstring(m_limit);
SQLHENV m_env = SQL_NULL_HENV;
SQLHDBC m_conn = SQL_NULL_HDBC;
SQLHSTMT m_hstmt = SQL_NULL_HSTMT;
Expand Down Expand Up @@ -291,16 +288,67 @@ TEST_F(TestSQLPrepare, NullQueryError) {
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
}*/

TEST_F(TestSQLExecDirect, Success) {
SQLRETURN ret = SQLExecDirect(m_hstmt, (SQLTCHAR*)m_query.c_str(), SQL_NTS);
TEST_F(TestSQLExecDirect, Success_100) {
int limit = 100;
std::wstring query =
L"SELECT * FROM promPerf.query LIMIT " + std::to_wstring(limit);
SQLRETURN ret = SQLExecDirect(m_hstmt, (SQLTCHAR*)query.c_str(), SQL_NTS);
EXPECT_EQ(SQL_SUCCESS, ret);
int cnt = 0;
while ((ret = SQLFetch(m_hstmt)) != SQL_NO_DATA) {
if (SQL_SUCCEEDED(ret)) {
cnt++;
}
}
EXPECT_EQ(limit, cnt);
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
}

TEST_F(TestSQLExecDirect, Success_800) {
int limit = 800;
std::wstring query =
L"SELECT * FROM promPerf.query LIMIT " + std::to_wstring(limit);
SQLRETURN ret = SQLExecDirect(m_hstmt, (SQLTCHAR*)query.c_str(), SQL_NTS);
EXPECT_EQ(SQL_SUCCESS, ret);
int cnt = 0;
while ((ret = SQLFetch(m_hstmt)) != SQL_NO_DATA) {
if (SQL_SUCCEEDED(ret)) {
cnt++;
}
}
EXPECT_EQ(limit, cnt);
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
}

TEST_F(TestSQLExecDirect, Success_5000) {
int limit = 5000;
std::wstring query =
L"SELECT * FROM promPerf.query LIMIT " + std::to_wstring(limit);
SQLRETURN ret = SQLExecDirect(m_hstmt, (SQLTCHAR*)query.c_str(), SQL_NTS);
EXPECT_EQ(SQL_SUCCESS, ret);
int cnt = 0;
while ((ret = SQLFetch(m_hstmt)) != SQL_NO_DATA) {
if (SQL_SUCCEEDED(ret)) {
cnt++;
}
}
EXPECT_EQ(limit, cnt);
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
}

TEST_F(TestSQLExecDirect, Success_10000) {
int limit = 10000;
std::wstring query =
L"SELECT * FROM promPerf.query LIMIT " + std::to_wstring(limit);
SQLRETURN ret = SQLExecDirect(m_hstmt, (SQLTCHAR*)query.c_str(), SQL_NTS);
EXPECT_EQ(SQL_SUCCESS, ret);
int cnt = 0;
while ((ret = SQLFetch(m_hstmt)) != SQL_NO_DATA) {
if (SQL_SUCCEEDED(ret)) {
cnt++;
}
}
EXPECT_EQ(m_limit, cnt);
EXPECT_EQ(limit, cnt);
LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret);
}

Expand Down
3 changes: 1 addition & 2 deletions src/PerformanceTests/PTODBCInfo/performance_odbc_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ runtime_options rt_opts = []() {
return temp_opts;
}();

void GetVersionInfoString(std::string& version_info) {
void GetVersionInfoString(std::string&) {
// Connect to DB
TSCommunication comm;
ASSERT_TRUE(comm.Setup(rt_opts));
Expand All @@ -89,7 +89,6 @@ void GetVersionInfoString(std::string& version_info) {

// Convert response to string
ASSERT_TRUE(response != nullptr);
comm.AwsHttpResponseToString(response, version_info);
}

void ParseVersionInfoString(
Expand Down
4 changes: 2 additions & 2 deletions src/odfesqlodbc/communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void Communication::StopResultRetrieval() {
m_result_queue.clear();
}

ESResult* Communication::PopResult() {
ESResult* result = nullptr;
TSResult* Communication::PopResult() {
TSResult* result = nullptr;
while (!m_result_queue.pop(QUEUE_TIMEOUT, result) && m_is_retrieving) {
}

Expand Down
17 changes: 2 additions & 15 deletions src/odfesqlodbc/communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ class Communication {
* @return std::string
*/
virtual std::string GetErrorPrefix() = 0;
/**
* Send cursor queries
* @param cursor const std::string&
*/
virtual void SendCursorQueries(const std::string& cursor) = 0;
/**
* Send request to close cursor
* @param cursor const std::string&
Expand All @@ -126,14 +121,6 @@ class Communication {
const std::string& endpoint, const Aws::Http::HttpMethod request_type,
const std::string& content_type, const std::string& query,
const std::string& fetch_size = "", const std::string& cursor = "") = 0;
/**
* Convert Aws::Http::HttpResponse to std::string
* @param response std::shared_ptr< Aws::Http::HttpResposne >
* @return output std::string
*/
virtual void AwsHttpResponseToString(
std::shared_ptr< Aws::Http::HttpResponse > response,
std::string& output) = 0;
/**
* Get client encoding
* @return std::string
Expand All @@ -151,9 +138,9 @@ class Communication {
virtual void StopResultRetrieval();
/**
* Pop result
* @return ESResult*
* @return TSResult*
*/
virtual ESResult* PopResult();
virtual TSResult* PopResult();
/**
* Log messages
* @param level ESLogLevel
Expand Down
10 changes: 3 additions & 7 deletions src/odfesqlodbc/es_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ int ESExecDirect(void* conn, const char* statement, const char* fetch_size) {
: -1;
}

void SendCursorQueries(void* conn, const char* cursor) {
static_cast< Communication* >(conn)->SendCursorQueries(cursor);
}

ESResult* ESGetResult(void* conn) {
TSResult* TSGetResult(void* conn) {
return conn ? static_cast< Communication* >(conn)->PopResult()
: NULL;
}
Expand All @@ -81,8 +77,8 @@ void Disconnect(void* conn) {
delete static_cast< Communication* >(conn);
}

void ESClearResult(ESResult* es_result) {
delete es_result;
void TSClearResult(TSResult* ts_result) {
delete ts_result;
}

void StopRetrieval(void* conn) {
Expand Down
5 changes: 2 additions & 3 deletions src/odfesqlodbc/es_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// C++ interface
std::string GetClientEncoding(void* conn);
bool SetClientEncoding(void* conn, std::string& encoding);
ESResult* ESGetResult(void* conn);
void ESClearResult(ESResult* es_result);
TSResult* TSGetResult(void* conn);
void TSClearResult(TSResult* ts_result);
void* ConnectDBParams(const runtime_options& rt_opts);
std::string GetVersion(void* conn);
std::vector< std::string > GetColumnsWithSelectQuery(
Expand All @@ -39,7 +39,6 @@ void XPlatformLeaveCriticalSection(void* critical_section_helper);
void XPlatformDeleteCriticalSection(void** critical_section_helper);
ConnStatusType Status(void* conn);
int ESExecDirect(void* conn, const char* statement, const char* fetch_size);
void SendCursorQueries(void* conn, const char* cursor);
void Disconnect(void* conn);
void StopRetrieval(void* conn);
#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/odfesqlodbc/es_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ typedef struct QueryInfo_ {
SQLLEN row_size;
SQLLEN fetch_size;
QResultClass *result_in;
const char *cursor;
const char *next_token;
} QueryInfo;

/* Used to save the error information */
Expand Down
Loading

0 comments on commit 806b53c

Please sign in to comment.