#1138 Found issue with DDL triggers
This commit is contained in:
parent
61b47617b8
commit
fd9d79372f
@ -4,14 +4,17 @@ CREATE OR REPLACE FUNCTION cartodb.cdb_handle_create_table ()
|
|||||||
RETURNS event_trigger SECURITY DEFINER LANGUAGE plpgsql AS $$
|
RETURNS event_trigger SECURITY DEFINER LANGUAGE plpgsql AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
event_info RECORD;
|
event_info RECORD;
|
||||||
|
rel_namespace TEXT;
|
||||||
BEGIN
|
BEGIN
|
||||||
event_info := schema_triggers.get_relation_create_eventinfo();
|
event_info := schema_triggers.get_relation_create_eventinfo();
|
||||||
|
|
||||||
-- We're only interested in real relations
|
-- We're only interested in real relations
|
||||||
IF (event_info.new).relkind != 'r' THEN RETURN; END IF;
|
IF (event_info.new).relkind != 'r' THEN RETURN; END IF;
|
||||||
|
|
||||||
RAISE DEBUG 'Relation % of kind % created in namespace oid %',
|
SELECT nspname FROM pg_namespace WHERE oid=(event_info.new).relnamespace INTO rel_namespace;
|
||||||
event_info.relation, (event_info.new).relkind, (event_info.new).relnamespace;
|
|
||||||
|
RAISE DEBUG 'Relation % of kind % created in table % namespace % (oid %)',
|
||||||
|
event_info.relation, (event_info.new).relkind, (event_info.new).relname::TEXT, rel_namespace, (event_info.new).relnamespace;
|
||||||
|
|
||||||
-- We don't want to react to alters triggered by superuser,
|
-- We don't want to react to alters triggered by superuser,
|
||||||
IF current_setting('is_superuser') = 'on' THEN
|
IF current_setting('is_superuser') = 'on' THEN
|
||||||
@ -22,7 +25,7 @@ BEGIN
|
|||||||
PERFORM cartodb.cdb_disable_ddl_hooks();
|
PERFORM cartodb.cdb_disable_ddl_hooks();
|
||||||
|
|
||||||
-- CDB_CartodbfyTable must not create tables, or infinite loop will happen
|
-- CDB_CartodbfyTable must not create tables, or infinite loop will happen
|
||||||
PERFORM cartodb.CDB_CartodbfyTable(event_info.relation);
|
PERFORM cartodb.CDB_CartodbfyTable(rel_namespace, (event_info.new).relname::TEXT);
|
||||||
|
|
||||||
PERFORM cartodb.cdb_enable_ddl_hooks();
|
PERFORM cartodb.cdb_enable_ddl_hooks();
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ RETURNS event_trigger SECURITY DEFINER LANGUAGE plpgsql AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
event_info RECORD;
|
event_info RECORD;
|
||||||
rel RECORD;
|
rel RECORD;
|
||||||
|
rel_namespace TEXT;
|
||||||
BEGIN
|
BEGIN
|
||||||
event_info := schema_triggers.get_column_alter_eventinfo();
|
event_info := schema_triggers.get_column_alter_eventinfo();
|
||||||
|
|
||||||
@ -80,9 +84,11 @@ BEGIN
|
|||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SELECT nspname FROM pg_namespace WHERE oid=(event_info.new).relnamespace INTO rel_namespace;
|
||||||
|
|
||||||
PERFORM cartodb.cdb_disable_ddl_hooks();
|
PERFORM cartodb.cdb_disable_ddl_hooks();
|
||||||
|
|
||||||
PERFORM cartodb.CDB_CartodbfyTable(event_info.relation);
|
PERFORM cartodb.CDB_CartodbfyTable(rel_namespace, (event_info.new).relname::TEXT);
|
||||||
|
|
||||||
PERFORM cartodb.cdb_enable_ddl_hooks();
|
PERFORM cartodb.cdb_enable_ddl_hooks();
|
||||||
|
|
||||||
@ -100,6 +106,7 @@ RETURNS event_trigger SECURITY DEFINER LANGUAGE plpgsql AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
event_info RECORD;
|
event_info RECORD;
|
||||||
rel RECORD;
|
rel RECORD;
|
||||||
|
rel_namespace TEXT;
|
||||||
BEGIN
|
BEGIN
|
||||||
event_info := schema_triggers.get_column_drop_eventinfo();
|
event_info := schema_triggers.get_column_drop_eventinfo();
|
||||||
|
|
||||||
@ -117,9 +124,11 @@ BEGIN
|
|||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SELECT nspname FROM pg_namespace WHERE oid=(event_info.new).relnamespace INTO rel_namespace;
|
||||||
|
|
||||||
PERFORM cartodb.cdb_disable_ddl_hooks();
|
PERFORM cartodb.cdb_disable_ddl_hooks();
|
||||||
|
|
||||||
PERFORM cartodb.CDB_CartodbfyTable(event_info.relation);
|
PERFORM cartodb.CDB_CartodbfyTable(rel_namespace, (event_info.new).relname::TEXT);
|
||||||
|
|
||||||
PERFORM cartodb.cdb_enable_ddl_hooks();
|
PERFORM cartodb.cdb_enable_ddl_hooks();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user