finishtableaftercopy(p_tab_id integer)

8.72. finishtableaftercopy(p_tab_id integer)

Function Properties

Language: PLPGSQL

Return Type: integer

Reenable index maintenance and reindex the table

declare
	v_tab_oid		oid;
	v_tab_fqname	text;
begin
	-- ----
	-- Get the tables OID and fully qualified name
	-- ---
	select	PGC.oid,
			slon_quote_brute(PGN.nspname) || '.' ||
			slon_quote_brute(PGC.relname) as tab_fqname
		into v_tab_oid, v_tab_fqname
			from sl_table T,   
				"pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN
				where T.tab_id = p_tab_id
				and T.tab_reloid = PGC.oid
				and PGC.relnamespace = PGN.oid;
	if not found then
		raise exception 'Table with ID % not found in sl_table', p_tab_id;
	end if;

	-- ----
	-- Reenable indexes and reindex the table.
	-- ----
	perform enable_indexes_on_table(v_tab_oid);
	execute 'reindex table ' || slon_quote_input(v_tab_fqname);

	return 1;
end;