pgsql: Improve RLS handling in copy.c

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve RLS handling in copy.c
Date: 2015-07-27 20:49:23
Message-ID: E1ZJpKt-0006x7-KH@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve RLS handling in copy.c

To avoid a race condition where the relation being COPY'd could be
changed into a view or otherwise modified, keep the original lock
on the relation. Further, fully qualify the relation when building
the query up.

Also remove the poorly thought-out Assert() and check the entire
relationOids list as, post-RLS, there can certainly be multiple
relations involved and the planner does not guarantee their ordering.

Per discussion with Noah and Andres.

Back-patch to 9.5 where RLS was introduced.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/5d179a28fb4c819f3812c40fa7e626b1d3081982

Modified Files
--------------
src/backend/commands/copy.c | 45 +++++++++++++++----------
src/test/regress/expected/rowsecurity.out | 50 +++++++++++++++++++++++++++-
src/test/regress/sql/rowsecurity.sql | 51 ++++++++++++++++++++++++++++-
3 files changed, 126 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Joe Conway 2015-07-28 03:26:35 pgsql: Fix pg_dump output of policies.
Previous Message Tom Lane 2015-07-27 20:29:48 pgsql: Further code review for pg_stat_ssl patch.