関数特性
言語: PLPGSQL
戻り値: bigint
unsubscribeSet (sub_set, sub_receiver) 購読セット set sub_set からノード sub_receiver を非購読にします。これはレシーバノードで起動されます。これが如何なる変更にも違反しないと実証されれば(例えば、他のノードに対して sub_receiver がプロバイダであること)、Slony 特有のキーを削除し、そのセットに対するテーブルエントリを削除し、購読を削除し、そしてそのノードが削除された事を発行する UNSUBSCRIBE_SET 事象を生成します。declare p_sub_set alias for $1; p_sub_receiver alias for $2; v_tab_row record; begin -- ---- -- Grab the central configuration lock -- ---- lock table sl_config_lock; -- ---- -- レシーバノードでこれが呼ばれる事の検査 -- ---- if p_sub_receiver != getLocalNodeId('_schemadoc') then raise exception 'Slony-I: unsubscribeSet() must be called on receiver'; end if; -- ---- -- これが如何なる連鎖にも違反しない事の検査 -- ---- if exists (select true from sl_subscribe where sub_set = p_sub_set and sub_provider = p_sub_receiver) then raise exception 'Slony-I: Cannot unsubscibe set % while being provider', p_sub_set; end if; -- ---- -- 全てのテーブルの元のトリガーとルールをリストアし -- 複製の諸々を削除 -- ---- for v_tab_row in select tab_id from sl_table where tab_set = p_sub_set order by tab_id loop perform alterTableRestore(v_tab_row.tab_id); perform tableDropKey(v_tab_row.tab_id); end loop; -- ---- -- setsync ステータスの削除。これは同時に -- 作業者スレッド(worker thread)がセットを無視し複製をすぐに -- 中止する事になります。 -- ---- delete from sl_setsync where ssy_setid = p_sub_set; -- ---- -- このセットに対する全ての sl_table と sl_sequence のエントリを削除 -- 再度購読を開始するとすれば、初期データ複写過程で -- 新規に作成します。 -- ---- delete from sl_table where tab_set = p_sub_set; delete from sl_sequence where seq_set = p_sub_set; -- ---- -- 購読削除のための内部プロシージャの呼び出し -- ---- perform unsubscribeSet_int(p_sub_set, p_sub_receiver); -- Rewrite sl_listen table perform RebuildListenEntries(); -- ---- -- UNSUBSCRIBE_SET 事象の作成 -- ---- return createEvent('_schemadoc', 'UNSUBSCRIBE_SET', p_sub_set, p_sub_receiver); end;