deny_truncate()

8.44. deny_truncate()

Function Properties

Language: PLPGSQL

Return Type: trigger

trigger function run when a replicated table receives a TRUNCATE request

	declare
		r_role text;
	begin
		-- Ignore this call if session_replication_role = 'local'
		select into r_role setting
			from pg_catalog.pg_settings where name = 'session_replication_role';
		if r_role = 'local' then
			return NULL;
		end if;

		raise exception 'truncation of replicated table forbidden on subscriber node';
    end