]> granicus.if.org Git - postgresql/commitdiff
Keep heap open until new heap generated in RMV.
authorKevin Grittner <kgrittn@postgresql.org>
Wed, 6 Nov 2013 18:26:36 +0000 (12:26 -0600)
committerKevin Grittner <kgrittn@postgresql.org>
Wed, 6 Nov 2013 18:26:36 +0000 (12:26 -0600)
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

src/backend/commands/matview.c

index f7b3244752e1298da4f56848f32e7ad915c4ddde..acf9564c3369c5d620e5089914ecde4e3e677f1b 100644 (file)
@@ -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.