From da518dc1ae7e78c753f5ea4fdfa27b140841de5d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 23 Sep 2010 11:04:58 +0200 Subject: Don't call store_result after we have reached the end --- odb/mysql/statement.cxx | 12 +++++++++++- odb/mysql/statement.hxx | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) 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 #include +#include // @@ 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_)) diff --git a/odb/mysql/statement.hxx b/odb/mysql/statement.hxx index d0c40d6..1684600 100644 --- a/odb/mysql/statement.hxx +++ b/odb/mysql/statement.hxx @@ -106,6 +106,7 @@ namespace odb query_statement& operator= (const query_statement&); private: + bool end_; bool cached_; binding& image_; -- cgit v1.1