if (0 == (qb->flags & FLGB_CREATE_KEYSET))
{
qb->errornumber = STMT_SEQUENCE_ERROR;
- qb->errormsg = "Should come here only when hamdling updatable cursors";
+ qb->errormsg = "Should come here only when handling updatable cursors";
return SQL_ERROR;
}
CVT_APPEND_STR(qb, ", \"ctid");
res = CC_send_query_append(conn, self->stmt_with_params, qryi, qflag, SC_get_ancestor(self), appendq);
if (useCursor && QR_command_maybe_successful(res))
{
+ /*
+ * If we sent a DECLARE CURSOR + FETCH, throw away the result of
+ * the DECLARE CURSOR statement, and only return the result of the
+ * FETCH to the caller. However, if we received any NOTICEs as
+ * part of the DECLARE CURSOR, carry those over.
+ */
if (appendq)
{
QResultClass *qres, *nres;
break;
}
nres = qres->next;
+ if (nres && QR_get_notice(qres) != NULL)
+ {
+ if (QR_command_successful(nres) &&
+ QR_command_nonfatal(qres))
+ {
+ QR_set_rstatus(nres, PORES_NONFATAL_ERROR);
+ }
+ QR_add_notice(nres, QR_get_notice(qres));
+ }
qres->next = NULL;
QR_Destructor(qres);
qres = nres;
#define SC_ref_CC_error(a) ((a->ref_CC_error) = TRUE)
void SC_forget_unnamed(StatementClass *self);
#define SC_can_parse_statement(a) (STMT_TYPE_SELECT == (a)->statement_type)
-#define SC_may_use_cursor(a) (STMT_TYPE_SELECT == (a)->statement_type || STMT_TYPE_WITH == (a)->statement_type)
+/*
+ * DECLARE CURSOR + FETCH can only be used with SELECT-type queries. And
+ * it's not currently supported with array-bound parameters.
+ */
+#define SC_may_use_cursor(a) \
+ (SC_get_APDF(a)->paramset_size <= 1 && \
+ (STMT_TYPE_SELECT == (a)->statement_type || STMT_TYPE_WITH == (a)->statement_type) )
#define SC_may_fetch_rows(a) (STMT_TYPE_SELECT == (a)->statement_type || STMT_TYPE_WITH == (a)->statement_type)
#define SC_can_req_colinfo(a) (STMT_TYPE_SELECT == (a)->statement_type || \
STMT_TYPE_WITH == (a)->statement_type || \
BOOL SC_SetCancelRequest(StatementClass *self);
BOOL SC_AcceptedCancelRequest(const StatementClass *self);
-DescriptorClass *SC_set_ARD(StatementClass *stmt, DescriptorClass *desc);
-DescriptorClass *SC_set_APD(StatementClass *stmt, DescriptorClass *desc);
int enqueueNeedDataCallback(StatementClass *self, NeedDataCallfunc, void *);
RETCODE dequeueNeedDataCallback(RETCODE, StatementClass *self);
void cancelNeedDataState(StatementClass *self);