Overview of triggers extended with function name and arguments.
Did a lot of refactoring on the catalog to keep things clean.
This commit is contained in:
parent
35813ae926
commit
fcb191f2cc
44 changed files with 797 additions and 404 deletions
|
|
@ -6,18 +6,39 @@
|
|||
|
||||
std::string PgTriggerContainer::getLoadQuery() const
|
||||
{
|
||||
return R"(SELECT oid, *
|
||||
FROM pg_trigger
|
||||
WHERE NOT tgisinternal)";
|
||||
std::string q =
|
||||
"SELECT oid, tgrelid, tgname, tgfoid, tgtype, tgenabled, tgisinternal, tgconstrrelid, \n"
|
||||
" tgconstrindid, tgconstraint, tgdeferrable, tginitdeferred, tgnargs, tgattr, \n"
|
||||
" tgargs, COALESCE(substring(pg_get_triggerdef(oid), 'WHEN (.*) EXECUTE PROCEDURE'), substring(pg_get_triggerdef(oid), 'WHEN (.*) \\$trigger')) AS whenclause";
|
||||
if (minimumVersion(90600)) {
|
||||
q += ", tgoldtable, tgnewtable";
|
||||
}
|
||||
q +=
|
||||
" FROM pg_trigger \n"
|
||||
" WHERE NOT tgisinternal";
|
||||
return q;
|
||||
}
|
||||
|
||||
PgTrigger PgTriggerContainer::loadElem(const Pgsql::Row &row)
|
||||
{
|
||||
|
||||
Pgsql::Col col(row);
|
||||
PgTrigger v;
|
||||
PgTrigger v(m_catalog);
|
||||
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;
|
||||
>> v.constrindid >> v.constraint >> v.deferrable >> v.initdeferred >> v.nargs >> v.attr;
|
||||
const unsigned char * args_bytea = reinterpret_cast<const unsigned char *>(col.nextValue().c_str());
|
||||
if (args_bytea) {
|
||||
size_t to_length;
|
||||
unsigned char *result = PQunescapeBytea(args_bytea, &to_length);
|
||||
if (result) {
|
||||
v.args = QString::fromUtf8(reinterpret_cast<const char*>(result), static_cast<int>(to_length));
|
||||
PQfreemem(result);
|
||||
}
|
||||
}
|
||||
col >> v.whenclause;
|
||||
if (minimumVersion(90600)) {
|
||||
col >> v.oldtable >> v.newtable;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue