aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-04-25 16:55:11 -0400
committerRobert Haas <rhaas@postgresql.org>2011-04-25 16:55:11 -0400
commit68ef051f5cf16f82a5368067a40ffba3c340b0d3 (patch)
tree6b8158651e981c35d3653f59114ef33ec9946a2f /src/backend/executor
parentbe90032e0d1cf473bdd99aee94218218f59f29f1 (diff)
downloadpostgresql-68ef051f5cf16f82a5368067a40ffba3c340b0d3.tar.gz
postgresql-68ef051f5cf16f82a5368067a40ffba3c340b0d3.zip
Refactor broken CREATE TABLE IF NOT EXISTS support.
Per bug #5988, reported by Marko Tiikkaja, and further analyzed by Tom Lane, the previous coding was broken in several respects: even if the target table already existed, a subsequent CREATE TABLE IF NOT EXISTS might try to add additional constraints or sequences-for-serial specified in the new CREATE TABLE statement. In passing, this also fixes a minor information leak: it's no longer possible to figure out whether a schema to which you don't have CREATE access contains a sequence named like "x_y_seq" by attempting to create a table in that schema called "x" with a serial column called "y". Some more refactoring of this code in the future might be warranted, but that will need to wait for a later major release.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execMain.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 86ec9870198..620efda8384 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -2341,7 +2341,6 @@ OpenIntoRel(QueryDesc *queryDesc)
Oid namespaceId;
Oid tablespaceId;
Datum reloptions;
- AclResult aclresult;
Oid intoRelationId;
TupleDesc tupdesc;
DR_intorel *myState;
@@ -2378,13 +2377,7 @@ OpenIntoRel(QueryDesc *queryDesc)
* Find namespace to create in, check its permissions
*/
intoName = into->rel->relname;
- namespaceId = RangeVarGetCreationNamespace(into->rel);
-
- aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(),
- ACL_CREATE);
- if (aclresult != ACLCHECK_OK)
- aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
- get_namespace_name(namespaceId));
+ namespaceId = RangeVarGetAndCheckCreationNamespace(into->rel);
/*
* Select tablespace to use. If not specified, use default tablespace
@@ -2444,8 +2437,7 @@ OpenIntoRel(QueryDesc *queryDesc)
into->onCommit,
reloptions,
true,
- allowSystemTableMods,
- false);
+ allowSystemTableMods);
Assert(intoRelationId != InvalidOid);
FreeTupleDesc(tupdesc);