DROP USER IF EXISTS rls_copy_test_user;

CREATE USER rls_copy_test_user;

CREATE TABLE foo (a int, b int, c int);

INSERT INTO foo VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);

CREATE POLICY p1 ON foo FOR SELECT USING (a % 2 = 0);

ALTER TABLE foo ENABLE ROW LEVEL SECURITY;
ALTER TABLE foo FORCE ROW LEVEL SECURITY;

GRANT SELECT ON TABLE foo TO rls_copy_test_user;

SET SESSION AUTHORIZATION rls_copy_test_user;

COPY foo TO stdout; -- pass

COPY foo (a) TO stdout; -- pass

COPY foo (b) TO stdout; -- pass

COPY foo (c) TO stdout; -- pass

COPY foo (a, b, c) TO stdout; -- fail

COPY foo (a, b) TO stdout; -- fail

COPY foo (b, c) TO stdout; -- fail
