Refactoring: common base for WriteQueryResult and WriteQueryEof phases