1.80. setdroptable( integer )

関数特性

言語: PLPGSQL

戻り値: bigint

setDropTable (tab_id)

declare
	p_tab_id		alias for $1;
	v_set_id		int4;
	v_set_origin		int4;
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
		raise exception 'Slony-I: setDropTable_int(): table % not found',
			p_tab_id;
	end if;

	-- ----
	-- 私たちがセットのオリジンかの検査
	-- ----
	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(): set % not found', v_set_id;
	end if;
	if v_set_origin != getLocalNodeId('_schemadoc') then
		raise exception 'Slony-I: setDropTable(): set % has remote origin', v_set_id;
	end if;

	-- ----
	-- セットからテーブルを削除し、SET_ADD_TABLE 事象を生成
	-- ----
	perform setDropTable_int(p_tab_id);
	return  createEvent('_schemadoc', 'SET_DROP_TABLE', p_tab_id);
end;