1.78. setdropsequence( integer )

関数特性

言語: PLPGSQL

戻り値: bigint

setDropSequence (seq_id) セットに対するオリジンノードで複製セットからシーケンス seq_id を削除し、購読ノードにこれを複製させるように SET_DROP_SEQUENCE を立ち上げます。

declare
	p_seq_id		alias for $1;
	v_set_id		int4;
	v_set_origin		int4;
begin
	-- ----
	-- 中枢構成にロックを所得
	-- ----
	lock table sl_config_lock;

	-- ----
	-- このシーケンスのセット識別子を決定
	-- ----
	select seq_set into v_set_id from sl_sequence where seq_id = p_seq_id;

	-- ----
	-- シーケンスの存在の確証
	-- ----
	if not found then
		raise exception 'Slony-I: setDropSequence_int(): sequence % not found',
			p_seq_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: setDropSequence(): set % not found', v_set_id;
	end if;
	if v_set_origin != getLocalNodeId('_schemadoc') then
		raise exception 'Slony-I: setDropSequence(): set % has remote origin', v_set_id;
	end if;

	-- ----
	-- シーケンスをセットに追加し、SET_ADD_SEQUENCE 事象を生成します。
	-- ----
	perform setDropSequence_int(p_seq_id);
	return  createEvent('_schemadoc', 'SET_DROP_SEQUENCE',
			p_seq_id);
end;