関数特性
言語: PLPGSQL
戻り値: integer
setDropTable_int (tab_id) この関数は遠隔ノードで SET_DROP_TABLE 事象を、その複製セットを遠隔ノードが購読していれば、複製からテーブルを削除する処理します。declare
p_tab_id alias for $1;
v_set_id int4;
v_local_node_id int4;
v_set_origin int4;
v_sub_provider int4;
v_tab_reloid oid;
begin
-- ----
-- 中枢構成にロックを取得
-- ----
lock table sl_config_lock;
-- ----
-- set_id の決定
-- ----
select tab_set into v_set_id from sl_table where tab_id = p_tab_id;
-- ----
-- テーブル存在の確証
-- ----
if not found then
return 0;
end if;
-- ----
-- 遠隔オリジンのセットに対して、そのセットに私たちが購読されて
-- いるかの検査。さもなければ、私たちのデータベースには全く
-- 存在しないであろうからそのテーブルを無視します。
-- ----
v_local_node_id := getLocalNodeId('_schemadoc');
select set_origin into v_set_origin
from sl_set
where set_id = v_set_id;
if not found then
raise exception 'Slony-I: setDropTable_int(): set % not found',
v_set_id;
end if;
if v_set_origin != v_local_node_id then
select sub_provider into v_sub_provider
from sl_subscribe
where sub_set = v_set_id
and sub_receiver = getLocalNodeId('_schemadoc');
if not found then
return 0;
end if;
end if;
-- ----
-- sl_table からテーブルを削除し、トリガーを削除します。
-- ----
perform alterTableRestore(p_tab_id);
perform tableDropKey(p_tab_id);
delete from sl_table where tab_id = p_tab_id;
return p_tab_id;
end;