Skip to content

Commit

Permalink
Minor comment improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
beaud76 committed Mar 7, 2023
1 parent 42ab013 commit 83e367e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 18 deletions.
53 changes: 51 additions & 2 deletions sql/emaj--4.1.0--devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3302,13 +3302,62 @@ $_event_trigger_sql_drop_fnct$;
COMMENT ON FUNCTION emaj._event_trigger_sql_drop_fnct() IS
$$E-Maj extension: support of the emaj_sql_drop_trg event trigger.$$;

CREATE OR REPLACE FUNCTION emaj.emaj_disable_protection_by_event_triggers()
RETURNS INT LANGUAGE plpgsql AS
$emaj_disable_protection_by_event_triggers$
-- This function disables all known E-Maj event triggers that are in enabled state.
-- It may be used by an emaj_adm role.
-- Output: number of effectively disabled event triggers.
DECLARE
v_eventTriggers TEXT[];
BEGIN
-- Call the _disable_event_triggers() function and get the disabled event trigger names array.
SELECT emaj._disable_event_triggers() INTO v_eventTriggers;
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('DISABLE_PROTECTION', 'EVENT TRIGGERS DISABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
-- Return the number of disabled event triggers.
RETURN coalesce(array_length(v_eventTriggers,1),0);
END;
$emaj_disable_protection_by_event_triggers$;
COMMENT ON FUNCTION emaj.emaj_disable_protection_by_event_triggers() IS
$$Disables the protection of E-Maj components by event triggers.$$;

CREATE OR REPLACE FUNCTION emaj.emaj_enable_protection_by_event_triggers()
RETURNS INT LANGUAGE plpgsql AS
$emaj_enable_protection_by_event_triggers$
-- This function enables all known E-Maj event triggers that are in disabled state.
-- It may be used by an emaj_adm role.
-- Output: number of effectively enabled event triggers.
DECLARE
v_eventTriggers TEXT[];
BEGIN
-- Build the event trigger names array from the pg_event_trigger table.
SELECT coalesce(array_agg(evtname ORDER BY evtname),ARRAY[]::TEXT[]) INTO v_eventTriggers
FROM pg_catalog.pg_event_trigger
WHERE evtname LIKE 'emaj%'
AND evtenabled = 'D';
-- Call the _enable_event_triggers() function.
PERFORM emaj._enable_event_triggers(v_eventTriggers);
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('ENABLE_PROTECTION', 'EVENT TRIGGERS ENABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
-- Return the number of enabled event triggers.
RETURN coalesce(array_length(v_eventTriggers,1),0);
END;
$emaj_enable_protection_by_event_triggers$;
COMMENT ON FUNCTION emaj.emaj_enable_protection_by_event_triggers() IS
$$Enables the protection of E-Maj components by event triggers.$$;

CREATE OR REPLACE FUNCTION emaj._enable_event_triggers(p_eventTriggers TEXT[])
RETURNS TEXT[] LANGUAGE plpgsql
SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS
$_enable_event_triggers$
-- This function enables all event triggers supplied as parameter.
-- It also recreates the emaj_protection_trg event trigger if it does not exist.
-- This is the only component that is not linked to the emaj extension and cannot be protected by another event trigger.
-- It also recreates the emaj_protection_trg event trigger if it does not exist. This event trigger is the only component
-- that is not linked to the emaj extension and cannot be protected by another event trigger.
-- The function is called by functions that alter or drop E-Maj components, such as
-- _drop_group(), _alter_groups(), _delete_before_mark_group() and _reset_groups().
-- It is also called by the user emaj_enable_event_triggers_protection() function.
Expand Down
10 changes: 5 additions & 5 deletions sql/emaj--devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12290,7 +12290,7 @@ $emaj_disable_protection_by_event_triggers$
BEGIN
-- Call the _disable_event_triggers() function and get the disabled event trigger names array.
SELECT emaj._disable_event_triggers() INTO v_eventTriggers;
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('DISABLE_PROTECTION', 'EVENT TRIGGERS DISABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
Expand All @@ -12317,11 +12317,11 @@ $emaj_enable_protection_by_event_triggers$
AND evtenabled = 'D';
-- Call the _enable_event_triggers() function.
PERFORM emaj._enable_event_triggers(v_eventTriggers);
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('ENABLE_PROTECTION', 'EVENT TRIGGERS ENABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
-- Return the number of disabled event triggers.
-- Return the number of enabled event triggers.
RETURN coalesce(array_length(v_eventTriggers,1),0);
END;
$emaj_enable_protection_by_event_triggers$;
Expand Down Expand Up @@ -12365,8 +12365,8 @@ RETURNS TEXT[] LANGUAGE plpgsql
SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS
$_enable_event_triggers$
-- This function enables all event triggers supplied as parameter.
-- It also recreates the emaj_protection_trg event trigger if it does not exist.
-- This is the only component that is not linked to the emaj extension and cannot be protected by another event trigger.
-- It also recreates the emaj_protection_trg event trigger if it does not exist. This event trigger is the only component
-- that is not linked to the emaj extension and cannot be protected by another event trigger.
-- The function is called by functions that alter or drop E-Maj components, such as
-- _drop_group(), _alter_groups(), _delete_before_mark_group() and _reset_groups().
-- It is also called by the user emaj_enable_event_triggers_protection() function.
Expand Down
10 changes: 5 additions & 5 deletions sql/emaj-devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12297,7 +12297,7 @@ $emaj_disable_protection_by_event_triggers$
BEGIN
-- Call the _disable_event_triggers() function and get the disabled event trigger names array.
SELECT emaj._disable_event_triggers() INTO v_eventTriggers;
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('DISABLE_PROTECTION', 'EVENT TRIGGERS DISABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
Expand All @@ -12324,11 +12324,11 @@ $emaj_enable_protection_by_event_triggers$
AND evtenabled = 'D';
-- Call the _enable_event_triggers() function.
PERFORM emaj._enable_event_triggers(v_eventTriggers);
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('ENABLE_PROTECTION', 'EVENT TRIGGERS ENABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
-- Return the number of disabled event triggers.
-- Return the number of enabled event triggers.
RETURN coalesce(array_length(v_eventTriggers,1),0);
END;
$emaj_enable_protection_by_event_triggers$;
Expand Down Expand Up @@ -12372,8 +12372,8 @@ RETURNS TEXT[] LANGUAGE plpgsql
SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS
$_enable_event_triggers$
-- This function enables all event triggers supplied as parameter.
-- It also recreates the emaj_protection_trg event trigger if it does not exist.
-- This is the only component that is not linked to the emaj extension and cannot be protected by another event trigger.
-- It also recreates the emaj_protection_trg event trigger if it does not exist. This event trigger is the only component
-- that is not linked to the emaj extension and cannot be protected by another event trigger.
-- The function is called by functions that alter or drop E-Maj components, such as
-- _drop_group(), _alter_groups(), _delete_before_mark_group() and _reset_groups().
-- It is also called by the user emaj_enable_event_triggers_protection() function.
Expand Down
10 changes: 5 additions & 5 deletions test/14/expected/install_psql.out
Original file line number Diff line number Diff line change
Expand Up @@ -12090,7 +12090,7 @@ $emaj_disable_protection_by_event_triggers$
BEGIN
-- Call the _disable_event_triggers() function and get the disabled event trigger names array.
SELECT emaj._disable_event_triggers() INTO v_eventTriggers;
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('DISABLE_PROTECTION', 'EVENT TRIGGERS DISABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
Expand All @@ -12116,11 +12116,11 @@ $emaj_enable_protection_by_event_triggers$
AND evtenabled = 'D';
-- Call the _enable_event_triggers() function.
PERFORM emaj._enable_event_triggers(v_eventTriggers);
-- Insert a row into the emaj_hist table.
-- Keep a trace into the emaj_hist table.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_wording)
VALUES ('ENABLE_PROTECTION', 'EVENT TRIGGERS ENABLED',
CASE WHEN v_eventTriggers <> ARRAY[]::TEXT[] THEN array_to_string(v_eventTriggers, ', ') ELSE '<none>' END);
-- Return the number of disabled event triggers.
-- Return the number of enabled event triggers.
RETURN coalesce(array_length(v_eventTriggers,1),0);
END;
$emaj_enable_protection_by_event_triggers$;
Expand Down Expand Up @@ -12162,8 +12162,8 @@ RETURNS TEXT[] LANGUAGE plpgsql
SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS
$_enable_event_triggers$
-- This function enables all event triggers supplied as parameter.
-- It also recreates the emaj_protection_trg event trigger if it does not exist.
-- This is the only component that is not linked to the emaj extension and cannot be protected by another event trigger.
-- It also recreates the emaj_protection_trg event trigger if it does not exist. This event trigger is the only component
-- that is not linked to the emaj extension and cannot be protected by another event trigger.
-- The function is called by functions that alter or drop E-Maj components, such as
-- _drop_group(), _alter_groups(), _delete_before_mark_group() and _reset_groups().
-- It is also called by the user emaj_enable_event_triggers_protection() function.
Expand Down
2 changes: 1 addition & 1 deletion test/14/expected/misc.out
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ begin;
select emaj.emaj_estimate_rollback_groups('{"myGroup1","myGroup2"}','Multi-1',FALSE);
emaj_estimate_rollback_groups
-------------------------------
@ 2.725913 secs
@ 2.710901 secs
(1 row)

-- should return 2.670001 sec (or 2.725913 sec is emaj is not an extension)
Expand Down

0 comments on commit 83e367e

Please sign in to comment.