Skip to content

Commit

Permalink
Refactor the code that processes the secondary schemas drop. With the…
Browse files Browse the repository at this point in the history
… latest added features, the logic of the existing code was too ugly. So add an internal table, named emaj_schema, that keeps the list of all existing secondary schemas. Also add some tests in the alter.sql scenario.
  • Loading branch information
beaud76 committed Nov 26, 2017
1 parent 0c005e6 commit 7f8216e
Show file tree
Hide file tree
Showing 82 changed files with 2,910 additions and 1,662 deletions.
6 changes: 3 additions & 3 deletions docs/en/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ A **log table** has the same structure as its corresponding application table. H

To let E-Maj work, some **other technical objects** are also created at extension installation time:

* 13 tables,
* 5 composite and 2 enum types,
* 15 tables,
* 5 composite and 3 enum types,
* 1 view,
* more than 90 functions, about half of them being directly callable by users,
* more than 100 functions, about half of them being directly callable by users,
* 1 sequence named *emaj_global_seq* used to assign to every update recorded in any log table of the database a unique identifier with an increasing value over time,
* 1 specific schema, named emaj, that contains all these relational objects,
* 2 roles acting as groups (NOLOGIN): *emaj_adm* to manage E-Maj components, and *emaj_viewer* to only look at E-Maj components
Expand Down
6 changes: 3 additions & 3 deletions docs/fr/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Une **table de log** a la même structure que la table applicative correspondant

Pour le bon fonctionnement d'E-Maj, un certain nombre d'**objets techniques** sont également créés à l'installation de cette extension :

* 13 tables,
* 5 types composites et 2 énumérations,
* 15 tables,
* 5 types composites et 3 énumérations,
* 1 vue,
* plus de 90 fonctions, dont environ la moitié directement appelables par les utilisateurs,
* plus de 100 fonctions, dont environ la moitié directement appelables par les utilisateurs,
* 1 séquence, nommée *emaj_global_seq*, permettant d'associer à chaque mise à jour enregistrée dans une table de log quelconque de la base de données un identifiant unique de valeur croissante au fil du temps,
* 1 schéma spécifique, nommé *emaj*, qui contient tous ces objets,
* 2 rôles de type groupe (sans possibilité de connexion) : *emaj_adm* pour administrer les composants E-Maj, et *emaj_viewer* pour uniquement consulter les composants E-Maj,
Expand Down
217 changes: 180 additions & 37 deletions sql/emaj--2.1.0--next_version.sql

Large diffs are not rendered by default.

143 changes: 67 additions & 76 deletions sql/emaj--next_version.sql

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions test/10/expected/adm1.out
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ select count(*) from emaj.emaj_group;
3
(1 row)

select count(*) from emaj.emaj_schema;
count
-------
3
(1 row)

select count(*) from emaj.emaj_relation;
count
-------
Expand Down Expand Up @@ -153,6 +159,12 @@ select * from emaj.emaj_group;
------------+------------------+-------------------------+----------------+-------------------+-----------------------+------------------------+--------------------------+------------------+---------------
(0 rows)

select sch_name from emaj.emaj_schema;
sch_name
----------
emaj
(1 row)

select * from emaj.emaj_relation;
rel_schema | rel_tblseq | rel_time_range | rel_group | rel_kind | rel_priority | rel_log_schema | rel_log_table | rel_log_dat_tsp | rel_log_index | rel_log_idx_tsp | rel_log_sequence | rel_log_function | rel_sql_columns | rel_sql_pk_columns | rel_sql_pk_eq_conditions
------------+------------+----------------+-----------+----------+--------------+----------------+---------------+-----------------+---------------+-----------------+------------------+------------------+-----------------+--------------------+--------------------------
Expand Down Expand Up @@ -2285,12 +2297,12 @@ ERROR: emaj_create_group: The group "dummyGroup" is unknown in the emaj_group_d
CONTEXT: PL/pgSQL function emaj.emaj_create_group(text,boolean,boolean) line 29 at RAISE
select emaj.emaj_drop_group('dummyGroup');
ERROR: _drop_group: The group "dummyGroup" does not exist.
CONTEXT: PL/pgSQL function emaj._drop_group(text,boolean) line 18 at RAISE
CONTEXT: PL/pgSQL function emaj._drop_group(text,boolean) line 17 at RAISE
SQL statement "SELECT emaj._drop_group(v_groupName, FALSE)"
PL/pgSQL function emaj.emaj_drop_group(text) line 12 at SQL statement
select emaj.emaj_force_drop_group('dummyGroup');
ERROR: _drop_group: The group "dummyGroup" does not exist.
CONTEXT: PL/pgSQL function emaj._drop_group(text,boolean) line 18 at RAISE
CONTEXT: PL/pgSQL function emaj._drop_group(text,boolean) line 17 at RAISE
SQL statement "SELECT emaj._drop_group(v_groupName, TRUE)"
PL/pgSQL function emaj.emaj_force_drop_group(text) line 17 at SQL statement
select emaj.emaj_get_previous_mark_group('dummyGroup', '2010-01-01');
Expand Down
18 changes: 9 additions & 9 deletions test/10/expected/adm2.out
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ WARNING: _check_fk_groups: The table "myschema2.mytbl6" is referenced by the fo
ERROR: _check_new_mark: The group "myGroup1" already contains a mark named "Multi-1".
CONTEXT: PL/pgSQL function emaj._check_new_mark(text,text[]) line 30 at RAISE
SQL statement "SELECT emaj._check_new_mark(v_mark, v_groupNames)"
PL/pgSQL function emaj._start_groups(text[],text,boolean,boolean) line 45 at SQL statement
PL/pgSQL function emaj._start_groups(text[],text,boolean,boolean) line 50 at SQL statement
SQL statement "SELECT emaj._start_groups(emaj._check_names_array(v_groupNames,'group'), v_mark, true, v_resetLog)"
PL/pgSQL function emaj.emaj_start_groups(text[],text,boolean) line 16 at SQL statement
-- really start both groups
Expand Down Expand Up @@ -1991,14 +1991,14 @@ select rlbk_id, rlbk_groups, rlbk_mark, rlbk_time_id, rlbk_is_logged, rlbk_is_al
22 | {myGroup1} | Conso_M2 | 3057 | t | | 1 | 5 | 2 | 3 | COMMITTED | 3447 | t | [ts] | {"Notice: 3 / 5 tables effectively processed.","Notice: 2 sequences processed."}
23 | {myGroup1} | Conso_M1 | 3059 | f | | 1 | 5 | 2 | 2 | COMMITTED | 3475 | t | [ts] | {"Notice: 2 / 5 tables effectively processed.","Notice: 2 sequences processed."}
24 | {myGroup4} | myGroup4_start | 3060 | f | | 1 | 5 | 0 | 0 | ABORTED | 3492 | t | [ts] | {"Notice: 0 / 5 tables effectively processed."}
6000 | {myGroup1} | Mk2b | 6058 | t | t | 1 | 5 | 1 | 0 | ABORTED | 6256 | t | [ts] | {"Notice: 0 / 5 tables effectively processed.","Notice: 1 sequences processed.","Warning: The sequence myschema1.\"myTbl3_col31_seq\" has been left unchanged (not in group anymore)"}
6001 | {myGroup1} | Mk2b | 6060 | f | t | 1 | 5 | 1 | 0 | ABORTED | 6270 | t | [ts] | {"Notice: 0 / 5 tables effectively processed.","Notice: 1 sequences processed."}
6004 | {myGroup1,myGroup2} | Mk3 | 6072 | f | f | 1 | 11 | 4 | 0 | COMMITTED | 6374 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6005 | {myGroup1,myGroup2} | Mk2 | 6073 | t | t | 1 | 11 | 4 | 1 | COMMITTED | 6386 | t | [ts] | {"Notice: 1 / 11 tables effectively processed.","Notice: 4 sequences processed.","Warning: Tables group change not rolled back: E-Maj priority for myschema1.mytbl1","Warning: Tables group change not rolled back: E-Maj log schema for myschema2.\"myTbl3\"","Warning: Tables group change not rolled back: E-Maj names prefix for myschema1.\"myTbl3\"","Warning: Tables group change not rolled back: log data tablespace for myschema1.mytbl2b","Warning: Tables group change not rolled back: log index tablespace for myschema2.mytbl6"}
6006 | {myGroup1,myGroup2} | Mk2 | 6075 | f | f | 1 | 11 | 4 | 1 | COMMITTED | 6410 | t | [ts] | {"Notice: 1 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6007 | {myGroup1,myGroup2} | Mk1 | 6076 | f | t | 1 | 11 | 4 | 0 | COMMITTED | 6435 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed.","Warning: Tables group change not rolled back: E-Maj priority for myschema1.mytbl1","Warning: Tables group change not rolled back: E-Maj log schema for myschema2.\"myTbl3\"","Warning: Tables group change not rolled back: E-Maj names prefix for myschema1.\"myTbl3\"","Warning: Tables group change not rolled back: log data tablespace for myschema1.mytbl2b","Warning: Tables group change not rolled back: log index tablespace for myschema2.mytbl6"}
6008 | {myGroup1,myGroup2} | Mk1 | 6077 | t | f | 1 | 11 | 4 | 0 | ABORTED | 6457 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6009 | {myGroup1,myGroup2} | Mk1 | 6079 | f | f | 1 | 11 | 4 | 0 | ABORTED | 6476 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6000 | {myGroup1} | Mk2b | 6059 | t | t | 1 | 5 | 1 | 0 | ABORTED | 6260 | t | [ts] | {"Notice: 0 / 5 tables effectively processed.","Notice: 1 sequences processed.","Warning: The sequence myschema1.\"myTbl3_col31_seq\" has been left unchanged (not in group anymore)"}
6001 | {myGroup1} | Mk2b | 6061 | f | t | 1 | 5 | 1 | 0 | ABORTED | 6274 | t | [ts] | {"Notice: 0 / 5 tables effectively processed.","Notice: 1 sequences processed."}
6004 | {myGroup1,myGroup2} | Mk3 | 6075 | f | f | 1 | 11 | 4 | 0 | COMMITTED | 6391 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6005 | {myGroup1,myGroup2} | Mk2 | 6076 | t | t | 1 | 11 | 4 | 1 | COMMITTED | 6403 | t | [ts] | {"Notice: 1 / 11 tables effectively processed.","Notice: 4 sequences processed.","Warning: Tables group change not rolled back: E-Maj priority for myschema1.mytbl1","Warning: Tables group change not rolled back: E-Maj log schema for myschema2.\"myTbl3\"","Warning: Tables group change not rolled back: E-Maj names prefix for myschema1.\"myTbl3\"","Warning: Tables group change not rolled back: log data tablespace for myschema1.mytbl2b","Warning: Tables group change not rolled back: log index tablespace for myschema2.mytbl6"}
6006 | {myGroup1,myGroup2} | Mk2 | 6078 | f | f | 1 | 11 | 4 | 1 | COMMITTED | 6427 | t | [ts] | {"Notice: 1 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6007 | {myGroup1,myGroup2} | Mk1 | 6079 | f | t | 1 | 11 | 4 | 0 | COMMITTED | 6452 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed.","Warning: Tables group change not rolled back: E-Maj priority for myschema1.mytbl1","Warning: Tables group change not rolled back: E-Maj log schema for myschema2.\"myTbl3\"","Warning: Tables group change not rolled back: E-Maj names prefix for myschema1.\"myTbl3\"","Warning: Tables group change not rolled back: log data tablespace for myschema1.mytbl2b","Warning: Tables group change not rolled back: log index tablespace for myschema2.mytbl6"}
6008 | {myGroup1,myGroup2} | Mk1 | 6080 | t | f | 1 | 11 | 4 | 0 | ABORTED | 6474 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
6009 | {myGroup1,myGroup2} | Mk1 | 6082 | f | f | 1 | 11 | 4 | 0 | ABORTED | 6493 | t | [ts] | {"Notice: 0 / 11 tables effectively processed.","Notice: 4 sequences processed."}
10000 | {myGroup2} | M2 | 10009 | t | f | 1 | 6 | 2 | 3 | COMMITTED | 10057 | f | [ts] | {"Notice: 3 / 6 tables effectively processed.","Notice: 2 sequences processed."}
10001 | {myGroup2} | M3 | 10011 | t | f | 1 | 6 | 2 | 3 | COMMITTED | 10076 | f | [ts] | {"Notice: 3 / 6 tables effectively processed.","Notice: 2 sequences processed."}
10002 | {myGroup1} | M2 | 10013 | f | f | 1 | 5 | 2 | 2 | COMMITTED | 10095 | t | [ts] | {"Notice: 2 / 5 tables effectively processed.","Notice: 2 sequences processed."}
Expand Down

0 comments on commit 7f8216e

Please sign in to comment.