B #5400,- : Bug fixes backport

* Fix PoolSQL::exist for PostgreSQL

* Sort hooks by execution id
This commit is contained in:
Pavel Czerný authored and GitHub committed 2021-06-17 17:26:11 +02:00
1 parent 7b9243f73a
commit b387ef06ae
2 files changed
+18 -9

No files matched your search

+3 -5
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);
+15 -4
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;
}
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */