diff --git a/include/BitMap.h b/include/BitMap.h index 5d9a330bcc..0c517c9594 100644 --- a/include/BitMap.h +++ b/include/BitMap.h @@ -122,7 +122,7 @@ public: std::ostringstream oss; oss << "DELETE FROM " << db_table << " WHERE id = " << id ; - return db->exec(oss); + return db->exec_wr(oss); } /* ---------------------------------------------------------------------- */ @@ -263,7 +263,7 @@ private: oss << "SELECT map FROM " << db_table << " WHERE id = " << id ; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); @@ -318,7 +318,7 @@ private: oss << "INTO " << db_table << " (id, map) VALUES (" << id << ",'" << ezipped64 << "')"; - int rc = db->exec(oss); + int rc = db->exec_wr(oss); delete zipped; diff --git a/include/Cluster.h b/include/Cluster.h index 689dadf1eb..9bcab4fee9 100644 --- a/include/Cluster.h +++ b/include/Cluster.h @@ -283,13 +283,13 @@ private: ostringstream oss; oss.str(Cluster::db_bootstrap); - rc = db->exec(oss); + rc = db->exec_bootstrap(oss); oss.str(Cluster::datastore_db_bootstrap); - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); oss.str(Cluster::network_db_bootstrap); - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); return rc; }; diff --git a/include/ClusterPool.h b/include/ClusterPool.h index 26729d315b..488acec7ce 100644 --- a/include/ClusterPool.h +++ b/include/ClusterPool.h @@ -201,7 +201,8 @@ public: int rc; rc = Cluster::bootstrap(_db); - rc += _db->exec(BitMap<0>::bootstrap(Cluster::bitmap_table, oss_bitmap)); + rc += _db->exec_bootstrap( + BitMap<0>::bootstrap(Cluster::bitmap_table, oss_bitmap)); return rc; }; diff --git a/include/Datastore.h b/include/Datastore.h index 978403d7a7..536344a236 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -364,7 +364,7 @@ private: { ostringstream oss(Datastore::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/Document.h b/include/Document.h index fb9950a26e..6e339bed02 100644 --- a/include/Document.h +++ b/include/Document.h @@ -107,7 +107,7 @@ private: { ostringstream oss(Document::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/Group.h b/include/Group.h index 21c2be5237..6696141d62 100644 --- a/include/Group.h +++ b/include/Group.h @@ -210,7 +210,7 @@ private: { ostringstream oss_group(Group::db_bootstrap); - return db->exec(oss_group); + return db->exec_bootstrap(oss_group); }; /** diff --git a/include/Host.h b/include/Host.h index a5ceb004af..d10a5ae1c7 100644 --- a/include/Host.h +++ b/include/Host.h @@ -532,8 +532,8 @@ private: ostringstream oss_host(Host::db_bootstrap); ostringstream oss_monit(Host::monit_db_bootstrap); - rc = db->exec(oss_host); - rc += db->exec(oss_monit); + rc = db->exec_bootstrap(oss_host); + rc += db->exec_bootstrap(oss_monit); return rc; }; diff --git a/include/Image.h b/include/Image.h index 8af3c0f2c1..f5dee683f0 100644 --- a/include/Image.h +++ b/include/Image.h @@ -696,7 +696,7 @@ private: { ostringstream oss_image(Image::db_bootstrap); - return db->exec(oss_image); + return db->exec_bootstrap(oss_image); }; /** diff --git a/include/MarketPlace.h b/include/MarketPlace.h index 4a6915a53f..ce75062fcf 100644 --- a/include/MarketPlace.h +++ b/include/MarketPlace.h @@ -221,7 +221,7 @@ private: { ostringstream oss(db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/MarketPlaceApp.h b/include/MarketPlaceApp.h index b1ce456e6c..c157c0d852 100644 --- a/include/MarketPlaceApp.h +++ b/include/MarketPlaceApp.h @@ -393,7 +393,7 @@ private: { ostringstream oss(db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/MySqlDB.h b/include/MySqlDB.h index 0de483cc1e..1d7414d824 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -52,14 +52,6 @@ public: ~MySqlDB(); - /** - * Wraps the mysql_query function call - * @param cmd the SQL command - * @param obj Callbackable obj to call if the query succeeds - * @return 0 on success - */ - int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false); - /** * This function returns a legal SQL string that can be used in an SQL * statement. The string is encoded to an escaped SQL string, taking into @@ -83,6 +75,15 @@ public: */ bool multiple_values_support(); +protected: + /** + * Wraps the mysql_query function call + * @param cmd the SQL command + * @param obj Callbackable obj to call if the query succeeds + * @return 0 on success + */ + int exec(ostringstream& cmd, Callbackable* obj, bool quiet); + private: /** @@ -151,13 +152,15 @@ public: ~MySqlDB(){}; - int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;}; char * escape_str(const string& str){return 0;}; void free_str(char * str){}; bool multiple_values_support(){return true;}; + +protected: + int exec(ostringstream& cmd, Callbackable* obj, bool quiet){return -1;}; }; #endif diff --git a/include/QuotasSQL.h b/include/QuotasSQL.h index 6ac539b187..c20a8d628e 100644 --- a/include/QuotasSQL.h +++ b/include/QuotasSQL.h @@ -167,7 +167,7 @@ public: { ostringstream oss_quota(GroupQuotas::db_bootstrap); - return db->exec(oss_quota); + return db->exec_bootstrap(oss_quota); }; protected: @@ -220,7 +220,7 @@ public: { ostringstream oss_quota(UserQuotas::db_bootstrap); - return db->exec(oss_quota); + return db->exec_bootstrap(oss_quota); }; protected: diff --git a/include/SecurityGroup.h b/include/SecurityGroup.h index 4b89a9ee8b..9c75471555 100644 --- a/include/SecurityGroup.h +++ b/include/SecurityGroup.h @@ -217,7 +217,7 @@ private: { ostringstream oss(SecurityGroup::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/SqlDB.h b/include/SqlDB.h index 8c1dee4778..e1353ef7c4 100644 --- a/include/SqlDB.h +++ b/include/SqlDB.h @@ -33,14 +33,31 @@ public: virtual ~SqlDB(){}; + /* ---------------------------------------------------------------------- */ + /* Database Operations */ + /* ---------------------------------------------------------------------- */ + /** - * Performs a DB transaction + * * @param sql_cmd the SQL command * @param callbak function to execute on each data returned - * @param quiet True to log errors with DDEBUG level instead of ERROR * @return 0 on success + * */ - virtual int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false) = 0; + int exec_bootstrap(ostringstream& cmd) + { + return exec(cmd, 0, false); + } + + int exec_rd(ostringstream& cmd, Callbackable* obj) + { + return exec(cmd, obj, false); + } + + int exec_wr(ostringstream& cmd) + { + return exec(cmd, 0, false); + } /** * This function returns a legal SQL string that can be used in an SQL @@ -63,6 +80,16 @@ public: * @return true if supported */ virtual bool multiple_values_support() = 0; + +protected: + /** + * Performs a DB transaction + * @param sql_cmd the SQL command + * @param callbak function to execute on each data returned + * @param quiet True to log errors with DDEBUG level instead of ERROR + * @return 0 on success + */ + virtual int exec(ostringstream& cmd, Callbackable* obj, bool quiet) = 0; }; #endif /*SQL_DB_H_*/ diff --git a/include/SqliteDB.h b/include/SqliteDB.h index 35dcea4a9a..cec4d5e39a 100644 --- a/include/SqliteDB.h +++ b/include/SqliteDB.h @@ -49,16 +49,6 @@ public: ~SqliteDB(); - /** - * Wraps the sqlite3_exec function call, and locks the DB mutex. - * @param sql_cmd the SQL command - * @param callbak function to execute on each data returned, watch the - * mutex you block in the callback. - * @param arg to pass to the callback function - * @return 0 on success - */ - int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false); - /** * This function returns a legal SQL string that can be used in an SQL * statement. @@ -81,6 +71,17 @@ public: */ bool multiple_values_support(); +protected: + /** + * Wraps the sqlite3_exec function call, and locks the DB mutex. + * @param sql_cmd the SQL command + * @param callbak function to execute on each data returned, watch the + * mutex you block in the callback. + * @param arg to pass to the callback function + * @return 0 on success + */ + int exec(ostringstream& cmd, Callbackable* obj, bool quiet); + private: /** * Fine-grain mutex for DB access @@ -121,13 +122,14 @@ public: ~SqliteDB(){}; - int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;}; - char * escape_str(const string& str){return 0;}; void free_str(char * str){}; bool multiple_values_support(){return true;}; + +protected: + int exec(ostringstream& cmd, Callbackable* obj, bool quiet){return -1;}; }; #endif diff --git a/include/User.h b/include/User.h index 0f919948c4..2d9d83f9a7 100644 --- a/include/User.h +++ b/include/User.h @@ -309,7 +309,7 @@ private: { ostringstream oss_user(User::db_bootstrap); - return db->exec(oss_user); + return db->exec_bootstrap(oss_user); }; /** diff --git a/include/VMGroup.h b/include/VMGroup.h index 786335e081..e297d2783a 100644 --- a/include/VMGroup.h +++ b/include/VMGroup.h @@ -166,7 +166,7 @@ private: { ostringstream oss(VMGroup::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/VMTemplate.h b/include/VMTemplate.h index 4dd9891900..a9fa1e5534 100644 --- a/include/VMTemplate.h +++ b/include/VMTemplate.h @@ -149,7 +149,7 @@ private: { ostringstream oss(VMTemplate::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/Vdc.h b/include/Vdc.h index 8b2d72529f..6dd7434d68 100644 --- a/include/Vdc.h +++ b/include/Vdc.h @@ -343,7 +343,7 @@ private: { ostringstream oss(Vdc::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 6c3ce0d3f5..357ce788be 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1750,10 +1750,10 @@ private: ostringstream oss_hist(History::db_bootstrap); ostringstream oss_showback(VirtualMachine::showback_db_bootstrap); - rc = db->exec(oss_vm); - rc += db->exec(oss_monit); - rc += db->exec(oss_hist); - rc += db->exec(oss_showback); + rc = db->exec_bootstrap(oss_vm); + rc += db->exec_bootstrap(oss_monit); + rc += db->exec_bootstrap(oss_hist); + rc += db->exec_bootstrap(oss_showback); return rc; }; diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h index bf1184a596..0794489d10 100644 --- a/include/VirtualMachinePool.h +++ b/include/VirtualMachinePool.h @@ -236,7 +236,7 @@ public: ostringstream oss_import(import_db_bootstrap); rc = VirtualMachine::bootstrap(_db); - rc += _db->exec(oss_import); + rc += _db->exec_bootstrap(oss_import); return rc; }; diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index 188863cbfe..0cff60dd88 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -596,7 +596,7 @@ private: { ostringstream oss_vnet(VirtualNetwork::db_bootstrap); - return db->exec(oss_vnet); + return db->exec_bootstrap(oss_vnet); }; /** diff --git a/include/VirtualNetworkPool.h b/include/VirtualNetworkPool.h index 76d24a9037..5322c9684e 100644 --- a/include/VirtualNetworkPool.h +++ b/include/VirtualNetworkPool.h @@ -122,7 +122,7 @@ public: int rc; rc = VirtualNetwork::bootstrap(_db); - rc += _db->exec(BitMap<0>::bootstrap(vlan_table, oss)); + rc += _db->exec_bootstrap(BitMap<0>::bootstrap(vlan_table, oss)); return rc; }; diff --git a/include/VirtualRouter.h b/include/VirtualRouter.h index 2ca924a346..a9e6f18a68 100644 --- a/include/VirtualRouter.h +++ b/include/VirtualRouter.h @@ -216,7 +216,7 @@ private: { ostringstream oss(VirtualRouter::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/Zone.h b/include/Zone.h index ffb406fb78..4ca4a5fe21 100644 --- a/include/Zone.h +++ b/include/Zone.h @@ -110,7 +110,7 @@ private: { ostringstream oss(Zone::db_bootstrap); - return db->exec(oss); + return db->exec_bootstrap(oss); }; /** diff --git a/include/ZoneServer.h b/include/ZoneServer.h index 0691b9419f..e9a920e875 100644 --- a/include/ZoneServer.h +++ b/include/ZoneServer.h @@ -32,6 +32,13 @@ public: virtual ~ZoneServer(){}; + /** + * Initialized server metadata: + * - NAME + * - ENDPOINT + * @param error string if any + * @return -1 if server data could not be initialized, 0 on success + */ int init(string& error) { if ( vector_value("NAME").empty() ) diff --git a/src/acl/AclManager.cc b/src/acl/AclManager.cc index 6bd02c8e2e..56deb3c341 100644 --- a/src/acl/AclManager.cc +++ b/src/acl/AclManager.cc @@ -64,7 +64,7 @@ AclManager::AclManager( oss << "SELECT last_oid FROM pool_control WHERE tablename='" << table << "'"; - db->exec(oss, this); + db->exec_rd(oss, this); unset_callback(); @@ -1094,7 +1094,7 @@ int AclManager::bootstrap(SqlDB * _db) { ostringstream oss(db_bootstrap); - return _db->exec(oss); + return _db->exec_bootstrap(oss); } /* -------------------------------------------------------------------------- */ @@ -1111,7 +1111,7 @@ void AclManager::update_lastOID() << "'" << table << "'," << lastOID << ")"; - db->exec(oss); + db->exec_wr(oss); } /* -------------------------------------------------------------------------- */ @@ -1186,7 +1186,7 @@ int AclManager::select() acl_rules.clear(); acl_rules_oids.clear(); - rc = db->exec(oss,this); + rc = db->exec_rd(oss,this); unlock(); @@ -1212,7 +1212,7 @@ int AclManager::insert(AclRule * rule, SqlDB * db) << rule->rights << "," << rule->zone << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } @@ -1229,7 +1229,7 @@ int AclManager::drop(int oid) oss << "DELETE FROM " << table << " WHERE " << "oid=" << oid; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } diff --git a/src/cluster/Cluster.cc b/src/cluster/Cluster.cc index ab661ae1b4..93d641457f 100644 --- a/src/cluster/Cluster.cc +++ b/src/cluster/Cluster.cc @@ -237,7 +237,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); @@ -252,11 +252,11 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str) oss.str(""); oss << "DELETE FROM " << network_table << " WHERE cid = " << oid; - rc += db->exec(oss); + rc += db->exec_wr(oss); oss.str(""); oss << "DELETE FROM " << datastore_table<< " WHERE cid = " << oid; - rc += db->exec(oss); + rc += db->exec_wr(oss); set datastore_set = datastores.get_collection(); @@ -275,7 +275,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str) oss << ", (" << oid << "," << *i << ")"; } - rc += db->exec(oss); + rc += db->exec_wr(oss); } set vnet_set = vnets.get_collection(); @@ -295,7 +295,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str) oss << ", (" << oid << "," << *i << ")"; } - rc += db->exec(oss); + rc += db->exec_wr(oss); } } else @@ -330,7 +330,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str) oss << "COMMIT"; - rc = db->exec(oss); + rc = db->exec_wr(oss); } } diff --git a/src/cluster/ClusterPool.cc b/src/cluster/ClusterPool.cc index 6767807c81..d82a776ba5 100644 --- a/src/cluster/ClusterPool.cc +++ b/src/cluster/ClusterPool.cc @@ -223,7 +223,7 @@ int ClusterPool::query_datastore_clusters(int oid, set &cluster_ids) oss << "SELECT cid FROM " << Cluster::datastore_table << " WHERE oid = " << oid; - int rc = db->exec(oss, this); + int rc = db->exec_rd(oss, this); unset_callback(); @@ -247,7 +247,7 @@ int ClusterPool::query_vnet_clusters(int oid, set &cluster_ids) oss << "SELECT cid FROM " << Cluster::network_table << " WHERE oid = " << oid; - int rc = db->exec(oss, this); + int rc = db->exec_rd(oss, this); unset_callback(); diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index cb1d9bf890..605d4624f9 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -606,7 +606,7 @@ int Datastore::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/document/Document.cc b/src/document/Document.cc index bb392a859b..f09eced775 100644 --- a/src/document/Document.cc +++ b/src/document/Document.cc @@ -154,7 +154,7 @@ int Document::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/group/Group.cc b/src/group/Group.cc index 6882a8bd23..291830456d 100644 --- a/src/group/Group.cc +++ b/src/group/Group.cc @@ -161,7 +161,7 @@ int Group::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/group/GroupPool.cc b/src/group/GroupPool.cc index 2c89a192e4..d245ece49a 100644 --- a/src/group/GroupPool.cc +++ b/src/group/GroupPool.cc @@ -249,7 +249,7 @@ int GroupPool::dump(ostringstream& oss, const string& where, const string& limit set_callback(static_cast(&GroupPool::dump_cb), static_cast(&oss)); - rc = db->exec(cmd, this); + rc = db->exec_rd(cmd, this); unset_callback(); diff --git a/src/host/Host.cc b/src/host/Host.cc index 62e2bfa1ed..d6f0c26ffc 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -140,7 +140,7 @@ int Host::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << "," << cluster_id << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_hostname); db->free_str(sql_xml); @@ -553,7 +553,7 @@ int Host::update_monitoring(SqlDB * db) db->free_str(sql_xml); - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc index e848f84cb7..61fa4b2bbf 100644 --- a/src/host/HostPool.cc +++ b/src/host/HostPool.cc @@ -254,7 +254,7 @@ int HostPool::discover( << " WHERE last_mon_time <= " << target_time << " ORDER BY last_mon_time ASC LIMIT " << host_limit; - rc = db->exec(sql,this); + rc = db->exec_rd(sql,this); unset_callback(); @@ -303,7 +303,7 @@ int HostPool::clean_expired_monitoring() oss << "DELETE FROM " << Host::monit_table << " WHERE last_mon_time < " << max_mon_time; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } @@ -318,7 +318,7 @@ int HostPool::clean_all_monitoring() oss << "DELETE FROM " << Host::monit_table; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } diff --git a/src/image/Image.cc b/src/image/Image.cc index 267a8768bb..76bc7c2a7f 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -291,7 +291,7 @@ int Image::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/market/MarketPlace.cc b/src/market/MarketPlace.cc index 29bee4d5f1..ec10dd75da 100644 --- a/src/market/MarketPlace.cc +++ b/src/market/MarketPlace.cc @@ -221,7 +221,7 @@ int MarketPlace::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/market/MarketPlaceApp.cc b/src/market/MarketPlaceApp.cc index 88273a9254..e1ad3075e1 100644 --- a/src/market/MarketPlaceApp.cc +++ b/src/market/MarketPlaceApp.cc @@ -186,7 +186,7 @@ int MarketPlaceApp::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/nebula/SystemDB.cc b/src/nebula/SystemDB.cc index 111596f2f0..52cd23933d 100644 --- a/src/nebula/SystemDB.cc +++ b/src/nebula/SystemDB.cc @@ -65,14 +65,14 @@ int SystemDB::shared_bootstrap() // db versioning, version of OpenNebula. // --------------------------------------------------------------------- oss.str(shared_ver_bootstrap); - rc = db->exec(oss); + rc = db->exec_bootstrap(oss); oss.str(""); oss << "INSERT INTO " << shared_ver_table << " (" << shared_ver_names << ") " << "VALUES (0, '" << Nebula::shared_db_version() << "', " << time(0) << ", '" << Nebula::version() << " daemon bootstrap')"; - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); return rc; }; @@ -89,14 +89,14 @@ int SystemDB::local_bootstrap() // pool control, tracks the last ID's assigned to objects // ------------------------------------------------------------------------ oss.str(pc_bootstrap); - rc = db->exec(oss); + rc = db->exec_bootstrap(oss); // ------------------------------------------------------------------------ // local db versioning, version of tables that are not replicated in a // slave OpenNebula. // ------------------------------------------------------------------------ oss.str(local_ver_bootstrap); - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); oss.str(""); oss << "INSERT INTO " << local_ver_table << " (" << local_ver_names << ") " @@ -104,13 +104,13 @@ int SystemDB::local_bootstrap() << ", '" << Nebula::version() << " daemon bootstrap', " << Nebula::instance().is_federation_slave() << ")"; - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); // ------------------------------------------------------------------------ // system // ------------------------------------------------------------------------ oss.str(sys_bootstrap); - rc += db->exec(oss); + rc += db->exec_bootstrap(oss); return rc; }; @@ -151,7 +151,7 @@ int SystemDB::check_db_version(const string& table, oss << "SELECT version FROM " << table <<" WHERE oid=(SELECT MAX(oid) FROM " << table << ")"; - int rc = db->exec(oss, this, true); + int rc = db->exec_rd(oss, this); unset_callback(); @@ -301,7 +301,7 @@ int SystemDB::insert_replace( << "'" << attr_name << "'," << "'" << sql_xml << "')"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_xml); @@ -350,7 +350,7 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml) oss << "SELECT body FROM " << sys_table << " WHERE name = '" << attr_name << "'"; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index 42550d2ad7..b006c0cfa5 100644 --- a/src/pool/PoolObjectSQL.cc +++ b/src/pool/PoolObjectSQL.cc @@ -59,7 +59,7 @@ int PoolObjectSQL::select(SqlDB *db) boid = oid; oid = -1; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); @@ -101,7 +101,7 @@ int PoolObjectSQL::select(SqlDB *db, const string& _name, int _uid) name = ""; uid = -1; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); @@ -125,7 +125,7 @@ int PoolObjectSQL::drop(SqlDB *db) oss << "DELETE FROM " << table << " WHERE oid=" << oid; - rc = db->exec(oss); + rc = db->exec_wr(oss); if ( rc == 0 ) { diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index cffdc1ed71..c9d403e889 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -62,7 +62,7 @@ PoolSQL::PoolSQL(SqlDB * _db, const char * _table, bool _cache, bool cache_by_na oss << "SELECT last_oid FROM pool_control WHERE tablename='" << table <<"'"; - db->exec(oss,this); + db->exec_rd(oss,this); unset_callback(); }; @@ -152,7 +152,7 @@ void PoolSQL::update_lastOID() << "'" << table << "'," << lastOID << ")"; - db->exec(oss); + db->exec_wr(oss); } /* -------------------------------------------------------------------------- */ @@ -635,7 +635,7 @@ int PoolSQL::dump(ostringstream& oss, set_callback(static_cast(&PoolSQL::dump_cb), static_cast(&oss)); - rc = db->exec(sql_query, this); + rc = db->exec_rd(sql_query, this); add_extra_xml(oss); @@ -685,7 +685,7 @@ int PoolSQL::search( sql << " WHERE " << where; } - rc = db->exec(sql, this); + rc = db->exec_rd(sql, this); unset_callback(); diff --git a/src/secgroup/SecurityGroup.cc b/src/secgroup/SecurityGroup.cc index cb77978e49..3246cc8eba 100644 --- a/src/secgroup/SecurityGroup.cc +++ b/src/secgroup/SecurityGroup.cc @@ -167,7 +167,7 @@ int SecurityGroup::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/um/QuotasSQL.cc b/src/um/QuotasSQL.cc index 8098941a22..2d6a5aa0db 100644 --- a/src/um/QuotasSQL.cc +++ b/src/um/QuotasSQL.cc @@ -64,7 +64,7 @@ int QuotasSQL::select(SqlDB * db) oss << "SELECT body FROM " << table() << " WHERE " << table_oid_column() << " = " << oid; - rc = db->exec(oss,this); + rc = db->exec_rd(oss,this); unset_callback(); @@ -134,7 +134,7 @@ int QuotasSQL::insert_replace(SqlDB *db, bool replace, string& error_str) << oid << "," << "'" << sql_quota_xml << "')"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_quota_xml); @@ -166,7 +166,7 @@ int QuotasSQL::drop(SqlDB *db) oss << "DELETE FROM " << table() << " WHERE " << table_oid_column() << " = " << oid; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } diff --git a/src/um/User.cc b/src/um/User.cc index b38cfd23e5..2b05b608e3 100644 --- a/src/um/User.cc +++ b/src/um/User.cc @@ -169,7 +169,7 @@ int User::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_username); db->free_str(sql_xml); diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 6038dfb87f..7a0cefa459 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -1283,7 +1283,7 @@ int UserPool::dump(ostringstream& oss, const string& where, const string& limit) set_callback(static_cast(&UserPool::dump_cb), static_cast(&oss)); - rc = db->exec(cmd, this); + rc = db->exec_rd(cmd, this); unset_callback(); diff --git a/src/vdc/Vdc.cc b/src/vdc/Vdc.cc index 7baa335a13..21ab18a47e 100644 --- a/src/vdc/Vdc.cc +++ b/src/vdc/Vdc.cc @@ -151,7 +151,7 @@ int Vdc::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/vm/History.cc b/src/vm/History.cc index 785f39dcbd..e7cb309992 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -185,7 +185,7 @@ int History::insert_replace(SqlDB *db, bool replace) << stime << "," << etime << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_xml); @@ -234,7 +234,7 @@ int History::select(SqlDB * db) set_callback(static_cast(&History::select_cb)); - rc = db->exec(oss,this); + rc = db->exec_rd(oss,this); unset_callback(); @@ -255,7 +255,7 @@ int History::drop(SqlDB * db) oss << "DELETE FROM " << table << " WHERE vid= "<< oid; - return db->exec(oss); + return db->exec_wr(oss); } /* -------------------------------------------------------------------------- */ diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 60315da813..9ee7e53d4e 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1523,7 +1523,7 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str) db->free_str(sql_name); db->free_str(sql_xml); - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; @@ -1594,7 +1594,7 @@ int VirtualMachine::update_monitoring(SqlDB * db) db->free_str(sql_xml); - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index 1ba75b3ec4..659e00aa69 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -238,7 +238,7 @@ int VirtualMachinePool::insert_index(const string& deploy_id, int vmid, db->free_str(deploy_name); - return db->exec(oss); + return db->exec_wr(oss); }; /* -------------------------------------------------------------------------- */ @@ -256,7 +256,7 @@ void VirtualMachinePool::drop_index(const string& deploy_id) oss << "DELETE FROM " << import_table << " WHERE deploy_id='" << deploy_name << "'"; - db->exec(oss); + db->exec_wr(oss); } /* -------------------------------------------------------------------------- */ @@ -469,7 +469,7 @@ int VirtualMachinePool::clean_expired_monitoring() oss << "DELETE FROM " << VirtualMachine::monit_table << " WHERE last_poll < " << max_last_poll; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } @@ -484,7 +484,7 @@ int VirtualMachinePool::clean_all_monitoring() oss << "DELETE FROM " << VirtualMachine::monit_table; - rc = db->exec(oss); + rc = db->exec_wr(oss); return rc; } @@ -543,7 +543,7 @@ int VirtualMachinePool::get_vmid (const string& deploy_id) oss << "SELECT vmid FROM " << import_table << " WHERE deploy_id = '" << db->escape_str(deploy_id.c_str()) << "'"; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); @@ -696,7 +696,7 @@ int VirtualMachinePool::calculate_showback( oss << "SELECT MIN(stime) FROM " << History::table; - rc = db->exec(oss, this); + rc = db->exec_rd(oss, this); unset_callback(); } @@ -973,7 +973,7 @@ int VirtualMachinePool::calculate_showback( { oss << sql_cmd_end; - rc = db->exec(oss); + rc = db->exec_wr(oss); if (rc != 0) { @@ -1004,7 +1004,7 @@ int VirtualMachinePool::calculate_showback( { oss << sql_cmd_end; - rc = db->exec(oss); + rc = db->exec_wr(oss); if (rc != 0) { diff --git a/src/vm_group/VMGroup.cc b/src/vm_group/VMGroup.cc index 50d0a9d49f..9b50906786 100644 --- a/src/vm_group/VMGroup.cc +++ b/src/vm_group/VMGroup.cc @@ -193,7 +193,7 @@ int VMGroup::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/vm_template/VMTemplate.cc b/src/vm_template/VMTemplate.cc index 86673d3059..824788ca28 100644 --- a/src/vm_template/VMTemplate.cc +++ b/src/vm_template/VMTemplate.cc @@ -139,7 +139,7 @@ int VMTemplate::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc index 1b5582f983..3be0218121 100644 --- a/src/vnm/VirtualNetwork.cc +++ b/src/vnm/VirtualNetwork.cc @@ -369,7 +369,7 @@ int VirtualNetwork::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << "," << parent_vid << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index ad3acf1155..f5ea75cba4 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -272,7 +272,7 @@ int VirtualRouter::insert_replace(SqlDB *db, bool replace, string& error_str) << group_u << "," << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml); diff --git a/src/zone/Zone.cc b/src/zone/Zone.cc index 50f33ac032..598b78b866 100644 --- a/src/zone/Zone.cc +++ b/src/zone/Zone.cc @@ -169,7 +169,7 @@ int Zone::insert_replace(SqlDB *db, bool replace, string& error_str) << other_u << ")"; - rc = db->exec(oss); + rc = db->exec_wr(oss); db->free_str(sql_name); db->free_str(sql_xml);