Skip to content

Commit

Permalink
Let E-Maj work with PostgreSQL 12. The only impact in the source code…
Browse files Browse the repository at this point in the history
… concerns the WITH OIDS tables suppression. The checks to avoid to include such tables in tables groups are dropped for PG12+. Add a PG12 corridor to the regression test suite.
  • Loading branch information
beaud76 committed May 31, 2019
1 parent 8659d3e commit 5044a66
Show file tree
Hide file tree
Showing 47 changed files with 32,738 additions and 192 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ E-Maj - Change log
<devel>
------
###Enhancements:###
* Let E-Maj work with PostgreSQL 12.
* The rollback functions now automatically disable the application triggers,
unless they are set in a list of triggers that should not be automatically
disabled during the operation. A new emaj_ignore_app_trigger() function
Expand Down
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Welcome to the E-Maj's documentation!

functionsList
content
versionsMatrix

Indices and tables
==================
Expand Down
34 changes: 34 additions & 0 deletions docs/en/versionsMatrix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PostgreSQL and E-Maj versions compatibility matrix
==================================================

+----------+----------+----------+------------+
| PostgreSQL versions | E-Maj versions |
+----------+----------+----------+------------+
| Min | Max | Min | Date |
+==========+==========+==========+============+
| 8.2 | 8.4 | 0.4.0 | 21/01/2010 |
+----------+----------+----------+------------+
| 8.2 | 9.0 | 0.8.0 | 16/10/2010 |
+----------+----------+----------+------------+
| 8.2 | 9.1 | 0.10.0 | 03/11/2011 |
+----------+----------+----------+------------+
| 8.2 | 9.2 | 0.11.1 | 28/07/2012 |
+----------+----------+----------+------------+
| 8.3 | 9.3 | 1.1.0 | 01/10/2013 |
+----------+----------+----------+------------+
| 8.3 | 9.5 | 1.2.0 | 02/01/2016 |
+----------+----------+----------+------------+
| 8.3 | 9.6 | 1.3.1 | 15/09/2016 |
+----------+----------+----------+------------+
| 9.1 | 9.6 | 2.0.0 | 15/11/2016 |
+----------+----------+----------+------------+
| 9.1 | 10 | 2.1.0 | 02/08/2017 |
+----------+----------+----------+------------+
| 9.2 | 10 | 2.3.0 | 08/07/2018 |
+----------+----------+----------+------------+
| 9.2 | 11 | 2.3.1 | 06/09/2018 |
+----------+----------+----------+------------+
| 9.5 | 11 | 3.0.0 | 18/03/2019 |
+----------+----------+----------+------------+
| 9.5 | 12 | devel | |
+----------+----------+----------+------------+
1 change: 1 addition & 0 deletions docs/fr/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Bienvenue dans la documentation E-Maj !

functionsList
content
versionsMatrix

Index et tables
===============
Expand Down
34 changes: 34 additions & 0 deletions docs/fr/versionsMatrix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Matrice de compatibilité des versions PostgreSQL et E-Maj
=========================================================

+----------+----------+----------+------------+
| Versions PostgreSQL | Versions E-Maj |
+----------+----------+----------+------------+
| Min | Max | Min | Date |
+==========+==========+==========+============+
| 8.2 | 8.4 | 0.4.0 | 21/01/2010 |
+----------+----------+----------+------------+
| 8.2 | 9.0 | 0.8.0 | 16/10/2010 |
+----------+----------+----------+------------+
| 8.2 | 9.1 | 0.10.0 | 03/11/2011 |
+----------+----------+----------+------------+
| 8.2 | 9.2 | 0.11.1 | 28/07/2012 |
+----------+----------+----------+------------+
| 8.3 | 9.3 | 1.1.0 | 01/10/2013 |
+----------+----------+----------+------------+
| 8.3 | 9.5 | 1.2.0 | 02/01/2016 |
+----------+----------+----------+------------+
| 8.3 | 9.6 | 1.3.1 | 15/09/2016 |
+----------+----------+----------+------------+
| 9.1 | 9.6 | 2.0.0 | 15/11/2016 |
+----------+----------+----------+------------+
| 9.1 | 10 | 2.1.0 | 02/08/2017 |
+----------+----------+----------+------------+
| 9.2 | 10 | 2.3.0 | 08/07/2018 |
+----------+----------+----------+------------+
| 9.2 | 11 | 2.3.1 | 06/09/2018 |
+----------+----------+----------+------------+
| 9.5 | 11 | 3.0.0 | 18/03/2019 |
+----------+----------+----------+------------+
| 9.5 | 12 | devel | |
+----------+----------+----------+------------+
522 changes: 509 additions & 13 deletions sql/emaj--3.0.0--devel.sql

Large diffs are not rendered by default.

74 changes: 39 additions & 35 deletions sql/emaj--devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1104,13 +1104,15 @@ $_check_conf_groups$
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relpersistence = 'u';
---- check no table is a WITH OIDS table (blocking rollbackable groups only)
RETURN QUERY
SELECT 21, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
format('in the group %s, the table %s.%s is declared WITH OIDS.', quote_ident(grpdef_group), quote_ident(grpdef_schema), quote_ident(grpdef_tblseq))
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relhasoids;
---- with PG11- check no table is a WITH OIDS table (blocking rollbackable groups only)
IF emaj._pg_version_num() < 120000 THEN
RETURN QUERY
SELECT 21, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
format('in the group %s, the table %s.%s is declared WITH OIDS.', quote_ident(grpdef_group), quote_ident(grpdef_schema), quote_ident(grpdef_tblseq))
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relhasoids;
END IF;
---- check every table has a primary key (blocking rollbackable groups only)
RETURN QUERY
SELECT 22, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
Expand Down Expand Up @@ -2733,21 +2735,23 @@ $_verify_groups$
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (8): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
-- for rollbackable groups, check no table has been altered as WITH OIDS after tables groups creation
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is declared WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND rel_group = ANY (v_groups) AND rel_kind = 'r' AND upper_inf(rel_time_range)
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY 1,2,3
LOOP
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (9): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
-- for rollbackable groups, with PG 11-, check no table has been altered as WITH OIDS after tables groups creation
IF emaj._pg_version_num() < 120000 THEN
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is declared WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND rel_group = ANY (v_groups) AND rel_kind = 'r' AND upper_inf(rel_time_range)
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY 1,2,3
LOOP
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (9): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
END IF;
-- check the primary key structure of all tables belonging to rollbackable groups is unchanged
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
Expand Down Expand Up @@ -3306,9 +3310,7 @@ $_alter_plan$
AND rel_kind = 'r'
AND coalesce(rel_log_idx_tsp,'') <> coalesce(grpdef_log_idx_tsp,'')
-- exclude tables that will have been repaired in a previous step
---- AND (rel_schema, rel_tblseq) NOT IN (
---- SELECT altr_schema, altr_tblseq FROM emaj.emaj_alter_plan WHERE altr_time_id = v_timeId AND altr_step = 'REPAIR_TBL');
AND NOT EXISTS (-----(rel_schema, rel_tblseq) NOT IN (
AND NOT EXISTS (
SELECT 0 FROM emaj.emaj_alter_plan
WHERE altr_schema = rel_schema AND altr_tblseq = rel_tblseq
AND altr_time_id = v_timeId AND altr_step = 'REPAIR_TBL');
Expand Down Expand Up @@ -7288,16 +7290,18 @@ $_verify_all_groups$
AND group_name = rel_group AND group_is_rollbackable
AND relpersistence <> 'p'
ORDER BY rel_schema, rel_tblseq, 1;
-- check all tables are WITHOUT OIDS (i.e. have not been altered as WITH OIDS after their tables group creation)
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE upper_inf(rel_time_range) AND rel_kind = 'r'
AND relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY rel_schema, rel_tblseq, 1;
-- with PG 11-, check all tables are WITHOUT OIDS (i.e. have not been altered as WITH OIDS after their tables group creation)
IF emaj._pg_version_num() < 120000 THEN
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE upper_inf(rel_time_range) AND rel_kind = 'r'
AND relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY rel_schema, rel_tblseq, 1;
END IF;
-- check the primary key structure of all tables belonging to rollbackable groups is unchanged
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the primary key of the table "' ||
Expand Down
74 changes: 39 additions & 35 deletions sql/emaj-devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1111,13 +1111,15 @@ $_check_conf_groups$
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relpersistence = 'u';
---- check no table is a WITH OIDS table (blocking rollbackable groups only)
RETURN QUERY
SELECT 21, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
format('in the group %s, the table %s.%s is declared WITH OIDS.', quote_ident(grpdef_group), quote_ident(grpdef_schema), quote_ident(grpdef_tblseq))
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relhasoids;
---- with PG11- check no table is a WITH OIDS table (blocking rollbackable groups only)
IF emaj._pg_version_num() < 120000 THEN
RETURN QUERY
SELECT 21, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
format('in the group %s, the table %s.%s is declared WITH OIDS.', quote_ident(grpdef_group), quote_ident(grpdef_schema), quote_ident(grpdef_tblseq))
FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace
WHERE grpdef_schema = nspname AND grpdef_tblseq = relname AND relnamespace = pg_namespace.oid
AND grpdef_group = ANY (v_groupNames) AND relkind = 'r' AND relhasoids;
END IF;
---- check every table has a primary key (blocking rollbackable groups only)
RETURN QUERY
SELECT 22, 2, grpdef_group, grpdef_schema, grpdef_tblseq, NULL::TEXT,
Expand Down Expand Up @@ -2740,21 +2742,23 @@ $_verify_groups$
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (8): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
-- for rollbackable groups, check no table has been altered as WITH OIDS after tables groups creation
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is declared WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND rel_group = ANY (v_groups) AND rel_kind = 'r' AND upper_inf(rel_time_range)
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY 1,2,3
LOOP
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (9): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
-- for rollbackable groups, with PG 11-, check no table has been altered as WITH OIDS after tables groups creation
IF emaj._pg_version_num() < 120000 THEN
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is declared WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND rel_group = ANY (v_groups) AND rel_kind = 'r' AND upper_inf(rel_time_range)
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY 1,2,3
LOOP
IF v_onErrorStop THEN RAISE EXCEPTION '_verify_groups (9): % %',r_object.msg,v_hint; END IF;
RETURN NEXT r_object;
END LOOP;
END IF;
-- check the primary key structure of all tables belonging to rollbackable groups is unchanged
FOR r_object IN
SELECT rel_schema, rel_tblseq, rel_group,
Expand Down Expand Up @@ -3313,9 +3317,7 @@ $_alter_plan$
AND rel_kind = 'r'
AND coalesce(rel_log_idx_tsp,'') <> coalesce(grpdef_log_idx_tsp,'')
-- exclude tables that will have been repaired in a previous step
---- AND (rel_schema, rel_tblseq) NOT IN (
---- SELECT altr_schema, altr_tblseq FROM emaj.emaj_alter_plan WHERE altr_time_id = v_timeId AND altr_step = 'REPAIR_TBL');
AND NOT EXISTS (-----(rel_schema, rel_tblseq) NOT IN (
AND NOT EXISTS (
SELECT 0 FROM emaj.emaj_alter_plan
WHERE altr_schema = rel_schema AND altr_tblseq = rel_tblseq
AND altr_time_id = v_timeId AND altr_step = 'REPAIR_TBL');
Expand Down Expand Up @@ -7295,16 +7297,18 @@ $_verify_all_groups$
AND group_name = rel_group AND group_is_rollbackable
AND relpersistence <> 'p'
ORDER BY rel_schema, rel_tblseq, 1;
-- check all tables are WITHOUT OIDS (i.e. have not been altered as WITH OIDS after their tables group creation)
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE upper_inf(rel_time_range) AND rel_kind = 'r'
AND relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY rel_schema, rel_tblseq, 1;
-- with PG 11-, check all tables are WITHOUT OIDS (i.e. have not been altered as WITH OIDS after their tables group creation)
IF emaj._pg_version_num() < 120000 THEN
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the table "' ||
rel_schema || '"."' || rel_tblseq || '" is WITH OIDS.' AS msg
FROM emaj.emaj_relation, pg_catalog.pg_class, pg_catalog.pg_namespace, emaj.emaj_group
WHERE upper_inf(rel_time_range) AND rel_kind = 'r'
AND relnamespace = pg_namespace.oid AND nspname = rel_schema AND relname = rel_tblseq
AND group_name = rel_group AND group_is_rollbackable
AND relhasoids
ORDER BY rel_schema, rel_tblseq, 1;
END IF;
-- check the primary key structure of all tables belonging to rollbackable groups is unchanged
RETURN QUERY
SELECT 'In rollbackable group "' || rel_group || '", the primary key of the table "' ||
Expand Down
6 changes: 2 additions & 4 deletions test/10/expected/misc.out
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ begin; --
(3 rows)

rollback;
-- detection of tables altered as WITH OIDS
-- detection of tables altered as WITH OIDS (PG12+ generates an error)
begin;
alter table myschema1.mytbl4 set with oids; -- table from a rollbackable group
alter table "phil's schema3"."myTbl2\" set with oids; -- table from an audit_only group
Expand Down Expand Up @@ -1779,7 +1779,6 @@ begin;
alter table myschema1.mytbl1 add column newcol int;
update emaj.emaj_relation set rel_kind = 'S' where rel_schema = 'myschema2' and rel_tblseq = 'mytbl1' and upper_inf(rel_time_range);
alter table myschema1.mytbl4 drop constraint mytbl4_pkey;
alter table myschema1.mytbl4 set with oids;
select * from emaj.emaj_verify_all();
emaj_verify_all
-----------------------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -1793,9 +1792,8 @@ begin;
In group "myGroup1", the log function "emaj_myschema1"."mytbl1_log_fnct" is not found.
In group "myGroup1", the log trigger "emaj_log_trg" on table "myschema1"."mytbl1" is not found.
In rollbackable group "myGroup1", the table "myschema1"."mytbl4" has no primary key any more.
In rollbackable group "myGroup1", the table "myschema1"."mytbl4" is WITH OIDS.
2 tables groups need to be altered to match their configuration definition or to be repaired
(12 rows)
(11 rows)

rollback;
--
Expand Down

0 comments on commit 5044a66

Please sign in to comment.