Commit 1b26bd40 authored by Tatsuo Ishii's avatar Tatsuo Ishii

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.
parent 3e256e55
......@@ -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);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment