In recordExtensionInitPriv(), keep the scan til we're done with it

Stephen Frost <sfrost@snowman.net>

Commit: 99f2f3c19ae7d6aa2950a9bdb549217c5a60d941
Author: Stephen Frost <sfrost@snowman.net>
Date: 2016-04-16T01:57:15Z
Releases: 9.6.0
In recordExtensionInitPriv(), keep the scan til we're done with it

For reasons of sheer brain fade, we (I) was calling systable_endscan()
immediately after systable_getnext() and expecting the tuple returned
by systable_getnext() to still be valid.

That's clearly wrong.  Move the systable_endscan() down below the tuple
usage.

Discovered initially by Pavel Stehule and then also by Alvaro.

Add a regression test based on Alvaro's testing.

Files