Remove curr_param_result property of StatementClass and separate parsed result from the exec result.
res = ParseAndDescribeWithLibpq(stmt, plan_name, pstmt->query, pstmt->num_params, "prepare_and_describe", NULL);
if (res == NULL)
goto cleanup;
- SC_set_Result(stmt, res);
+ // SC_set_Result(stmt, res);
+ QR_Destructor(stmt->parsed);
+ stmt->parsed = res;
if (!QR_command_maybe_successful(res))
{
SC_set_error(stmt, STMT_EXEC_ERROR, "Error while preparing parameters", func);
retval = Exec_with_parameters_resolved(stmt, stmt->exec_type, &exec_end);
if (!exec_end)
{
- stmt->curr_param_result = 0;
goto next_param_row;
}
cleanup:
retval = dequeueNeedDataCallback(retval, stmt);
goto cleanup;
}
- else
- {
- stmt->curr_param_result = 0;
- }
if (retval = PGAPI_Execute(estmt, flag), SQL_NEED_DATA != retval)
{
ColAttSet(StatementClass *stmt, TABLE_INFO *rti)
{
CSTR func = "ColAttSet";
- QResultClass *res = SC_get_Curres(stmt);
+ QResultClass *res = SC_get_Parsed(stmt);
IRDFields *irdflds = SC_get_IRDF(stmt);
COL_INFO *col_info = NULL;
FIELD_INFO **fi, *wfi;
PODBC_NOT_SEARCH_PATTERN, 0, 0);
MYLOG(0, " Past PG_Columns\n");
- res = SC_get_Curres(col_stmt);
+ res = SC_get_Parsed(col_stmt);
if (SQL_SUCCEEDED(result)
&& res != NULL && QR_get_num_cached_tuples(res) > 0)
{
BOOL exec_ok = TRUE;
num_fields = SC_describe(stmt);
- result = SC_get_Curres(stmt);
+ result = SC_get_Parsed(stmt);
MYLOG(0, "entering result = %p, status = %d, numcols = %d\n", result, stmt->status, result != NULL ? QR_NumResultCols(result) : -1);
/****if ((!result) || ((stmt->status != STMT_FINISHED) && (stmt->status != STMT_PREMATURE))) ****/
goto cleanup;
}
- result = SC_get_Curres(stmt);
+ result = SC_get_Parsed(stmt);
*pccol = QR_NumPublicResultCols(result);
}
goto cleanup;
}
- res = SC_get_Curres(stmt);
+ res = SC_get_Parsed(stmt);
if (icol >= QR_NumPublicResultCols(res))
{
SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in DescribeCol.", func);
if (icol < irdflds->nfields && irdflds->fi)
fi = irdflds->fi[icol];
}
- res = SC_get_Curres(stmt);
+ res = SC_get_Parsed(stmt);
#ifdef SUPPRESS_LONGEST_ON_CURSORS
if (UNKNOWNS_AS_LONGEST == unknown_sizes)
{
* is ignored anyway, so it may be 0.
*/
- res = SC_get_Curres(stmt);
+ res = SC_get_Parsed(stmt);
if (0 == icol && SQL_DESC_COUNT != fDescType) /* bookmark column */
{
MYLOG(DETAIL_LOG_LEVEL, "answering bookmark info\n");
if (!SC_describe_ok(stmt, build_fi, col_idx, func))
return SQL_ERROR;
- res = SC_get_Curres(stmt);
+ res = SC_get_Parsed(stmt);
cols = QR_NumPublicResultCols(res);
/*
rv->phstmt = NULL;
rv->rhold.first = rv->rhold.last = NULL;
rv->curres = NULL;
+ rv->parsed = NULL;
rv->catalog_result = FALSE;
rv->prepare = NON_PREPARE_STATEMENT;
rv->prepared = NOT_YET_PREPARED;
rv->put_data = FALSE;
rv->ref_CC_error = FALSE;
rv->join_info = 0;
- rv->curr_param_result = 0;
SC_init_parse_method(rv);
rv->lobj_fd = -1;
{
self->rhold.first = self->rhold.last = NULL;
self->curres = NULL;
- self->curr_param_result = 0;
MYLOG(0, "leaving(%p)\n", self);
}
QResultClass *last = NULL, *res;
MYLOG(0, "(%p, %p)\n", self, first);
+ QR_Destructor(self->parsed);
+ self->parsed = NULL;
QR_Destructor(self->rhold.first);
for (res = first; res; res = QR_nextr(res))
last = res;
self->curres = first;
self->rhold.first = first;
self->rhold.last = last;
- if (NULL != first)
- self->curr_param_result = 1;
}
}
if (rhold.first != self->rhold.first)
{
MYLOG(0, "(%p, {%p, %p})\n", self, rhold.first, rhold.last);
+ QR_Destructor(self->parsed);
+ self->parsed = NULL;
QR_Destructor(self->rhold.first);
self->curres = rhold.first;
self->rhold = rhold;
- if (NULL != rhold.first)
- self->curr_param_result = 1;
}
else if (rhold.last != self->rhold.last)
{
else
{
QR_reset_for_re_execute(res);
- self->curr_param_result = 1;
SC_set_Curres(self, NULL);
}
}
/* Free any cursors */
if (SC_get_Result(self))
SC_set_Result(self, NULL);
+ QR_Destructor(self->parsed);
+ self->parsed = NULL;
self->miscinfo = 0;
self->execinfo = 0;
/* self->rbonerr = 0; Never clear the bits here */
QResultClass *res;
MYLOG(0, "entering status = %d\n", self->status);
- res = SC_get_Curres(self);
+ res = SC_get_Parsed(self);
if (NULL != res)
{
num_fields = QR_NumResultCols(res);
self->status = STMT_DESCRIBED;
break;
}
- if (res = SC_get_Curres(self), NULL != res)
+ if (res = SC_get_Parsed(self), NULL != res)
{
num_fields = QR_NumResultCols(res);
return num_fields;
SC_create_errorinfo(const StatementClass *self, PG_ErrorInfo *pgerror_fail_safe)
{
QResultClass *res = SC_get_Curres(self);
+ if (!res)
+ res = SC_get_Parsed(self);
ConnectionClass *conn = SC_get_conn(self);
Int4 errornum;
size_t pos;
appendq = fetch;
qflag &= (~READ_ONLY_QUERY); /* must be a SAVEPOINT after DECLARE */
}
- first = SC_get_Result(self);
- if (self->curr_param_result && first)
- SC_set_Result(self, QR_nextr(first));
rhold = CC_send_query_append(conn, self->stmt_with_params, qryi, qflag, SC_get_ancestor(self), appendq);
first = rhold.first;
if (useCursor && QR_command_maybe_successful(first))
if (self->rhold.last != rhold.first)
QR_concat(self->rhold.last, rhold.first);
self->rhold.last = rhold.last;
- self->curr_param_result = 1;
}
if (NULL == SC_get_Curres(self))
SC_set_Curres(self, SC_get_Result(self));
{
QResultClass *res = NULL, *newres = NULL;
- if (stmt->curr_param_result)
- res = stmt->rhold.last;
- if (!res)
- newres = res = QR_Constructor();
+ newres = res = QR_Constructor();
nrarg->conn = SC_get_conn(stmt);
nrarg->comment = __FUNCTION__;
nrarg->res = res;
}
/* 3. Receive results */
-MYLOG(DETAIL_LOG_LEVEL, "get_Result=%p %p %d\n", res, SC_get_Result(stmt), stmt->curr_param_result);
+MYLOG(DETAIL_LOG_LEVEL, "get_Result=%p %p\n", res, SC_get_Result(stmt));
pgresstatus = PQresultStatus(pgres);
switch (pgresstatus)
{
ConnectionClass *hdbc; /* pointer to ConnectionClass this
* statement belongs to */
QResultHold rhold;
- // QResultClass *result; /* result of the current statement */
QResultClass *curres; /* the current result in the chain */
- // QResultClass *lastres; /* maybe the last result in the chain */
+ QResultClass *parsed; /* parsed result before exec */
HSTMT *phstmt;
StatementOptions options;
StatementOptions options_orig;
po_ind_t lock_CC_for_rb; /* lock CC for statement rollback ? */
po_ind_t join_info; /* have joins ? */
po_ind_t parse_method; /* parse_statement is forced or ? */
- po_ind_t curr_param_result; /* current param result is set ? */
po_ind_t has_notice; /* exec result contains notice messages ? */
pgNAME cursor_name;
char *plan_name;
#define SC_get_Result(a) ((a)->rhold).first
#define SC_set_Curres(a, b) ((a)->curres = b)
#define SC_get_Curres(a) ((a)->curres)
+#define SC_get_Parsed(a) ((a)->parsed ? (a)->parsed : (a)->curres)
#define SC_get_ARD(a) ((a)->ard)
#define SC_get_APD(a) ((a)->apd)
#define SC_get_IRD(a) ((a)->ird)