Commit d9596406 authored by msobczak's avatar msobczak

Corrected row support for multiple use of the same row object.

parent 3534cdd5
......@@ -45,6 +45,21 @@ std::size_t row::size() const
return holders_.size();
}
void row::clean_up()
{
std::size_t const hsize = holders_.size();
for (std::size_t i = 0; i != hsize; ++i)
{
delete holders_[i];
delete indicators_[i];
}
columns_.clear();
holders_.clear();
indicators_.clear();
index_.clear();
}
indicator row::get_indicator(std::size_t pos) const
{
assert(indicators_.size() >= static_cast<std::size_t>(pos + 1));
......@@ -82,10 +97,5 @@ std::size_t row::find_column(std::string const &name) const
row::~row()
{
std::size_t const hsize = holders_.size();
for (std::size_t i = 0; i != hsize; ++i)
{
delete holders_[i];
delete indicators_[i];
}
clean_up();
}
......@@ -45,6 +45,7 @@ public:
void add_properties(column_properties const &cp);
std::size_t size() const;
void clean_up();
indicator get_indicator(std::size_t pos) const;
indicator get_indicator(std::string const &name) const;
......
......@@ -598,6 +598,8 @@ void statement_impl::bind_into<dt_date>()
void statement_impl::describe()
{
row_->clean_up();
int numcols = backEnd_->prepare_for_describe();
for (int i = 1; i <= numcols; ++i)
......
......@@ -2001,7 +2001,27 @@ void test12()
assert(t.tm_sec == 17);
assert(c == "a");
}
}
// additional test to check if the row object can be
// reused between queries
{
row r;
sql << "select * from soci_test", into(r);
assert(r.size() == 5);
assert(r.get_properties(0).get_data_type() == dt_double);
assert(r.get_properties(1).get_data_type() == dt_integer);
assert(r.get_properties(2).get_data_type() == dt_string);
assert(r.get_properties(3).get_data_type() == dt_date);
sql << "select name, num_int from soci_test", into(r);
assert(r.size() == 2);
assert(r.get_properties(0).get_data_type() == dt_string);
assert(r.get_properties(1).get_data_type() == dt_integer);
}
}
......
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