diff --git a/NEWS.md b/NEWS.md index 437fd48..fc39c37 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +0.31.0 (XXXX-XX-XX) +* Ghost tables: Add missing tags (#370) + 0.30.0 (2019-07-17) * Added new admin functions to connect CARTO with user FDW's (#369) diff --git a/scripts-available/CDB_ForeignTable.sql b/scripts-available/CDB_ForeignTable.sql index ae3a5ea..c86f5ef 100644 --- a/scripts-available/CDB_ForeignTable.sql +++ b/scripts-available/CDB_ForeignTable.sql @@ -191,13 +191,13 @@ BEGIN -- (not even using IF NOT EXIST to avoid throwing warnings) IF NOT EXISTS ( SELECT * FROM pg_extension WHERE extname = 'postgres_fdw') THEN CREATE EXTENSION postgres_fdw; - RAISE NOTICE 'Created postgres_fdw extension'; + RAISE NOTICE 'Created postgres_fdw EXTENSION'; END IF; -- Create FDW first if it does not exist IF NOT EXISTS ( SELECT * FROM pg_foreign_server WHERE srvname = fdw_objects_name) THEN EXECUTE FORMAT('CREATE SERVER %I FOREIGN DATA WRAPPER postgres_fdw', fdw_objects_name); - RAISE NOTICE 'Created server % using postgres_fdw', fdw_objects_name; + RAISE NOTICE 'Created SERVER % using postgres_fdw', fdw_objects_name; END IF; -- Set FDW settings @@ -214,7 +214,7 @@ BEGIN -- Create specific role for this IF NOT EXISTS ( SELECT 1 FROM pg_roles WHERE rolname = fdw_objects_name) THEN EXECUTE format('CREATE ROLE %I NOLOGIN', fdw_objects_name); - RAISE NOTICE 'Created special role % to access the correponding FDW', fdw_objects_name; + RAISE NOTICE 'Created special ROLE % to access the correponding FDW', fdw_objects_name; END IF; -- Transfer ownership of the server to the fdw role @@ -225,7 +225,7 @@ BEGIN -- so that we don't need to create a mapping for every user nor store credentials elsewhere IF NOT EXISTS ( SELECT * FROM pg_user_mappings WHERE srvname = fdw_objects_name AND usename = 'public' ) THEN EXECUTE FORMAT ('CREATE USER MAPPING FOR public SERVER %I', fdw_objects_name); - RAISE NOTICE 'Created user mapping for accesing foreign server %', fdw_objects_name; + RAISE NOTICE 'Created USER MAPPING for accesing foreign server %', fdw_objects_name; END IF; -- Update user mapping settings @@ -239,19 +239,19 @@ BEGIN -- Grant usage on the wrapper and server to the fdw role EXECUTE FORMAT ('GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO %I', fdw_objects_name); - RAISE NOTICE 'Granted usage on the postgres_fdw to the role %', fdw_objects_name; + RAISE NOTICE 'Granted USAGE on the postgres_fdw to the role %', fdw_objects_name; EXECUTE FORMAT ('GRANT USAGE ON FOREIGN SERVER %I TO %I', fdw_objects_name, fdw_objects_name); - RAISE NOTICE 'Granted usage on the foreign server to the role %', fdw_objects_name; + RAISE NOTICE 'Granted USAGE on the foreign server to the role %', fdw_objects_name; -- Create schema if it does not exist. IF NOT EXISTS ( SELECT * from pg_namespace WHERE nspname=fdw_objects_name) THEN EXECUTE FORMAT ('CREATE SCHEMA %I', fdw_objects_name); - RAISE NOTICE 'Created schema % to host foreign tables', fdw_objects_name; + RAISE NOTICE 'Created SCHEMA % to host foreign tables', fdw_objects_name; END IF; -- Give the fdw role ownership over the schema EXECUTE FORMAT ('ALTER SCHEMA %I OWNER TO %I', fdw_objects_name, fdw_objects_name); - RAISE NOTICE 'Gave ownership on the schema % to %', fdw_objects_name, fdw_objects_name; + RAISE NOTICE 'Gave ownership on the SCHEMA % to %', fdw_objects_name, fdw_objects_name; -- TODO: Bring here the remote cdb_tablemetadata END diff --git a/scripts-available/CDB_GhostTables.sql b/scripts-available/CDB_GhostTables.sql index dcbb7f9..d402618 100644 --- a/scripts-available/CDB_GhostTables.sql +++ b/scripts-available/CDB_GhostTables.sql @@ -106,7 +106,33 @@ AS $$ CREATE EVENT TRIGGER link_ghost_tables ON ddl_command_end - WHEN TAG IN ('CREATE TABLE', 'SELECT INTO', 'DROP TABLE', 'ALTER TABLE', 'CREATE TRIGGER', 'DROP TRIGGER', 'CREATE VIEW', 'DROP VIEW', 'ALTER VIEW', 'CREATE FOREIGN TABLE', 'ALTER FOREIGN TABLE', 'DROP FOREIGN TABLE') + WHEN TAG IN ('CREATE TABLE', + 'SELECT INTO', + 'DROP TABLE', + 'ALTER TABLE', + + 'CREATE TRIGGER', + 'DROP TRIGGER', + 'ALTER TRIGGER', + + 'CREATE VIEW', + 'DROP VIEW', + 'ALTER VIEW', + + 'CREATE FOREIGN TABLE', + 'ALTER FOREIGN TABLE', + 'DROP FOREIGN TABLE', + + 'ALTER MATERIALIZED VIEW', + 'CREATE MATERIALIZED VIEW', + 'DROP MATERIALIZED VIEW', + + 'IMPORT FOREIGN SCHEMA', + + 'DROP EXTENSION', + 'DROP SCHEMA', + 'DROP SERVER', + 'DROP TYPE') EXECUTE PROCEDURE @extschema@.CDB_SaveDDLTransaction(); END; $$ LANGUAGE plpgsql VOLATILE PARALLEL UNSAFE;