1.107. tablehasserialkey( text )

関数特性

言語: PLPGSQL

戻り値: boolean

tableHasSerialKey (tab_fqname) テーブルが普通の一意性制約を持たない場合に使用される、特別のシリアルキー列を所有しているか検査します。

declare
	p_tab_fqname            alias for $1;
	v_tab_fqname_quoted	text default '';
	v_attnum		int2;
begin
	v_tab_fqname_quoted := slon_quote_input(p_tab_fqname);
	select PGA.attnum into v_attnum
			from "pg_catalog".pg_class PGC,
				"pg_catalog".pg_namespace PGN,
				"pg_catalog".pg_attribute PGA
			where slon_quote_brute(PGN.nspname) || '.' ||
				slon_quote_brute(PGC.relname) = v_tab_fqname_quoted
				and PGC.relnamespace = PGN.oid
				and PGA.attrelid = PGC.oid
				and PGA.attname = '_Slony-I_schemadoc_rowID'
				and not PGA.attisdropped;
	return found;
end;