| Slony-I 2.1.4 Documentation | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
8.46. ddlscript_prepare(p_only_on_node integer, p_set_id integer)
Function Properties
Language: PLPGSQL
Return Type: integer
Prepare for DDL script execution on origindeclare
v_set_origin int4;
begin
-- ----
-- Check that the set exists and originates here
-- ----
select set_origin into v_set_origin
from sl_set
where set_id = p_set_id
for update;
if not found then
raise exception 'Slony-I: set % not found', p_set_id;
end if;
if p_only_on_node = -1 then
if v_set_origin <> getLocalNodeId('_schemadoc') then
raise exception 'Slony-I: set % does not originate on local node',
p_set_id;
end if;
-- ----
-- Create a SYNC event
-- ----
perform createEvent('_schemadoc', 'SYNC', NULL);
else
-- If running "ONLY ON NODE", there are two possibilities:
-- 1. Running on origin, where denyaccess() triggers are already shut off
-- 2. Running on replica, where we need the LOCAL role to suppress denyaccess() triggers
execute 'create temp table _slony1_saved_session_replication_role (
setting text);';
execute 'insert into _slony1_saved_session_replication_role
select setting from pg_catalog.pg_settings
where name = ''session_replication_role'';';
if (v_set_origin <> getLocalNodeId('_schemadoc')) then
execute 'set session_replication_role to local;';
end if;
end if;
return 1;
end;