Improve RLS handling in copy.c
Stephen Frost <sfrost@snowman.net>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/copy.c | modified | +27 −18 |
| src/test/regress/expected/rowsecurity.out | modified | +49 −1 |
| src/test/regress/sql/rowsecurity.sql | modified | +50 −1 |