aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2018-03-31 09:26:43 +0900
committerTatsuo Ishii <ishii@postgresql.org>2018-03-31 09:26:43 +0900
commit1b26bd4089a388929c644ffea2832f3841c25969 (patch)
tree8111f558308eb18e71b8f97e28df6d039251b21f
parent3e256e550672657375fc3058b2b8ff6568d65cef (diff)
downloadpostgresql-1b26bd4089a388929c644ffea2832f3841c25969.tar.gz
postgresql-1b26bd4089a388929c644ffea2832f3841c25969.zip
Fix bug with view locking code.
LockViewRecurese() obtains view relation using heap_open() and passes it to get_view_query() to get view info. It immediately closes the relation then uses the returned view info by calling LockViewRecurse_walker(). Since get_view_query() returns a pointer within the relcache, the relcache should be kept until LockViewRecurse_walker() returns. Otherwise the relation could point to a garbage memory area. Fix is moving the heap_close() call after LockViewRecurse_walker(). Problem reported by Tom Lane (buildfarm is unhappy, especially prion since it enables -DRELCACHE_FORCE_RELEASE cpp flag), fix by me.
-rw-r--r--src/backend/commands/lockcmds.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index 1dbb35f6315..b247c0fe2e1 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -263,7 +263,6 @@ LockViewRecurse(Oid reloid, Oid root_reloid, LOCKMODE lockmode, bool nowait)
view = heap_open(reloid, NoLock);
viewquery = get_view_query(view);
- heap_close(view, NoLock);
context.root_reloid = root_reloid;
context.lockmode = lockmode;
@@ -272,6 +271,8 @@ LockViewRecurse(Oid reloid, Oid root_reloid, LOCKMODE lockmode, bool nowait)
context.viewoid = reloid;
LockViewRecurse_walker((Node *) viewquery, &context);
+
+ heap_close(view, NoLock);
}
/*