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

Commitb7fe5f7

Browse files
committed
Fix CREATE TABLE ... LIKE ... INCLUDING INDEXES to not cause unwanted
tablespace permissions failures when copying an index that is in thedatabase's default tablespace. A side-effect of the change is that explicitlyspecifying the default tablespace no longer triggers a permissions check;this is not how it was done in pre-8.3 releases but is argued to be moreconsistent. Per bug #3921 from Andrew Gilligan. (Note: I argued in thesubsequent discussion that maybe LIKE shouldn't copy index tablespacesat all, but since no one indicated agreement with that idea, I've refrainedfrom doing it.)
1 parent26351d1 commitb7fe5f7

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.170 2008/01/09 21:52:36 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.171 2008/02/07 17:09:51 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -215,7 +215,7 @@ DefineIndex(RangeVar *heapRelation,
215215
}
216216

217217
/* Check permissions except when using database's default */
218-
if (OidIsValid(tablespaceId))
218+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
219219
{
220220
AclResultaclresult;
221221

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.241 2008/01/30 19:46:48 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242 2008/02/07 17:09:51 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -340,7 +340,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
340340
}
341341

342342
/* Check permissions except when using database's default */
343-
if (OidIsValid(tablespaceId))
343+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
344344
{
345345
AclResultaclresult;
346346

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.302 2008/01/01 19:45:49 momjian Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.303 2008/02/07 17:09:51 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -2594,7 +2594,7 @@ OpenIntoRel(QueryDesc *queryDesc)
25942594
}
25952595

25962596
/* Check permissions except when using the database's default space */
2597-
if (OidIsValid(tablespaceId))
2597+
if (OidIsValid(tablespaceId)&&tablespaceId!=MyDatabaseTableSpace)
25982598
{
25992599
AclResultaclresult;
26002600

‎src/backend/parser/parse_utilcmd.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
22-
*$PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.8 2008/01/01 19:45:51momjian Exp $
22+
*$PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.9 2008/02/07 17:09:51tgl Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -767,7 +767,10 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
767767
index=makeNode(IndexStmt);
768768
index->relation=cxt->relation;
769769
index->accessMethod=pstrdup(NameStr(amrec->amname));
770-
index->tableSpace=get_tablespace_name(source_idx->rd_node.spcNode);
770+
if (OidIsValid(idxrelrec->reltablespace))
771+
index->tableSpace=get_tablespace_name(idxrelrec->reltablespace);
772+
else
773+
index->tableSpace=NULL;
771774
index->unique=idxrec->indisunique;
772775
index->primary=idxrec->indisprimary;
773776
index->concurrent= false;

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.358 2008/01/01 19:45:58 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.359 2008/02/07 17:09:51 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1537,7 +1537,7 @@ typedef struct IndexStmt
15371537
char*idxname;/* name of new index, or NULL for default */
15381538
RangeVar*relation;/* relation to build index on */
15391539
char*accessMethod;/* name of access method (eg. btree) */
1540-
char*tableSpace;/* tablespace, or NULLto use parent's */
1540+
char*tableSpace;/* tablespace, or NULLfor default */
15411541
List*indexParams;/* a list of IndexElem */
15421542
List*options;/* options from WITH clause */
15431543
Node*whereClause;/* qualification (partial-index predicate) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp