aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/object-statements.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-18 11:38:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-18 11:38:40 +0200
commit7391841a063328828621c8b70e02a81674686c97 (patch)
treedd76ccec9aa962461acc9a8e64d12fe75d2313c4 /odb/pgsql/object-statements.hxx
parent206f2b922531a6a2222145aae3ae90041c3c7ffe (diff)
Fix custom recursive loading in post_load callback
Before we called the callback while holding the statements locked. As a result, if the callback tried to load another object of this type, it failed. Now we unlock the statements (since we have completely loaded the object from ODB's point of view) and then call the callback. The callback test has been updated to test this situation.
Diffstat (limited to 'odb/pgsql/object-statements.hxx')
-rw-r--r--odb/pgsql/object-statements.hxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/odb/pgsql/object-statements.hxx b/odb/pgsql/object-statements.hxx
index 32ea24b..ca5aecd 100644
--- a/odb/pgsql/object-statements.hxx
+++ b/odb/pgsql/object-statements.hxx
@@ -74,6 +74,22 @@ namespace odb
{
}
+ struct auto_unlock
+ {
+ // Unlocks the statement on construction and re-locks it on
+ // destruction.
+ //
+ auto_unlock (object_statements_base&);
+ ~auto_unlock ();
+
+ private:
+ auto_unlock (const auto_unlock&);
+ auto_unlock& operator= (const auto_unlock&);
+
+ private:
+ object_statements_base& s_;
+ };
+
protected:
connection_type& conn_;
bool locked_;