From 68399fe62cfa92b574dd9b9aa15d5b4797a3296e Mon Sep 17 00:00:00 2001 From: Michael Douchin Date: Wed, 7 Aug 2024 17:39:22 +0200 Subject: [PATCH] =?UTF-8?q?Utils=20-=20Ajout=20du=20statut=20actif=20pour?= =?UTF-8?q?=20la=20requ=C3=AAte=20listant=20les=20triggers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/utils.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/utils.md b/docs/utils.md index 6df0284..d446085 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -282,21 +282,26 @@ SELECT trigger_name, string_agg(event_manipulation, ',') AS event, action_timing AS activation, - action_condition AS condition, + action_condition AS condition, + CASE WHEN tgenabled = 'O' THEN True ELSE False END AS trigger_active, action_statement AS definition -FROM information_schema.triggers -GROUP BY 1,2,3,4,6,7,8 +FROM information_schema.triggers AS t +INNER JOIN pg_trigger AS p + ON p.tgrelid = concat('"', event_object_schema, '"."', event_object_table, '"')::regclass + AND trigger_name = tgname +WHERE True +GROUP BY 1,2,3,4,6,7,8,9 ORDER BY table_schema, table_name ; ``` Cette requête renvoie un tableau de la forme : -| table_schema | table_name | trigger_schema | trigger_name | event | activation | condition | definition | -|--------------|------------------------|----------------|----------------------|--------|------------|-----------|------------------------------------------------------| -| gestion | acteur | gestion | tr_date_maj | UPDATE | BEFORE | | EXECUTE FUNCTION occtax.maj_date() | -| occtax | organisme | occtax | tr_date_maj | UPDATE | BEFORE | | EXECUTE FUNCTION occtax.maj_date() | -| taxon | iso_metadata_reference | taxon | update_imr_timestamp | UPDATE | BEFORE | | EXECUTE FUNCTION taxon.update_imr_timestamp_column() | +| table_schema | table_name | trigger_schema | trigger_name | event | activation | condition | trigger_active | definition | +|--------------|------------------------|----------------|----------------------|--------|------------|-----------|--------------- |------------------------------------------------------| +| gestion | acteur | gestion | tr_date_maj | UPDATE | BEFORE | | f | EXECUTE FUNCTION occtax.maj_date() | +| occtax | organisme | occtax | tr_date_maj | UPDATE | BEFORE | | t | EXECUTE FUNCTION occtax.maj_date() | +| taxon | iso_metadata_reference | taxon | update_imr_timestamp | UPDATE | BEFORE | | t | EXECUTE FUNCTION taxon.update_imr_timestamp_column() | ## Lister les fonctions installées par les extensions