Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f7fdd2

Browse files
committed
Make CREATE EXTENSION check schema creation permissions.
When creating a new schema for a non-relocatable extension, we neglectedto check whether the calling user has permission to create schemas.That didn't matter in the original coding, since we had already checkedsuperuserness, but in the new dispensation where users need not besuperusers, we should check it. Use CreateSchemaCommand() rather thancalling NamespaceCreate() directly, so that we also enforce the rulesabout reserved schema names.Per complaint from KaiGai Kohei, though this isn't the same as his patch.
1 parent48f545a commit7f7fdd2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎src/backend/commands/extension.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include"commands/alter.h"
4141
#include"commands/comment.h"
4242
#include"commands/extension.h"
43+
#include"commands/schemacmds.h"
4344
#include"commands/trigger.h"
4445
#include"executor/executor.h"
4546
#include"funcapi.h"
@@ -1369,9 +1370,18 @@ CreateExtension(CreateExtensionStmt *stmt)
13691370

13701371
if (schemaOid==InvalidOid)
13711372
{
1372-
schemaOid=NamespaceCreate(schemaName,extowner);
1373-
/* Advance cmd counter to make the namespace visible */
1374-
CommandCounterIncrement();
1373+
CreateSchemaStmt*csstmt=makeNode(CreateSchemaStmt);
1374+
1375+
csstmt->schemaname=schemaName;
1376+
csstmt->authid=NULL;/* will be created by current user */
1377+
csstmt->schemaElts=NIL;
1378+
CreateSchemaCommand(csstmt,NULL);
1379+
1380+
/*
1381+
* CreateSchemaCommand includes CommandCounterIncrement, so new
1382+
* schema is now visible
1383+
*/
1384+
schemaOid=get_namespace_oid(schemaName, false);
13751385
}
13761386
}
13771387
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp