aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-12-19 22:53:30 -0500
committerRobert Haas <rhaas@postgresql.org>2016-12-19 22:53:30 -0500
commit7cd0fd655d681e0ed5f7269fa421d977f1df0889 (patch)
tree34487d830afb8717502aa5b2eb6242a1545ab291 /src/backend/commands/tablecmds.c
parente13029a5ce353574516c64fd1ec9c50201e705fd (diff)
downloadpostgresql-7cd0fd655d681e0ed5f7269fa421d977f1df0889.tar.gz
postgresql-7cd0fd655d681e0ed5f7269fa421d977f1df0889.zip
Invalid parent's relcache after CREATE TABLE .. PARTITION OF.
Otherwise, subsequent commands in the same transaction see the wrong partition descriptor. Amit Langote. Reported by Tomas Vondra and David Fetter. Reviewed by me. Discussion: http://postgr.es/m/22dd313b-d7fd-22b5-0787-654845c8f849%402ndquadrant.com Discussion: http://postgr.es/m/20161215090916.GB20659%40fetter.org
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7a574dc50da..1c219b03dd9 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -777,10 +777,11 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
* it does not return on error.
*/
check_new_partition_bound(relname, parent, bound);
- heap_close(parent, NoLock);
/* Update the pg_class entry. */
- StorePartitionBound(rel, bound);
+ StorePartitionBound(rel, parent, bound);
+
+ heap_close(parent, NoLock);
/*
* The code that follows may also update the pg_class tuple to update
@@ -13141,7 +13142,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
cmd->bound);
/* Update the pg_class entry. */
- StorePartitionBound(attachRel, cmd->bound);
+ StorePartitionBound(attachRel, rel, cmd->bound);
/*
* Generate partition constraint from the partition bound specification.
@@ -13352,12 +13353,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
}
}
- /*
- * Invalidate the parent's relcache so that the new partition is now
- * included its partition descriptor.
- */
- CacheInvalidateRelcache(rel);
-
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(attachRel));
/* keep our lock until commit */