diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-02-07 17:09:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-02-07 17:09:51 +0000 |
commit | b7fe5f70d32fcc56c425d5d35fa1f7c27c99ab37 (patch) | |
tree | e0e0348013741558bc3ed75c282df5436c7cb4b1 /src/backend/parser/parse_utilcmd.c | |
parent | 26351d1c747f6e682e0f1ba05b41be64c3f98dae (diff) | |
download | postgresql-b7fe5f70d32fcc56c425d5d35fa1f7c27c99ab37.tar.gz postgresql-b7fe5f70d32fcc56c425d5d35fa1f7c27c99ab37.zip |
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.)
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index d7a1114bf15..a9079ff2a9e 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -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; |