Skip to content

Commit

Permalink
Remove from _verify_all_groups() the check on the postgres version at…
Browse files Browse the repository at this point in the history
… group's creation time. The same check is already performed at the beginning of the extension upgrade script.
  • Loading branch information
beaud76 committed Feb 24, 2023
1 parent c920979 commit b1e4169
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 132 deletions.
437 changes: 437 additions & 0 deletions sql/emaj--4.1.0--devel.sql

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions sql/emaj--devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11405,14 +11405,6 @@ $_verify_all_groups$
--
-- Errors detection.
--
-- Check that the postgres version at groups creation time is compatible (i.e. >= 8.4).
RETURN QUERY
SELECT 'Error: The group "' || group_name || '" has been created with a non compatible postgresql version (' ||
group_pg_version || '). It must be dropped and recreated.' AS msg
FROM emaj.emaj_group
WHERE cast(to_number(substring(group_pg_version FROM E'^(\\d+)'),'99') * 100 +
to_number(substring(group_pg_version FROM E'^\\d+\\.(\\d+)'),'99') AS INTEGER) < 804
ORDER BY msg;
-- Check that all application schemas referenced in the emaj_relation table still exist.
RETURN QUERY
SELECT 'Error: The application schema "' || rel_schema || '" does not exist any more.' AS msg
Expand Down
8 changes: 0 additions & 8 deletions sql/emaj-devel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11412,14 +11412,6 @@ $_verify_all_groups$
--
-- Errors detection.
--
-- Check that the postgres version at groups creation time is compatible (i.e. >= 8.4).
RETURN QUERY
SELECT 'Error: The group "' || group_name || '" has been created with a non compatible postgresql version (' ||
group_pg_version || '). It must be dropped and recreated.' AS msg
FROM emaj.emaj_group
WHERE cast(to_number(substring(group_pg_version FROM E'^(\\d+)'),'99') * 100 +
to_number(substring(group_pg_version FROM E'^\\d+\\.(\\d+)'),'99') AS INTEGER) < 804
ORDER BY msg;
-- Check that all application schemas referenced in the emaj_relation table still exist.
RETURN QUERY
SELECT 'Error: The application schema "' || rel_schema || '" does not exist any more.' AS msg
Expand Down
8 changes: 4 additions & 4 deletions test/11/expected/check.out
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ select funcname, calls from pg_stat_user_functions
_start_groups | 53
_stop_groups | 67
_truncate_trigger_fnct | 16
_verify_all_groups | 48
_verify_all_schemas | 48
_verify_all_groups | 47
_verify_all_schemas | 47
emaj_assign_sequence | 6
emaj_assign_sequences | 7
emaj_assign_sequences | 13
Expand Down Expand Up @@ -255,14 +255,14 @@ select funcname, calls from pg_stat_user_functions
emaj_stop_groups | 10
emaj_unprotect_group | 7
emaj_unprotect_mark_group | 6
emaj_verify_all | 48
emaj_verify_all | 47
(168 rows)

-- count the total number of user-callable function calls (those who failed are not counted)
select sum(calls) from pg_stat_user_functions where funcname like E'emaj\\_%';
sum
-----
998
997
(1 row)

-----------------------------
Expand Down
18 changes: 3 additions & 15 deletions test/11/expected/verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ rollback;
--
-- tests on groups errors
--
-- detection of too old group
begin;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
(1 row)

rollback;
-- detection of a missing application schema
begin;
drop schema myschema1 cascade;
Expand Down Expand Up @@ -378,26 +368,24 @@ begin;
create table emaj.dummy_log (col1 int);
create function emaj.dummy_log_fnct () returns int language sql as $$ select 0 $$;
create function emaj.dummy_rlbk_fnct () returns int language sql as $$ select 0 $$;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
drop trigger emaj_log_trg on myschema1.mytbl1;
drop function emaj_myschema1.mytbl1_log_fnct() cascade;
drop table emaj_myschema1.mytbl1_log;
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;
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
msg
---------------------------------------------------------------------------------------------------------------
Error: In the schema "emaj", the table "emaj"."dummy_log" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_log_fnct" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_rlbk_fnct" is not linked to any created tables group.
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
Error: In the group "myGroup2", the sequence "myschema2"."mytbl1" does not exist any more.
Error: In the group "myGroup1", the log table "emaj_myschema1"."mytbl1_log" is not found.
Error: In the group "myGroup1", the log function "emaj_myschema1"."mytbl1_log_fnct" is not found.
Error: In the group "myGroup1", the log trigger "emaj_log_trg" on table "myschema1"."mytbl1" is not found.
Error: In the rollbackable group "myGroup1", the table "myschema1"."mytbl4" has no primary key any more.
(9 rows)
(8 rows)

rollback;
--
Expand Down
12 changes: 6 additions & 6 deletions test/12/expected/check.out
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ select funcname, calls from pg_stat_user_functions
_start_groups | 53
_stop_groups | 67
_truncate_trigger_fnct | 16
_verify_all_groups | 47
_verify_all_schemas | 47
_verify_all_groups | 46
_verify_all_schemas | 46
emaj_assign_sequence | 6
emaj_assign_sequences | 7
emaj_assign_sequences | 13
Expand Down Expand Up @@ -255,14 +255,14 @@ select funcname, calls from pg_stat_user_functions
emaj_stop_groups | 10
emaj_unprotect_group | 7
emaj_unprotect_mark_group | 6
emaj_verify_all | 47
emaj_verify_all | 46
(168 rows)

-- count the total number of user-callable function calls (those who failed are not counted)
select sum(calls) from pg_stat_user_functions where funcname like E'emaj\\_%';
sum
------
1000
sum
-----
999
(1 row)

-----------------------------
Expand Down
18 changes: 3 additions & 15 deletions test/12/expected/verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ rollback;
--
-- tests on groups errors
--
-- detection of too old group
begin;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
(1 row)

rollback;
-- detection of a missing application schema
begin;
drop schema myschema1 cascade;
Expand Down Expand Up @@ -380,26 +370,24 @@ begin;
create table emaj.dummy_log (col1 int);
create function emaj.dummy_log_fnct () returns int language sql as $$ select 0 $$;
create function emaj.dummy_rlbk_fnct () returns int language sql as $$ select 0 $$;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
drop trigger emaj_log_trg on myschema1.mytbl1;
drop function emaj_myschema1.mytbl1_log_fnct() cascade;
drop table emaj_myschema1.mytbl1_log;
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;
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
msg
---------------------------------------------------------------------------------------------------------------
Error: In the schema "emaj", the table "emaj"."dummy_log" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_log_fnct" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_rlbk_fnct" is not linked to any created tables group.
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
Error: In the group "myGroup2", the sequence "myschema2"."mytbl1" does not exist any more.
Error: In the group "myGroup1", the log table "emaj_myschema1"."mytbl1_log" is not found.
Error: In the group "myGroup1", the log function "emaj_myschema1"."mytbl1_log_fnct" is not found.
Error: In the group "myGroup1", the log trigger "emaj_log_trg" on table "myschema1"."mytbl1" is not found.
Error: In the rollbackable group "myGroup1", the table "myschema1"."mytbl4" has no primary key any more.
(9 rows)
(8 rows)

rollback;
--
Expand Down
12 changes: 6 additions & 6 deletions test/13/expected/check.out
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ select funcname, calls from pg_stat_user_functions
_start_groups | 53
_stop_groups | 67
_truncate_trigger_fnct | 16
_verify_all_groups | 47
_verify_all_schemas | 47
_verify_all_groups | 46
_verify_all_schemas | 46
emaj_assign_sequence | 6
emaj_assign_sequences | 7
emaj_assign_sequences | 13
Expand Down Expand Up @@ -255,14 +255,14 @@ select funcname, calls from pg_stat_user_functions
emaj_stop_groups | 10
emaj_unprotect_group | 7
emaj_unprotect_mark_group | 6
emaj_verify_all | 47
emaj_verify_all | 46
(168 rows)

-- count the total number of user-callable function calls (those who failed are not counted)
select sum(calls) from pg_stat_user_functions where funcname like E'emaj\\_%';
sum
------
1000
sum
-----
999
(1 row)

-----------------------------
Expand Down
18 changes: 3 additions & 15 deletions test/13/expected/verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ rollback;
--
-- tests on groups errors
--
-- detection of too old group
begin;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
(1 row)

rollback;
-- detection of a missing application schema
begin;
drop schema myschema1 cascade;
Expand Down Expand Up @@ -380,26 +370,24 @@ begin;
create table emaj.dummy_log (col1 int);
create function emaj.dummy_log_fnct () returns int language sql as $$ select 0 $$;
create function emaj.dummy_rlbk_fnct () returns int language sql as $$ select 0 $$;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
drop trigger emaj_log_trg on myschema1.mytbl1;
drop function emaj_myschema1.mytbl1_log_fnct() cascade;
drop table emaj_myschema1.mytbl1_log;
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;
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
msg
---------------------------------------------------------------------------------------------------------------
Error: In the schema "emaj", the table "emaj"."dummy_log" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_log_fnct" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_rlbk_fnct" is not linked to any created tables group.
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
Error: In the group "myGroup2", the sequence "myschema2"."mytbl1" does not exist any more.
Error: In the group "myGroup1", the log table "emaj_myschema1"."mytbl1_log" is not found.
Error: In the group "myGroup1", the log function "emaj_myschema1"."mytbl1_log_fnct" is not found.
Error: In the group "myGroup1", the log trigger "emaj_log_trg" on table "myschema1"."mytbl1" is not found.
Error: In the rollbackable group "myGroup1", the table "myschema1"."mytbl4" has no primary key any more.
(9 rows)
(8 rows)

rollback;
--
Expand Down
12 changes: 6 additions & 6 deletions test/14/expected/check.out
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ select funcname, calls from pg_stat_user_functions
_start_groups | 53
_stop_groups | 67
_truncate_trigger_fnct | 16
_verify_all_groups | 47
_verify_all_schemas | 47
_verify_all_groups | 46
_verify_all_schemas | 46
emaj_assign_sequence | 6
emaj_assign_sequences | 7
emaj_assign_sequences | 13
Expand Down Expand Up @@ -255,14 +255,14 @@ select funcname, calls from pg_stat_user_functions
emaj_stop_groups | 10
emaj_unprotect_group | 7
emaj_unprotect_mark_group | 6
emaj_verify_all | 47
emaj_verify_all | 46
(168 rows)

-- count the total number of user-callable function calls (those who failed are not counted)
select sum(calls) from pg_stat_user_functions where funcname like E'emaj\\_%';
sum
------
1000
sum
-----
999
(1 row)

-----------------------------
Expand Down
10 changes: 1 addition & 9 deletions test/14/expected/install_psql.out
Original file line number Diff line number Diff line change
Expand Up @@ -11212,14 +11212,6 @@ $_verify_all_groups$
--
-- Errors detection.
--
-- Check that the postgres version at groups creation time is compatible (i.e. >= 8.4).
RETURN QUERY
SELECT 'Error: The group "' || group_name || '" has been created with a non compatible postgresql version (' ||
group_pg_version || '). It must be dropped and recreated.' AS msg
FROM emaj.emaj_group
WHERE cast(to_number(substring(group_pg_version FROM E'^(\\d+)'),'99') * 100 +
to_number(substring(group_pg_version FROM E'^\\d+\\.(\\d+)'),'99') AS INTEGER) < 804
ORDER BY msg;
-- Check that all application schemas referenced in the emaj_relation table still exist.
RETURN QUERY
SELECT 'Error: The application schema "' || rel_schema || '" does not exist any more.' AS msg
Expand Down Expand Up @@ -12317,7 +12309,7 @@ $do$
RETURN;
END;
$do$;
psql:sql/emaj-devel.sql:12549: NOTICE: E-Maj installation: E-Maj successfully installed.
psql:sql/emaj-devel.sql:12541: NOTICE: E-Maj installation: E-Maj successfully installed.
COMMIT;
-----------------------------
-- check installation
Expand Down
18 changes: 3 additions & 15 deletions test/14/expected/verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ rollback;
--
-- tests on groups errors
--
-- detection of too old group
begin;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
(1 row)

rollback;
-- detection of a missing application schema
begin;
drop schema myschema1 cascade;
Expand Down Expand Up @@ -380,26 +370,24 @@ begin;
create table emaj.dummy_log (col1 int);
create function emaj.dummy_log_fnct () returns int language sql as $$ select 0 $$;
create function emaj.dummy_rlbk_fnct () returns int language sql as $$ select 0 $$;
update emaj.emaj_group set group_pg_version = '8.0.0' where group_name = 'myGroup1';
drop trigger emaj_log_trg on myschema1.mytbl1;
drop function emaj_myschema1.mytbl1_log_fnct() cascade;
drop table emaj_myschema1.mytbl1_log;
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;
select * from emaj.emaj_verify_all() t(msg) where msg like 'Error%';
msg
----------------------------------------------------------------------------------------------------------------------------------
msg
---------------------------------------------------------------------------------------------------------------
Error: In the schema "emaj", the table "emaj"."dummy_log" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_log_fnct" is not linked to any created tables group.
Error: In the schema "emaj", the function "emaj"."dummy_rlbk_fnct" is not linked to any created tables group.
Error: The group "myGroup1" has been created with a non compatible postgresql version (8.0.0). It must be dropped and recreated.
Error: In the group "myGroup2", the sequence "myschema2"."mytbl1" does not exist any more.
Error: In the group "myGroup1", the log table "emaj_myschema1"."mytbl1_log" is not found.
Error: In the group "myGroup1", the log function "emaj_myschema1"."mytbl1_log_fnct" is not found.
Error: In the group "myGroup1", the log trigger "emaj_log_trg" on table "myschema1"."mytbl1" is not found.
Error: In the rollbackable group "myGroup1", the table "myschema1"."mytbl4" has no primary key any more.
(9 rows)
(8 rows)

rollback;
--
Expand Down

0 comments on commit b1e4169

Please sign in to comment.