From: Kevin Grittner Date: Wed, 6 Nov 2013 18:26:36 +0000 (-0600) Subject: Keep heap open until new heap generated in RMV. X-Git-Tag: REL9_3_2~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc06faeb78c0e66927cd04f46ed8b5d41ab18427;p=postgresql Keep heap open until new heap generated in RMV. Early close became apparent when invalidation messages were processed in a new location under CLOBBER_CACHE_ALWAYS builds, due to additional locking. Back-patch to 9.3 --- diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index f7b3244752..acf9564c33 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -208,8 +208,6 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString, tableSpace = matviewRel->rd_rel->reltablespace; - heap_close(matviewRel, NoLock); - /* Create the transient table that will receive the regenerated data. */ OIDNewHeap = make_new_heap(matviewOid, tableSpace); dest = CreateTransientRelDestReceiver(OIDNewHeap); @@ -218,6 +216,8 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString, if (!stmt->skipData) refresh_matview_datafill(dest, dataQuery, queryString); + heap_close(matviewRel, NoLock); + /* * Swap the physical files of the target and transient tables, then * rebuild the target's indexes and throw away the transient table.