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

Commit86e58ae

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 parent586bea6 commit86e58ae

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
@@ -8534,21 +8534,26 @@ static void
85348534
ATPrepSetTableSpace(AlteredTableInfo*tab,Relationrel,char*tablespacename,LOCKMODElockmode)
85358535
{
85368536
OidtablespaceId;
8537-
AclResultaclresult;
85388537

85398538
/* Check that the tablespace exists */
85408539
tablespaceId=get_tablespace_oid(tablespacename, false);
85418540

8542-
/* Check its permissions */
8543-
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
8544-
if (aclresult!=ACLCHECK_OK)
8545-
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
8541+
/* Check permissions except when moving to database's default */
8542+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
8543+
{
8544+
AclResultaclresult;
8545+
8546+
aclresult=pg_tablespace_aclcheck(tablespaceId,GetUserId(),ACL_CREATE);
8547+
if (aclresult!=ACLCHECK_OK)
8548+
aclcheck_error(aclresult,ACL_KIND_TABLESPACE,tablespacename);
8549+
}
85468550

85478551
/* Save info for Phase 3 to do the real work */
85488552
if (OidIsValid(tab->newTableSpace))
85498553
ereport(ERROR,
85508554
(errcode(ERRCODE_SYNTAX_ERROR),
85518555
errmsg("cannot have multiple SET TABLESPACE subcommands")));
8556+
85528557
tab->newTableSpace=tablespaceId;
85538558
}
85548559

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp