From 55b36b8297ef9aac9e4ccc7b98f8649534ee0ac1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Aug 2014 09:37:06 +0200 Subject: Implement bulk database operation support for Oracle and SQL Server --- odb/relational/validator.cxx | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'odb/relational/validator.cxx') diff --git a/odb/relational/validator.cxx b/odb/relational/validator.cxx index 3c8c327..6c3a6fd 100644 --- a/odb/relational/validator.cxx +++ b/odb/relational/validator.cxx @@ -387,6 +387,66 @@ namespace relational names (c, data_member_names_); + // Validate bulk operation support. + // + for (bool i (true); i && c.count ("bulk"); i = false) + { + location_t l (c.get ("bulk-location")); + + if (polymorphic (c)) + { + error (l) << "bulk operations on polymorphic objects are " + "not supported" << endl; + valid_ = false; + break; + } + + if (has_a (c, test_straight_container)) + { + error (l) << "bulk operations on objects with containers are " + "not supported" << endl; + valid_ = false; + break; + } + + if (optimistic (c)) + { + error (l) << "bulk operations on optimistic objects are not " + "supported" << endl; + valid_ = false; + break; + } + + bool update (true); + + // If we have a change-updated section, then we cannot generate + // the bulk update operation. + // + user_sections& uss (c.get ("user-sections")); + + for (user_sections::iterator i (uss.begin ()); + update && i != uss.end (); + ++i) + { + const user_section& s (*i); + + // Skip special sections. + // + if (s.special != user_section::special_ordinary) + continue; + + // Always-updated section still needs a separate statement + // (since it may not be loaded). + // + if (!s.update_empty () && s.update != user_section::update_manual) + update = false; + } + + c.set ("bulk-persist", true); + if (update) c.set ("bulk-update", true); + c.set ("bulk-erase", true); + } + // Validate indexes. // { -- cgit v1.1