From 967c270b858ce52d45b7e0a8cfe7e0bf24cb1dbd Mon Sep 17 00:00:00 2001 From: amit Date: Tue, 13 Dec 2016 15:07:06 +0900 Subject: [PATCH 3/5] Invalidate the parent's relcache after partition creation. --- src/backend/commands/tablecmds.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a9650114d4..f94cab60a3 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -777,12 +777,19 @@ 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); /* + * We must invalidate the parent's relcache so that the next + * CommandCounterIncrement() will cause the same to be rebuilt with + * the new partition's info included in its partition descriptor. + */ + CacheInvalidateRelcache(parent); + heap_close(parent, NoLock); + + /* * The code that follows may also update the pg_class tuple to update * relnumchecks, so bump up the command counter to avoid the "already * updated by self" error. -- 2.11.0