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

Commite70c428

Browse files
committed
Allow SET TABLESPACE to database default
We've always allowed CREATE TABLE to create tables in the database's defaulttablespace without checking for CREATE permissions on that tablespace.Unfortunately, the original implementation of ALTER TABLE ... SET TABLESPACEdidn't pick up on that exception.This changes ALTER TABLE ... SET TABLESPACE to allow the database's defaulttablespace without checking for CREATE rights on that tablespace, just asCREATE TABLE works today. Users could always do this through a series ofcommands (CREATE TABLE ... AS SELECT * FROM ...; DROP TABLE ...; etc), solet's fix the oversight in SET TABLESPACE's original implementation.
1 parent2346c38 commite70c428

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,7 +6829,6 @@ static void
68296829
ATPrepSetTableSpace(AlteredTableInfo*tab,Relationrel,char*tablespacename)
68306830
{
68316831
OidtablespaceId;
6832-
AclResultaclresult;
68336832

68346833
/* Check that the tablespace exists */
68356834
tablespaceId=get_tablespace_oid(tablespacename);
@@ -6838,16 +6837,22 @@ ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename)
68386837
(errcode(ERRCODE_UNDEFINED_OBJECT),
68396838
errmsg("tablespace \"%s\" does not exist",tablespacename)));
68406839

6841-
/* Check its permissions */
6842-
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
6843-
if (aclresult!=ACLCHECK_OK)
6844-
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
6840+
/* Check permissions except when moving to database's default */
6841+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
6842+
{
6843+
AclResultaclresult;
6844+
6845+
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
6846+
if (aclresult!=ACLCHECK_OK)
6847+
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
6848+
}
68456849

68466850
/* Save info for Phase 3 to do the real work */
68476851
if (OidIsValid(tab->newTableSpace))
68486852
ereport(ERROR,
68496853
(errcode(ERRCODE_SYNTAX_ERROR),
68506854
errmsg("cannot have multiple SET TABLESPACE subcommands")));
6855+
68516856
tab->newTableSpace=tablespaceId;
68526857
}
68536858

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp