Make partition-lock-release coding more transparent in BufferAlloc().
Make partition-lock-release coding more transparent in BufferAlloc().

Coverity complained that oldPartitionLock was possibly dereferenced after
having been set to NULL.  That actually can't happen, because we'd only use
it if (oldFlags & BM_TAG_VALID) is true.  But nonetheless Coverity is
justified in complaining, because at line 1275 we actually overwrite
oldFlags, and then still expect its BM_TAG_VALID bit to be a safe guide to
whether to release the oldPartitionLock.  Thus, the code would be incorrect
if someone else had changed the buffer's BM_TAG_VALID flag meanwhile.
That should not happen, since we hold pin on the buffer throughout this
sequence, but it's starting to look like a rather shaky chain of logic.
And there's no need for such assumptions, because we can simply replace
the (oldFlags & BM_TAG_VALID) tests with (oldPartitionLock != NULL),
which has identical results and makes it plain to all comers that we don't
dereference a null pointer.  A small side benefit is that the range of
liveness of oldFlags is greatly reduced, possibly allowing the compiler
to save a register.

This is just cleanup, not an actual bug fix, so there seems no need
for a back-patch.

ashwinstar/gpdb,lisakowen/gpdb,greenplum-db/gpdb,adam8157/gpdb,lisakowen/gpdb,50wu/gpdb,ashwinstar/gpdb,adam8157/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,50wu/gpdb,xinzweb/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,lisakowen/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,xinzweb/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,adam8157/gpdb,xinzweb/gpdb,greenplum-db/gpdb,50wu/gpdb,jmcatamney/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,lisakowen/gpdb,ashwinstar/gpdb,50wu/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,xinzweb/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,xinzweb/gpdb,ashwinstar/gpdb,50wu/gpdb,ashwinstar/gpdb,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,lisakowen/gpdb,50wu/gpdb,adam8157/gpdb,xinzweb/gpdb,adam8157/gpdb,xinzweb/gpdb