1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

B #5400,- : Bug fixes backport

* Fix PoolSQL::exist for PostgreSQL

* Sort hooks by execution id
This commit is contained in:
Pavel Czerný 2021-06-17 17:26:11 +02:00 committed by GitHub
parent 7b9243f73a
commit b387ef06ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -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("<HOOKLOG>");
cb.set_callback(&xml_log);

View File

@ -228,20 +228,31 @@ PoolObjectSQL * PoolSQL::get_ro(int oid)
void PoolSQL::exist(const string& id_str, std::set<int>& id_list)
{
std::vector<int> existing_items;
std::set<int>::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;
}
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */