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

Commitd4aa491

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 parent43f0c20 commitd4aa491

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"
@@ -1370,9 +1371,18 @@ CreateExtension(CreateExtensionStmt *stmt)
13701371

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp