}
else
{
- QResultClass *res;
-
self->cursor_name = NULL;
- for (res = QR_nextr(self); NULL != res; res = QR_nextr(res))
+
+ /*
+ * The isSqlServr() check below was added because the code was freeing
+ * cursors prematurely when other results with open cursors exist. The
+ * code was originally added for a scenario using SQL Server linked
+ * servers in commit c07342d22d82ea6293d27057840babfc2ff6d750.
+ */
+ if (isSqlServr())
{
- if (NULL != res->cursor_name)
- free(res->cursor_name);
- res->cursor_name = NULL;
+ QResultClass *res;
+
+ for (res = QR_nextr(self); NULL != res; res = QR_nextr(res))
+ {
+ if (NULL != res->cursor_name)
+ free(res->cursor_name);
+ res->cursor_name = NULL;
+ }
}
}
}
connected
disconnecting
--- TEST using FetchRefcursors=0, autocommit=1, numresults=2
+-- TEST using Fetch=1;FetchRefcursors=0, autocommit=1, numresults=2
connected
Output param num_cursor is 2
--1 Result set:
2 <unnamed portal 1> <unnamed portal 2>
disconnecting
--- TEST using FetchRefcursors=1, autocommit=1, numresults=2
+-- TEST using Fetch=1;FetchRefcursors=1, autocommit=1, numresults=2
connected
SQLExecute failed
HY000=Query must be executed in a transaction when FetchRefcursors setting is enabled.
--- TEST using FetchRefcursors=1, autocommit=0, numresults=0
+-- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=0
connected
Output param num_cursor is 0
--1 Result set:
disconnecting
--- TEST using FetchRefcursors=1, autocommit=0, numresults=1
+-- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=1
connected
Output param num_cursor is 1
--1 Result set:
3 foobar
disconnecting
--- TEST using FetchRefcursors=1, autocommit=0, numresults=2
+-- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=2
connected
Output param num_cursor is 2
--1 Result set:
foo 1
disconnecting
--- TEST using FetchRefcursors=1, autocommit=0, numresults=3
+-- TEST using Fetch=1;FetchRefcursors=1, autocommit=0, numresults=3
connected
Output param num_cursor is 2
--1 Result set:
{
setup_procedure();
- refcursor_test("FetchRefcursors=0", SQL_AUTOCOMMIT_ON, 2);
- refcursor_test("FetchRefcursors=1", SQL_AUTOCOMMIT_ON, 2);
- refcursor_test("FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 0);
- refcursor_test("FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 1);
- refcursor_test("FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 2);
- refcursor_test("FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 3);
+ /* Using a fetch cache size of 1 to test multiple fetches per cursor */
+ refcursor_test("Fetch=1;FetchRefcursors=0", SQL_AUTOCOMMIT_ON, 2);
+ refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_ON, 2);
+ refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 0);
+ refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 1);
+ refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 2);
+ refcursor_test("Fetch=1;FetchRefcursors=1", SQL_AUTOCOMMIT_OFF, 3);
return 0;
}