add explicit schema for all functions

This commit is contained in:
Gonzalo Riestra
2019-03-12 18:39:48 +01:00
parent 2f40261b8d
commit 83707297de

View File

@@ -1,5 +1,5 @@
-- Enqueues a job to run Ghost tables linking process for the provided username
CREATE OR REPLACE FUNCTION _CDB_LinkGhostTables(username text, db_name text, event_name text)
CREATE OR REPLACE FUNCTION cartodb._CDB_LinkGhostTables(username text, db_name text, event_name text)
RETURNS void
AS $$
if not username:
@@ -46,7 +46,7 @@ AS $$
$$ LANGUAGE 'plpythonu' VOLATILE PARALLEL UNSAFE;
-- Enqueues a job to run Ghost tables linking process for the current user
CREATE OR REPLACE FUNCTION CDB_LinkGhostTables(event_name text DEFAULT 'USER')
CREATE OR REPLACE FUNCTION cartodb.CDB_LinkGhostTables(event_name text DEFAULT 'USER')
RETURNS void
AS $$
DECLARE
@@ -56,13 +56,13 @@ AS $$
EXECUTE 'SELECT CDB_Username();' INTO username;
EXECUTE 'SELECT current_database();' INTO db_name;
PERFORM _CDB_LinkGhostTables(username, db_name, event_name);
PERFORM cartodb._CDB_LinkGhostTables(username, db_name, event_name);
RAISE NOTICE '_CDB_LinkGhostTables() called with username=%, event_name=%', username, event_name;
END;
$$ LANGUAGE plpgsql VOLATILE PARALLEL UNSAFE SECURITY DEFINER;
-- Trigger function to call CDB_LinkGhostTables()
CREATE OR REPLACE FUNCTION _CDB_LinkGhostTablesTrigger()
CREATE OR REPLACE FUNCTION cartodb._CDB_LinkGhostTablesTrigger()
RETURNS trigger
AS $$
DECLARE
@@ -70,13 +70,13 @@ AS $$
BEGIN
EXECUTE 'SELECT tag FROM cartodb.cdb_ddl_execution WHERE txid = txid_current();' INTO ddl_tag;
DELETE FROM cartodb.cdb_ddl_execution WHERE txid = txid_current();
PERFORM CDB_LinkGhostTables(ddl_tag);
PERFORM cartodb.CDB_LinkGhostTables(ddl_tag);
RETURN NULL;
END;
$$ LANGUAGE plpgsql VOLATILE PARALLEL UNSAFE SECURITY DEFINER;
-- Event trigger to save the current transaction in cartodb.cdb_ddl_execution
CREATE OR REPLACE FUNCTION CDB_SaveDDLTransaction()
CREATE OR REPLACE FUNCTION cartodb.CDB_SaveDDLTransaction()
RETURNS event_trigger
AS $$
BEGIN
@@ -85,7 +85,7 @@ AS $$
$$ LANGUAGE plpgsql VOLATILE PARALLEL UNSAFE SECURITY DEFINER;
-- Creates the trigger on DDL events to link ghost tables
CREATE OR REPLACE FUNCTION CDB_EnableGhostTablesTrigger()
CREATE OR REPLACE FUNCTION cartodb.CDB_EnableGhostTablesTrigger()
RETURNS void
AS $$
BEGIN
@@ -99,17 +99,17 @@ AS $$
AFTER INSERT ON cartodb.cdb_ddl_execution
INITIALLY DEFERRED
FOR EACH ROW
EXECUTE PROCEDURE _CDB_LinkGhostTablesTrigger();
EXECUTE PROCEDURE cartodb._CDB_LinkGhostTablesTrigger();
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')
EXECUTE PROCEDURE CDB_SaveDDLTransaction();
EXECUTE PROCEDURE cartodb.CDB_SaveDDLTransaction();
END;
$$ LANGUAGE plpgsql VOLATILE PARALLEL UNSAFE;
-- Drops the trigger on DDL events to link ghost tables
CREATE OR REPLACE FUNCTION CDB_DisableGhostTablesTrigger()
CREATE OR REPLACE FUNCTION cartodb.CDB_DisableGhostTablesTrigger()
RETURNS void
AS $$
BEGIN