Fix logical decoding bug leading to inefficient reopening of files.
Fix logical decoding bug leading to inefficient reopening of files.

When spilling transaction data to disk a simple typo caused the output
file to be closed and reopened for every serialized change. That happens
to not have a huge impact on linux, which is why it probably wasn't
noticed so far, but on windows that appears to trigger actual disk
writes after every change. Not fun.

The bug fortunately does not have any impact besides speed. A change
could end up being in the wrong segment (last instead of next), but
since we read all files to the end, that's just ugly, not really
problematic. It's not a problem to upgrade, since transaction spill
files do not persist across restarts.

Bug: #13484
Reported-By: Olivier Gosseaume
Discussion: 20150703090217.1190.63940@wrigleys.postgresql.org

Backpatch to 9.4, where logical decoding was added.

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