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

Commitd263648

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 parent6d969b0 commitd263648

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
@@ -7735,21 +7735,26 @@ static void
77357735
ATPrepSetTableSpace(AlteredTableInfo*tab,Relationrel,char*tablespacename,LOCKMODElockmode)
77367736
{
77377737
OidtablespaceId;
7738-
AclResultaclresult;
77397738

77407739
/* Check that the tablespace exists */
77417740
tablespaceId=get_tablespace_oid(tablespacename, false);
77427741

7743-
/* Check its permissions */
7744-
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
7745-
if (aclresult!=ACLCHECK_OK)
7746-
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
7742+
/* Check permissions except when moving to database's default */
7743+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
7744+
{
7745+
AclResultaclresult;
7746+
7747+
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
7748+
if (aclresult!=ACLCHECK_OK)
7749+
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
7750+
}
77477751

77487752
/* Save info for Phase 3 to do the real work */
77497753
if (OidIsValid(tab->newTableSpace))
77507754
ereport(ERROR,
77517755
(errcode(ERRCODE_SYNTAX_ERROR),
77527756
errmsg("cannot have multiple SET TABLESPACE subcommands")));
7757+
77537758
tab->newTableSpace=tablespaceId;
77547759
}
77557760

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp