Skip to content

Commit

Permalink
Fix regression with statement re-execution when using Firebird backend.
Browse files Browse the repository at this point in the history
Since the introduction of endOfRowSet_ flag in 4c3cb62, executing the same
statement again stopped working as the flag was never reset after fetching all
the results of the first execution.

Fix this by resetting it in firebird_statement_backend::execute().

Also add a test verifying that this does indeed work.
  • Loading branch information
vadz authored and mloskot committed Mar 24, 2013
1 parent a83861b commit e063fbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/backends/firebird/statement.cpp
Expand Up @@ -438,6 +438,10 @@ firebird_statement_backend::execute(int number)
}
}

// Successfully re-executing the statement must reset the "end of rowset"
// flag, we might be able to fetch data again now.
endOfRowSet_ = false;

if (sqldap_->sqld)
{
// query may return some data
Expand Down
18 changes: 12 additions & 6 deletions src/backends/firebird/test/test-firebird.cpp
Expand Up @@ -370,18 +370,24 @@ void test6()
}

{
char c='a', c1, c2;
char c, c1, c2;

statement st = (sql.prepare <<
"select p1,p2 from test6 order by p1", into(c1), into(c2));

st.execute();
while (st.fetch())
// Verify that fetch after re-executing the same statement works.
for (int n = 0; n < 2; ++n)
{
assert(c == c1 && c == c2);
++c;
st.execute();

c='a';
while (st.fetch())
{
assert(c == c1 && c == c2);
++c;
}
assert(c == 'z'+1);
}
assert(c == 'z'+1);
}

{
Expand Down

0 comments on commit e063fbc

Please sign in to comment.