aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/statement.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-09-23 11:04:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-09-23 11:04:58 +0200
commitda518dc1ae7e78c753f5ea4fdfa27b140841de5d (patch)
tree00ae6ef2ef326c7b682007292ee8d4ddea63bdc5 /odb/mysql/statement.cxx
parent959f49cdeb02c1be24a535befde7b02de78a7fbd (diff)
Don't call store_result after we have reached the end
Diffstat (limited to 'odb/mysql/statement.cxx')
-rw-r--r--odb/mysql/statement.cxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/odb/mysql/statement.cxx b/odb/mysql/statement.cxx
index 457c4bd..1e822b0 100644
--- a/odb/mysql/statement.cxx
+++ b/odb/mysql/statement.cxx
@@ -8,6 +8,8 @@
#include <odb/mysql/connection.hxx>
#include <odb/mysql/exceptions.hxx>
+#include <iostream> // @@ tmp
+
using namespace std;
namespace odb
@@ -64,6 +66,7 @@ namespace odb
binding& image,
MYSQL_BIND* parameters)
: statement (conn),
+ end_ (false),
cached_ (false),
image_ (image),
image_version_ (0),
@@ -85,6 +88,8 @@ namespace odb
if (cached_)
free_result ();
+ end_ = false;
+
if (mysql_stmt_reset (stmt_))
throw database_exception (stmt_);
@@ -120,10 +125,13 @@ namespace odb
void query_statement::
cache ()
{
- if (!cached_)
+ if (!cached_ && !end_)
{
if (mysql_stmt_store_result (stmt_))
+ {
+ std::cerr << "store result failed" << std::endl;
throw database_exception (stmt_);
+ }
cached_ = true;
}
@@ -153,6 +161,7 @@ namespace odb
}
case MYSQL_NO_DATA:
{
+ end_ = true;
return no_data;
}
case MYSQL_DATA_TRUNCATED:
@@ -187,6 +196,7 @@ namespace odb
void query_statement::
free_result ()
{
+ end_ = true;
cached_ = false;
if (mysql_stmt_free_result (stmt_))