Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2636ecf

Browse files
committed
Lock relation used to generate fresh data for RMV.
The relation should not be accessible to any other process, but it should be locked for consistency. Since this is not known to cause any bug, it will not be back-patch, at least for now. Per report from Andres Freund
1 parent 6331de1 commit 2636ecf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/commands/matview.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "miscadmin.h"
3131
#include "parser/parse_relation.h"
3232
#include "rewrite/rewriteHandler.h"
33+
#include "storage/lmgr.h"
3334
#include "storage/smgr.h"
3435
#include "tcop/tcopprot.h"
3536
#include "utils/builtins.h"
@@ -240,9 +241,14 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
240241

241242
heap_close(matviewRel, NoLock);
242243

243-
/* Create the transient table that will receive the regenerated data. */
244+
/*
245+
* Create the transient table that will receive the regenerated data.
246+
* Lock it against access by any other process until commit (by which time
247+
* it will be gone).
248+
*/
244249
OIDNewHeap = make_new_heap(matviewOid, tableSpace, concurrent,
245250
ExclusiveLock);
251+
LockRelationOid(OIDNewHeap, AccessExclusiveLock);
246252
dest = CreateTransientRelDestReceiver(OIDNewHeap);
247253

248254
/* Generate the data, if wanted. */

0 commit comments

Comments
 (0)