}
else if (QR_NumResultCols(res) > 0)
{
- *pcrow = SC_is_fetchcursor(stmt) ? -1 : QR_get_num_total_tuples(res) - res->dl_count;
+ *pcrow = QR_get_cursor(res) ? -1 : QR_get_num_total_tuples(res) - res->dl_count;
mylog("RowCount=%d\n", *pcrow);
return SQL_SUCCESS;
}
ConnInfo *ci;
SQLLEN currp;
UWORD pstatus;
- BOOL currp_is_valid, reached_eof;
+ BOOL currp_is_valid, reached_eof, useCursor;
mylog("%s: stmt=%p rowsetSize=%d\n", func, stmt, rowsetSize);
if (pcrow)
*pcrow = 0;
+ useCursor = (SC_is_fetchcursor(stmt) && NULL != QR_get_cursor(res));
num_tuples = QR_get_num_total_tuples(res);
reached_eof = QR_once_reached_eof(res) && QR_get_cursor(res);
- if (SC_is_fetchcursor(stmt) && !reached_eof)
+ if (useCursor && !reached_eof)
num_tuples = INT_MAX;
inolog("num_tuples=%d\n", num_tuples);
*/
if (!should_set_rowset_start)
rowset_start = SC_get_rowset_start(stmt);
- if (SC_is_fetchcursor(stmt))
+ if (useCursor)
{
if (reached_eof &&
rowset_start >= num_tuples)
/* currTuple is always 1 row prior to the rowset start */
stmt->currTuple = RowIdx2GIdx(-1, stmt);
- if (SC_is_fetchcursor(stmt) ||
+ if (useCursor ||
SQL_CURSOR_KEYSET_DRIVEN == stmt->options.cursor_type)
{
move_cursor_position_if_needed(stmt, res);
stmt->currTuple = RowIdx2GIdx(0, stmt);
/* For declare/fetch, need to reset cursor to beginning of rowset */
- if (SC_is_fetchcursor(stmt))
+ if (useCursor)
QR_set_position(res, 0);
/* Set the number of rows retrieved */
char *value;
ColumnInfoClass *coli;
BindInfoClass *bookmark;
+ BOOL useCursor;
/* TupleField *tupleField; */
mylog("fetch_cursor=%d, %p->total_read=%d\n", SC_is_fetchcursor(self), res, res->num_total_read);
- if (!SC_is_fetchcursor(self))
+ useCursor = (SC_is_fetchcursor(self) && (NULL != QR_get_cursor(res)));
+ if (!useCursor)
{
if (self->currTuple >= (Int4) QR_get_num_total_tuples(res) - 1 ||
(self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1))
mylog("type = %d, atttypmod = %d\n", type, atttypmod);
- if (SC_is_fetchcursor(self))
+ if (useCursor)
value = QR_get_value_backend(res, lf);
else
{
BOOL is_in_trans, issue_begin, has_out_para;
BOOL use_extended_protocol;
int func_cs_count = 0, i;
+ BOOL useCursor;
conn = SC_get_conn(self);
ci = &(conn->connInfo);
goto cleanup;
}
is_in_trans = CC_is_in_trans(conn);
+ if (useCursor = SC_is_fetchcursor(self))
+ {
+ QResultClass *curres = SC_get_Curres(self);
+
+ if (NULL != curres)
+ useCursor = (NULL != QR_get_cursor(curres));
+ }
/* issue BEGIN ? */
issue_begin = TRUE;
if (self->internal)
}
}
else if (CC_does_autocommit(conn) &&
- (!SC_is_fetchcursor(self)
+ (!useCursor
/* || SC_is_with_hold(self) thiw would lose the performance */
))
issue_begin = FALSE;
mylog(" Sending SELECT statement on stmt=%p, cursor_name='%s' qflag=%d,%d\n", self, SC_cursor_name(self), qflag, self->options.scroll_concurrency);
/* send the declare/select */
- if (SC_is_fetchcursor(self))
+ if (useCursor)
{
qi.result_in = NULL;
qi.cursor = SC_cursor_name(self);
qflag |= IGNORE_ROUND_TRIP;
}
res = CC_send_query_append(conn, self->stmt_with_params, qryi, qflag, SC_get_ancestor(self), appendq);
- if (SC_is_fetchcursor(self) && QR_command_maybe_successful(res))
+ if (useCursor && QR_command_maybe_successful(res))
{
if (appendq)
{
*/
if (SQL_CURSOR_KEYSET_DRIVEN == self->options.cursor_type &&
SQL_CONCUR_READ_ONLY != self->options.scroll_concurrency &&
- !SC_is_fetchcursor(self))
+ !useCursor)
{
if (tres = res->next, tres)
{