timescaledb/sql/ddl_triggers.sql
Dmitry Simonenko 4daeb06eee Track hypertables used during process utility hook execution
This patch does refactoring necessary to support execution of DDL
commands on remote servers.

Basically it extends cross module api with ddl_command_start,
ddl_command_end and sql_drop functions.

Variable hypertables_list added to ProcessUtilityArg. It is used
to keep a list of found hypertables during Utility/DDL statement
parsing. This information and information gathered from other
hook functions will be used to distinct distributed hypertables
and forward DDL commands to any remote servers associated with
them.
2019-03-29 13:04:18 +03:00

18 lines
880 B
SQL

-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
DROP EVENT TRIGGER IF EXISTS timescaledb_ddl_command_end;
CREATE OR REPLACE FUNCTION _timescaledb_internal.process_ddl_event() RETURNS event_trigger
AS '@MODULE_PATHNAME@', 'ts_timescaledb_process_ddl_event' LANGUAGE C;
--EVENT TRIGGER MUST exclude the ALTER EXTENSION tag.
CREATE EVENT TRIGGER timescaledb_ddl_command_end ON ddl_command_end
WHEN TAG IN ('ALTER TABLE','CREATE TRIGGER','CREATE TABLE','CREATE INDEX','ALTER INDEX', 'DROP TABLE', 'DROP INDEX')
EXECUTE PROCEDURE _timescaledb_internal.process_ddl_event();
DROP EVENT TRIGGER IF EXISTS timescaledb_ddl_sql_drop;
CREATE EVENT TRIGGER timescaledb_ddl_sql_drop ON sql_drop
EXECUTE PROCEDURE _timescaledb_internal.process_ddl_event();