pgLab/pglablib/PgTriggerContainer.cpp

34 lines
794 B
C++
Raw Normal View History

2018-09-23 10:43:32 +02:00
#include "PgTriggerContainer.h"
#include "Pgsql_Connection.h"
#include "Pgsql_Col.h"
#include <algorithm>
#include <iterator>
2018-09-23 10:43:32 +02:00
std::string PgTriggerContainer::getLoadQuery() const
{
return R"(SELECT oid, *
2018-09-23 10:43:32 +02:00
FROM pg_trigger
WHERE NOT tgisinternal)";
}
PgTrigger PgTriggerContainer::loadElem(const Pgsql::Row &row)
{
Pgsql::Col col(row);
PgTrigger v;
col >> v.oid >> v.relid >> v.name >> v.foid >> v.type >> v.enabled >> v.isinternal >> v.constrrelid
>> v.constrindid >> v.constraint >> v.deferrable >> v.initdeferred >> v.nargs >> v.attr
>> v.args >> v.qual;
2018-09-23 10:43:32 +02:00
return v;
}
std::vector<PgTrigger> PgTriggerContainer::getTriggersForRelation(Oid cls) const
{
std::vector<PgTrigger> result;
for (auto e : m_container)
if (e.relid == cls)
result.push_back(e);
return result;
}