Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit de38ce1

Browse files
committed
Don't allow partitioned indexes in pg_global tablespace
Missing in dfa6081. Author: David Rowley Discussion: https://postgr.es/m/CAKJS1f-M3NMTCpv=vDfkoqHbMPFf=3-Z1ud=+1DHH00tC+zLaQ@mail.gmail.com
1 parent a80dcac commit de38ce1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/backend/commands/tablecmds.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10939,6 +10939,12 @@ ATExecPartedIdxSetTableSpace(Relation rel, Oid newTableSpace)
1093910939

1094010940
Assert(rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX);
1094110941

10942+
/* Can't allow a non-shared relation in pg_global */
10943+
if (newTableSpace == GLOBALTABLESPACE_OID)
10944+
ereport(ERROR,
10945+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
10946+
errmsg("only shared relations can be placed in pg_global tablespace")));
10947+
1094210948
/*
1094310949
* No work if no change in tablespace.
1094410950
*/

src/test/regress/input/tablespace.source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
101101

102102
ALTER TABLE testschema.atable SET TABLESPACE regress_tblspace;
103103
ALTER INDEX testschema.anindex SET TABLESPACE regress_tblspace;
104+
ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_global;
104105
ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default;
105106
ALTER INDEX testschema.part_a_idx SET TABLESPACE regress_tblspace;
106107

src/test/regress/output/tablespace.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ CREATE TABLE testschema.atable AS VALUES (1), (2);
214214
CREATE UNIQUE INDEX anindex ON testschema.atable(column1);
215215
ALTER TABLE testschema.atable SET TABLESPACE regress_tblspace;
216216
ALTER INDEX testschema.anindex SET TABLESPACE regress_tblspace;
217+
ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_global;
218+
ERROR: only shared relations can be placed in pg_global tablespace
217219
ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default;
218220
ALTER INDEX testschema.part_a_idx SET TABLESPACE regress_tblspace;
219221
INSERT INTO testschema.atable VALUES(3); -- ok

0 commit comments

Comments
 (0)