From d6b671154a8ee4e2b52ec24ccdc2ffac26430e09 Mon Sep 17 00:00:00 2001 From: proller Date: Fri, 11 May 2018 20:32:29 +0300 Subject: [PATCH] Support SQL_ATTR_ROW_ARRAY_SIZE (#86) --- driver/attr.cpp | 8 +++++--- driver/result_set.cpp | 2 +- driver/statement.h | 1 + driver/ut/nano.cpp | 2 +- test/test.sh | 2 ++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/driver/attr.cpp b/driver/attr.cpp index 56a0c13b6..568c9eb81 100644 --- a/driver/attr.cpp +++ b/driver/attr.cpp @@ -205,6 +205,10 @@ impl_SQLSetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute, statement.rows_fetched_ptr = static_cast(value); return SQL_SUCCESS; + case SQL_ATTR_ROW_ARRAY_SIZE: + statement.row_array_size = reinterpret_cast(value); + return SQL_SUCCESS; + case SQL_ATTR_APP_ROW_DESC: case SQL_ATTR_APP_PARAM_DESC: case SQL_ATTR_CURSOR_SCROLLABLE: @@ -228,7 +232,6 @@ impl_SQLSetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute, case SQL_ATTR_ROW_NUMBER: case SQL_ATTR_ROW_OPERATION_PTR: case SQL_ATTR_ROW_STATUS_PTR: /// Libreoffice Base - case SQL_ATTR_ROW_ARRAY_SIZE: case SQL_ATTR_SIMULATE_CURSOR: case SQL_ATTR_USE_BOOKMARKS: return SQL_SUCCESS; @@ -310,7 +313,7 @@ impl_SQLGetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute, CASE_NUM(SQL_ATTR_ROW_NUMBER, SQLULEN, statement.result.getNumRows()); CASE_NUM(SQL_ATTR_USE_BOOKMARKS, SQLULEN, SQL_UB_OFF); CASE_NUM(SQL_ATTR_ROW_BIND_TYPE, SQLULEN, SQL_BIND_TYPE_DEFAULT); - + CASE_NUM(SQL_ATTR_ROW_ARRAY_SIZE, SQLULEN, statement.row_array_size); case SQL_ATTR_FETCH_BOOKMARK_PTR: case SQL_ATTR_KEYSET_SIZE: @@ -323,7 +326,6 @@ impl_SQLGetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute, case SQL_ATTR_ROW_BIND_OFFSET_PTR: case SQL_ATTR_ROW_OPERATION_PTR: case SQL_ATTR_ROW_STATUS_PTR: - case SQL_ATTR_ROW_ARRAY_SIZE: case SQL_ATTR_SIMULATE_CURSOR: default: LOG("GetStmtAttr: Unsupported attribute (throw) " << attribute); diff --git a/driver/result_set.cpp b/driver/result_set.cpp index 85425d359..f4fbea4e9 100644 --- a/driver/result_set.cpp +++ b/driver/result_set.cpp @@ -191,7 +191,7 @@ std::istream & ResultSet::in() bool ResultSet::readNextBlock() { - static constexpr auto max_block_size = 8192; + auto max_block_size = statement->row_array_size; current_block.data.clear(); current_block.data.reserve(max_block_size); diff --git a/driver/statement.h b/driver/statement.h index 3fd5a6a44..c588404f6 100644 --- a/driver/statement.h +++ b/driver/statement.h @@ -76,6 +76,7 @@ class Statement { std::map bindings; SQLULEN * rows_fetched_ptr = nullptr; + SQLULEN row_array_size = 1; private: std::unique_ptr response; diff --git a/driver/ut/nano.cpp b/driver/ut/nano.cpp index 5df80a486..2299d1755 100644 --- a/driver/ut/nano.cpp +++ b/driver/ut/nano.cpp @@ -138,7 +138,7 @@ void run_test(nanodbc::string const& connection_string) } execute(connection, NANODBC_TEXT("DROP TABLE IF EXISTS test.strings;")); execute(connection, NANODBC_TEXT("CREATE TABLE test.strings (id UInt64, str String, dt DateTime DEFAULT now()) engine = Log;")); - execute(connection, NANODBC_TEXT("INSERT INTO test.strings SELECT number, hex(number+100000), 1 FROM system.numbers LIMIT 100000;")); + execute(connection, NANODBC_TEXT("INSERT INTO test.strings SELECT number, hex(number+100000), 1 FROM system.numbers LIMIT 100;")); { auto results = execute(connection, NANODBC_TEXT("SELECT COUNT(*) FROM test.strings;")); show(results); diff --git a/test/test.sh b/test/test.sh index 197e42674..625ed1886 100755 --- a/test/test.sh +++ b/test/test.sh @@ -126,6 +126,8 @@ for i in `seq 1 ${NUM}`; do q 'select * from test.increment;' > /dev/null done +q 'select * from test.increment;' + echo "should be ${NUM}:" q 'select count(*) from test.increment;'