Commit 45be6928 authored by msobczak's avatar msobczak

Improved handling of empty vectors in bulk fetch.

parent 23c261e3
......@@ -258,6 +258,14 @@ void statement_impl::undefine_and_bind()
bool statement_impl::execute(bool withDataExchange)
{
initialFetchSize_ = intos_size();
if (intos_.empty() == false && initialFetchSize_ == 0)
{
// this can happen only with into-vectors elements
// and is not allowed when calling execute
throw soci_error("Vectors of size 0 are not allowed.");
}
fetchSize_ = initialFetchSize_;
std::size_t bindSize = uses_size();
......@@ -411,11 +419,6 @@ std::size_t statement_impl::intos_size()
if (i==0)
{
intos_size = intos_[i]->size();
if (intos_size == 0)
{
// this can happen only for vectors
throw soci_error("Vectors of size 0 are not allowed.");
}
}
else if (intos_size != intos_[i]->size())
{
......
......@@ -1015,6 +1015,14 @@ void test4()
// for convenience, vectors should be truncated
assert(vals.empty());
assert(inds.empty());
// for even more convenience, fetch should not fail
// but just report end of rowset
const bool fetched = st.fetch();
assert(fetched == false);
assert(vals.empty());
assert(inds.empty());
}
// additional test for "no data" without prepared statement
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment