2019-03-07 01:19:38 +08:00
|
|
|
-- Create user and enable Ghost tables trigger
|
|
|
|
\set QUIET on
|
2019-03-08 16:18:46 +08:00
|
|
|
SET client_min_messages TO error;
|
2019-03-11 21:02:45 +08:00
|
|
|
SELECT CDB_EnableGhostTablesTrigger();
|
2019-03-08 15:28:06 +08:00
|
|
|
CREATE ROLE "fulano" LOGIN;
|
|
|
|
GRANT ALL ON SCHEMA cartodb TO "fulano";
|
|
|
|
GRANT SELECT ON cartodb.cdb_ddl_execution TO "fulano";
|
|
|
|
GRANT EXECUTE ON FUNCTION CDB_Username() TO "fulano";
|
2019-03-11 21:02:45 +08:00
|
|
|
GRANT EXECUTE ON FUNCTION CDB_LinkGhostTables(text) TO "fulano";
|
2019-03-13 23:34:12 +08:00
|
|
|
SELECT cartodb.CDB_Conf_SetConf('api_keys_fulano', '{"username": "fulanito", "permissions":[]}');
|
|
|
|
DELETE FROM cdb_conf WHERE key = 'invalidation_service';
|
2019-03-08 15:28:06 +08:00
|
|
|
SET SESSION AUTHORIZATION "fulano";
|
2019-03-08 16:18:46 +08:00
|
|
|
SET client_min_messages TO notice;
|
2019-03-07 01:19:38 +08:00
|
|
|
\set QUIET off
|
|
|
|
|
2019-03-13 23:34:12 +08:00
|
|
|
SELECT CDB_LinkGhostTables(); -- _CDB_LinkGhostTables called, TIS connection not tried
|
|
|
|
|
|
|
|
-- Disable Ghost tables trigger
|
|
|
|
\set QUIET on
|
|
|
|
SET SESSION AUTHORIZATION postgres;
|
|
|
|
SELECT cartodb.CDB_Conf_SetConf('invalidation_service', '{"host": "fake-tis-host", "port": 3142}');
|
|
|
|
SET SESSION AUTHORIZATION "fulano";
|
|
|
|
\set QUIET off
|
|
|
|
|
2019-03-07 01:19:38 +08:00
|
|
|
SELECT CDB_LinkGhostTables(); -- _CDB_LinkGhostTables called
|
|
|
|
|
|
|
|
BEGIN;
|
2019-03-11 21:02:45 +08:00
|
|
|
SELECT to_regclass('cartodb.cdb_ddl_execution'); -- exists
|
2019-03-07 01:19:38 +08:00
|
|
|
SELECT COUNT(*) FROM cartodb.cdb_ddl_execution; -- 0
|
2019-03-08 15:28:06 +08:00
|
|
|
CREATE TABLE tmp(id INT);
|
2019-03-07 01:19:38 +08:00
|
|
|
SELECT COUNT(*) FROM cartodb.cdb_ddl_execution; -- 1
|
|
|
|
END; -- _CDB_LinkGhostTables called
|
|
|
|
|
|
|
|
-- Disable Ghost tables trigger
|
|
|
|
\set QUIET on
|
|
|
|
SET SESSION AUTHORIZATION postgres;
|
|
|
|
SELECT CDB_DisableGhostTablesTrigger();
|
2019-03-08 15:28:06 +08:00
|
|
|
SET SESSION AUTHORIZATION "fulano";
|
2019-03-07 01:19:38 +08:00
|
|
|
\set QUIET off
|
|
|
|
|
2019-03-11 21:02:45 +08:00
|
|
|
SELECT to_regclass('cartodb.cdb_ddl_execution'); -- not exists
|
|
|
|
DROP TABLE tmp; -- _CDB_LinkGhostTables not called
|
2019-03-07 01:19:38 +08:00
|
|
|
|
2019-03-11 21:02:45 +08:00
|
|
|
-- Cleanup
|
2019-03-07 01:19:38 +08:00
|
|
|
\set QUIET on
|
|
|
|
SET SESSION AUTHORIZATION postgres;
|
2019-03-11 21:02:45 +08:00
|
|
|
REVOKE EXECUTE ON FUNCTION CDB_LinkGhostTables(text) FROM "fulano";
|
2019-03-08 15:28:06 +08:00
|
|
|
REVOKE EXECUTE ON FUNCTION CDB_Username() FROM "fulano";
|
|
|
|
REVOKE ALL ON SCHEMA cartodb FROM "fulano";
|
|
|
|
DROP ROLE "fulano";
|
2019-03-08 19:03:55 +08:00
|
|
|
DELETE FROM cdb_conf WHERE key = 'api_keys_fulano' OR key = 'invalidation_service';
|
2019-03-07 01:19:38 +08:00
|
|
|
\set QUIET off
|