aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-03-06 16:50:47 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-03-06 16:50:47 -0500
commit943140d572adc94b957d123aa4c35ec88e40e869 (patch)
tree52bb5137895d9419d0821fa2e44afdb269baef06 /src/backend
parent68f7b91e509d9ac95a376805df22bc9b51e71255 (diff)
downloadpostgresql-943140d572adc94b957d123aa4c35ec88e40e869.tar.gz
postgresql-943140d572adc94b957d123aa4c35ec88e40e869.zip
Avoid dangling pointer to relation name in RLS code path in DoCopy().
With RLS active, "COPY tab TO ..." failed under -DRELCACHE_FORCE_RELEASE, and would sometimes fail without that, because it used the relation name directly from the relcache as part of the parsetree it's building. That becomes a potentially-dangling pointer as soon as the relcache entry is closed, a bit further down. Typical symptom if the relcache entry chanced to get cleared would be "relation does not exist" error with a garbage relation name, or possibly a core dump; but if you were really truly unlucky, the COPY might copy from the wrong table. Per report from Andrew Dunstan that regression tests fail with -DRELCACHE_FORCE_RELEASE. The core tests now pass for me (but have not tried "make check-world" yet). Discussion: https://postgr.es/m/7b52f900-0579-cda9-ae2e-de5da17090e6@2ndQuadrant.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/copy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 5e38edfb703..db6ef783145 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -938,7 +938,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
* relation which we have opened and locked.
*/
from = makeRangeVar(get_namespace_name(RelationGetNamespace(rel)),
- RelationGetRelationName(rel), -1);
+ pstrdup(RelationGetRelationName(rel)),
+ -1);
/* Build query */
select = makeNode(SelectStmt);