BEGIN; CREATE EXTENSION IF NOT EXISTS anon CASCADE; CREATE TABLE hundred AS SELECT generate_series(1,100) AS h; SELECT anon.get_tablesample_ratio('hundred'::REGCLASS::OID) IS NULL; ?column? ---------- t (1 row) SAVEPOINT before_error_invalid_label; SECURITY LABEL FOR anon ON TABLE hundred IS 'INVALID LABEL'; ERROR: 'INVALID LABEL' is not a valid label for a table ROLLBACK TO before_error_invalid_label; SAVEPOINT before_error_invalid_label2; SECURITY LABEL FOR anon ON DATABASE contrib_regression IS 'INVALID LABEL'; ERROR: 'INVALID LABEL' is not a valid label for a database ROLLBACK TO before_error_invalid_label2; SAVEPOINT before_sql_injection; SECURITY LABEL FOR anon ON TABLE hundred IS 'TABLESAMPLE BERNOULLI (33); CREATE ROLE bob SUPERUSER;'; ERROR: 'TABLESAMPLE BERNOULLI (33); CREATE ROLE bob SUPERUSER;' is not a valid label for a table ROLLBACK TO before_sql_injection; SECURITY LABEL FOR anon ON TABLE hundred IS 'TABLESAMPLE SYSTEM(33)'; SELECT anon.get_tablesample_ratio('hundred'::REGCLASS::OID) IS NOT NULL; ?column? ---------- t (1 row) SECURITY LABEL FOR anon ON TABLE hundred IS NULL; SELECT anon.get_tablesample_ratio('hundred'::REGCLASS::OID) IS NULL; ?column? ---------- t (1 row) SECURITY LABEL FOR anon ON DATABASE contrib_regression IS 'TABLESAMPLE BERNOULLI(50)'; SELECT anon.get_tablesample_ratio('hundred'::REGCLASS::OID) IS NOT NULL; ?column? ---------- t (1 row) SECURITY LABEL FOR anon ON COLUMN hundred.h IS 'MASKED WITH VALUE 0'; SELECT count(*) = 100 FROM hundred; ?column? ---------- t (1 row) SELECT anon.start_dynamic_masking(); start_dynamic_masking ----------------------- t (1 row) SELECT count(*) < 100 FROM mask.hundred; ?column? ---------- t (1 row) -- This should raise a notice SELECT anon.anonymize_column('hundred','h'); NOTICE: The TABLESAMPLE rule will be ignored. HINT: Only anonymize_table() and anonymize_database() can apply sampling rules anonymize_column ------------------ t (1 row) -- The sampling rule is ignored, the table is NOT sampled SELECT count(*) = 100 FROM hundred; ?column? ---------- t (1 row) SAVEPOINT before_anonymize_database; SELECT anon.anonymize_database(); anonymize_database -------------------- t (1 row) SELECT count(*) < 100 FROM hundred; ?column? ---------- t (1 row) ROLLBACK TO before_anonymize_database; SAVEPOINT before_anonymize_table; SELECT anon.anonymize_table('hundred'); anonymize_table ----------------- t (1 row) SELECT count(*) < 100 FROM hundred; ?column? ---------- t (1 row) ROLLBACK TO before_anonymize_table; SECURITY LABEL FOR anon ON DATABASE contrib_regression IS NULL; ROLLBACK;