From df1fdb4f500308adf2fff1a08b2ef62bf5a88de7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Jan 2012 10:46:55 +0200 Subject: Detect and throw when object/view with long data is re-loaded from query result --- odb/mssql/object-result.txx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'odb/mssql/object-result.txx') diff --git a/odb/mssql/object-result.txx b/odb/mssql/object-result.txx index 338f78a..161978e 100644 --- a/odb/mssql/object-result.txx +++ b/odb/mssql/object-result.txx @@ -6,8 +6,9 @@ #include #include -#include +#include // result_not_cached +#include // long_data_reload #include namespace odb @@ -50,6 +51,9 @@ namespace odb void object_result_impl:: load (object_type& obj, bool) { + if (!can_load_) + throw long_data_reload (); + // This is a top-level call so the statements cannot be locked. // assert (!statements_.locked ()); @@ -66,7 +70,7 @@ namespace odb // If we are using a copy, make sure the callback information for // long data also comes from the copy. // - statement_->stream_result ( + can_load_ = !statement_->stream_result ( use_copy_ ? &statements_.image () : 0, use_copy_ ? image_copy_ : 0); @@ -103,6 +107,7 @@ namespace odb void object_result_impl:: next () { + can_load_ = true; this->current (pointer_type ()); typename object_traits::image_type& im (statements_.image ()); @@ -200,6 +205,9 @@ namespace odb void object_result_impl_no_id:: load (object_type& obj) { + if (!can_load_) + throw long_data_reload (); + odb::database& db (this->database ()); object_traits::callback (db, obj, callback_event::pre_load); @@ -211,7 +219,7 @@ namespace odb // If we are using a copy, make sure the callback information for // long data also comes from the copy. // - statement_->stream_result ( + can_load_ = !statement_->stream_result ( use_copy_ ? &statements_.image () : 0, use_copy_ ? image_copy_ : 0); @@ -222,6 +230,7 @@ namespace odb void object_result_impl_no_id:: next () { + can_load_ = true; this->current (pointer_type ()); typename object_traits::image_type& im (statements_.image ()); -- cgit v1.1