BEGIN; CREATE SCHEMA dbo; CREATE TABLE dbo.tbl1 AS SELECT 1234::INTEGER AS staff_id, 'John'::TEXT AS firstname, 'Doe'::TEXT AS lastname, 'john@doe.com'::TEXT AS email ; SECURITY LABEL FOR anon ON COLUMN dbo.tbl1.lastname IS 'MASKED WITH FUNCTION anon.fake_last_name()'; CREATE EXTENSION IF NOT EXISTS anon CASCADE; SELECT anon.load(); load ------ t (1 row) SELECT lastname = 'Doe' FROM dbo.tbl1; ?column? ---------- t (1 row) -- Test with the masked schema in the search path SET search_path=dbo,public; SELECT anon.start_dynamic_masking('dbo', 'dbo_mask'); start_dynamic_masking ----------------------- t (1 row) SELECT lastname != 'Doe' FROM dbo_mask.tbl1; ?column? ---------- t (1 row) SELECT anon.stop_dynamic_masking(); stop_dynamic_masking ---------------------- t (1 row) -- Test WITHOUT the masked schema in the search path SET search_path=public; SELECT anon.start_dynamic_masking('dbo', 'dbo_mask_2'); start_dynamic_masking ----------------------- t (1 row) SELECT lastname != 'Doe' FROM dbo_mask_2.tbl1; ?column? ---------- t (1 row) SELECT anon.stop_dynamic_masking(); stop_dynamic_masking ---------------------- t (1 row) ROLLBACK;