diff --git a/src/hm/HookLog.cc b/src/hm/HookLog.cc index 280e0e563e..ee257e1dcf 100644 --- a/src/hm/HookLog.cc +++ b/src/hm/HookLog.cc @@ -66,11 +66,7 @@ int HookLog::_dump_log(int hkid, int exec_id, std::string &xml_log) cmd << "SELECT body FROM "<< table; - if ( hkid == -1 ) - { - cmd << " ORDER BY hkid DESC"; - } - else + if ( hkid != -1 ) { cmd << " WHERE hkid = " << hkid; } @@ -80,6 +76,8 @@ int HookLog::_dump_log(int hkid, int exec_id, std::string &xml_log) cmd << " AND exeid = " << exec_id; } + cmd << " ORDER BY hkid DESC, exeid"; + xml_log.append(""); cb.set_callback(&xml_log); diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index 80321e14be..317079970a 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -228,20 +228,31 @@ PoolObjectSQL * PoolSQL::get_ro(int oid) void PoolSQL::exist(const string& id_str, std::set& id_list) { std::vector existing_items; - std::set::iterator iterator; one_util::split_unique(id_str, ',', id_list); - search(existing_items, table.c_str(), "1 order by 1 ASC"); + if (Nebula::instance().get_db_backend() == "postgresql") + { + search(existing_items, table.c_str(), "true order by 1 ASC"); + } + else + { + search(existing_items, table.c_str(), "1 order by 1 ASC"); + } - for (iterator = id_list.begin(); iterator != id_list.end(); ++iterator) + for (auto iterator = id_list.begin(); iterator != id_list.end();) { if (!std::binary_search(existing_items.begin(), existing_items.end(), *iterator)) { - id_list.erase(iterator); + iterator = id_list.erase(iterator); + } + else + { + ++iterator; } } } + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */