aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-07 00:44:17 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-07 00:44:17 -0400
commita36c84c3e4a9bee6baa740848f67a5db3fa279b0 (patch)
tree58c76b721006622f1bbd491ba86a7eca42ee3d5f /src/backend/commands/tablecmds.c
parentd8261595bc6f5189896cdce6861915ac23830e7c (diff)
downloadpostgresql-a36c84c3e4a9bee6baa740848f67a5db3fa279b0.tar.gz
postgresql-a36c84c3e4a9bee6baa740848f67a5db3fa279b0.zip
Fix default_tablespace usage for partitioned tables
In commit 87259588d0ab I (Álvaro) tried to rationalize the determination of tablespace to use for partitioned tables, but failed to handle the default_tablespace case. Repair and add proper tests. Author: Amit Langote, Rushabh Lathia Reported-by: Rushabh Lathia Reviewed-by: Amit Langote, Álvaro Herrera Discussion: https://postgr.es/m/CAGPqQf0cYjm1=rjxk_6gU0SjUS70=yFUAdCJLwWzh9bhNJnyVg@mail.gmail.com
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index e13b96d2522..2a72c1b501d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -660,8 +660,8 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
}
/*
- * Select tablespace to use. If not specified, use default tablespace
- * (which may in turn default to database's default).
+ * Select tablespace to use: an explicitly indicated one, or (in the case
+ * of a partitioned table) the parent's, if it has one.
*/
if (stmt->tablespacename)
{
@@ -682,6 +682,10 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
tablespaceId = get_rel_tablespace(linitial_oid(inheritOids));
}
else
+ tablespaceId = InvalidOid;
+
+ /* still nothing? use the default */
+ if (!OidIsValid(tablespaceId))
tablespaceId = GetDefaultTablespace(stmt->relation->relpersistence,
partitioned);