Fix CREATE TABLE ... LIKE ... INCLUDING INDEXES to not cause unwanted
tablespace permissions failures when copying an index that is in the database's default tablespace. A side-effect of the change is that explicitly specifying 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 more consistent. Per bug #3921 from Andrew Gilligan. (Note: I argued in the subsequent discussion that maybe LIKE shouldn't copy index tablespaces at all, but since no one indicated agreement with that idea, I've refrained from doing it.)
This commit is contained in:
parent
26351d1c74
commit
b7fe5f70d3
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.170 2008/01/09 21:52:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.171 2008/02/07 17:09:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -215,7 +215,7 @@ DefineIndex(RangeVar *heapRelation,
|
||||
}
|
||||
|
||||
/* Check permissions except when using database's default */
|
||||
if (OidIsValid(tablespaceId))
|
||||
if (OidIsValid(tablespaceId) && tablespaceId != MyDatabaseTableSpace)
|
||||
{
|
||||
AclResult aclresult;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.241 2008/01/30 19:46:48 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242 2008/02/07 17:09:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -340,7 +340,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
}
|
||||
|
||||
/* Check permissions except when using database's default */
|
||||
if (OidIsValid(tablespaceId))
|
||||
if (OidIsValid(tablespaceId) && tablespaceId != MyDatabaseTableSpace)
|
||||
{
|
||||
AclResult aclresult;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.302 2008/01/01 19:45:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.303 2008/02/07 17:09:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2594,7 +2594,7 @@ OpenIntoRel(QueryDesc *queryDesc)
|
||||
}
|
||||
|
||||
/* Check permissions except when using the database's default space */
|
||||
if (OidIsValid(tablespaceId))
|
||||
if (OidIsValid(tablespaceId) && tablespaceId != MyDatabaseTableSpace)
|
||||
{
|
||||
AclResult aclresult;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.8 2008/01/01 19:45:51 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.9 2008/02/07 17:09:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -767,7 +767,10 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
||||
index = makeNode(IndexStmt);
|
||||
index->relation = cxt->relation;
|
||||
index->accessMethod = pstrdup(NameStr(amrec->amname));
|
||||
index->tableSpace = get_tablespace_name(source_idx->rd_node.spcNode);
|
||||
if (OidIsValid(idxrelrec->reltablespace))
|
||||
index->tableSpace = get_tablespace_name(idxrelrec->reltablespace);
|
||||
else
|
||||
index->tableSpace = NULL;
|
||||
index->unique = idxrec->indisunique;
|
||||
index->primary = idxrec->indisprimary;
|
||||
index->concurrent = false;
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.358 2008/01/01 19:45:58 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.359 2008/02/07 17:09:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1537,7 +1537,7 @@ typedef struct IndexStmt
|
||||
char *idxname; /* name of new index, or NULL for default */
|
||||
RangeVar *relation; /* relation to build index on */
|
||||
char *accessMethod; /* name of access method (eg. btree) */
|
||||
char *tableSpace; /* tablespace, or NULL to use parent's */
|
||||
char *tableSpace; /* tablespace, or NULL for default */
|
||||
List *indexParams; /* a list of IndexElem */
|
||||
List *options; /* options from WITH clause */
|
||||
Node *whereClause; /* qualification (partial-index predicate) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user