default_tablespace_for_partition.patch

text/x-patch

Filename: default_tablespace_for_partition.patch
Type: text/x-patch
Part: 0
Message: behaviour change - default_tablesapce + partition table

Patch

Format: unified
File+
src/backend/commands/tablecmds.c 3 0
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index bfcf947..0cc9c0b 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -680,6 +680,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
 		 */
 		Assert(list_length(inheritOids) == 1);
 		tablespaceId = get_rel_tablespace(linitial_oid(inheritOids));
+
+		if (!OidIsValid(tablespaceId))
+			tablespaceId = GetDefaultTablespace(stmt->relation->relpersistence, partitioned);
 	}
 	else
 		tablespaceId = GetDefaultTablespace(stmt->relation->relpersistence,