I've attached an additional patch that fixes a pre-existing bug where cursors were being freed prematurely when there are multiple results that use cursors. It can happen when the fetch cache size is smaller than the number of rows being fetched. To ensure the bug doesn't resurface, the patch includes updates to the test that was modified in my previous patch (Fix-FetchRefcursors-issues.patch).
Some details about this patch:
The patch adds a condition to skip existing code that closes all subsequent cursors when the current one gets closed. It does not seem logical that closing one cursor should cause others to also be closed. The code was originally added in commit c07342d22d82ea6293d27057840babfc2ff6d750 to fix a crash when using SQL Server linked servers, but it's still not clear exactly why it was needed, because the change that prevents a crash seems to be in a different file (parse.c).
I was tempted to remove the code completely because there are no tests that rely on its existence, but that may be because testing it would have required integration with SQL Server. So I've assumed that the code is only required for SQL Server, and therefore made it run only for SQL Server.
The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities. If you have received this email in error please notify the sender immediately and delete this email.