Skip to content

Commit cc8998c

Browse files
author
hackorum
committed
Apply partitioned_and_tablespaces.patch
1 parent b597835 commit cc8998c

5 files changed

Lines changed: 20 additions & 22 deletions

File tree

src/backend/commands/indexcmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,12 @@ DefineIndex(ParseState *pstate,
794794
if (stmt->tableSpace)
795795
{
796796
tablespaceId = get_tablespace_oid(stmt->tableSpace, false);
797+
/*
797798
if (partitioned && tablespaceId == MyDatabaseTableSpace)
798799
ereport(ERROR,
799800
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
800801
errmsg("cannot specify default tablespace for partitioned relations")));
802+
*/
801803
}
802804
else
803805
{

src/backend/commands/tablecmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,12 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
940940
if (stmt->tablespacename)
941941
{
942942
tablespaceId = get_tablespace_oid(stmt->tablespacename, false);
943-
943+
/*
944944
if (partitioned && tablespaceId == MyDatabaseTableSpace)
945945
ereport(ERROR,
946946
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
947947
errmsg("cannot specify default tablespace for partitioned relations")));
948+
*/
948949
}
949950
else if (stmt->partbound)
950951
{

src/backend/commands/tablespace.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,9 +1141,7 @@ check_default_tablespace(char **newval, void **extra, GucSource source)
11411141
* GetDefaultTablespace -- get the OID of the current default tablespace
11421142
*
11431143
* Temporary objects have different default tablespaces, hence the
1144-
* relpersistence parameter must be specified. Also, for partitioned tables,
1145-
* we disallow specifying the database default, so that needs to be specified
1146-
* too.
1144+
* relpersistence parameter must be specified.
11471145
*
11481146
* May return InvalidOid to indicate "use the database's default tablespace".
11491147
*
@@ -1180,16 +1178,15 @@ GetDefaultTablespace(char relpersistence, bool partitioned)
11801178

11811179
/*
11821180
* Allow explicit specification of database's default tablespace in
1183-
* default_tablespace without triggering permissions checks. Don't allow
1184-
* specifying that when creating a partitioned table, however, since the
1185-
* result is confusing.
1181+
* default_tablespace without triggering permissions checks.
11861182
*/
11871183
if (result == MyDatabaseTableSpace)
11881184
{
1189-
if (partitioned)
1185+
/* if (partitioned)
11901186
ereport(ERROR,
11911187
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11921188
errmsg("cannot specify default tablespace for partitioned relations")));
1189+
*/
11931190
result = InvalidOid;
11941191
}
11951192
return result;

src/test/regress/expected/tablespace.out

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,14 @@ Partitions:
398398
testschema.part2_a_idx
399399
Tablespace: "regress_tblspace"
400400

401-
-- partitioned rels cannot specify the default tablespace. These fail:
401+
-- partitioned rels can specify the default tablespace. These should not fail:
402402
CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default;
403-
ERROR: cannot specify default tablespace for partitioned relations
404-
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a);
405-
ERROR: cannot specify default tablespace for partitioned relations
403+
CREATE TABLE testschema.dflt2 (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a);
406404
SET default_tablespace TO 'pg_default';
407-
CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
408-
ERROR: cannot specify default tablespace for partitioned relations
409-
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a);
410-
ERROR: cannot specify default tablespace for partitioned relations
411-
-- but these work:
405+
CREATE TABLE testschema.dflt3 (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
406+
CREATE TABLE testschema.dflt4 (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a);
407+
DROP TABLE testschema.dflt, testschema.dflt2, testschema.dflt3, testschema.dflt4;
408+
-- and these work:
412409
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
413410
SET default_tablespace TO '';
414411
CREATE TABLE testschema.dflt2 (a int PRIMARY KEY) PARTITION BY LIST (a);

src/test/regress/sql/tablespace.sql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,14 @@ SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
231231
\d testschema.part_a_idx
232232
\d+ testschema.part_a_idx
233233

234-
-- partitioned rels cannot specify the default tablespace. These fail:
234+
-- partitioned rels can specify the default tablespace. These should not fail:
235235
CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default;
236-
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a);
236+
CREATE TABLE testschema.dflt2 (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a);
237237
SET default_tablespace TO 'pg_default';
238-
CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
239-
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a);
240-
-- but these work:
238+
CREATE TABLE testschema.dflt3 (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
239+
CREATE TABLE testschema.dflt4 (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a);
240+
DROP TABLE testschema.dflt, testschema.dflt2, testschema.dflt3, testschema.dflt4;
241+
-- and these work:
241242
CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) TABLESPACE regress_tblspace;
242243
SET default_tablespace TO '';
243244
CREATE TABLE testschema.dflt2 (a int PRIMARY KEY) PARTITION BY LIST (a);

0 commit comments

Comments
 (0)