Skip to content

Commit

Permalink
Setup the new 4.2.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
beaud76 committed Apr 2, 2023
1 parent 1c6cf0a commit 4b18db0
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 7 deletions.
13 changes: 11 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ E-Maj - Change log
==================
<devel>
------
###Enhancements:###


###Bug fixes:###



4.2.0 (2023-Apr-03)
------
###Enhancements:###
* Remove the support of postgres versions prior V11.
* Improve the sequences rollback processing: move it at the beginning of the
Expand Down Expand Up @@ -29,7 +38,7 @@ E-Maj - Change log
tables/sequences, the called function returned a wrong number of effectively
moved tables/sequences.

4.1.0 (2022-Oct.-01)
4.1.0 (2022-Oct-01)
------
###Enhancements:###
* E-Maj is compatible with PostgreSQL V15.
Expand All @@ -40,7 +49,7 @@ E-Maj - Change log
rows, an overflow in internal computations may happen. The problem can also
be seen with old E-Maj versions.

4.0.1 (2022-Apr.-02)
4.0.1 (2022-Apr-02)
------
###Enhancements:###

Expand Down
8 changes: 4 additions & 4 deletions sql/emaj--4.1.0--devel.sql → sql/emaj--4.1.0--4.2.0.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- E-Maj: migration from 4.1.0 to <devel>
-- E-Maj: migration from 4.1.0 to 4.2.0
--
-- This software is distributed under the GNU General Public License.
--
Expand Down Expand Up @@ -80,7 +80,7 @@ $do$;

-- Insert the upgrade begin record in the operation history.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording)
VALUES ('EMAJ_INSTALL','BEGIN','E-Maj <devel>', 'Upgrade from 4.1.0 started');
VALUES ('EMAJ_INSTALL','BEGIN','E-Maj 4.2.0', 'Upgrade from 4.1.0 started');

-- Lock emaj_group table to avoid any concurrent E-Maj activity.
LOCK TABLE emaj.emaj_group IN EXCLUSIVE MODE;
Expand Down Expand Up @@ -5811,12 +5811,12 @@ INSERT INTO pg_catalog.pg_description (objoid, classoid, objsubid, description)

-- Update the version id in the emaj_param table.
ALTER TABLE emaj.emaj_param DISABLE TRIGGER emaj_param_change_trg;
UPDATE emaj.emaj_param SET param_value_text = '<devel>' WHERE param_key = 'emaj_version';
UPDATE emaj.emaj_param SET param_value_text = '4.2.0' WHERE param_key = 'emaj_version';
ALTER TABLE emaj.emaj_param ENABLE TRIGGER emaj_param_change_trg;

-- Insert the upgrade end record in the operation history.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording)
VALUES ('EMAJ_INSTALL','END','E-Maj <devel>', 'Upgrade from 4.1.0 completed');
VALUES ('EMAJ_INSTALL','END','E-Maj 4.2.0', 'Upgrade from 4.1.0 completed');

-- Post installation checks.
DO
Expand Down
176 changes: 176 additions & 0 deletions sql/emaj--4.2.0--devel.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
--
-- E-Maj: migration from 4.2.0 to <devel>
--
-- This software is distributed under the GNU General Public License.
--
-- This script upgrades an existing installation of E-Maj extension.
--

-- Complain if this script is executed in psql, rather than via an ALTER EXTENSION statement.
\echo Use "ALTER EXTENSION emaj UPDATE TO..." to upgrade the E-Maj extension. \quit

--SET client_min_messages TO WARNING;
SET client_min_messages TO NOTICE;

------------------------------------
-- --
-- Checks --
-- --
------------------------------------
-- Check that the upgrade conditions are met.
DO
$do$
DECLARE
v_emajVersion TEXT;
v_nbNoError INT;
v_nbWarning INT;
BEGIN
-- The emaj version registered in emaj_param must be '4.2.0'.
SELECT param_value_text INTO v_emajVersion FROM emaj.emaj_param WHERE param_key = 'emaj_version';
IF v_emajVersion <> '4.2.0' THEN
RAISE EXCEPTION 'E-Maj upgrade: the current E-Maj version (%) is not 4.2.0',v_emajVersion;
END IF;
-- The installed postgres version must be at least 11.
IF current_setting('server_version_num')::int < 110000 THEN
RAISE EXCEPTION 'E-Maj upgrade: the current PostgreSQL version (%) is not compatible with the new E-Maj version. The PostgreSQL '
'version should be at least 11.', current_setting('server_version');
END IF;
-- Check E-Maj environment state.
SELECT count(msg) FILTER (WHERE msg = 'No error detected'),
count(msg) FILTER (WHERE msg LIKE 'Warning:%')
INTO v_nbNoError, v_nbWarning
FROM emaj.emaj_verify_all() AS t(msg);
IF v_nbNoError = 0 THEN
RAISE EXCEPTION 'E-Maj upgrade: the E-Maj environment is damaged. Please fix the issue before upgrading. You may execute '
'"SELECT * FROM emaj.emaj_verify_all();" to get more details.';
END IF;
IF v_nbWarning > 0 THEN
RAISE WARNING 'E-Maj upgrade: the E-Maj environment health check reports warning. You may execute "SELECT * FROM '
'emaj.emaj_verify_all();" to get more details.';
END IF;
END;
$do$;

-- OK, the upgrade operation can start...

-- Insert the upgrade begin record in the operation history.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording)
VALUES ('EMAJ_INSTALL','BEGIN','E-Maj <devel>', 'Upgrade from 4.2.0 started');

-- Lock emaj_group table to avoid any concurrent E-Maj activity.
LOCK TABLE emaj.emaj_group IN EXCLUSIVE MODE;

-- Disable the event triggers during the upgrade operation.
SELECT emaj._disable_event_triggers();

----------------------------------------------
-- --
-- emaj enums, tables, views and sequences --
-- --
----------------------------------------------


--
-- Add created or recreated tables and sequences to the list of content to save by pg_dump.
--

------------------------------------
-- --
-- emaj types --
-- --
------------------------------------

------------------------------------
-- --
-- emaj functions --
-- --
------------------------------------
-- Recreate functions that have been previously dropped in the tables structure upgrade step and will not be recreated later in this script.


--<begin_functions> pattern used by the tool that extracts and insert the functions definition

--<end_functions> pattern used by the tool that extracts and insert the functions definition
------------------------------------------
-- --
-- event triggers and related functions --
-- --
------------------------------------------

------------------------------------
-- --
-- emaj roles and rights --
-- --
------------------------------------
REVOKE ALL ON ALL FUNCTIONS IN SCHEMA emaj FROM PUBLIC;

GRANT ALL ON ALL TABLES IN SCHEMA emaj TO emaj_adm;
GRANT ALL ON ALL SEQUENCES IN SCHEMA emaj TO emaj_adm;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA emaj TO emaj_adm;

GRANT SELECT ON ALL TABLES IN SCHEMA emaj TO emaj_viewer;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA emaj TO emaj_viewer;
REVOKE SELECT ON TABLE emaj.emaj_param FROM emaj_viewer;


------------------------------------
-- --
-- Complete the upgrade --
-- --
------------------------------------

-- Enable the event triggers.
DO
$tmp$
DECLARE
v_event_trigger_array TEXT[];
BEGIN
-- Build the event trigger names array from the pg_event_trigger table.
SELECT coalesce(array_agg(evtname),ARRAY[]::TEXT[]) INTO v_event_trigger_array
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_event_trigger_array);
END;
$tmp$;

-- Set comments for all internal functions, by directly inserting a row in the pg_description table for all emaj functions
-- that do not have yet a recorded comment.
INSERT INTO pg_catalog.pg_description (objoid, classoid, objsubid, description)
SELECT pg_proc.oid, pg_class.oid, 0 , 'E-Maj internal function'
FROM pg_catalog.pg_proc, pg_catalog.pg_class
WHERE pg_class.relname = 'pg_proc'
AND pg_proc.oid IN -- list all emaj functions that do not have yet a comment in pg_description
(SELECT pg_proc.oid
FROM pg_catalog.pg_proc
JOIN pg_catalog.pg_namespace ON (pronamespace=pg_namespace.oid)
LEFT OUTER JOIN pg_catalog.pg_description ON (pg_description.objoid = pg_proc.oid
AND classoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'pg_proc')
AND objsubid = 0)
WHERE nspname = 'emaj' AND (proname LIKE E'emaj\\_%' OR proname LIKE E'\\_%')
AND pg_description.description IS NULL
);

-- Update the version id in the emaj_param table.
ALTER TABLE emaj.emaj_param DISABLE TRIGGER emaj_param_change_trg;
UPDATE emaj.emaj_param SET param_value_text = '<devel>' WHERE param_key = 'emaj_version';
ALTER TABLE emaj.emaj_param ENABLE TRIGGER emaj_param_change_trg;

-- Insert the upgrade end record in the operation history.
INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording)
VALUES ('EMAJ_INSTALL','END','E-Maj <devel>', 'Upgrade from 4.2.0 completed');

-- Post installation checks.
DO
$tmp$
DECLARE
BEGIN
-- Check the max_prepared_transactions GUC value.
IF current_setting('max_prepared_transactions')::int <= 1 THEN
RAISE WARNING 'E-Maj upgrade: as the max_prepared_transactions parameter value (%) on this cluster is too low, no parallel rollback '
'is possible.', current_setting('max_prepared_transactions');
END IF;
END;
$tmp$;

RESET default_tablespace;
SET client_min_messages TO default;
1 change: 0 additions & 1 deletion tar.index
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ emaj-4.2.0/sql/emaj-0.11.0-to-0.11.1.sql
emaj-4.2.0/sql/emaj_demo.sql
emaj-4.2.0/sql/emaj_prepare_parallel_rollback_test.sql
emaj-4.2.0/sql/emaj_uninstall.sql
emaj-4.2.0/sql/emaj_upgrade_after_postgres_upgrade.sql
emaj-4.2.0/doc/Emaj.4.2.0_doc_en.pdf
emaj-4.2.0/doc/Emaj.4.2.0_doc_fr.pdf
emaj-4.2.0/doc/Emaj.4.2.0_pres_en.odp
Expand Down

0 comments on commit 4b18db0

Please sign in to comment.