if (res)
{
SQLSMALLINT num_p;
+ int errnum = 0, curerr;
if (stmt->multi_statement < 0)
PGAPI_NumParams(stmt, &num_p);
stmt->diag_row_count = res->recent_processed_row_count;
SC_set_rowset_start(stmt, -1, FALSE);
stmt->currTuple = -1;
+
+ if (!QR_command_maybe_successful(res))
+ {
+ ret = SQL_ERROR;
+ errnum = STMT_EXEC_ERROR;
+ }
+ else if (NULL != QR_get_notice(res))
+ {
+ ret = SQL_SUCCESS_WITH_INFO;
+ errnum = STMT_INFO_ONLY;
+ }
+ if (0 != errnum)
+ {
+ curerr = SC_get_errornumber(stmt);
+ if (0 == curerr ||
+ (0 > curerr && errnum > 0))
+ SC_set_errornumber(stmt, errnum);
+ }
}
else
{
}
}
+static
+QResultClass *add_libpq_notice_receiver(StatementClass *stmt, notice_receiver_arg *nrarg)
+{
+ QResultClass *res = NULL, *newres = NULL;
+
+ if (stmt->curr_param_result)
+ for (res = SC_get_Result(stmt); NULL != res && NULL != res->next; res = res->next);
+ if (!res)
+ newres = res = QR_Constructor();
+ nrarg->conn = SC_get_conn(stmt);
+ nrarg->comment = __FUNCTION__;
+ nrarg->res = res;
+ PQsetNoticeReceiver(nrarg->conn->pqconn, receive_libpq_notice, nrarg);
+
+ return newres;
+}
+
static QResultClass *
libpq_bind_and_exec(StatementClass *stmt)
{
QResultClass *res = NULL;
char *cmdtag;
char *rowcount;
+ notice_receiver_arg nrarg;
if (!RequestStart(stmt, conn, func))
return NULL;
pstmt = stmt->processed_statements;
QLOG(0, "PQexecParams: %p '%s' nParams=%d\n", conn->pqconn, pstmt->query, nParams);
log_params(nParams, paramTypes, (const UCHAR * const *) paramValues, paramLengths, paramFormats, resultFormat);
+ /* set notice receiver */
+ newres = add_libpq_notice_receiver(stmt, &nrarg);
pgres = PQexecParams(conn->pqconn,
pstmt->query,
nParams,
/* already prepared */
QLOG(0, "PQexecPrepared: %p plan=%s nParams=%d\n", conn->pqconn, plan_name, nParams);
log_params(nParams, paramTypes, (const UCHAR * const *) paramValues, paramLengths, paramFormats, resultFormat);
+ /* set notice receiver */
+ newres = add_libpq_notice_receiver(stmt, &nrarg);
pgres = PQexecPrepared(conn->pqconn,
plan_name, /* portal name == plan name */
nParams,
(const char **) paramValues, paramLengths, paramFormats,
resultFormat);
}
- if (stmt->curr_param_result)
- {
- for (res = SC_get_Result(stmt); NULL != res && NULL != res->next; res = res->next) ;
- }
- else
- res = NULL;
-
- if (!res)
+ /* reset notice receiver */
+ PQsetNoticeReceiver(conn->pqconn, receive_libpq_notice, NULL);
+ if (!(res = nrarg.res))
{
- newres = res = QR_Constructor();
- if (!res)
- {
- SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory while allocating result set", func);
- goto cleanup;
- }
+ SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Out of memory while allocating result set", func);
+ goto cleanup;
}
/* 3. Receive results */