diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/copy.c | 5 | ||||
-rw-r--r-- | src/backend/commands/copyto.c | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 8265b981ebd..e4dee3f11ff 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -244,11 +244,14 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt, /* * Build RangeVar for from clause, fully qualified based on the - * relation which we have opened and locked. + * relation which we have opened and locked. Use "ONLY" so that + * COPY retrieves rows from only the target table not any + * inheritance children, the same as when RLS doesn't apply. */ from = makeRangeVar(get_namespace_name(RelationGetNamespace(rel)), pstrdup(RelationGetRelationName(rel)), -1); + from->inh = false; /* apply ONLY */ /* Build query */ select = makeNode(SelectStmt); diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c index b6a4b77053a..a9f422b71ce 100644 --- a/src/backend/commands/copyto.c +++ b/src/backend/commands/copyto.c @@ -508,8 +508,8 @@ BeginCopyTo(ParseState *pstate, /* * With row-level security and a user using "COPY relation TO", we * have to convert the "COPY relation TO" to a query-based COPY (eg: - * "COPY (SELECT * FROM relation) TO"), to allow the rewriter to add - * in any RLS clauses. + * "COPY (SELECT * FROM ONLY relation) TO"), to allow the rewriter to + * add in any RLS clauses. * * When this happens, we are passed in the relid of the originally * found relation (which we have locked). As the planner will look up |