diff --git a/CHANGES b/CHANGES index 266d58df..8c3a7781 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Enhancements: it. - at create_group() or alter_group() time, a check is added to be sure no temporary tables and no unlogged tables are recorded into tables groups. + Some other tests on tables groups content have been enforced too. - the default value of the 'history_retention' parameter is now 1 year (previously 1 month). - a new emaj_gen_sql_groups() function generates a sql script replaying diff --git a/sql/emaj--next_version.sql b/sql/emaj--next_version.sql index 36aaac6c..5fa09a98 100644 --- a/sql/emaj--next_version.sql +++ b/sql/emaj--next_version.sql @@ -665,33 +665,75 @@ $_check_names_array$ END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS @@ -1865,7 +1907,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -1878,11 +1919,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -1894,20 +1932,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -1930,23 +1956,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -1959,7 +1986,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2137,7 +2164,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2165,21 +2191,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2302,27 +2315,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2335,7 +2348,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6133,7 +6146,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6225,7 +6238,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6314,7 +6327,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/sql/emaj.sql b/sql/emaj.sql index 5bcf4965..995d083f 100644 --- a/sql/emaj.sql +++ b/sql/emaj.sql @@ -741,33 +741,75 @@ $_check_names_array$ END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS @@ -1941,7 +1983,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -1954,11 +1995,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -1970,20 +2008,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2006,23 +2032,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2035,7 +2062,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2213,7 +2240,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2241,21 +2267,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2378,27 +2391,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2411,7 +2424,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6209,7 +6222,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6301,7 +6314,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6390,7 +6403,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/sql/emaj_src.sql b/sql/emaj_src.sql index 849040e7..1586b731 100644 --- a/sql/emaj_src.sql +++ b/sql/emaj_src.sql @@ -764,33 +764,75 @@ $_check_names_array$ END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS @@ -1964,7 +2006,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -1977,11 +2018,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -1993,20 +2031,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2029,23 +2055,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2058,7 +2085,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2236,7 +2263,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2264,21 +2290,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2401,27 +2414,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2434,7 +2447,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6232,7 +6245,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6324,7 +6337,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6413,7 +6426,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/83/expected/adm1.out b/test/83/expected/adm1.out index c7c72e88..f64efd9c 100644 --- a/test/83/expected/adm1.out +++ b/test/83/expected/adm1.out @@ -26,7 +26,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; @@ -212,65 +212,65 @@ NOTICE: table "myschema1_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema1_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_log_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_log_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_log_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_log_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2b_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emajb.myschema1_mytbl2b_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_log_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_log_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -288,68 +288,68 @@ NOTICE: table "myschema2_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_log_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_log_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema2_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_log_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_log_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl5_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl5_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_log_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_log_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl6_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl6_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_log_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_log_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 diff --git a/test/83/expected/adm2.out b/test/83/expected/adm2.out index 080658c0..0c666719 100644 --- a/test/83/expected/adm2.out +++ b/test/83/expected/adm2.out @@ -529,22 +529,22 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 4 @@ -559,12 +559,12 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -592,12 +592,12 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -624,28 +624,28 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl2_col21_fkey, from table phil's schema3.myTbl2\, references phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table phil's schema3.phil's tbl1 is referenced by foreign key mytbl4_col44_fkey from table phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 4 diff --git a/test/83/expected/createDrop.out b/test/83/expected/createDrop.out index a37fc181..440173eb 100644 --- a/test/83/expected/createDrop.out +++ b/test/83/expected/createDrop.out @@ -30,7 +30,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblm'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -38,37 +40,22 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- -- invalid group names select emaj.emaj_create_group(NULL); -ERROR: emaj_create_group: group name can't be NULL. +ERROR: emaj_create_group: group name can't be NULL or empty. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(''); -ERROR: emaj_create_group: group name must at least contain 1 character. -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(NULL,false); -ERROR: emaj_create_group: group name can't be NULL. select emaj.emaj_create_group('',false); -ERROR: emaj_create_group: group name must at least contain 1 character. +ERROR: emaj_create_group: group name can't be NULL or empty. -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('unknownGroup',false); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp1',false); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (dummySchema.mytbl4, myschema1.dummyTable). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp2',false); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -90,15 +77,16 @@ rollback; begin; insert into emaj.emaj_group_def values ('myGroup5','myschema5','myunloggedtbl'); select emaj.emaj_create_group('myGroup5'); -ERROR: _check_class: table or sequence myunloggedtbl doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (myschema5.myunloggedtbl). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- table without pkey for a rollbackable group select emaj.emaj_create_group('phil''s group#3",',true); ERROR: _create_tbl: table myTbl2\ has no PRIMARY KEY. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM -- sequence with a log schema suffix defined in the emaj_group_def table begin; update emaj.emaj_group_def set grpdef_log_schema_suffix = 'something' where grpdef_group = 'myGroup1' and grpdef_schema = 'myschema1' and grpdef_tblseq = 'myTbl3_col31_seq'; @@ -121,7 +109,7 @@ ERROR: tablespace "dummyTablespace" does not exist CONTEXT: SQL statement "CREATE TABLE emaj.myschema1_mytbl1_log ( LIKE myschema1.mytbl1) TABLESPACE "dummyTablespace"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- already existing secondary schema @@ -130,14 +118,14 @@ begin; select emaj.emaj_create_group('myGroup1'); ERROR: _create_log_schema: schema emajb should not exist. Drop it manually, or modify emaj_group_def table's content. CONTEXT: SQL statement "SELECT emaj._create_log_schema( $1 )" -PL/pgSQL function "emaj_create_group" line 68 at PERFORM +PL/pgSQL function "emaj_create_group" line 52 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- should be OK select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -150,10 +138,10 @@ alter table myschema2.myTbl8 add foreign key (col81) references myschema2.myTbl6 select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -166,7 +154,7 @@ begin; select emaj.emaj_create_group('phil''s group#3",',false); WARNING: _create_seq: Sequence phil's schema3.myTbl2\_col21_seq is linked to table phil's schema3.myTbl2\ but this table belong to another tables group (dummyGrp3). CONTEXT: SQL statement "SELECT emaj._create_seq( $1 , $2 , $3 )" -PL/pgSQL function "emaj_create_group" line 103 at PERFORM +PL/pgSQL function "emaj_create_group" line 88 at PERFORM emaj_create_group ------------------- 3 @@ -183,17 +171,24 @@ select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); WARNING: _create_tbl: table myschema4.mytblm has triggers (mytblm_insert_trigger). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- 3 (1 row) +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); +ERROR: _check_group_content: one or several tables or sequences belong to an E-Maj schema (emajC.myschema1_myTbl3_log, emaj.emaj_param). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3'); -ERROR: emaj_create_group: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN +ERROR: _check_group_content: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM +PL/pgSQL function "emaj_create_group" line 6 at RETURN -- already created select emaj.emaj_create_group('myGroup2'); ERROR: emaj_create_group: group myGroup2 is already created. @@ -394,7 +389,7 @@ PL/pgSQL function "emaj_force_drop_group" line 16 at SQL statement select emaj.emaj_create_group('myGroup1',false); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 6 @@ -415,10 +410,10 @@ select emaj.emaj_force_drop_group('myGroup1'); select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -442,7 +437,7 @@ ERROR: emaj_alter_group: group unkownGroup has not been created. select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -468,11 +463,11 @@ begin; select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -481,7 +476,9 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN insert into emaj.emaj_group_def values ('myGroup1','myschema2','mytbl1'); select emaj.emaj_alter_group('myGroup1'); -ERROR: emaj_alter_group: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +ERROR: _check_group_content: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_alter_group" line 47 at PERFORM rollback; -- the group is now empty begin; @@ -541,10 +538,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 4 @@ -569,10 +566,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 3 @@ -680,7 +677,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 @@ -690,7 +687,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 diff --git a/test/83/expected/instPsql.out b/test/83/expected/instPsql.out index 06569985..3bbc0d38 100644 --- a/test/83/expected/instPsql.out +++ b/test/83/expected/instPsql.out @@ -903,33 +903,75 @@ $_check_names_array$ RETURN v_outputNames; END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS $_check_new_mark$ @@ -2082,7 +2124,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2095,11 +2136,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -2111,20 +2149,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2147,23 +2173,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2176,7 +2203,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2349,7 +2376,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2377,21 +2403,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2514,27 +2527,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2547,7 +2560,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6275,7 +6288,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6366,7 +6379,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6453,7 +6466,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/83/expected/misc.out b/test/83/expected/misc.out index fdd98b56..2062d151 100644 --- a/test/83/expected/misc.out +++ b/test/83/expected/misc.out @@ -1342,11 +1342,11 @@ PL/pgSQL function "emaj_rollback_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1358,10 +1358,10 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 8 @@ -1398,11 +1398,11 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1441,16 +1441,16 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 @@ -1479,10 +1479,10 @@ begin; select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 diff --git a/test/83/expected/startStop.out b/test/83/expected/startStop.out index 94db677a..49e28dca 100644 --- a/test/83/expected/startStop.out +++ b/test/83/expected/startStop.out @@ -6,7 +6,7 @@ SET client_min_messages TO WARNING; select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -16,11 +16,11 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- diff --git a/test/83/expected/viewer.out b/test/83/expected/viewer.out index 8849082f..cb3c5960 100644 --- a/test/83/expected/viewer.out +++ b/test/83/expected/viewer.out @@ -25,7 +25,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; diff --git a/test/84/expected/adm1.out b/test/84/expected/adm1.out index e37cf841..a9ddb7d2 100644 --- a/test/84/expected/adm1.out +++ b/test/84/expected/adm1.out @@ -26,7 +26,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; @@ -212,95 +212,95 @@ NOTICE: table "myschema1_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema1_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_log_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_trunc_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_log_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_trunc_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_log_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_trunc_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_log_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_trunc_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2b_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emajb.myschema1_mytbl2b_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_log_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_log_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_trunc_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_trunc_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -318,98 +318,98 @@ NOTICE: table "myschema2_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_log_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_trunc_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_log_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_trunc_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema2_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_log_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_trunc_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_log_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_trunc_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl5_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl5_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_log_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_log_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_trunc_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_trunc_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl6_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl6_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_log_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_log_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_trunc_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_trunc_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 diff --git a/test/84/expected/adm2.out b/test/84/expected/adm2.out index c9c9ab54..720cce99 100644 --- a/test/84/expected/adm2.out +++ b/test/84/expected/adm2.out @@ -529,32 +529,32 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 4 @@ -569,17 +569,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -607,17 +607,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -644,38 +644,38 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl2_col21_fkey, from table phil's schema3.myTbl2\, references phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table phil's schema3.phil's tbl1 is referenced by foreign key mytbl4_col44_fkey from table phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 4 diff --git a/test/84/expected/createDrop.out b/test/84/expected/createDrop.out index e095225c..421568b9 100644 --- a/test/84/expected/createDrop.out +++ b/test/84/expected/createDrop.out @@ -30,7 +30,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblm'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -38,37 +40,22 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- -- invalid group names select emaj.emaj_create_group(NULL); -ERROR: emaj_create_group: group name can't be NULL. +ERROR: emaj_create_group: group name can't be NULL or empty. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(''); -ERROR: emaj_create_group: group name must at least contain 1 character. -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(NULL,false); -ERROR: emaj_create_group: group name can't be NULL. select emaj.emaj_create_group('',false); -ERROR: emaj_create_group: group name must at least contain 1 character. +ERROR: emaj_create_group: group name can't be NULL or empty. -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('unknownGroup',false); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp1',false); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (dummySchema.mytbl4, myschema1.dummyTable). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp2',false); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -82,22 +69,23 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table mytemptbl is a temporary table. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- group with an unlogged table begin; insert into emaj.emaj_group_def values ('myGroup5','myschema5','myunloggedtbl'); select emaj.emaj_create_group('myGroup5'); -ERROR: _check_class: table or sequence myunloggedtbl doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (myschema5.myunloggedtbl). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- table without pkey for a rollbackable group select emaj.emaj_create_group('phil''s group#3",',true); ERROR: _create_tbl: table myTbl2\ has no PRIMARY KEY. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM -- sequence with a log schema suffix defined in the emaj_group_def table begin; update emaj.emaj_group_def set grpdef_log_schema_suffix = 'something' where grpdef_group = 'myGroup1' and grpdef_schema = 'myschema1' and grpdef_tblseq = 'myTbl3_col31_seq'; @@ -120,7 +108,7 @@ ERROR: tablespace "dummyTablespace" does not exist CONTEXT: SQL statement "CREATE TABLE emaj.myschema1_mytbl1_log ( LIKE myschema1.mytbl1) TABLESPACE "dummyTablespace"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- already existing secondary schema @@ -129,14 +117,14 @@ begin; select emaj.emaj_create_group('myGroup1'); ERROR: _create_log_schema: schema emajb should not exist. Drop it manually, or modify emaj_group_def table's content. CONTEXT: SQL statement "SELECT emaj._create_log_schema( $1 )" -PL/pgSQL function "emaj_create_group" line 68 at PERFORM +PL/pgSQL function "emaj_create_group" line 52 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- should be OK select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -149,10 +137,10 @@ alter table myschema2.myTbl8 add foreign key (col81) references myschema2.myTbl6 select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -165,7 +153,7 @@ begin; select emaj.emaj_create_group('phil''s group#3",',false); WARNING: _create_seq: Sequence phil's schema3.myTbl2\_col21_seq is linked to table phil's schema3.myTbl2\ but this table belong to another tables group (dummyGrp3). CONTEXT: SQL statement "SELECT emaj._create_seq( $1 , $2 , $3 )" -PL/pgSQL function "emaj_create_group" line 103 at PERFORM +PL/pgSQL function "emaj_create_group" line 88 at PERFORM emaj_create_group ------------------- 3 @@ -182,17 +170,24 @@ select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); WARNING: _create_tbl: table myschema4.mytblm has triggers (mytblm_insert_trigger). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- 3 (1 row) +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); +ERROR: _check_group_content: one or several tables or sequences belong to an E-Maj schema (emajC.myschema1_myTbl3_log, emaj.emaj_param). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3'); -ERROR: emaj_create_group: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN +ERROR: _check_group_content: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM +PL/pgSQL function "emaj_create_group" line 6 at RETURN -- already created select emaj.emaj_create_group('myGroup2'); ERROR: emaj_create_group: group myGroup2 is already created. @@ -393,7 +388,7 @@ PL/pgSQL function "emaj_force_drop_group" line 16 at SQL statement select emaj.emaj_create_group('myGroup1',false); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 6 @@ -414,10 +409,10 @@ select emaj.emaj_force_drop_group('myGroup1'); select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -441,7 +436,7 @@ ERROR: emaj_alter_group: group unkownGroup has not been created. select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -467,11 +462,11 @@ begin; select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -480,7 +475,9 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN insert into emaj.emaj_group_def values ('myGroup1','myschema2','mytbl1'); select emaj.emaj_alter_group('myGroup1'); -ERROR: emaj_alter_group: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +ERROR: _check_group_content: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content( $1 )" +PL/pgSQL function "emaj_alter_group" line 47 at PERFORM rollback; -- the group is now empty begin; @@ -540,10 +537,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 4 @@ -568,10 +565,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 3 @@ -680,7 +677,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 @@ -690,7 +687,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 diff --git a/test/84/expected/instPsql.out b/test/84/expected/instPsql.out index a660953f..3d1d1d3a 100644 --- a/test/84/expected/instPsql.out +++ b/test/84/expected/instPsql.out @@ -903,33 +903,75 @@ $_check_names_array$ RETURN v_outputNames; END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS $_check_new_mark$ @@ -2082,7 +2124,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2095,11 +2136,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -2111,20 +2149,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2147,23 +2173,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2176,7 +2203,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2349,7 +2376,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2377,21 +2403,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2514,27 +2527,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2547,7 +2560,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6275,7 +6288,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6366,7 +6379,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6453,7 +6466,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/84/expected/misc.out b/test/84/expected/misc.out index c5cc6400..99a41e88 100644 --- a/test/84/expected/misc.out +++ b/test/84/expected/misc.out @@ -1342,11 +1342,11 @@ PL/pgSQL function "emaj_rollback_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1358,10 +1358,10 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 8 @@ -1401,11 +1401,11 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1444,16 +1444,16 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 @@ -1482,10 +1482,10 @@ begin; select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[ $1 ])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 diff --git a/test/84/expected/startStop.out b/test/84/expected/startStop.out index 29655b07..3ad869ff 100644 --- a/test/84/expected/startStop.out +++ b/test/84/expected/startStop.out @@ -6,7 +6,7 @@ SET client_min_messages TO WARNING; select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl( $1 , $2 , $3 , coalesce( $4 , $5 ), coalesce( $6 , $5 ), $7 )" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -16,11 +16,11 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[ $1 ])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- diff --git a/test/84/expected/viewer.out b/test/84/expected/viewer.out index c9f10eb5..bd77ee32 100644 --- a/test/84/expected/viewer.out +++ b/test/84/expected/viewer.out @@ -25,7 +25,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; diff --git a/test/90/expected/adm1.out b/test/90/expected/adm1.out index 53ec47e1..7178ec62 100644 --- a/test/90/expected/adm1.out +++ b/test/90/expected/adm1.out @@ -26,7 +26,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; @@ -212,95 +212,95 @@ NOTICE: table "myschema1_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema1_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_log_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_trunc_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_log_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_trunc_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_log_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_trunc_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_log_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_trunc_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: table "myschema1_mytbl2b_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emajb.myschema1_mytbl2b_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_log_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_log_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_trunc_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_trunc_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -318,98 +318,98 @@ NOTICE: table "myschema2_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl1_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_log_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_trunc_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl2_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_log_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_trunc_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema2_myTbl3_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_log_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_trunc_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl4_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_log_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_trunc_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl5_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl5_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_log_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_log_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_trunc_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_trunc_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "myschema2_mytbl6_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl6_log" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_log_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_log_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_trunc_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_trunc_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 diff --git a/test/90/expected/adm2.out b/test/90/expected/adm2.out index aa9dfffa..dcd9055c 100644 --- a/test/90/expected/adm2.out +++ b/test/90/expected/adm2.out @@ -529,32 +529,32 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 4 @@ -569,17 +569,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -607,17 +607,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 4 @@ -644,38 +644,38 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 104 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 163 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 171 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl2_col21_fkey, from table phil's schema3.myTbl2\, references phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table phil's schema3.phil's tbl1 is referenced by foreign key mytbl4_col44_fkey from table phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 4 diff --git a/test/90/expected/createDrop.out b/test/90/expected/createDrop.out index a555101e..bfdccf79 100644 --- a/test/90/expected/createDrop.out +++ b/test/90/expected/createDrop.out @@ -30,7 +30,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblm'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -38,37 +40,22 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- -- invalid group names select emaj.emaj_create_group(NULL); -ERROR: emaj_create_group: group name can't be NULL. +ERROR: emaj_create_group: group name can't be NULL or empty. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(''); -ERROR: emaj_create_group: group name must at least contain 1 character. -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group(NULL,false); -ERROR: emaj_create_group: group name can't be NULL. select emaj.emaj_create_group('',false); -ERROR: emaj_create_group: group name must at least contain 1 character. +ERROR: emaj_create_group: group name can't be NULL or empty. -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('unknownGroup',false); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp1',false); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (dummySchema.mytbl4, myschema1.dummyTable). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN -select emaj.emaj_create_group('dummyGrp2',false); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -82,22 +69,23 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table mytemptbl is a temporary table. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- group with an unlogged table begin; insert into emaj.emaj_group_def values ('myGroup5','myschema5','myunloggedtbl'); select emaj.emaj_create_group('myGroup5'); -ERROR: _check_class: table or sequence myunloggedtbl doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 83 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (myschema5.myunloggedtbl). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- table without pkey for a rollbackable group select emaj.emaj_create_group('phil''s group#3",',true); ERROR: _create_tbl: table myTbl2\ has no PRIMARY KEY. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM -- sequence with a log schema suffix defined in the emaj_group_def table begin; update emaj.emaj_group_def set grpdef_log_schema_suffix = 'something' where grpdef_group = 'myGroup1' and grpdef_schema = 'myschema1' and grpdef_tblseq = 'myTbl3_col31_seq'; @@ -120,7 +108,7 @@ ERROR: tablespace "dummyTablespace" does not exist CONTEXT: SQL statement "CREATE TABLE emaj.myschema1_mytbl1_log ( LIKE myschema1.mytbl1) TABLESPACE "dummyTablespace"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- already existing secondary schema @@ -129,14 +117,14 @@ begin; select emaj.emaj_create_group('myGroup1'); ERROR: _create_log_schema: schema emajb should not exist. Drop it manually, or modify emaj_group_def table's content. CONTEXT: SQL statement "SELECT emaj._create_log_schema(r_schema.log_schema)" -PL/pgSQL function "emaj_create_group" line 68 at PERFORM +PL/pgSQL function "emaj_create_group" line 52 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN rollback; -- should be OK select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -149,10 +137,10 @@ alter table myschema2.myTbl8 add foreign key (col81) references myschema2.myTbl6 select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -165,7 +153,7 @@ begin; select emaj.emaj_create_group('phil''s group#3",',false); WARNING: _create_seq: Sequence phil's schema3.myTbl2\_col21_seq is linked to table phil's schema3.myTbl2\ but this table belong to another tables group (dummyGrp3). CONTEXT: SQL statement "SELECT emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName)" -PL/pgSQL function "emaj_create_group" line 103 at PERFORM +PL/pgSQL function "emaj_create_group" line 88 at PERFORM emaj_create_group ------------------- 3 @@ -182,17 +170,24 @@ select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); WARNING: _create_tbl: table myschema4.mytblm has triggers (mytblm_insert_trigger). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- 3 (1 row) +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); +ERROR: _check_group_content: one or several tables or sequences belong to an E-Maj schema (emajC.myschema1_myTbl3_log, emaj.emaj_param). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3'); -ERROR: emaj_create_group: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). -CONTEXT: PL/pgSQL function "emaj_create_group" line 6 at RETURN +ERROR: _check_group_content: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 38 at PERFORM +PL/pgSQL function "emaj_create_group" line 6 at RETURN -- already created select emaj.emaj_create_group('myGroup2'); ERROR: emaj_create_group: group myGroup2 is already created. @@ -393,7 +388,7 @@ PL/pgSQL function "emaj_force_drop_group" line 16 at SQL statement select emaj.emaj_create_group('myGroup1',false); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM emaj_create_group ------------------- 6 @@ -414,10 +409,10 @@ select emaj.emaj_force_drop_group('myGroup1'); select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM emaj_create_group ------------------- 8 @@ -441,7 +436,7 @@ ERROR: emaj_alter_group: group unkownGroup has not been created. select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -467,11 +462,11 @@ begin; select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -480,7 +475,9 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN insert into emaj.emaj_group_def values ('myGroup1','myschema2','mytbl1'); select emaj.emaj_alter_group('myGroup1'); -ERROR: emaj_alter_group: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +ERROR: _check_group_content: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_alter_group" line 47 at PERFORM rollback; -- the group is now empty begin; @@ -540,10 +537,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 4 @@ -568,10 +565,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 3 @@ -680,7 +677,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 @@ -690,7 +687,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 200 at PERFORM +PL/pgSQL function "emaj_alter_group" line 186 at PERFORM emaj_alter_group ------------------ 6 diff --git a/test/90/expected/instPsql.out b/test/90/expected/instPsql.out index 327b6310..7d58d7c5 100644 --- a/test/90/expected/instPsql.out +++ b/test/90/expected/instPsql.out @@ -903,33 +903,75 @@ $_check_names_array$ RETURN v_outputNames; END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS $_check_new_mark$ @@ -2082,7 +2124,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2095,11 +2136,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -2111,20 +2149,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2147,23 +2173,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2176,7 +2203,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2349,7 +2376,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2377,21 +2403,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2514,27 +2527,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2547,7 +2560,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6275,7 +6288,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6366,7 +6379,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6453,7 +6466,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/90/expected/misc.out b/test/90/expected/misc.out index dc6b4e49..c6afb38c 100644 --- a/test/90/expected/misc.out +++ b/test/90/expected/misc.out @@ -1342,11 +1342,11 @@ PL/pgSQL function "emaj_rollback_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1358,10 +1358,10 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 8 @@ -1401,11 +1401,11 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -1444,16 +1444,16 @@ PL/pgSQL function "emaj_force_stop_group" line 14 at SQL statement select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 @@ -1482,10 +1482,10 @@ begin; select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 230 at PERFORM +PL/pgSQL function "emaj_alter_group" line 216 at PERFORM emaj_alter_group ------------------ 7 diff --git a/test/90/expected/startStop.out b/test/90/expected/startStop.out index 7a3fa3a0..e2eeb8fe 100644 --- a/test/90/expected/startStop.out +++ b/test/90/expected/startStop.out @@ -6,7 +6,7 @@ SET client_min_messages TO WARNING; select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 88 at PERFORM +PL/pgSQL function "emaj_create_group" line 73 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- @@ -16,11 +16,11 @@ PL/pgSQL function "emaj_create_group" line 6 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 114 at PERFORM +PL/pgSQL function "emaj_create_group" line 99 at PERFORM PL/pgSQL function "emaj_create_group" line 6 at RETURN emaj_create_group ------------------- diff --git a/test/90/expected/viewer.out b/test/90/expected/viewer.out index c9f10eb5..bd77ee32 100644 --- a/test/90/expected/viewer.out +++ b/test/90/expected/viewer.out @@ -25,7 +25,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; diff --git a/test/91/expected/adm1.out b/test/91/expected/adm1.out index 84616263..7ab9980f 100644 --- a/test/91/expected/adm1.out +++ b/test/91/expected/adm1.out @@ -26,7 +26,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; @@ -212,95 +212,95 @@ NOTICE: table "myschema1_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema1_myTbl3_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_log_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_trunc_trg" ON myschema1."myTbl3"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: table "myschema1_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl1_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_log_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_trunc_trg ON myschema1.mytbl1" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: table "myschema1_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl4_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_log_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_trunc_trg ON myschema1.mytbl4" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: table "myschema1_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl2_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_log_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_trunc_trg ON myschema1.mytbl2" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: table "myschema1_mytbl2b_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emajb.myschema1_mytbl2b_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_log_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_log_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_trunc_trg" for table "mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_trunc_trg ON myschema1.mytbl2b" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -318,98 +318,98 @@ NOTICE: table "myschema2_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl1_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_log_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_log_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_trunc_trg" for table "mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_trunc_trg ON myschema2.mytbl1" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "myschema2_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl2_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_log_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_log_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_trunc_trg" for table "mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_trunc_trg ON myschema2.mytbl2" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "myschema2_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema2_myTbl3_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_log_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_log_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_trunc_trg" for table "myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_trunc_trg" ON myschema2."myTbl3"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "myschema2_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl4_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_log_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_log_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_trunc_trg" for table "mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_trunc_trg ON myschema2.mytbl4" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "myschema2_mytbl5_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl5_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_log_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_log_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_trunc_trg" for table "mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_trunc_trg ON myschema2.mytbl5" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "myschema2_mytbl6_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl6_log" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_log_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_log_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_trunc_trg" for table "mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_trunc_trg ON myschema2.mytbl6" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM emaj_create_group ------------------- 8 diff --git a/test/91/expected/adm2.out b/test/91/expected/adm2.out index f4537e0e..5c20235d 100644 --- a/test/91/expected/adm2.out +++ b/test/91/expected/adm2.out @@ -529,32 +529,32 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM emaj_create_group ------------------- 4 @@ -569,17 +569,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM emaj_alter_group ------------------ 4 @@ -607,17 +607,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM emaj_alter_group ------------------ 4 @@ -644,38 +644,38 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function "_create_tbl" line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function "_create_tbl" line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl2_col21_fkey, from table phil's schema3.myTbl2\, references phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM WARNING: _check_fk_groups: table phil's schema3.phil's tbl1 is referenced by foreign key mytbl4_col44_fkey from table phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM emaj_create_group ------------------- 4 diff --git a/test/91/expected/createDrop.out b/test/91/expected/createDrop.out index e85ee604..8df783bc 100644 --- a/test/91/expected/createDrop.out +++ b/test/91/expected/createDrop.out @@ -30,7 +30,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblm'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -38,37 +40,22 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- -- invalid group names select emaj.emaj_create_group(NULL); -ERROR: emaj_create_group: group name can't be NULL. +ERROR: emaj_create_group: group name can't be NULL or empty. CONTEXT: PL/pgSQL function "emaj_create_group" line 7 at RETURN -select emaj.emaj_create_group(''); -ERROR: emaj_create_group: group name must at least contain 1 character. -CONTEXT: PL/pgSQL function "emaj_create_group" line 7 at RETURN -select emaj.emaj_create_group(NULL,false); -ERROR: emaj_create_group: group name can't be NULL. select emaj.emaj_create_group('',false); -ERROR: emaj_create_group: group name must at least contain 1 character. +ERROR: emaj_create_group: group name can't be NULL or empty. -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. CONTEXT: PL/pgSQL function "emaj_create_group" line 7 at RETURN select emaj.emaj_create_group('unknownGroup',false); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 84 at assignment -PL/pgSQL function "emaj_create_group" line 7 at RETURN -select emaj.emaj_create_group('dummyGrp1',false); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 84 at assignment --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 84 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (dummySchema.mytbl4, myschema1.dummyTable). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 39 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN -select emaj.emaj_create_group('dummyGrp2',false); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function "emaj_create_group" line 84 at assignment -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -82,7 +69,7 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table mytemptbl is a temporary table. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN rollback; -- group with an unlogged table @@ -91,14 +78,14 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table myunloggedtbl is an unlogged table. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN rollback; -- table without pkey for a rollbackable group select emaj.emaj_create_group('phil''s group#3",',true); ERROR: _create_tbl: table myTbl2\ has no PRIMARY KEY. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM -- sequence with a log schema suffix defined in the emaj_group_def table begin; update emaj.emaj_group_def set grpdef_log_schema_suffix = 'something' where grpdef_group = 'myGroup1' and grpdef_schema = 'myschema1' and grpdef_tblseq = 'myTbl3_col31_seq'; @@ -121,7 +108,7 @@ ERROR: tablespace "dummyTablespace" does not exist CONTEXT: SQL statement "CREATE TABLE emaj.myschema1_mytbl1_log ( LIKE myschema1.mytbl1) TABLESPACE "dummyTablespace"" PL/pgSQL function "_create_tbl" line 106 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN rollback; -- already existing secondary schema @@ -130,14 +117,14 @@ begin; select emaj.emaj_create_group('myGroup1'); ERROR: _create_log_schema: schema emajb should not exist. Drop it manually, or modify emaj_group_def table's content. CONTEXT: SQL statement "SELECT emaj._create_log_schema(r_schema.log_schema)" -PL/pgSQL function "emaj_create_group" line 69 at PERFORM +PL/pgSQL function "emaj_create_group" line 53 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN rollback; -- should be OK select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -150,10 +137,10 @@ alter table myschema2.myTbl8 add foreign key (col81) references myschema2.myTbl6 select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM emaj_create_group ------------------- 8 @@ -166,7 +153,7 @@ begin; select emaj.emaj_create_group('phil''s group#3",',false); WARNING: _create_seq: Sequence phil's schema3.myTbl2\_col21_seq is linked to table phil's schema3.myTbl2\ but this table belong to another tables group (dummyGrp3). CONTEXT: SQL statement "SELECT emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName)" -PL/pgSQL function "emaj_create_group" line 104 at PERFORM +PL/pgSQL function "emaj_create_group" line 89 at PERFORM emaj_create_group ------------------- 3 @@ -183,17 +170,24 @@ select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); WARNING: _create_tbl: table myschema4.mytblm has triggers (mytblm_insert_trigger). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- 3 (1 row) +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); +ERROR: _check_group_content: one or several tables or sequences belong to an E-Maj schema (emajC.myschema1_myTbl3_log, emaj.emaj_param). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 39 at PERFORM -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3'); -ERROR: emaj_create_group: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). -CONTEXT: PL/pgSQL function "emaj_create_group" line 7 at RETURN +ERROR: _check_group_content: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_create_group" line 39 at PERFORM +PL/pgSQL function "emaj_create_group" line 7 at RETURN -- already created select emaj.emaj_create_group('myGroup2'); ERROR: emaj_create_group: group myGroup2 is already created. @@ -394,7 +388,7 @@ PL/pgSQL function "emaj_force_drop_group" line 17 at SQL statement select emaj.emaj_create_group('myGroup1',false); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM emaj_create_group ------------------- 6 @@ -415,10 +409,10 @@ select emaj.emaj_force_drop_group('myGroup1'); select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM emaj_create_group ------------------- 8 @@ -442,7 +436,7 @@ ERROR: emaj_alter_group: group unkownGroup has not been created. select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -468,11 +462,11 @@ begin; select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -481,7 +475,9 @@ PL/pgSQL function "emaj_create_group" line 7 at RETURN insert into emaj.emaj_group_def values ('myGroup1','myschema2','mytbl1'); select emaj.emaj_alter_group('myGroup1'); -ERROR: emaj_alter_group: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +ERROR: _check_group_content: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function "emaj_alter_group" line 48 at PERFORM rollback; -- the group is now empty begin; @@ -541,10 +537,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM emaj_alter_group ------------------ 4 @@ -569,10 +565,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM emaj_alter_group ------------------ 3 @@ -680,7 +676,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM emaj_alter_group ------------------ 6 @@ -690,7 +686,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_alter_group" line 201 at PERFORM +PL/pgSQL function "emaj_alter_group" line 187 at PERFORM emaj_alter_group ------------------ 6 diff --git a/test/91/expected/instPsql.out b/test/91/expected/instPsql.out index a50dd1ad..525c02a2 100644 --- a/test/91/expected/instPsql.out +++ b/test/91/expected/instPsql.out @@ -903,33 +903,75 @@ $_check_names_array$ RETURN v_outputNames; END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS $_check_new_mark$ @@ -2082,7 +2124,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2095,11 +2136,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -2111,20 +2149,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2147,23 +2173,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2176,7 +2203,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2349,7 +2376,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2377,21 +2403,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2514,27 +2527,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2547,7 +2560,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6275,7 +6288,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6366,7 +6379,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6453,7 +6466,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/91/expected/misc.out b/test/91/expected/misc.out index f3e36cd2..38a361e8 100644 --- a/test/91/expected/misc.out +++ b/test/91/expected/misc.out @@ -1334,11 +1334,11 @@ PL/pgSQL function "emaj_rollback_group" line 7 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -1350,10 +1350,10 @@ PL/pgSQL function "emaj_create_group" line 7 at RETURN select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM emaj_alter_group ------------------ 8 @@ -1393,11 +1393,11 @@ PL/pgSQL function "emaj_force_stop_group" line 15 at SQL statement select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -1436,16 +1436,16 @@ PL/pgSQL function "emaj_force_stop_group" line 15 at SQL statement select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM emaj_alter_group ------------------ 7 @@ -1474,10 +1474,10 @@ begin; select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function "emaj_alter_group" line 231 at PERFORM +PL/pgSQL function "emaj_alter_group" line 217 at PERFORM emaj_alter_group ------------------ 7 diff --git a/test/91/expected/restore.out b/test/91/expected/restore.out index 8e7ece78..897f29cf 100644 --- a/test/91/expected/restore.out +++ b/test/91/expected/restore.out @@ -945,7 +945,6 @@ REVOKE REVOKE GRANT GRANT -GRANT REVOKE REVOKE GRANT diff --git a/test/91/expected/startStop.out b/test/91/expected/startStop.out index fe380170..a4d62fb8 100644 --- a/test/91/expected/startStop.out +++ b/test/91/expected/startStop.out @@ -6,7 +6,7 @@ SET client_min_messages TO WARNING; select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function "emaj_create_group" line 89 at PERFORM +PL/pgSQL function "emaj_create_group" line 74 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- @@ -16,11 +16,11 @@ PL/pgSQL function "emaj_create_group" line 7 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function "emaj_create_group" line 115 at PERFORM +PL/pgSQL function "emaj_create_group" line 100 at PERFORM PL/pgSQL function "emaj_create_group" line 7 at RETURN emaj_create_group ------------------- diff --git a/test/91/expected/viewer.out b/test/91/expected/viewer.out index c9f10eb5..bd77ee32 100644 --- a/test/91/expected/viewer.out +++ b/test/91/expected/viewer.out @@ -25,7 +25,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; diff --git a/test/92/expected/adm1.out b/test/92/expected/adm1.out index befc81a0..3c3b74fa 100644 --- a/test/92/expected/adm1.out +++ b/test/92/expected/adm1.out @@ -26,7 +26,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; @@ -212,95 +212,95 @@ NOTICE: table "myschema1_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema1_myTbl3_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_log_trg" for table "myschema1.myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_log_trg" ON myschema1."myTbl3"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_myTbl3_emaj_trunc_trg" for table "myschema1.myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema1_myTbl3_emaj_trunc_trg" ON myschema1."myTbl3"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: table "myschema1_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl1_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_log_trg" for table "myschema1.mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_log_trg ON myschema1.mytbl1" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl1_emaj_trunc_trg" for table "myschema1.mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl1_emaj_trunc_trg ON myschema1.mytbl1" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: table "myschema1_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl4_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_log_trg" for table "myschema1.mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_log_trg ON myschema1.mytbl4" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl4_emaj_trunc_trg" for table "myschema1.mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl4_emaj_trunc_trg ON myschema1.mytbl4" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: table "myschema1_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema1_mytbl2_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_log_trg" for table "myschema1.mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_log_trg ON myschema1.mytbl2" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl2_emaj_trunc_trg" for table "myschema1.mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2_emaj_trunc_trg ON myschema1.mytbl2" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: table "myschema1_mytbl2b_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emajb.myschema1_mytbl2b_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_log_trg" for table "myschema1.mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_log_trg ON myschema1.mytbl2b" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN NOTICE: trigger "myschema1_mytbl2b_emaj_trunc_trg" for table "myschema1.mytbl2b" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema1_mytbl2b_emaj_trunc_trg ON myschema1.mytbl2b" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -318,98 +318,98 @@ NOTICE: table "myschema2_mytbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl1_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_log_trg" for table "myschema2.mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_log_trg ON myschema2.mytbl1" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl1_emaj_trunc_trg" for table "myschema2.mytbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl1_emaj_trunc_trg ON myschema2.mytbl1" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "myschema2_mytbl2_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl2_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_log_trg" for table "myschema2.mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_log_trg ON myschema2.mytbl2" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl2_emaj_trunc_trg" for table "myschema2.mytbl2" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl2_emaj_trunc_trg ON myschema2.mytbl2" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "myschema2_myTbl3_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emajC"."myschema2_myTbl3_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_log_trg" for table "myschema2.myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_log_trg" ON myschema2."myTbl3"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_myTbl3_emaj_trunc_trg" for table "myschema2.myTbl3" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "myschema2_myTbl3_emaj_trunc_trg" ON myschema2."myTbl3"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "myschema2_mytbl4_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl4_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_log_trg" for table "myschema2.mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_log_trg ON myschema2.mytbl4" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl4_emaj_trunc_trg" for table "myschema2.mytbl4" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl4_emaj_trunc_trg ON myschema2.mytbl4" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "myschema2_mytbl5_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl5_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_log_trg" for table "myschema2.mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_log_trg ON myschema2.mytbl5" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl5_emaj_trunc_trg" for table "myschema2.mytbl5" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl5_emaj_trunc_trg ON myschema2.mytbl5" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "myschema2_mytbl6_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj.myschema2_mytbl6_log" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_log_trg" for table "myschema2.mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_log_trg ON myschema2.mytbl6" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "myschema2_mytbl6_emaj_trunc_trg" for table "myschema2.mytbl6" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS myschema2_mytbl6_emaj_trunc_trg ON myschema2.mytbl6" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM emaj_create_group ------------------- 8 diff --git a/test/92/expected/adm2.out b/test/92/expected/adm2.out index 03847d8c..36be4202 100644 --- a/test/92/expected/adm2.out +++ b/test/92/expected/adm2.out @@ -529,32 +529,32 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "phil's schema3.myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "phil's schema3.myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM emaj_create_group ------------------- 4 @@ -569,17 +569,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM emaj_alter_group ------------------ 4 @@ -607,17 +607,17 @@ NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM emaj_alter_group ------------------ 4 @@ -644,38 +644,38 @@ NOTICE: table "phil's schema3_myTbl2\_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS emaj."phil's schema3_myTbl2\_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_log_trg" for table "phil's schema3.myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_log_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_myTbl2\_emaj_trunc_trg" for table "phil's schema3.myTbl2\" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_myTbl2\_emaj_trunc_trg" ON "phil's schema3"."myTbl2\"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: table "phil's schema3_phil's tbl1_log" does not exist, skipping CONTEXT: SQL statement "DROP TABLE IF EXISTS "emaj #'3"."phil's schema3_phil's tbl1_log"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 105 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_log_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_log_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 164 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM NOTICE: trigger "phil's schema3_phil's tbl1_emaj_trunc_trg" for table "phil's schema3.phil's tbl1" does not exist, skipping CONTEXT: SQL statement "DROP TRIGGER IF EXISTS "phil's schema3_phil's tbl1_emaj_trunc_trg" ON "phil's schema3"."phil's tbl1"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 172 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM WARNING: _check_fk_groups: Foreign key mytbl2_col21_fkey, from table phil's schema3.myTbl2\, references phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM WARNING: _check_fk_groups: table phil's schema3.phil's tbl1 is referenced by foreign key mytbl4_col44_fkey from table phil's schema3.mytbl4 that is outside groups (phil's group#3",). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM emaj_create_group ------------------- 4 diff --git a/test/92/expected/createDrop.out b/test/92/expected/createDrop.out index e47a68b0..5f38f3f1 100644 --- a/test/92/expected/createDrop.out +++ b/test/92/expected/createDrop.out @@ -30,7 +30,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblm'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -38,37 +40,22 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- -- invalid group names select emaj.emaj_create_group(NULL); -ERROR: emaj_create_group: group name can't be NULL. +ERROR: emaj_create_group: group name can't be NULL or empty. CONTEXT: PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN -select emaj.emaj_create_group(''); -ERROR: emaj_create_group: group name must at least contain 1 character. -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN -select emaj.emaj_create_group(NULL,false); -ERROR: emaj_create_group: group name can't be NULL. select emaj.emaj_create_group('',false); -ERROR: emaj_create_group: group name must at least contain 1 character. +ERROR: emaj_create_group: group name can't be NULL or empty. -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. CONTEXT: PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN select emaj.emaj_create_group('unknownGroup',false); ERROR: emaj_create_group: Group unknownGroup is unknown in emaj_group_def table. --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text,boolean) line 84 at assignment -PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN -select emaj.emaj_create_group('dummyGrp1',false); -ERROR: _check_class: schema dummySchema doesn't exist. -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text,boolean) line 84 at assignment --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text,boolean) line 84 at assignment +ERROR: _check_group_content: one or several tables or sequences do not exist (dummySchema.mytbl4, myschema1.dummyTable). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 39 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN -select emaj.emaj_create_group('dummyGrp2',false); -ERROR: _check_class: table or sequence dummyTable doesn't exist. -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text,boolean) line 84 at assignment -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -82,7 +69,7 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table mytemptbl is a temporary table. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN rollback; -- group with an unlogged table @@ -91,14 +78,14 @@ begin; select emaj.emaj_create_group('myGroup5'); ERROR: _create_tbl: table myunloggedtbl is an unlogged table. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN rollback; -- table without pkey for a rollbackable group select emaj.emaj_create_group('phil''s group#3",',true); ERROR: _create_tbl: table myTbl2\ has no PRIMARY KEY. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM -- sequence with a log schema suffix defined in the emaj_group_def table begin; update emaj.emaj_group_def set grpdef_log_schema_suffix = 'something' where grpdef_group = 'myGroup1' and grpdef_schema = 'myschema1' and grpdef_tblseq = 'myTbl3_col31_seq'; @@ -121,7 +108,7 @@ ERROR: tablespace "dummyTablespace" does not exist CONTEXT: SQL statement "CREATE TABLE emaj.myschema1_mytbl1_log ( LIKE myschema1.mytbl1) TABLESPACE "dummyTablespace"" PL/pgSQL function emaj._create_tbl(text,text,text,text,text,boolean) line 106 at EXECUTE statement SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN rollback; -- already existing secondary schema @@ -130,14 +117,14 @@ begin; select emaj.emaj_create_group('myGroup1'); ERROR: _create_log_schema: schema emajb should not exist. Drop it manually, or modify emaj_group_def table's content. CONTEXT: SQL statement "SELECT emaj._create_log_schema(r_schema.log_schema)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 69 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 53 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN rollback; -- should be OK select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -150,10 +137,10 @@ alter table myschema2.myTbl8 add foreign key (col81) references myschema2.myTbl6 select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM emaj_create_group ------------------- 8 @@ -166,7 +153,7 @@ begin; select emaj.emaj_create_group('phil''s group#3",',false); WARNING: _create_seq: Sequence phil's schema3.myTbl2\_col21_seq is linked to table phil's schema3.myTbl2\ but this table belong to another tables group (dummyGrp3). CONTEXT: SQL statement "SELECT emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 104 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM emaj_create_group ------------------- 3 @@ -183,17 +170,24 @@ select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); WARNING: _create_tbl: table myschema4.mytblm has triggers (mytblm_insert_trigger). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- 3 (1 row) +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); +ERROR: _check_group_content: one or several tables or sequences belong to an E-Maj schema (emajC.myschema1_myTbl3_log, emaj.emaj_param). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 39 at PERFORM -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3'); -ERROR: emaj_create_group: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). -CONTEXT: PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN +ERROR: _check_group_content: one or several tables already belong to another group (myschema1.mytbl1 in myGroup1, myschema2.mytbl2 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 39 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN -- already created select emaj.emaj_create_group('myGroup2'); ERROR: emaj_create_group: group myGroup2 is already created. @@ -394,7 +388,7 @@ PL/pgSQL function emaj.emaj_force_drop_group(text) line 17 at SQL statement select emaj.emaj_create_group('myGroup1',false); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM emaj_create_group ------------------- 6 @@ -415,10 +409,10 @@ select emaj.emaj_force_drop_group('myGroup1'); select emaj.emaj_create_group('myGroup2',true); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM emaj_create_group ------------------- 8 @@ -442,7 +436,7 @@ ERROR: emaj_alter_group: group unkownGroup has not been created. select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -468,11 +462,11 @@ begin; select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -481,7 +475,9 @@ PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN insert into emaj.emaj_group_def values ('myGroup1','myschema2','mytbl1'); select emaj.emaj_alter_group('myGroup1'); -ERROR: emaj_alter_group: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +ERROR: _check_group_content: one or several tables already belong to another group (myschema2.mytbl1 in myGroup2). +CONTEXT: SQL statement "SELECT emaj._check_group_content(v_groupName)" +PL/pgSQL function emaj.emaj_alter_group(text) line 48 at PERFORM rollback; -- the group is now empty begin; @@ -541,10 +537,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM emaj_alter_group ------------------ 4 @@ -569,10 +565,10 @@ delete from emaj.emaj_group_def where grpdef_schema = 'myschema1' and grpdef_tbl select emaj.emaj_alter_group('myGroup1'); WARNING: _check_fk_groups: table myschema1.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema1.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema1.mytbl4 that is outside groups (myGroup1). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM emaj_alter_group ------------------ 3 @@ -681,7 +677,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM emaj_alter_group ------------------ 6 @@ -691,7 +687,7 @@ update emaj.emaj_group_def set grpdef_log_dat_tsp = case when grpdef_log_dat_tsp select emaj.emaj_alter_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_alter_group(text) line 201 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 187 at PERFORM emaj_alter_group ------------------ 6 diff --git a/test/92/expected/instPsql.out b/test/92/expected/instPsql.out index 2358cff7..2f879b61 100644 --- a/test/92/expected/instPsql.out +++ b/test/92/expected/instPsql.out @@ -903,33 +903,75 @@ $_check_names_array$ RETURN v_outputNames; END; $_check_names_array$; -CREATE OR REPLACE FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) -RETURNS TEXT LANGUAGE plpgsql AS -$_check_class$ --- This function verifies that an application table or sequence exists in pg_class --- It also protects from a recursive use : tables or sequences from emaj schema cannot be managed by EMAJ --- Input: the names of the schema and the class (table or sequence) --- Output: the relkind of the class : 'r' for a table and 's' for a sequence --- If the schema or the class is not known, the function stops. +CREATE OR REPLACE FUNCTION emaj._check_group_content(v_groupName TEXT) +RETURNS VOID LANGUAGE plpgsql AS +$_check_group_content$ +-- This function verifies that the content of tables group as defined into the emaj_group_def table is correct. +-- It is called by emaj_create_group() and emaj_alter_group() functions. +-- It checks that the referenced application tables and sequences, +-- - exist, +-- - is not located into an E-Maj schema (to protect against an E-Maj recursive use), +-- - do not already belong to another tables group. +-- Input: the name of the tables group to check DECLARE - v_relKind TEXT; - v_schemaOid OID; + v_msg TEXT := ''; + r_tblsq RECORD; BEGIN - IF v_schemaName = 'emaj' THEN - RAISE EXCEPTION '_check_class: object from schema % cannot be managed by EMAJ.', v_schemaName; +-- check that all application tables and sequences listed for the group really exist + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName + EXCEPT + SELECT nspname || '.' || relname FROM pg_catalog.pg_class, pg_catalog.pg_namespace + WHERE relnamespace = pg_namespace.oid AND relkind IN ('r','S') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences do not exist (%).', v_msg; END IF; - SELECT oid INTO v_schemaOid FROM pg_catalog.pg_namespace WHERE nspname = v_schemaName; - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: schema % doesn''t exist.', v_schemaName; +-- check no application schema listed for the group in the emaj_group_def table is an E-Maj schema + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq AS full_name + FROM emaj.emaj_group_def + WHERE grpdef_group = v_groupName + AND grpdef_schema IN ( + SELECT DISTINCT rel_log_schema FROM emaj.emaj_relation + UNION + SELECT 'emaj') + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables or sequences belong to an E-Maj schema (%).', v_msg; END IF; - SELECT relkind INTO v_relKind FROM pg_catalog.pg_class - WHERE relnamespace = v_schemaOid AND relname = v_className AND relkind IN ('r','S'); - IF NOT FOUND THEN - RAISE EXCEPTION '_check_class: table or sequence % doesn''t exist.', v_className; +-- check that no table or sequence of the new group already belongs to another created group + FOR r_tblsq IN + SELECT grpdef_schema || '.' || grpdef_tblseq || ' in ' || rel_group AS full_name + FROM emaj.emaj_group_def, emaj.emaj_relation + WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq + AND grpdef_group = v_groupName AND rel_group <> v_groupName + ORDER BY 1 + LOOP + IF v_msg <> '' THEN + v_msg = v_msg || ', '; + END IF; + v_msg = v_msg || r_tblsq.full_name; + END LOOP; + IF v_msg <> '' THEN + RAISE EXCEPTION '_check_group_content: one or several tables already belong to another group (%).', v_msg; END IF; - RETURN v_relKind; + RETURN; END; -$_check_class$; +$_check_group_content$; CREATE OR REPLACE FUNCTION emaj._check_new_mark(v_mark TEXT, v_groupNames TEXT[]) RETURNS TEXT LANGUAGE plpgsql AS $_check_new_mark$ @@ -2082,7 +2124,6 @@ $emaj_create_group$ v_schemaPrefix TEXT := 'emaj'; v_logSchema TEXT; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2095,11 +2136,8 @@ $emaj_create_group$ INSERT INTO emaj.emaj_hist (hist_function, hist_event, hist_object, hist_wording) VALUES ('CREATE_GROUP', 'BEGIN', v_groupName, CASE WHEN v_isRollbackable THEN 'rollbackable' ELSE 'audit_only' END); -- check that the group name is valid - IF v_groupName IS NULL THEN - RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL.'; - END IF; - IF v_groupName = '' THEN - RAISE EXCEPTION 'emaj_create_group: group name must at least contain 1 character.'; + IF v_groupName IS NULL OR v_groupName = ''THEN + RAISE EXCEPTION 'emaj_create_group: group name can''t be NULL or empty.'; END IF; -- check the group is known in emaj_group_def table PERFORM 0 FROM emaj.emaj_group_def WHERE grpdef_group = v_groupName LIMIT 1; @@ -2111,20 +2149,8 @@ $emaj_create_group$ IF FOUND THEN RAISE EXCEPTION 'emaj_create_group: group % is already created.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq AND grpdef_group = v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_create_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- OK, insert group row in the emaj_group table INSERT INTO emaj.emaj_group (group_name, group_is_logging, group_is_rollbackable) VALUES (v_groupName, FALSE,v_isRollbackable); @@ -2147,23 +2173,24 @@ $emaj_create_group$ SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- scan all classes of the group (in priority order, NULLS being processed last) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName + AND relnamespace = pg_namespace.oid + AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); v_nbTbl = v_nbTbl + 1; - ELSEIF v_relkind = 'S' THEN + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_create_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2176,7 +2203,7 @@ $emaj_create_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); v_nbSeq = v_nbSeq + 1; END IF; END LOOP; @@ -2349,7 +2376,6 @@ $emaj_alter_group$ v_logSchema TEXT; v_logSchemasArray TEXT[]; v_msg TEXT; - v_relkind TEXT; v_logDatTsp TEXT; v_logIdxTsp TEXT; v_defTsp TEXT; @@ -2377,21 +2403,8 @@ $emaj_alter_group$ IF NOT FOUND THEN RAISE EXCEPTION 'emaj_alter_group: Group % is unknown in emaj_group_def table.', v_groupName; END IF; --- check that no table or sequence of the new group already belongs to another created group - v_msg = ''; - FOR r_tblsq IN - SELECT grpdef_schema, grpdef_tblseq, rel_group FROM emaj.emaj_group_def, emaj.emaj_relation - WHERE grpdef_schema = rel_schema AND grpdef_tblseq = rel_tblseq - AND grpdef_group = v_groupName AND rel_group <> v_groupName - LOOP - IF v_msg <> '' THEN - v_msg = v_msg || ', '; - END IF; - v_msg = v_msg || r_tblsq.grpdef_schema || '.' || r_tblsq.grpdef_tblseq || ' in ' || r_tblsq.rel_group; - END LOOP; - IF v_msg <> '' THEN - RAISE EXCEPTION 'emaj_alter_group: one or several tables already belong to another group (%).', v_msg; - END IF; +-- performs various checks on the group's content described in the emaj_group_def table + PERFORM emaj._check_group_content(v_groupName); -- define the default tablespace, NULL if tspemaj tablespace doesn't exist SELECT 'tspemaj' INTO v_defTsp FROM pg_catalog.pg_tablespace WHERE spcname = 'tspemaj'; -- OK, we can now process: @@ -2514,27 +2527,27 @@ $emaj_alter_group$ -- -- list new relations in the tables group (really new or intentionaly dropped in the preceeding steps) FOR r_tblsq IN - SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp - FROM emaj.emaj_group_def + SELECT grpdef_priority, grpdef_schema, grpdef_tblseq, relkind, + grpdef_log_schema_suffix, grpdef_log_dat_tsp, grpdef_log_idx_tsp + FROM emaj.emaj_group_def, pg_catalog.pg_class, pg_catalog.pg_namespace WHERE grpdef_group = v_groupName AND (grpdef_schema, grpdef_tblseq) NOT IN ( SELECT rel_schema, rel_tblseq FROM emaj.emaj_relation WHERE rel_group = v_groupName) + AND relnamespace = pg_namespace.oid AND nspname = grpdef_schema AND relname = grpdef_tblseq ORDER BY grpdef_priority, grpdef_schema, grpdef_tblseq LOOP -- --- check the class is valid - v_relkind = emaj._check_class(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq); - IF v_relkind = 'r' THEN + IF r_tblsq.relkind = 'r' THEN -- if it is a table, build the log schema name v_logSchema = coalesce(v_schemaPrefix || r_tblsq.grpdef_log_schema_suffix, v_emajSchema); -- create the related emaj objects PERFORM emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable); -- and record the table in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_log_schema, rel_log_dat_tsp, rel_log_idx_tsp, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_relkind); - ELSEIF v_relkind = 'S' THEN + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), 'r'); + ELSEIF r_tblsq.relkind = 'S' THEN -- if it is a sequence, check no log schema has been set as parameter in the emaj_group_def table IF r_tblsq.grpdef_log_schema_suffix IS NOT NULL THEN RAISE EXCEPTION 'emaj_alter_group: Defining a secondary log schema is not allowed for a sequence (%.%).', r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq; @@ -2547,7 +2560,7 @@ $emaj_alter_group$ PERFORM emaj._create_seq(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName); -- and record it in the emaj_relation table INSERT INTO emaj.emaj_relation (rel_schema, rel_tblseq, rel_group, rel_priority, rel_kind) - VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, v_relkind); + VALUES (r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_groupName, r_tblsq.grpdef_priority, 'S'); END IF; v_nbCreate = v_nbCreate + 1; END LOOP; @@ -6275,7 +6288,7 @@ REVOKE ALL ON FUNCTION emaj._get_mark_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) FROM PUBLIC; -REVOKE ALL ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) FROM PUBLIC; +REVOKE ALL ON FUNCTION emaj._check_group_content(v_groupName TEXT) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._forbid_truncate_fnct() FROM PUBLIC; REVOKE ALL ON FUNCTION emaj._log_truncate_fnct() FROM PUBLIC; @@ -6366,7 +6379,7 @@ GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_names_array(v_groupNames TEXT[], v_type TEXT) TO emaj_adm; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_adm; +GRANT EXECUTE ON FUNCTION emaj._check_group_content(v_groupName TEXT) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._check_new_mark(INOUT v_mark TEXT, v_groupNames TEXT[]) TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._forbid_truncate_fnct() TO emaj_adm; GRANT EXECUTE ON FUNCTION emaj._log_truncate_fnct() TO emaj_adm; @@ -6453,7 +6466,6 @@ GRANT EXECUTE ON FUNCTION emaj._dblink_is_cnx_opened(v_cnxName TEXT) TO emaj_vie GRANT EXECUTE ON FUNCTION emaj._get_mark_name(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._get_mark_datetime(TEXT, TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._build_log_seq_name(TEXT, TEXT) TO emaj_viewer; -GRANT EXECUTE ON FUNCTION emaj._check_class(v_schemaName TEXT, v_className TEXT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._log_stat_tbl(v_schemaName TEXT, v_tableName TEXT, v_logSchema TEXT, v_tsFirstMark TIMESTAMPTZ, v_tsLastMark TIMESTAMPTZ, v_firstLastSeqHoleId BIGINT, v_lastLastSeqHoleId BIGINT) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj._verify_groups(v_groupNames TEXT[], v_onErrorStop boolean) TO emaj_viewer; GRANT EXECUTE ON FUNCTION emaj.emaj_get_previous_mark_group(v_groupName TEXT, v_datetime TIMESTAMPTZ) TO emaj_viewer; diff --git a/test/92/expected/misc.out b/test/92/expected/misc.out index 32df2af6..5cf3980d 100644 --- a/test/92/expected/misc.out +++ b/test/92/expected/misc.out @@ -1334,11 +1334,11 @@ PL/pgSQL function emaj.emaj_rollback_group(text,text) line 7 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -1350,10 +1350,10 @@ PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM emaj_alter_group ------------------ 8 @@ -1393,11 +1393,11 @@ PL/pgSQL function emaj.emaj_force_stop_group(text) line 15 at SQL statement select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -1436,16 +1436,16 @@ PL/pgSQL function emaj.emaj_force_stop_group(text) line 15 at SQL statement select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl2 is referenced by foreign key mytbl4_col43_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl1 is referenced by foreign key mytbl4_col44_fkey from table myschema2.mytbl4 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM emaj_alter_group ------------------ 7 @@ -1474,10 +1474,10 @@ begin; select emaj.emaj_alter_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups(array[v_groupName])" -PL/pgSQL function emaj.emaj_alter_group(text) line 231 at PERFORM +PL/pgSQL function emaj.emaj_alter_group(text) line 217 at PERFORM emaj_alter_group ------------------ 7 diff --git a/test/92/expected/startStop.out b/test/92/expected/startStop.out index 0466401b..5fd74994 100644 --- a/test/92/expected/startStop.out +++ b/test/92/expected/startStop.out @@ -6,7 +6,7 @@ SET client_min_messages TO WARNING; select emaj.emaj_create_group('myGroup1'); WARNING: _create_tbl: table myschema1.mytbl2 has triggers (mytbl2trg). Verify the compatibility with emaj rollback operations (in particular if triggers update one or several other tables). Triggers may have to be manualy disabled before rollback. CONTEXT: SQL statement "SELECT emaj._create_tbl(r_tblsq.grpdef_schema, r_tblsq.grpdef_tblseq, v_logSchema, coalesce(r_tblsq.grpdef_log_dat_tsp, v_defTsp), coalesce(r_tblsq.grpdef_log_idx_tsp, v_defTsp), v_isRollbackable)" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 89 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 74 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- @@ -16,11 +16,11 @@ PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN select emaj.emaj_create_group('myGroup2'); WARNING: _check_fk_groups: Foreign key mytbl6_col61_fkey, from table myschema2.mytbl6, references myschema2.mytbl7 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN WARNING: _check_fk_groups: table myschema2.mytbl6 is referenced by foreign key mytbl8_col81_fkey from table myschema2.mytbl8 that is outside groups (myGroup2). CONTEXT: SQL statement "SELECT emaj._check_fk_groups (array[v_groupName])" -PL/pgSQL function emaj.emaj_create_group(text,boolean) line 115 at PERFORM +PL/pgSQL function emaj.emaj_create_group(text,boolean) line 100 at PERFORM PL/pgSQL function emaj.emaj_create_group(text) line 7 at RETURN emaj_create_group ------------------- diff --git a/test/92/expected/viewer.out b/test/92/expected/viewer.out index c9f10eb5..bd77ee32 100644 --- a/test/92/expected/viewer.out +++ b/test/92/expected/viewer.out @@ -25,7 +25,7 @@ select count(*) from emaj.emaj_hist; select count(*) from emaj.emaj_group_def; count ------- - 25 + 27 (1 row) select count(*) from emaj.emaj_group; diff --git a/test/sql/createDrop.sql b/test/sql/createDrop.sql index 014da474..531b3aa0 100644 --- a/test/sql/createDrop.sql +++ b/test/sql/createDrop.sql @@ -33,7 +33,9 @@ insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc1'); insert into emaj.emaj_group_def values ('myGroup4','myschema4','mytblc2'); insert into emaj.emaj_group_def values ('dummyGrp1','dummySchema','mytbl4'); -insert into emaj.emaj_group_def values ('dummyGrp2','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp1','myschema1','dummyTable'); +insert into emaj.emaj_group_def values ('dummyGrp2','emaj','emaj_param'); +insert into emaj.emaj_group_def values ('dummyGrp2','emajC','myschema1_myTbl3_log'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema1','mytbl1'); insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); ----------------------------- @@ -42,18 +44,12 @@ insert into emaj.emaj_group_def values ('dummyGrp3','myschema2','mytbl2'); -- invalid group names select emaj.emaj_create_group(NULL); -select emaj.emaj_create_group(''); -select emaj.emaj_create_group(NULL,false); select emaj.emaj_create_group('',false); -- group is unknown in emaj_group_def select emaj.emaj_create_group('unknownGroup'); select emaj.emaj_create_group('unknownGroup',false); --- unknown schema in emaj_group_def +-- unknown schema or table in emaj_group_def select emaj.emaj_create_group('dummyGrp1'); -select emaj.emaj_create_group('dummyGrp1',false); --- unknown table in emaj_group_def -select emaj.emaj_create_group('dummyGrp2'); -select emaj.emaj_create_group('dummyGrp2',false); -- group with a temp table begin; CREATE TEMPORARY TABLE myTempTbl ( @@ -112,6 +108,9 @@ rollback; select emaj.emaj_create_group('phil''s group#3",',false); select emaj.emaj_create_group('myGroup4'); +-- create a group with a table from an E-Maj secondary schema +select emaj.emaj_create_group('dummyGrp2',false); + -- create a group with a table already belonging to another group select emaj.emaj_create_group('dummyGrp3');