Skip to content

Commit

Permalink
Support SQL_ATTR_ROW_ARRAY_SIZE (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
proller authored May 11, 2018
1 parent b60fcb6 commit d6b6711
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions driver/attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ impl_SQLSetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute,
statement.rows_fetched_ptr = static_cast<SQLULEN*>(value);
return SQL_SUCCESS;

case SQL_ATTR_ROW_ARRAY_SIZE:
statement.row_array_size = reinterpret_cast<decltype(statement.row_array_size)>(value);
return SQL_SUCCESS;

case SQL_ATTR_APP_ROW_DESC:
case SQL_ATTR_APP_PARAM_DESC:
case SQL_ATTR_CURSOR_SCROLLABLE:
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion driver/result_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions driver/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Statement {
std::map<SQLUSMALLINT, Binding> bindings;

SQLULEN * rows_fetched_ptr = nullptr;
SQLULEN row_array_size = 1;

private:
std::unique_ptr<Poco::Net::HTTPResponse> response;
Expand Down
2 changes: 1 addition & 1 deletion driver/ut/nano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;'

Expand Down

0 comments on commit d6b6711

Please sign in to comment.