[mod_pgsql] Use PQcmdTuples() to get number of effected rows to support UPDATE and INSERT without RETURNING.
This commit is contained in:
parent
9c589b7750
commit
fddc6adf8d
|
@ -633,6 +633,7 @@ error:
|
||||||
|
|
||||||
switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int msec)
|
switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pgsql_result_t **result_out, int msec)
|
||||||
{
|
{
|
||||||
|
char *affected_rows = NULL;
|
||||||
switch_pgsql_result_t *res;
|
switch_pgsql_result_t *res;
|
||||||
switch_time_t start;
|
switch_time_t start;
|
||||||
switch_time_t ctime;
|
switch_time_t ctime;
|
||||||
|
@ -747,6 +748,11 @@ switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pg
|
||||||
|
|
||||||
res->result = PQgetResult(handle->con);
|
res->result = PQgetResult(handle->con);
|
||||||
if (res->result) {
|
if (res->result) {
|
||||||
|
affected_rows = PQcmdTuples(res->result);
|
||||||
|
if (!zstr(affected_rows)) {
|
||||||
|
handle->affected_rows = atoi(affected_rows);
|
||||||
|
}
|
||||||
|
|
||||||
*result_out = res;
|
*result_out = res;
|
||||||
res->status = PQresultStatus(res->result);
|
res->status = PQresultStatus(res->result);
|
||||||
switch (res->status) {
|
switch (res->status) {
|
||||||
|
@ -757,7 +763,6 @@ switch_status_t pgsql_next_result_timed(switch_pgsql_handle_t *handle, switch_pg
|
||||||
case PGRES_TUPLES_OK:
|
case PGRES_TUPLES_OK:
|
||||||
{
|
{
|
||||||
res->rows = PQntuples(res->result);
|
res->rows = PQntuples(res->result);
|
||||||
handle->affected_rows = res->rows;
|
|
||||||
res->cols = PQnfields(res->result);
|
res->cols = PQnfields(res->result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue