関数特性
言語: PLPGSQL
戻り値: bigint
setAddTable (set_id, tab_id, tab_fqname, tab_idxname, tab_comment) オリジンノードでテーブル tab_fqname を複製セットに追加し、他のノードにこれが伝播するように SET_ADD_TABLE 事象を生成します。 全てのセットに対してテーブル識別子、tab_id、は一意である必要があることに注意してください。declare
p_set_id alias for $1;
p_tab_id alias for $2;
p_fqname alias for $3;
p_tab_idxname alias for $4;
p_tab_comment alias for $5;
v_set_origin int4;
begin
-- ----
-- 中枢構成にロックを取得
-- ----
lock table sl_config_lock;
-- ----
-- 私たちがセットのオリジンかどうかの検査
-- ----
select set_origin into v_set_origin
from sl_set
where set_id = p_set_id;
if not found then
raise exception 'Slony-I: setAddTable(): set % not found', p_set_id;
end if;
if v_set_origin != getLocalNodeId('_schemadoc') then
raise exception 'Slony-I: setAddTable(): set % has remote origin', p_set_id;
end if;
if exists (select true from sl_subscribe
where sub_set = p_set_id)
then
raise exception 'Slony-I: cannot add table to currently subscribed set %',
p_set_id;
end if;
-- ----
-- セットにテーブルを追加し、SET_ADD_TABLE 事象を生成します。
-- ----
perform setAddTable_int(p_set_id, p_tab_id, p_fqname,
p_tab_idxname, p_tab_comment);
return createEvent('_schemadoc', 'SET_ADD_TABLE',
p_set_id, p_tab_id, p_fqname,
p_tab_idxname, p_tab_comment);
end;