From b08bd1a315ac75d27850d080dd67b8da1702b78f Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 9 Feb 2019 17:36:37 +0100 Subject: [PATCH] The trigger SQL now also shows the function definition. --- pglab/TriggerPage.cpp | 6 ++++++ pglablib/catalog/PgProc.cpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/pglab/TriggerPage.cpp b/pglab/TriggerPage.cpp index e2fb82c..dd78f00 100644 --- a/pglab/TriggerPage.cpp +++ b/pglab/TriggerPage.cpp @@ -7,6 +7,7 @@ #include "CustomFilterSortModel.h" #include "CustomDataRole.h" #include "PgLabTableView.h" +#include "catalog/PgProcContainer.h" #include #include @@ -44,6 +45,11 @@ void TriggerPage::tableView_selectionChanged(const QItemSelection &/*selected*/, auto&& t = m_model->trigger(rij); drops += t.dropSql() % "\n"; creates += t.createSql() % "\n"; + + const PgProc *proc = m_catalog->procs()->getByKey(t.foid); + if (proc) { + creates += "\n" % proc->createSql() % "\n"; + } } m_definitionView->setPlainText(drops % "\n" % creates); } diff --git a/pglablib/catalog/PgProc.cpp b/pglablib/catalog/PgProc.cpp index 757cc69..83fe734 100644 --- a/pglablib/catalog/PgProc.cpp +++ b/pglablib/catalog/PgProc.cpp @@ -343,7 +343,9 @@ QString PgProc::createSql() const // sql += wxT("\n") // + GetGrant(wxT("X"), wxT("FUNCTION ") + qtSig); + sql += "\n"; sql += alterOwnerSql("FUNCTION " + quoted_sig); + sql += "\n"; sql += grantSql(); // if (!GetComment().IsNull())