aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-08-23 21:49:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-08-23 21:49:16 -0400
commit7f7fdd2a17ce087f995a0660fadf3e9523d72810 (patch)
tree8f75ea9a05deeebaf895bd17f79710c4dfe70fb3 /src/backend/commands
parent48f545a3aef461a635b975443a99dd268269590a (diff)
downloadpostgresql-7f7fdd2a17ce087f995a0660fadf3e9523d72810.tar.gz
postgresql-7f7fdd2a17ce087f995a0660fadf3e9523d72810.zip
Make CREATE EXTENSION check schema creation permissions.
When creating a new schema for a non-relocatable extension, we neglected to check whether the calling user has permission to create schemas. That didn't matter in the original coding, since we had already checked superuserness, but in the new dispensation where users need not be superusers, we should check it. Use CreateSchemaCommand() rather than calling NamespaceCreate() directly, so that we also enforce the rules about reserved schema names. Per complaint from KaiGai Kohei, though this isn't the same as his patch.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/extension.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index f6a03e16688..278bbcfc988 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -40,6 +40,7 @@
#include "commands/alter.h"
#include "commands/comment.h"
#include "commands/extension.h"
+#include "commands/schemacmds.h"
#include "commands/trigger.h"
#include "executor/executor.h"
#include "funcapi.h"
@@ -1369,9 +1370,18 @@ CreateExtension(CreateExtensionStmt *stmt)
if (schemaOid == InvalidOid)
{
- schemaOid = NamespaceCreate(schemaName, extowner);
- /* Advance cmd counter to make the namespace visible */
- CommandCounterIncrement();
+ CreateSchemaStmt *csstmt = makeNode(CreateSchemaStmt);
+
+ csstmt->schemaname = schemaName;
+ csstmt->authid = NULL; /* will be created by current user */
+ csstmt->schemaElts = NIL;
+ CreateSchemaCommand(csstmt, NULL);
+
+ /*
+ * CreateSchemaCommand includes CommandCounterIncrement, so new
+ * schema is now visible
+ */
+ schemaOid = get_namespace_oid(schemaName, false);
}
}
else